CMS 3D CMS Logo

Public Member Functions | Private Attributes

gen::Py8PtGun Class Reference

Inheritance diagram for gen::Py8PtGun:
gen::Py8GunBase gen::Py8InterfaceBase

List of all members.

Public Member Functions

const char * classname () const
bool generatePartonsAndHadronize ()
 Py8PtGun (edm::ParameterSet const &)
 ~Py8PtGun ()

Private Attributes

bool fAddAntiParticle
double fMaxEta
double fMaxPt
double fMinEta
double fMinPt

Detailed Description

Definition at line 10 of file Py8PtGun.cc.


Constructor & Destructor Documentation

gen::Py8PtGun::Py8PtGun ( edm::ParameterSet const &  ps)

Definition at line 33 of file Py8PtGun.cc.

References fAddAntiParticle, fMaxEta, fMaxPt, fMinEta, fMinPt, and edm::ParameterSet::getParameter().

   : Py8GunBase(ps) 
{

   // ParameterSet defpset ;
   edm::ParameterSet pgun_params = 
      ps.getParameter<edm::ParameterSet>("PGunParameters"); // , defpset ) ;
   fMinEta     = pgun_params.getParameter<double>("MinEta"); // ,-2.2);
   fMaxEta     = pgun_params.getParameter<double>("MaxEta"); // , 2.2);
   fMinPt      = pgun_params.getParameter<double>("MinPt"); // ,  0.);
   fMaxPt      = pgun_params.getParameter<double>("MaxPt"); // ,  0.);
   fAddAntiParticle = pgun_params.getParameter<bool>("AddAntiParticle"); //, false) ;  

}
gen::Py8PtGun::~Py8PtGun ( ) [inline]

Definition at line 15 of file Py8PtGun.cc.

{}

Member Function Documentation

const char * gen::Py8PtGun::classname ( ) const [virtual]

Implements gen::Py8InterfaceBase.

Definition at line 111 of file Py8PtGun.cc.

{
   return "Py8PtGun"; 
}
bool gen::Py8PtGun::generatePartonsAndHadronize ( ) [virtual]

Implements gen::Py8InterfaceBase.

Definition at line 48 of file Py8PtGun.cc.

References python::multivaluedict::append(), funct::cos(), eta(), gen::Py8GunBase::event(), create_public_lumi_plots::exp, fAddAntiParticle, gen::Py8InterfaceBase::fMasterGen, fMaxEta, gen::Py8GunBase::fMaxPhi, fMaxPt, fMinEta, gen::Py8GunBase::fMinPhi, fMinPt, gen::Py8GunBase::fPartIDs, i, phi, createTree::pp, randomEngine, funct::sin(), mathSSE::sqrt(), and gen::Py8InterfaceBase::toHepMC.

{

   fMasterGen->event.reset();
   
   for ( size_t i=0; i<fPartIDs.size(); i++ )
   {

      int particleID = fPartIDs[i]; // this is PDG - need to convert to Py8 ???

      // FIXME !!!
      // Ouch, it's using bare randomEngine pointer - that's NOT safe.
      // Need to hold a pointer somewhere properly !!!
      //
      double phi = (fMaxPhi-fMinPhi) * randomEngine->flat() + fMinPhi;
      double eta  = (fMaxEta-fMinEta) * randomEngine->flat() + fMinEta;                                                      
      double the  = 2.*atan(exp(-eta));                                                                          

      double pt   = (fMaxPt-fMinPt) * randomEngine->flat() + fMinPt;
      
      double mass = (fMasterGen->particleData).mass( particleID );
//      double mass = (pythia->particleData).m0( particleID );

      double pp = pt / sin(the); // sqrt( ee*ee - mass*mass );
      double ee = sqrt( pp*pp + mass*mass );
      
      double px = pt * cos(phi);
      double py = pt * sin(phi);
      double pz = pp * cos(the);

      if ( !((fMasterGen->particleData).isParticle( particleID )) )
      {
         particleID = std::fabs(particleID) ;
      }
      (fMasterGen->event).append( particleID, 1, 0, 0, px, py, pz, ee, mass ); 

// Here also need to add anti-particle (if any)
// otherwise just add a 2nd particle of the same type 
// (for example, gamma)
//
      if ( fAddAntiParticle )
      {
         if ( (fMasterGen->particleData).isParticle( -particleID ) )
         {
            (fMasterGen->event).append( -particleID, 1, 0, 0, px, py, pz, ee, mass );
         }
         else
         {
            (fMasterGen->event).append( particleID, 1, 0, 0, px, py, pz, ee, mass );
         }
      }

   }
   
   if ( !fMasterGen->next() ) return false;
   
   event().reset(new HepMC::GenEvent);
   toHepMC.fill_next_event( fMasterGen->event, event().get() );
      
   return true;   
  
}

Member Data Documentation

Definition at line 27 of file Py8PtGun.cc.

Referenced by generatePartonsAndHadronize(), and Py8PtGun().

double gen::Py8PtGun::fMaxEta [private]

Definition at line 24 of file Py8PtGun.cc.

Referenced by generatePartonsAndHadronize(), and Py8PtGun().

double gen::Py8PtGun::fMaxPt [private]

Definition at line 26 of file Py8PtGun.cc.

Referenced by generatePartonsAndHadronize(), and Py8PtGun().

double gen::Py8PtGun::fMinEta [private]

Definition at line 23 of file Py8PtGun.cc.

Referenced by generatePartonsAndHadronize(), and Py8PtGun().

double gen::Py8PtGun::fMinPt [private]

Definition at line 25 of file Py8PtGun.cc.

Referenced by generatePartonsAndHadronize(), and Py8PtGun().