Hydra  4.0.1
A header-only templated C++ framework to perform data analysis on massively parallel platforms.
extended_logLL_fit.inl File Reference
#include <iostream>
#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>
#include <algorithm>
#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/AddPdf.h>
#include <hydra/Filter.h>
#include <hydra/DenseHistogram.h>
#include <hydra/functions/Gaussian.h>
#include <hydra/functions/Exponential.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 extended_logLL_fit.inl:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXTENDED_LOGLL_FIT_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.begin(), range.end())
 
std::cout<< "Minimum: "<< minimum_d<< std::endl;std::cout<< "-----------------------------------------"<< std::endl;std::cout<< "| [Fit] 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)
 
model SetExtended (1)
 

Variables

char ** argc
 
std::cout<< std::endl<< "Generated data:"<< std::endl;for(size_t i=0;i< 10;i++) std::cout<< "["<< i<< "] :"<< data_d[i]<< std::endl;auto filter=hydra::wrap_lambda([=] __hydra_dual__(double x){ return(x > min) &&(x< max);});auto range=hydra::filter(data_d, filter);std::cout<< std::endl<< "Filtered data:"<< std::endl;for(size_t i=0;i< 10;i++) std::cout<< "["<< i<< "] :"<< range.begin()[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(50000, 5));auto end_d=std::chrono::high_resolution_clock::now();std::chrono::duration< double, std::milli > elapsed_d = end_d - start_d
 
auto Exp_PDF
 
auto Gauss1_PDF
 
auto Gauss2_PDF
 
double max = 10.0
 
hydra::Parameter mean1_p = hydra::Parameter::Create().Name("Mean_1").Value( 2.5) .Error(0.0001).Limits(0.0, 10.0)
 
hydra::Parameter mean2_p = hydra::Parameter::Create().Name("Mean_2").Value(5.0) .Error(0.0001).Limits(0.0, 10.0)
 
double min = 0.0
 
auto model = hydra::add_pdfs( {N_Gauss_1_p, N_Gauss_2_p, N_Exp_p }, Gauss1_PDF, Gauss2_PDF, Exp_PDF)
 
hydra::Parameter N_Exp_p ("N_Exp", nentries, sqrt(nentries), nentries-nentries/2, nentries+nentries/2)
 
hydra::Parameter N_Gauss_1_p ("N_Gauss1", nentries, sqrt(nentries), nentries-nentries/2, nentries+nentries/2)
 
hydra::Parameter N_Gauss_2_p ("N_Gauss2", nentries, sqrt(nentries), nentries-nentries/2, nentries+nentries/2)
 
 nentries = EArg.getValue()
 
 return
 
hydra::Parameter sigma1_p = hydra::Parameter::Create().Name("Sigma_1").Value(0.5).Error(0.0001).Limits(0.01, 1.5)
 
hydra::Parameter sigma2_p = hydra::Parameter::Create().Name("Sigma_2").Value(0.5).Error(0.0001).Limits(0.01, 1.5)
 
hydra::Parameter tau_p = hydra::Parameter::Create().Name("Tau").Value(1.0).Error(0.0001).Limits(-2.0, 2.0)
 
 try
 

Macro Definition Documentation

◆ EXTENDED_LOGLL_FIT_INL_

#define EXTENDED_LOGLL_FIT_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.  begin(),
range.  end() 
)

◆ Hist_Data()

std::cout<< "Minimum: " << minimum_d << std::endl; std::cout << "-----------------------------------------"<<std::endl; std::cout << "| [Fit] 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   
)

◆ SetExtended()

model SetExtended ( )

Variable Documentation

◆ argc

char** argc
Initial value:
{
size_t nentries = 0
nentries
Definition: extended_logLL_fit.inl:110
Examples:
extended_logLL_fit.inl.

◆ elapsed_d

std::cout<< std::endl<< "Generated data:"<< std::endl; for(size_t i=0; i<10; i++) std::cout << "[" << i << "] :" << data_d[i] << std::endl; auto filter = hydra::wrap_lambda( [=] __hydra_dual__ (double x){ return (x > min) && (x < max ); }); auto range = hydra::filter(data_d, filter); std::cout<< std::endl<< "Filtered data:"<< std::endl; for(size_t i=0; i<10; i++) std::cout << "[" << i << "] :" << range.begin()[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(50000, 5)); auto end_d = std::chrono::high_resolution_clock::now(); std::chrono::duration<double, std::milli> elapsed_d = end_d - start_d

◆ Exp_PDF

auto Exp_PDF
Initial value:
Pdf< FUNCTOR, INTEGRATOR > make_pdf(FUNCTOR const &functor, INTEGRATOR integrator)
Build a hydra::Pdf given a shape described by a functor and a integrator (algorithm or functor)...
Definition: Pdf.h:299
https://en.wikipedia.org/wiki/Exponential_function
Definition: Exponential.h:57
double max
Definition: extended_logLL_fit.inl:121
double min
Definition: extended_logLL_fit.inl:120
Definition: AnalyticalIntegral.inl:39
hydra::Parameter tau_p
Definition: extended_logLL_fit.inl:146
Examples:
extended_logLL_fit.inl.

◆ Gauss1_PDF

auto Gauss1_PDF
Initial value:
hydra::Parameter mean1_p
Definition: extended_logLL_fit.inl:125
Pdf< FUNCTOR, INTEGRATOR > make_pdf(FUNCTOR const &functor, INTEGRATOR integrator)
Build a hydra::Pdf given a shape described by a functor and a integrator (algorithm or functor)...
Definition: Pdf.h:299
double max
Definition: extended_logLL_fit.inl:121
hydra::Parameter sigma1_p
Definition: extended_logLL_fit.inl:126
Gaussian functions are often used to represent the probability density function of a normally dist...
Definition: Gaussian.h:62
double min
Definition: extended_logLL_fit.inl:120
Definition: AnalyticalIntegral.inl:39
Examples:
extended_logLL_fit.inl.

◆ Gauss2_PDF

auto Gauss2_PDF
Initial value:
Pdf< FUNCTOR, INTEGRATOR > make_pdf(FUNCTOR const &functor, INTEGRATOR integrator)
Build a hydra::Pdf given a shape described by a functor and a integrator (algorithm or functor)...
Definition: Pdf.h:299
hydra::Parameter sigma2_p
Definition: extended_logLL_fit.inl:136
double max
Definition: extended_logLL_fit.inl:121
Gaussian functions are often used to represent the probability density function of a normally dist...
Definition: Gaussian.h:62
double min
Definition: extended_logLL_fit.inl:120
Definition: AnalyticalIntegral.inl:39
hydra::Parameter mean2_p
Definition: extended_logLL_fit.inl:135
Examples:
extended_logLL_fit.inl.

◆ max

double max = 10.0

◆ mean1_p

hydra::Parameter mean1_p = hydra::Parameter::Create().Name("Mean_1").Value( 2.5) .Error(0.0001).Limits(0.0, 10.0)

◆ mean2_p

hydra::Parameter mean2_p = hydra::Parameter::Create().Name("Mean_2").Value(5.0) .Error(0.0001).Limits(0.0, 10.0)

◆ min

double min = 0.0

◆ model

◆ N_Exp_p

hydra::Parameter N_Exp_p("N_Exp",nentries, sqrt(nentries), nentries-nentries/2, nentries+nentries/2)

◆ N_Gauss_1_p

hydra::Parameter N_Gauss_1_p("N_Gauss1",nentries, sqrt(nentries), nentries-nentries/2, nentries+nentries/2)

◆ N_Gauss_2_p

hydra::Parameter N_Gauss_2_p("N_Gauss2",nentries, sqrt(nentries), nentries-nentries/2, nentries+nentries/2)

◆ nentries

nentries = EArg.getValue()

◆ return

return

◆ sigma1_p

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

◆ sigma2_p

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

◆ tau_p

hydra::Parameter tau_p = hydra::Parameter::Create().Name("Tau").Value(1.0).Error(0.0001).Limits(-2.0, 2.0)

◆ try

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