CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
gen::PtYDistributor Class Reference

#include <PtYDistributor.h>

Public Member Functions

double firePt (CLHEP::HepRandomEngine *)
 
double firePt (double ptmin, double ptmax, CLHEP::HepRandomEngine *)
 
double fireY (CLHEP::HepRandomEngine *)
 
double fireY (double ymin, double ymax, CLHEP::HepRandomEngine *)
 
 PtYDistributor ()
 
 PtYDistributor (const edm::FileInPath &fip, double ptmax, double ptmin, double ymax, double ymin, int ptbins, int ybins)
 
virtual ~PtYDistributor ()
 

Private Attributes

CLHEP::RandGeneral * fPtGenerator
 
CLHEP::RandGeneral * fYGenerator
 
int ptbins_
 
double ptmax_
 
double ptmin_
 
int ybins_
 
double ymax_
 
double ymin_
 

Detailed Description

Definition at line 14 of file PtYDistributor.h.

Constructor & Destructor Documentation

◆ PtYDistributor() [1/2]

gen::PtYDistributor::PtYDistributor ( )
inline

Definition at line 16 of file PtYDistributor.h.

16 {};

◆ PtYDistributor() [2/2]

PtYDistributor::PtYDistributor ( const edm::FileInPath fip,
double  ptmax = 100,
double  ptmin = 0,
double  ymax = 10,
double  ymin = -10,
int  ptbins = 1000,
int  ybins = 50 
)

Definition at line 16 of file PtYDistributor.cc.

24  // edm::FileInPath f1(input);
25  std::string fDataFile = fip.fullPath();
26 
27  std::cout << " File from " << fDataFile << std::endl;
28  TFile f(fDataFile.c_str(), "READ");
29  TGraph* yfunc = (TGraph*)f.Get("rapidity");
30  TGraph* ptfunc = (TGraph*)f.Get("pt");
31 
32  if (!yfunc)
33  throw edm::Exception(edm::errors::NullPointerError, "PtYDistributor")
34  << "Rapidity distribution could not be found in file " << fDataFile;
35 
36  if (!ptfunc)
37  throw edm::Exception(edm::errors::NullPointerError, "PtYDistributor")
38  << "Pt distribution could not be found in file " << fDataFile;
39 
40  if (ptbins_ > 100000) {
41  ptbins_ = 100000;
42  }
43 
44  if (ybins_ > 100000) {
45  ybins_ = 100000;
46  }
47 
48  double aProbFunc1[100000];
49  double aProbFunc2[100000];
50 
51  for (int i = 0; i < ybins_; ++i) {
52  double xy = ymin_ + i * (ymax_ - ymin_) / ybins_;
53  double yy = yfunc->Eval(xy);
54  aProbFunc1[i] = yy;
55  }
56 
57  for (int ip = 0; ip < ptbins_; ++ip) {
58  double xpt = ptmin_ + ip * (ptmax_ - ptmin_) / ptbins_;
59  double ypt = ptfunc->Eval(xpt);
60  aProbFunc2[ip] = ypt;
61  }
62 
63  fYGenerator = new CLHEP::RandGeneral(nullptr, aProbFunc1, ybins_);
64  fPtGenerator = new CLHEP::RandGeneral(nullptr, aProbFunc2, ptbins_);
65 
66  f.Close();
67 
68 } // from file

References gather_cfg::cout, Exception, f, fPtGenerator, edm::FileInPath::fullPath(), fYGenerator, mps_fire::i, edm::errors::NullPointerError, ptbins_, ptmax_, ptmin_, AlCaHLTBitMon_QueryRunRegistry::string, geometryCSVtoXML::xy, ybins_, ymax_, ymin_, and geometryCSVtoXML::yy.

◆ ~PtYDistributor()

virtual gen::PtYDistributor::~PtYDistributor ( )
inlinevirtual

Definition at line 20 of file PtYDistributor.h.

20 {};

Member Function Documentation

◆ firePt() [1/2]

double PtYDistributor::firePt ( CLHEP::HepRandomEngine *  engine)

Definition at line 72 of file PtYDistributor.cc.

72 { return firePt(ptmin_, ptmax_, engine); }

References ptmax_, and ptmin_.

Referenced by gen::Pythia6PtYDistGun::generateEvent().

◆ firePt() [2/2]

double PtYDistributor::firePt ( double  ptmin,
double  ptmax,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 87 of file PtYDistributor.cc.

87  {
88  double pt = -999;
89 
90  if (fPtGenerator) {
91  while (pt < ptmin || pt > ptmax)
92  pt = ptmin_ + (ptmax_ - ptmin_) * fPtGenerator->shoot(engine);
93  } else {
94  throw edm::Exception(edm::errors::NullPointerError, "PtYDistributor")
95  << "Random pt requested but Random Number Generator for pt not Initialized!";
96  }
97  return pt;
98 }

References Exception, fPtGenerator, edm::errors::NullPointerError, DiDispStaMuonMonitor_cfi::pt, muonTiming_cfi::ptmax, ptmax_, and ptmin_.

◆ fireY() [1/2]

double PtYDistributor::fireY ( CLHEP::HepRandomEngine *  engine)

Definition at line 70 of file PtYDistributor.cc.

70 { return fireY(ymin_, ymax_, engine); }

References ymax_, and ymin_.

Referenced by gen::Pythia6PtYDistGun::generateEvent().

◆ fireY() [2/2]

double PtYDistributor::fireY ( double  ymin,
double  ymax,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 74 of file PtYDistributor.cc.

74  {
75  double y = -999;
76 
77  if (fYGenerator) {
78  while (y < ymin || y > ymax)
79  y = ymin_ + (ymax_ - ymin_) * fYGenerator->shoot(engine);
80  } else {
81  throw edm::Exception(edm::errors::NullPointerError, "PtYDistributor")
82  << "Random y requested but Random Number Generator for y not Initialized!";
83  }
84  return y;
85 }

References Exception, fYGenerator, edm::errors::NullPointerError, L1TOccupancyClient_cfi::ymax, ymax_, and ymin_.

Member Data Documentation

◆ fPtGenerator

CLHEP::RandGeneral* gen::PtYDistributor::fPtGenerator
private

Definition at line 37 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

◆ fYGenerator

CLHEP::RandGeneral* gen::PtYDistributor::fYGenerator
private

Definition at line 36 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

◆ ptbins_

int gen::PtYDistributor::ptbins_
private

Definition at line 33 of file PtYDistributor.h.

Referenced by PtYDistributor().

◆ ptmax_

double gen::PtYDistributor::ptmax_
private

Definition at line 28 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

◆ ptmin_

double gen::PtYDistributor::ptmin_
private

Definition at line 29 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

◆ ybins_

int gen::PtYDistributor::ybins_
private

Definition at line 34 of file PtYDistributor.h.

Referenced by PtYDistributor().

◆ ymax_

double gen::PtYDistributor::ymax_
private

Definition at line 30 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

◆ ymin_

double gen::PtYDistributor::ymin_
private

Definition at line 31 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::errors::NullPointerError
Definition: EDMException.h:40
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
gen::PtYDistributor::fireY
double fireY(CLHEP::HepRandomEngine *)
Definition: PtYDistributor.cc:70
gen::PtYDistributor::ybins_
int ybins_
Definition: PtYDistributor.h:34
gen::PtYDistributor::fYGenerator
CLHEP::RandGeneral * fYGenerator
Definition: PtYDistributor.h:36
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
gen::PtYDistributor::ptmin_
double ptmin_
Definition: PtYDistributor.h:29
gen::PtYDistributor::ptbins_
int ptbins_
Definition: PtYDistributor.h:33
gen::PtYDistributor::ymax_
double ymax_
Definition: PtYDistributor.h:30
gen::PtYDistributor::ptmax_
double ptmax_
Definition: PtYDistributor.h:28
LepHTMonitor_cff.ptbins
ptbins
Definition: LepHTMonitor_cff.py:39
muonTiming_cfi.ptmax
ptmax
Definition: muonTiming_cfi.py:22
gen::PtYDistributor::fPtGenerator
CLHEP::RandGeneral * fPtGenerator
Definition: PtYDistributor.h:37
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
Exception
Definition: hltDiff.cc:246
ptmin
double ptmin
Definition: HydjetWrapper.h:84
gen::PtYDistributor::firePt
double firePt(CLHEP::HepRandomEngine *)
Definition: PtYDistributor.cc:72
gen::PtYDistributor::ymin_
double ymin_
Definition: PtYDistributor.h:31
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163