CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
gen::PtYDistributor Class Reference

#include <PtYDistributor.h>

Public Member Functions

double firePt ()
 
double firePt (double ptmin, double ptmax)
 
double fireY ()
 
double fireY (double ymin, double ymax)
 
 PtYDistributor ()
 
 PtYDistributor (const edm::FileInPath &fip, CLHEP::HepRandomEngine &fRandomEngine, 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

Definition at line 17 of file PtYDistributor.h.

17 {};
PtYDistributor::PtYDistributor ( const edm::FileInPath fip,
CLHEP::HepRandomEngine &  fRandomEngine,
double  ptmax = 100,
double  ptmin = 0,
double  ymax = 10,
double  ymin = -10,
int  ptbins = 1000,
int  ybins = 50 
)

Definition at line 10 of file PtYDistributor.cc.

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

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

Definition at line 22 of file PtYDistributor.h.

22 {};

Member Function Documentation

double PtYDistributor::firePt ( )

Definition at line 68 of file PtYDistributor.cc.

References ptmax_, and ptmin_.

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

68  {
69  return firePt(ptmin_,ptmax_);
70 }
double PtYDistributor::firePt ( double  ptmin,
double  ptmax 
)

Definition at line 88 of file PtYDistributor.cc.

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

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

Definition at line 63 of file PtYDistributor.cc.

References ymax_, and ymin_.

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

63  {
64  return fireY(ymin_,ymax_);
65 }
double PtYDistributor::fireY ( double  ymin,
double  ymax 
)

Definition at line 73 of file PtYDistributor.cc.

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

73  {
74 
75  double y = -999;
76 
77  if(fYGenerator){
78  while(y < ymin || y > ymax)
79  y = ymin_+(ymax_-ymin_)*fYGenerator->fire();
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

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