Hydra  4.0.1
A header-only templated C++ framework to perform data analysis on massively parallel platforms.
double_gaussian_plus_exponential.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/DenseHistogram.h>
#include <hydra/functions/Gaussian.h>
#include <hydra/functions/Exponential.h>
#include <hydra/Placeholders.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 double_gaussian_plus_exponential.inl:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DOUBLE_GAUSSIAN_PLUS_EXPONENTIAL_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
 
auto Background_PDF = hydra::make_pdf(hydra::Exponential<_X>(tau) , hydra::AnalyticalIntegral<hydra::Exponential<_X>>(min, max))
 
auto Core_PDF = hydra::make_pdf( hydra::Gaussian<_X>(mean, sigma_core), hydra::AnalyticalIntegral<hydra::Gaussian<_X>>(min, max))
 
std::cout<< std::endl<< "Generated 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(5000, 5));auto end_d=std::chrono::high_resolution_clock::now();std::chrono::duration< double, std::milli > elapsed_d = end_d - start_d
 
auto fraction = hydra::Parameter("Core_Fraction" , 0.5, 0.001, 0.2 , 0.7)
 
double max = 10.0
 
auto mean = hydra::Parameter::Create().Name("Mean").Value(0.0).Error(0.0001).Limits(-1.5, 1.5)
 
double min = -10.0
 
auto model = hydra::add_pdfs( {N_Signal, N_Background}, Signal_PDF, Background_PDF)
 
char const * model_name = "Gaussian (core) + Gaussian (tail) + Exponential"
 
hydra::Parameter N_Background ("N_Background", 2000, 1, 100, nentries)
 
hydra::Parameter N_Signal ("N_Signal", 2000, 1, 100, nentries)
 
 nentries = EArg.getValue()
 
auto range = hydra::sample(data, min, max, model.GetFunctor())
 
 return
 
auto sigma_core = hydra::Parameter::Create().Name("Sigma_Core").Value(0.5).Error(0.0001).Limits(0.1, 1.0)
 
auto sigma_tail = hydra::Parameter::Create().Name("Sigma_Tail").Value(1.5).Error(0.0001).Limits(1.0, 2.0)
 
auto Signal_PDF = hydra::add_pdfs( std::array<hydra::Parameter, 1>{fraction}, Core_PDF, Tail_PDF)
 
auto Tail_PDF = hydra::make_pdf( hydra::Gaussian<_X>(mean, sigma_tail), hydra::AnalyticalIntegral<hydra::Gaussian<_X>>(min, max))
 
auto tau = hydra::Parameter::Create().Name("Tau").Value(-0.5).Error(0.0001).Limits(-1.0, 0.0)
 
 try
 

Macro Definition Documentation

◆ DOUBLE_GAUSSIAN_PLUS_EXPONENTIAL_INL_

#define DOUBLE_GAUSSIAN_PLUS_EXPONENTIAL_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: double_gaussian_plus_exponential.inl:108
Examples:
double_gaussian_plus_exponential.inl.

◆ Background_PDF

◆ Core_PDF

◆ elapsed_d

std::cout<< std::endl<< "Generated 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(5000, 5)); auto end_d = std::chrono::high_resolution_clock::now(); std::chrono::duration<double, std::milli> elapsed_d = end_d - start_d

◆ fraction

auto fraction = hydra::Parameter("Core_Fraction" , 0.5, 0.001, 0.2 , 0.7)

◆ max

◆ mean

auto mean = hydra::Parameter::Create().Name("Mean").Value(0.0).Error(0.0001).Limits(-1.5, 1.5)

◆ min

◆ model

◆ model_name

char const* model_name = "Gaussian (core) + Gaussian (tail) + Exponential"

◆ N_Background

hydra::Parameter N_Background("N_Background", 2000, 1, 100, nentries)

◆ N_Signal

hydra::Parameter N_Signal("N_Signal",2000, 1, 100, nentries)

◆ nentries

nentries = EArg.getValue()

◆ range

auto range = hydra::sample(data, min, max, model.GetFunctor())

◆ return

return

◆ sigma_core

auto sigma_core = hydra::Parameter::Create().Name("Sigma_Core").Value(0.5).Error(0.0001).Limits(0.1, 1.0)

◆ sigma_tail

auto sigma_tail = hydra::Parameter::Create().Name("Sigma_Tail").Value(1.5).Error(0.0001).Limits(1.0, 2.0)

◆ Signal_PDF

◆ Tail_PDF

◆ tau

auto tau = hydra::Parameter::Create().Name("Tau").Value(-0.5).Error(0.0001).Limits(-1.0, 0.0)

◆ try

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