CMS 3D CMS Logo

edm::PtYDistributor Class Reference

#include <GeneratorInterface/Pythia6Interface/interface/PtYDistributor.h>

List of all members.

Public Member Functions

double firePt (double ptmin, double ptmax)
double firePt ()
double fireY (double ymin, double ymax)
double fireY ()
 PtYDistributor (std::string inputfile, CLHEP::HepRandomEngine &fRandomEngine, double ptmax, double ptmin, double ymax, double ymin, int ptbins, int ybins)
 PtYDistributor ()
virtual ~PtYDistributor ()

Private Attributes

std::string file
RandGeneral * fPtGenerator
RandGeneral * fYGenerator
int ptbins_
double ptmax_
double ptmin_
int ybins_
double ymax_
double ymin_


Detailed Description

Definition at line 13 of file PtYDistributor.h.


Constructor & Destructor Documentation

edm::PtYDistributor::PtYDistributor (  )  [inline]

Definition at line 15 of file PtYDistributor.h.

00015 {};

PtYDistributor::PtYDistributor ( std::string  inputfile,
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 GenMuonPlsPt100GeV_cfg::cout, lat::endl(), f, f1, fPtGenerator, edm::FileInPath::fullPath(), fYGenerator, i, edm::errors::NullPointerError, ptbins_, ptmax_, ptmin_, ybins_, ymax_, and ymin_.

00010                                                                                                                                                                                                  : ptmax_(ptmax),ptmin_(ptmin),ymax_(ymax),ymin_(ymin), ptbins_(ptbins), ybins_(ybins)
00011 {  
00012    edm::FileInPath f1(input);
00013    std::string fDataFile = f1.fullPath();
00014 
00015    std::cout<<" File from "<<fDataFile <<std::endl;
00016    TFile f(fDataFile.c_str(),"READ");
00017    TGraph* yfunc = (TGraph*)f.Get("rapidity"); 
00018    TGraph* ptfunc = (TGraph*)f.Get("pt");
00019 
00020    if( !yfunc ) 
00021       throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
00022          <<"Rapidity distribution could not be found in file "<<fDataFile;
00023 
00024    if( !ptfunc )
00025       throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
00026          <<"Pt distribution could not be found in file "<<fDataFile;
00027 
00028    if(ptbins_ > 100000){
00029       ptbins_ = 100000;
00030    }
00031 
00032    if(ybins_ > 100000){
00033       ybins_ = 100000;
00034    }
00035 
00036    double aProbFunc1[100000];
00037    double aProbFunc2[100000];
00038 
00039    for(int i = 0; i < ybins_; ++i){
00040       double xy = ymin_+i*(ymax_-ymin_)/ybins_;
00041       double yy = yfunc->Eval(xy);   
00042       aProbFunc1[i] = yy;
00043    }
00044 
00045    for(int ip = 0; ip < ptbins_; ++ip){
00046       double xpt = ptmin_+ip*(ptmax_-ptmin_)/ptbins_;
00047       double ypt = ptfunc->Eval(xpt);
00048       aProbFunc2[ip] = ypt;
00049    }
00050 
00051   fYGenerator = new RandGeneral(fRandomEngine,aProbFunc1,ybins_);
00052   fPtGenerator = new RandGeneral(fRandomEngine,aProbFunc2,ptbins_);
00053 
00054   f.Close();
00055   
00056 } // from file

virtual edm::PtYDistributor::~PtYDistributor (  )  [inline, virtual]

Definition at line 17 of file PtYDistributor.h.

00017 {};


Member Function Documentation

double PtYDistributor::firePt ( double  ptmin,
double  ptmax 
)

Definition at line 84 of file PtYDistributor.cc.

References fPtGenerator, edm::errors::NullPointerError, ptmax_, and ptmin_.

00084                                                 {
00085 
00086    double pt = -999;
00087 
00088    if(fPtGenerator){
00089       while(pt < ptmin || pt > ptmax)
00090          pt = ptmin_+(ptmax_-ptmin_)*fPtGenerator->fire();
00091    }else{
00092       throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
00093          <<"Random pt requested but Random Number Generator for pt not Initialized!";
00094    }
00095    return pt;
00096 }

double PtYDistributor::firePt (  ) 

Definition at line 64 of file PtYDistributor.cc.

References ptmax_, and ptmin_.

Referenced by edm::PythiaSource::produce(), and edm::PythiaProducer::produce().

00064                       {
00065    return firePt(ptmin_,ptmax_);
00066 }

double PtYDistributor::fireY ( double  ymin,
double  ymax 
)

Definition at line 69 of file PtYDistributor.cc.

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

00069                                              {
00070 
00071    double y = -999;
00072 
00073    if(fYGenerator){
00074       while(y < ymin || y > ymax)
00075          y = ymin_+(ymax_-ymin_)*fYGenerator->fire();
00076    }else{
00077       throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
00078          <<"Random y requested but Random Number Generator for y not Initialized!";
00079    }
00080    return y;
00081 }

double PtYDistributor::fireY (  ) 

Definition at line 59 of file PtYDistributor.cc.

References ymax_, and ymin_.

Referenced by edm::PythiaSource::produce(), and edm::PythiaProducer::produce().

00059                      {
00060    return fireY(ymin_,ymax_);
00061 }


Member Data Documentation

std::string edm::PtYDistributor::file [private]

Definition at line 33 of file PtYDistributor.h.

RandGeneral* edm::PtYDistributor::fPtGenerator [private]

Definition at line 36 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

RandGeneral* edm::PtYDistributor::fYGenerator [private]

Definition at line 35 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

int edm::PtYDistributor::ptbins_ [private]

Definition at line 30 of file PtYDistributor.h.

Referenced by PtYDistributor().

double edm::PtYDistributor::ptmax_ [private]

Definition at line 25 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

double edm::PtYDistributor::ptmin_ [private]

Definition at line 26 of file PtYDistributor.h.

Referenced by firePt(), and PtYDistributor().

int edm::PtYDistributor::ybins_ [private]

Definition at line 31 of file PtYDistributor.h.

Referenced by PtYDistributor().

double edm::PtYDistributor::ymax_ [private]

Definition at line 27 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().

double edm::PtYDistributor::ymin_ [private]

Definition at line 28 of file PtYDistributor.h.

Referenced by fireY(), and PtYDistributor().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:43:14 2009 for CMSSW by  doxygen 1.5.4