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.

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.

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
std::string fullPath() const
Definition: FileInPath.cc:161
double f[11][100]
CLHEP::RandGeneral * fYGenerator
CLHEP::RandGeneral * fPtGenerator
double ptmin
Definition: HydjetWrapper.h:84

◆ ~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.

References ptmax_, and ptmin_.

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

72 { return firePt(ptmin_, ptmax_, engine); }
double firePt(CLHEP::HepRandomEngine *)

◆ firePt() [2/2]

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

Definition at line 87 of file PtYDistributor.cc.

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

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 }
CLHEP::RandGeneral * fPtGenerator

◆ fireY() [1/2]

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

Definition at line 70 of file PtYDistributor.cc.

References ymax_, and ymin_.

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

70 { return fireY(ymin_, ymax_, engine); }
double fireY(CLHEP::HepRandomEngine *)

◆ fireY() [2/2]

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

Definition at line 74 of file PtYDistributor.cc.

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

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 }
CLHEP::RandGeneral * fYGenerator

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().