Hydra  4.0.1
A header-only templated C++ framework to perform data analysis on massively parallel platforms.
basic_fit_range_semantics.inl File Reference
#include <iostream>
#include <assert.h>
#include <time.h>
#include <chrono>
#include <tclap/CmdLine.h>
#include <hydra/device/System.h>
#include <hydra/Function.h>
#include <hydra/Lambda.h>
#include <hydra/Random.h>
#include <hydra/LogLikelihoodFCN.h>
#include <hydra/Parameter.h>
#include <hydra/UserParameters.h>
#include <hydra/Pdf.h>
#include <hydra/Filter.h>
#include <hydra/functions/Gaussian.h>
#include <hydra/DenseHistogram.h>
#include <hydra/RandomFill.h>
#include "Minuit2/FunctionMinimum.h"
#include "Minuit2/MnUserParameterState.h"
#include "Minuit2/MnPrint.h"
#include "Minuit2/MnMigrad.h"
#include "Minuit2/MnMinimize.h"
Include dependency graph for basic_fit_range_semantics.inl:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BASIC_FIT_RANGE_SEMANTICS_INL_
 

Functions

cmd add (EArg)
 
 catch (TCLAP::ArgException &e)
 
 declarg (_X, double) int main(int argv
 
TCLAP::ValueArg< size_t > EArg ("n", "number-of-events","Number of events", true, 10e6, "size_t")
 
Hist_Data Fill (range)
 
std::cout<<"minimum: "<< minimum_d<< std::endl;std::cout<< "-----------------------------------------"<< std::endl;std::cout<< "| GPU Time (ms) ="<< elapsed_d.count()<< std::endl;std::cout<< "-----------------------------------------"<< std::endl;hydra::DenseHistogram< double, 1, hydra::device::sys_tHist_Data (100, min, max)
 
cmd parse (argv, argc)
 

Variables

char ** argc
 
std::cout<< std::endl<< "Generated data:"<< std::endl;for(size_t i=0;i< 10;i++) std::cout<< "["<< i<< "] :"<< data[i]<< std::endl;auto filter=hydra::wrap_lambda([=] __hydra_dual__(_X x){ return(x > min) &&(x< max);});auto range=hydra::filter(data, filter);std::cout<< std::endl<< "Filtered data:"<< std::endl;for(size_t i=0;i< 10;i++) std::cout<< "["<< i<< "] :"<< range[i]<< std::endl;auto fcn=hydra::make_loglikehood_fcn(model, range);ROOT::Minuit2::MnPrint::SetGlobalLevel(3);hydra::Print::SetLevel(hydra::WARNING);MnStrategy strategy(2);MnMigrad migrad_d(fcn, fcn.GetParameters().GetMnState(), strategy);std::cout<< fcn.GetParameters().GetMnState()<< std::endl;auto start_d=std::chrono::high_resolution_clock::now();FunctionMinimum minimum_d=FunctionMinimum(migrad_d(std::numeric_limits< unsigned int >::max(), 5));auto end_d=std::chrono::high_resolution_clock::now();std::chrono::duration< double, std::milli > elapsed_d = end_d - start_d
 
hydra::Gaussian< _X > gaussian (mean_p, sigma_p)
 
double max = 5.0
 
double mean = 0.0
 
hydra::Parameter mean_p = hydra::Parameter::Create().Name("Mean").Value(0.5).Error(0.0001).Limits(-1.0, 1.0)
 
double min = -5.0
 
auto model = hydra::make_pdf(gaussian, hydra::AnalyticalIntegral<hydra::Gaussian< _X>>(min, max) )
 
 nentries = EArg.getValue()
 
 return
 
double sigma = 1.0
 
hydra::Parameter sigma_p = hydra::Parameter::Create().Name("Sigma").Value(0.5).Error(0.0001).Limits(0.01, 1.5)
 
 try
 

Macro Definition Documentation

◆ BASIC_FIT_RANGE_SEMANTICS_INL_

#define BASIC_FIT_RANGE_SEMANTICS_INL_

Function Documentation

◆ add()

cmd add ( EArg  )

◆ catch()

catch ( TCLAP::ArgException &  e)

◆ declarg()

declarg ( _X  ,
double   
)

◆ EArg()

TCLAP::ValueArg<size_t> EArg ( "n"  ,
"number-of-events"  ,
"Number of events"  ,
true  ,
10e6  ,
"size_t"   
)

◆ Fill()

Hist_Data Fill ( range  )

◆ Hist_Data()

std::cout<<"minimum: "<<minimum_d<<std::endl; std::cout << "-----------------------------------------"<<std::endl; std::cout << "| GPU Time (ms) ="<< elapsed_d.count() <<std::endl; std::cout << "-----------------------------------------"<<std::endl; hydra::DenseHistogram<double,1, hydra::device::sys_t> Hist_Data ( 100  ,
min  ,
max   
)

◆ parse()

cmd parse ( argv  ,
argc   
)

Variable Documentation

◆ argc

char** argc
Initial value:
{
size_t nentries = 0
nentries
Definition: basic_fit_range_semantics.inl:105
Examples:
basic_fit_range_semantics.inl.

◆ elapsed_d

std::cout<< std::endl<< "Generated data:"<< std::endl; for(size_t i=0; i<10; i++) std::cout << "[" << i << "] :" << data[i] << std::endl; auto filter = hydra::wrap_lambda( [=] __hydra_dual__ (_X x){ return (x > min) && (x < max ); }); auto range = hydra::filter(data, filter); std::cout<< std::endl<< "Filtered data:"<< std::endl; for(size_t i=0; i<10; i++) std::cout << "[" << i << "] :" << range[i] << std::endl; auto fcn = hydra::make_loglikehood_fcn(model, range); ROOT::Minuit2::MnPrint::SetGlobalLevel(3); hydra::Print::SetLevel(hydra::WARNING); MnStrategy strategy(2); MnMigrad migrad_d(fcn, fcn.GetParameters().GetMnState() , strategy); std::cout<<fcn.GetParameters().GetMnState()<<std::endl; auto start_d = std::chrono::high_resolution_clock::now(); FunctionMinimum minimum_d = FunctionMinimum(migrad_d(std::numeric_limits<unsigned int>::max(), 5)); auto end_d = std::chrono::high_resolution_clock::now(); std::chrono::duration<double, std::milli> elapsed_d = end_d - start_d

◆ gaussian

◆ max

double max = 5.0

◆ mean

◆ mean_p

hydra::Parameter mean_p = hydra::Parameter::Create().Name("Mean").Value(0.5).Error(0.0001).Limits(-1.0, 1.0)

◆ min

double min = -5.0

◆ model

◆ nentries

nentries = EArg.getValue()

◆ return

return

◆ sigma

◆ sigma_p

hydra::Parameter sigma_p = hydra::Parameter::Create().Name("Sigma").Value(0.5).Error(0.0001).Limits(0.01, 1.5)

◆ try

try
Initial value:
{
TCLAP::CmdLine cmd("Command line arguments for ", '=')