CMS 3D CMS Logo

Public Member Functions | Private Attributes

gen::PtYDistributor Class Reference

#include <PtYDistributor.h>

List of all members.

Public Member Functions

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

{};
PtYDistributor::PtYDistributor ( 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, Exception, f, fPtGenerator, edm::FileInPath::fullPath(), fYGenerator, i, edm::errors::NullPointerError, ptbins_, ptmax_, ptmin_, create_public_lumi_plots::xy, ybins_, ymax_, and ymin_.

   : ptmax_(ptmax),ptmin_(ptmin),ymax_(ymax),ymin_(ymin), ptbins_(ptbins), ybins_(ybins)
{  
   // edm::FileInPath f1(input);
   std::string fDataFile = fip.fullPath();

   std::cout<<" File from "<<fDataFile <<std::endl;
   TFile f(fDataFile.c_str(),"READ");
   TGraph* yfunc = (TGraph*)f.Get("rapidity"); 
   TGraph* ptfunc = (TGraph*)f.Get("pt");

   if( !yfunc ) 
      throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
         <<"Rapidity distribution could not be found in file "<<fDataFile;

   if( !ptfunc )
      throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
         <<"Pt distribution could not be found in file "<<fDataFile;

   if(ptbins_ > 100000){
      ptbins_ = 100000;
   }

   if(ybins_ > 100000){
      ybins_ = 100000;
   }

   double aProbFunc1[100000];
   double aProbFunc2[100000];

   for(int i = 0; i < ybins_; ++i){
      double xy = ymin_+i*(ymax_-ymin_)/ybins_;
      double yy = yfunc->Eval(xy);   
      aProbFunc1[i] = yy;
   }

   for(int ip = 0; ip < ptbins_; ++ip){
      double xpt = ptmin_+ip*(ptmax_-ptmin_)/ptbins_;
      double ypt = ptfunc->Eval(xpt);
      aProbFunc2[ip] = ypt;
   }

  fYGenerator = new CLHEP::RandGeneral(fRandomEngine,aProbFunc1,ybins_);
  fPtGenerator = new CLHEP::RandGeneral(fRandomEngine,aProbFunc2,ptbins_);

  f.Close();
  
} // from file
virtual gen::PtYDistributor::~PtYDistributor ( ) [inline, virtual]

Definition at line 22 of file PtYDistributor.h.

{};

Member Function Documentation

double PtYDistributor::firePt ( )

Definition at line 68 of file PtYDistributor.cc.

References ptmax_, and ptmin_.

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

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

Definition at line 88 of file PtYDistributor.cc.

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

                                                {

   double pt = -999;

   if(fPtGenerator){
      while(pt < ptmin || pt > ptmax)
         pt = ptmin_+(ptmax_-ptmin_)*fPtGenerator->fire();
   }else{
      throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
         <<"Random pt requested but Random Number Generator for pt not Initialized!";
   }
   return pt;
}
double PtYDistributor::fireY ( double  ymin,
double  ymax 
)

Definition at line 73 of file PtYDistributor.cc.

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

                                             {

   double y = -999;

   if(fYGenerator){
      while(y < ymin || y > ymax)
         y = ymin_+(ymax_-ymin_)*fYGenerator->fire();
   }else{
      throw edm::Exception(edm::errors::NullPointerError,"PtYDistributor")
         <<"Random y requested but Random Number Generator for y not Initialized!";
   }
   return y;
}
double PtYDistributor::fireY ( )

Definition at line 63 of file PtYDistributor.cc.

References ymax_, and ymin_.

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

                     {
   return fireY(ymin_,ymax_);
}

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

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

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