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 15 of file PtYDistributor.h.

Constructor & Destructor Documentation

gen::PtYDistributor::PtYDistributor ( )
inline
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, i, edm::errors::NullPointerError, ptbins_, ptmax_, ptmin_, AlCaHLTBitMon_QueryRunRegistry::string, geometryCSVtoXML::xy, ybins_, ymax_, ymin_, and geometryCSVtoXML::yy.

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

Definition at line 22 of file PtYDistributor.h.

22 {};

Member Function Documentation

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

Definition at line 74 of file PtYDistributor.cc.

References ptmax_, and ptmin_.

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

74  {
75  return firePt(ptmin_,ptmax_, engine);
76 }
double firePt(CLHEP::HepRandomEngine *)
double PtYDistributor::firePt ( double  ptmin,
double  ptmax,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 94 of file PtYDistributor.cc.

References Exception, fPtGenerator, edm::errors::NullPointerError, EnergyCorrector::pt, ptmax_, and ptmin_.

94  {
95 
96  double pt = -999;
97 
98  if(fPtGenerator){
99  while(pt < ptmin || pt > ptmax)
100  pt = ptmin_+(ptmax_-ptmin_)*fPtGenerator->shoot(engine);
101  }else{
102  throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
103  <<"Random pt requested but Random Number Generator for pt not Initialized!";
104  }
105  return pt;
106 }
CLHEP::RandGeneral * fPtGenerator
double PtYDistributor::fireY ( CLHEP::HepRandomEngine *  engine)

Definition at line 69 of file PtYDistributor.cc.

References ymax_, and ymin_.

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

69  {
70  return fireY(ymin_,ymax_, engine);
71 }
double fireY(CLHEP::HepRandomEngine *)
double PtYDistributor::fireY ( double  ymin,
double  ymax,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 79 of file PtYDistributor.cc.

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

79  {
80 
81  double y = -999;
82 
83  if(fYGenerator){
84  while(y < ymin || y > ymax)
85  y = ymin_+(ymax_-ymin_)*fYGenerator->shoot(engine);
86  }else{
87  throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
88  <<"Random y requested but Random Number Generator for y not Initialized!";
89  }
90  return y;
91 }
CLHEP::RandGeneral * fYGenerator

Member Data Documentation

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

Definition at line 39 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

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

Definition at line 38 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

int gen::PtYDistributor::ptbins_
private

Definition at line 35 of file PtYDistributor.h.

Referenced by PtYDistributor().

double gen::PtYDistributor::ptmax_
private

Definition at line 30 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

double gen::PtYDistributor::ptmin_
private

Definition at line 31 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

int gen::PtYDistributor::ybins_
private

Definition at line 36 of file PtYDistributor.h.

Referenced by PtYDistributor().

double gen::PtYDistributor::ymax_
private

Definition at line 32 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

double gen::PtYDistributor::ymin_
private

Definition at line 33 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().