ATLAS Offline Software
Loading...
Searching...
No Matches
PunchThroughPDFCreator Class Reference

Creates random numbers with a distribution given as ROOT TF1. More...

#include <PunchThroughPDFCreator.h>

Collaboration diagram for PunchThroughPDFCreator:

Public Member Functions

 PunchThroughPDFCreator ()
 construct the class with a given TF1 and a random engine
 ~PunchThroughPDFCreator ()
void setName (const std::string &PDFname)
 all following is used to set up the class
void addToEnergyEtaHist1DMap (int energy, int etaMin, TH1 *hist)
double getRand (CLHEP::HepRandomEngine *rndmEngine, const std::vector< int > &inputParameters) const
 get the random value with this method, by providing the input parameters
const std::string & getName () const

Private Attributes

std::string m_name
 Give pdf a name for debug purposes.
std::map< int, std::map< int, TH1 * > > m_energy_eta_hists1D
 map of energies to map of eta ranges to 1D histograms

Detailed Description

Creates random numbers with a distribution given as ROOT TF1.

The TF1 function parameters will be retrieved from a histogram given by addPar.

Author
Elmar Ritsch Elmar.nosp@m..Rit.nosp@m.sch@c.nosp@m.ern..nosp@m.ch @maintainer/updater Thomas Carter thoma.nosp@m.s.mi.nosp@m.chael.nosp@m..car.nosp@m.ter@c.nosp@m.ern..nosp@m.ch @maintainer/updater Firdaus Soberi firda.nosp@m.us.s.nosp@m.oberi.nosp@m.@cer.nosp@m.n.ch

Definition at line 34 of file PunchThroughPDFCreator.h.

Constructor & Destructor Documentation

◆ PunchThroughPDFCreator()

PunchThroughPDFCreator::PunchThroughPDFCreator ( )
inline

construct the class with a given TF1 and a random engine

Definition at line 39 of file PunchThroughPDFCreator.h.

39{};

◆ ~PunchThroughPDFCreator()

PunchThroughPDFCreator::~PunchThroughPDFCreator ( )

Definition at line 21 of file PunchThroughPDFCreator.cxx.

21 {
22 for(auto & each_outter : m_energy_eta_hists1D) {
23 for(auto & each_inner : each_outter.second) {
24 delete each_inner.second;
25 }
26 }
27}
std::map< int, std::map< int, TH1 * > > m_energy_eta_hists1D
map of energies to map of eta ranges to 1D histograms

Member Function Documentation

◆ addToEnergyEtaHist1DMap()

void PunchThroughPDFCreator::addToEnergyEtaHist1DMap ( int energy,
int etaMin,
TH1 * hist )

Definition at line 29 of file PunchThroughPDFCreator.cxx.

29 {
30 // Make a local copy
31 TH1* localHist = (TH1*) hist->Clone();
32 localHist->SetDirectory(0);
33
34 if(m_energy_eta_hists1D.find(energy) != m_energy_eta_hists1D.end()){ //if energy entry exists, insert into inner eta map
35 (m_energy_eta_hists1D.find(energy)->second).insert(std::make_pair(etaMin, localHist));
36 }
37 else{ //if energy entry does not exist create new full energy entry
38 std::map< int, TH1*> inner;
39 inner.insert(std::make_pair(etaMin, localHist));
40 m_energy_eta_hists1D.insert(std::make_pair(energy, inner));
41 }
42}

◆ getName()

const std::string & PunchThroughPDFCreator::getName ( ) const
inline

Definition at line 49 of file PunchThroughPDFCreator.h.

49{return m_name;};
std::string m_name
Give pdf a name for debug purposes.

◆ getRand()

double PunchThroughPDFCreator::getRand ( CLHEP::HepRandomEngine * rndmEngine,
const std::vector< int > & inputParameters ) const

get the random value with this method, by providing the input parameters

Definition at line 44 of file PunchThroughPDFCreator.cxx.

45{
46
47 //define variable to return from getRand call, should never return zero
48 float randomHist = 0.;
49
50 if( m_energy_eta_hists1D.find(inputParameters.at(0)) == m_energy_eta_hists1D.end()) {
51 //this should never be reached
52 return 0.;
53 }
54
55 const std::map< int, TH1*>& etaMin_hists = m_energy_eta_hists1D.at(inputParameters.at(0));
56
57 if( etaMin_hists.find(inputParameters.at(1)) == etaMin_hists.end()) {
58 //this should never be reached
59 return 0.;
60 }
61
62 //get the chosen histogram from the map
63 TH1* hist = etaMin_hists.at(inputParameters.at(1));
64
65 //Draw randomly from the histogram CDF distribution.
66 double randomShoot = CLHEP::RandFlat::shoot(rndmEngine);
67
68 //first select the matching CDF bin
69 int iBinSelect = 0;
70 for(int iBin = 0; iBin < hist->GetNbinsX(); iBin ++){
71 iBinSelect = iBin;
72 if(hist->GetBinContent(iBin) > randomShoot){
73 break;
74 }
75 }
76
77 //Select random value within bin
78 randomHist = CLHEP::RandFlat::shoot(rndmEngine, hist->GetBinLowEdge(iBinSelect) , hist->GetBinLowEdge(iBinSelect+1));
79
80 return randomHist;
81
82}

◆ setName()

void PunchThroughPDFCreator::setName ( const std::string & PDFname)
inline

all following is used to set up the class

Definition at line 44 of file PunchThroughPDFCreator.h.

44{ m_name = PDFname; }; //get the pdf's name

Member Data Documentation

◆ m_energy_eta_hists1D

std::map< int , std::map< int, TH1*> > PunchThroughPDFCreator::m_energy_eta_hists1D
private

map of energies to map of eta ranges to 1D histograms

Definition at line 53 of file PunchThroughPDFCreator.h.

◆ m_name

std::string PunchThroughPDFCreator::m_name
private

Give pdf a name for debug purposes.

Definition at line 52 of file PunchThroughPDFCreator.h.


The documentation for this class was generated from the following files: