CMS 3D CMS Logo

edm::PythiaProducer Class Reference

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

Inheritance diagram for edm::PythiaProducer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

void endRun (Run &r, const EventSetup &es)
 PythiaProducer (const ParameterSet &)
 Constructor.
virtual ~PythiaProducer ()
 Destructor.

Private Member Functions

bool call_pygive (const std::string &iParm)
 Interface to the PYGIVE pythia routine, with add'l protections.
bool call_slha_init ()
bool call_slhagive (const std::string &iParm)
bool call_txgive (const std::string &iParm)
bool call_txgive_init ()
void clear ()
virtual void produce (Event &e, const EventSetup &es)

Private Attributes

bool doubleParticle
double emax
double emin
double etamax
double etamin
int eventNumber_
HepMC::GenEvent * evt
double extCrossSect
double extFilterEff
std::string fBeam1
std::string fBeam2
double fCOMEnergy
std::string fFrame
bool flatEnergy
PtYDistributorfPtYGenerator
CLHEP::HepRandomEngine & fRandomEngine
CLHEP::RandFlat * fRandomGenerator
bool gluinoHadronsEnabled
bool imposeProperTimes_
 Impose proper times for pions/kaons at generator level.
std::string kinedata
unsigned int maxEventsToPrint_
 Events to print if verbosity.
int particleID
double phimax
double phimin
double ptmax
double ptmin
bool pythiaHepMCVerbosity_
 HepMC verbosity flag.
unsigned int pythiaPylistVerbosity_
 Pythia PYLIST Verbosity flag.
bool stopHadronsEnabled
TauolaInterface tauola_
bool useExternalGenerators_
bool useTauola_
bool useTauolaPolarization_
double ymax
double ymin


Detailed Description

Definition at line 34 of file PythiaProducer.h.


Constructor & Destructor Documentation

PythiaProducer::PythiaProducer ( const ParameterSet pset  ) 

Constructor.

Definition at line 128 of file PythiaProducer.cc.

References call_pygive(), call_slha_init(), call_slhagive(), call_txgive(), call_txgive_init(), cards, edm::errors::Configuration, GenMuonPlsPt100GeV_cfg::cout, edm::TauolaInterface::disablePolarizationEffects(), doubleParticle, emax, emin, edm::TauolaInterface::enablePolarizationEffects(), lat::endl(), etamax, etamin, fBeam1, fBeam2, fCOMEnergy, fFrame, fPtYGenerator, fRandomEngine, fRandomGenerator, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), gluinoHadronsEnabled, i, edm::TauolaInterface::initialize(), kinedata, maxEventsToPrint_, pars, particleID, phimax, phimin, ptmax, ptmin, PYGLRHAD, PYSTRHAD, pythiaHepMCVerbosity_, pythiaPylistVerbosity_, randomEngine, stopHadronsEnabled, tauola_, useExternalGenerators_, useTauola_, useTauolaPolarization_, ymax, and ymin.

00128                                                          :
00129   EDProducer(), evt(0), 
00130   fFrame(pset.getParameter<string>("pythiaFrame")),
00131   fBeam1(pset.getUntrackedParameter<string>("pythiaBeam1","p")),
00132   fBeam2(pset.getUntrackedParameter<string>("pythiaBeam2","p")),
00133   fCOMEnergy(pset.getParameter<double>("comEnergy")),
00134   pythiaPylistVerbosity_ (pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0)),
00135   pythiaHepMCVerbosity_ (pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false)),
00136   imposeProperTimes_ (pset.getUntrackedParameter<bool>("imposeProperTimes",false)),
00137   maxEventsToPrint_ (pset.getUntrackedParameter<int>("maxEventsToPrint",1)),
00138   extCrossSect(pset.getUntrackedParameter<double>("crossSection", -1.)),
00139   extFilterEff(pset.getUntrackedParameter<double>("filterEfficiency", -1.)),
00140   useExternalGenerators_(false),
00141   useTauola_(false),
00142   useTauolaPolarization_(false),
00143   stopHadronsEnabled(false), gluinoHadronsEnabled(false),
00144   fRandomEngine(getEngineReference()),
00145   eventNumber_(0)
00146 {
00147   
00148   // PYLIST Verbosity Level
00149   // Valid PYLIST arguments are: 1, 2, 3, 5, 7, 11, 12, 13
00150   pythiaPylistVerbosity_ = pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0);
00151   
00152   // HepMC event verbosity Level
00153   pythiaHepMCVerbosity_ = pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false);
00154 
00155   //Max number of events printed on verbosity level 
00156   maxEventsToPrint_ = pset.getUntrackedParameter<int>("maxEventsToPrint",0);
00157   
00158   particleID = pset.getUntrackedParameter<int>("ParticleID", 0);
00159 
00160 // Initialize the random engine unconditionally
00161   randomEngine = &fRandomEngine;
00162   fRandomGenerator = new CLHEP::RandFlat(fRandomEngine) ;
00163 
00164   if(particleID) {
00165 
00166     cout <<" Particle ID = " << particleID << endl; 
00167 
00168     doubleParticle = pset.getUntrackedParameter<bool>("DoubleParticle",true);
00169     cout <<" double back-to-back " << doubleParticle << endl; 
00170 
00171     kinedata = pset.getUntrackedParameter<string>("kinematicsFile","");
00172 
00173     ptmin = pset.getUntrackedParameter<double>("Ptmin",20.);
00174     ptmax = pset.getUntrackedParameter<double>("Ptmax",420.);
00175     cout <<" ptmin = " << ptmin <<" ptmax = " << ptmax << endl;
00176   
00177     emin = pset.getUntrackedParameter<double>("Emin",-1);
00178     emax = pset.getUntrackedParameter<double>("Emax",-1);
00179     if ( emin > 0 && emax > 0 ) {
00180       cout <<" emin = " << emin <<" emax = " << emax << endl;
00181     }
00182 
00183     if(kinedata.size() < 1){
00184       etamin = pset.getUntrackedParameter<double>("Etamin",0.);
00185       etamax = pset.getUntrackedParameter<double>("Etamax",2.2);
00186       cout <<" etamin = " << etamin <<" etamax = " << etamax << endl;
00187     }else{
00188       ymin = pset.getUntrackedParameter<double>("ymin",0.);
00189       ymax = pset.getUntrackedParameter<double>("ymax",10.);
00190       cout <<" ymin = " << ymin <<" ymax = " << ymax << endl;
00191     }
00192 
00193     phimin = pset.getUntrackedParameter<double>("Phimin",0.);
00194     phimax = pset.getUntrackedParameter<double>("Phimax",360.);
00195     cout <<" phimin = " << phimin <<" phimax = " << phimax << endl;
00196 
00197     if(kinedata.size() > 0)
00198     {
00199        int ptbins = pset.getUntrackedParameter<int>("ptBinning",1000);
00200        int ybins = pset.getUntrackedParameter<int>("yBinning",50);
00201        fPtYGenerator = new PtYDistributor(kinedata, fRandomEngine,
00202                                           ptmax, ptmin, ymax, ymin, ptbins, ybins);
00203     }
00204   }
00205 
00206   // Set PYTHIA parameters in a single ParameterSet
00207   ParameterSet pythia_params = 
00208     pset.getParameter<ParameterSet>("PythiaParameters") ;
00209   
00210   // The parameter sets to be read (default, min bias, user ...) in the
00211   // proper order.
00212   vector<string> setNames = 
00213     pythia_params.getParameter<vector<string> >("parameterSets");
00214   
00215   // Loop over the sets
00216   for ( unsigned i=0; i<setNames.size(); ++i ) {
00217     
00218     string mySet = setNames[i];
00219     
00220     // Read the PYTHIA parameters for each set of parameters
00221     vector<string> pars = 
00222       pythia_params.getParameter<vector<string> >(mySet);
00223     
00224     if (mySet != "SLHAParameters" && mySet != "CSAParameters"){
00225     
00226     // Loop over all parameters and stop in case of mistake
00227     for( vector<string>::const_iterator  
00228            itPar = pars.begin(); itPar != pars.end(); ++itPar ) {
00229       static string sRandomValueSetting("MRPY(1)");
00230       if( 0 == itPar->compare(0,sRandomValueSetting.size(),sRandomValueSetting) ) {
00231         throw edm::Exception(edm::errors::Configuration,"PythiaError")
00232           <<" attempted to set random number using pythia command 'MRPY(1)' this is not allowed.\n  Please use the RandomNumberGeneratorService to set the random number seed.";
00233       }
00234       if( ! call_pygive(*itPar) ) {
00235         throw edm::Exception(edm::errors::Configuration,"PythiaError") 
00236           <<" pythia did not accept the following \""<<*itPar<<"\"";
00237       }
00238     }
00239     } else if(mySet == "CSAParameters"){   
00240 
00241    // Read CSA parameter
00242   
00243    pars = pythia_params.getParameter<vector<string> >("CSAParameters");
00244 
00245    call_txgive_init();
00246   
00247   
00248    // Loop over all parameters and stop in case of a mistake
00249     for (vector<string>::const_iterator 
00250             itPar = pars.begin(); itPar != pars.end(); ++itPar) {
00251       call_txgive(*itPar); 
00252      
00253          } 
00254      
00255    } else if(mySet == "SLHAParameters"){   
00256 
00257    // Read SLHA parameter
00258   
00259    pars = pythia_params.getParameter<vector<string> >("SLHAParameters");
00260 
00261    // Loop over all parameters and stop in case of a mistake
00262     for (vector<string>::const_iterator 
00263             itPar = pars.begin(); itPar != pars.end(); ++itPar) {
00264       call_slhagive(*itPar); 
00265      
00266          } 
00267  
00268     call_slha_init(); 
00269   
00270   }
00271   }
00272 
00273    stopHadronsEnabled = pset.getUntrackedParameter<bool>("stopHadrons",false);
00274    gluinoHadronsEnabled = pset.getUntrackedParameter<bool>("gluinoHadrons",false);
00275 
00276   //Init names and pdg code of r-hadrons
00277    if(stopHadronsEnabled)  PYSTRHAD();
00278    if(gluinoHadronsEnabled)  PYGLRHAD();
00279 
00280 #ifdef NOTYET
00281   //In the future, we will get the random number seed on each event and tell 
00282   // pythia to use that new seed
00283 // The random engine has already been initialized.  DO NOT do it again!
00284   edm::Service<RandomNumberGenerator> rng;
00285   uint32_t seed = rng->mySeed();
00286   ostringstream sRandomSet;
00287   sRandomSet <<"MRPY(1)="<<seed;
00288   call_pygive(sRandomSet.str());
00289 #endif
00290   
00291   call_pyinit( fFrame.c_str(), fBeam1.c_str(), fBeam2.c_str(), fCOMEnergy );
00292   
00293   // TAUOLA, etc.
00294   //
00295   useExternalGenerators_ = pset.getUntrackedParameter<bool>("UseExternalGenerators",false);
00296 //  useTauola_ = pset.getUntrackedParameter<bool>("UseTauola", false);
00297 //  useTauolaPolarization_ = pset.getUntrackedParameter<bool>("UseTauolaPolarization", false);
00298   
00299   if ( useExternalGenerators_ ) {
00300  // read External Generator parameters
00301     ParameterSet ext_gen_params =
00302        pset.getParameter<ParameterSet>("ExternalGenerators") ;
00303     vector<string> extGenNames =
00304        ext_gen_params.getParameter< vector<string> >("parameterSets");
00305     for (unsigned int ip=0; ip<extGenNames.size(); ++ip )
00306     {
00307       string curSet = extGenNames[ip];
00308       ParameterSet gen_par_set =
00309          ext_gen_params.getUntrackedParameter< ParameterSet >(curSet);
00310 /*
00311      cout << "----------------------------------------------" << endl;
00312      cout << "Read External Generator parameter set "  << endl;
00313      cout << "----------------------------------------------" << endl;
00314 */
00315      if ( curSet == "Tauola" )
00316      {
00317         useTauola_ = true;
00318         if ( useTauola_ ) {
00319            cout << "--> use TAUOLA" << endl;
00320         } 
00321         useTauolaPolarization_ = gen_par_set.getParameter<bool>("UseTauolaPolarization");
00322         if ( useTauolaPolarization_ ) 
00323         {
00324            cout << "(Polarization effects enabled)" << endl;
00325            tauola_.enablePolarizationEffects();
00326         } 
00327         else 
00328         {
00329            cout << "(Polarization effects disabled)" << endl;
00330            tauola_.disablePolarizationEffects();
00331         }
00332         vector<string> cards = gen_par_set.getParameter< vector<string> >("InputCards");
00333         cout << "----------------------------------------------" << endl;
00334         cout << "Initializing Tauola" << endl;
00335         for( vector<string>::const_iterator
00336                 itPar = cards.begin(); itPar != cards.end(); ++itPar )
00337         {
00338            call_txgive(*itPar);
00339         }
00340         tauola_.initialize();
00341         //call_pretauola(-1); // initialize TAUOLA package for tau decays
00342      }
00343     }
00344     // cout << "----------------------------------------------" << endl;
00345   }
00346 
00347 
00348   cout << endl; // Statically add for the output
00349   //********                                      
00350   
00351   produces<HepMCProduct>();
00352   produces<GenInfoProduct, edm::InRun>();
00353 }

PythiaProducer::~PythiaProducer (  )  [virtual]

Destructor.

Definition at line 356 of file PythiaProducer.cc.

References clear().

00356                                {
00357   clear(); 
00358 }


Member Function Documentation

bool PythiaProducer::call_pygive ( const std::string &  iParm  )  [private]

Interface to the PYGIVE pythia routine, with add'l protections.

Definition at line 583 of file PythiaProducer.cc.

References pydat1, and PYGIVE.

Referenced by produce(), and PythiaProducer().

00583                                                    {
00584 
00585   int numWarn = pydat1.mstu[26]; //# warnings
00586   int numErr = pydat1.mstu[22];// # errors
00587   
00588 //call the fortran routine pygive with a fortran string
00589   PYGIVE( iParm.c_str(), iParm.length() );  
00590   //  PYGIVE( iParm );  
00591 //if an error or warning happens it is problem
00592   return pydat1.mstu[26] == numWarn && pydat1.mstu[22] == numErr;   
00593  
00594 }

bool PythiaProducer::call_slha_init (  )  [private]

Definition at line 650 of file PythiaProducer.cc.

References SLHA_INIT.

Referenced by PythiaProducer().

00650                                {
00651   
00652    SLHA_INIT();
00653    return 1;  
00654 }

bool PythiaProducer::call_slhagive ( const std::string &  iParm  )  [private]

Definition at line 612 of file PythiaProducer.cc.

References GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), f1, file, edm::FileInPath::fullPath(), SLHAGIVE, and pyDBSRunClass::temp.

Referenced by PythiaProducer().

00612                                                      {
00613         if( iParm.find( "SLHAFILE", 0 ) != string::npos ) {
00614                 string::size_type start = iParm.find_first_of( "=" ) + 1;
00615                 string::size_type end = iParm.length() - 1;
00616                 string::size_type temp = iParm.find_first_of( "'", start );
00617                 if( temp != string::npos ) {
00618                         start = temp + 1;
00619                         end = iParm.find_last_of( "'" ) - 1;
00620                 } 
00621                 start = iParm.find_first_not_of( " ", start );
00622                 end = iParm.find_last_not_of( " ", end );               
00623                 string shortfile = iParm.substr( start, end - start + 1 );
00624                 string file;
00625                 if( shortfile[0] == '/' ) {
00626                         cout << "SLHA file given with absolut path." << endl;
00627                         file = shortfile;
00628                 } else {
00629                 //      try {
00630                                 FileInPath f1( shortfile );
00631                                 file = f1.fullPath();
00632                 //      } catch(...) {
00633                 //              cout << "SLHA file not in path. Trying anyway." << endl;
00634                 //              file = shortfile;
00635                 //      }
00636                 }
00637                 file = "SLHAFILE = '" + file + "'";
00638                 SLHAGIVE( file.c_str(), file.length() );
00639                 cout << "     " <<  file.c_str() << endl;
00640                 
00641         } else {
00642                 SLHAGIVE( iParm.c_str(), iParm.length() );
00643                 cout << "     " <<  iParm.c_str() << endl; 
00644         }
00645         return 1;
00646 }

bool PythiaProducer::call_txgive ( const std::string &  iParm  )  [private]

Definition at line 597 of file PythiaProducer.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and TXGIVE.

Referenced by PythiaProducer().

00597                                                    {
00598   
00599    TXGIVE( iParm.c_str(), iParm.length() );
00600    cout << "     " <<  iParm.c_str() << endl; 
00601    return 1;  
00602 }

bool PythiaProducer::call_txgive_init (  )  [private]

Definition at line 605 of file PythiaProducer.cc.

References TXGIVE_INIT.

Referenced by PythiaProducer().

00605                                  {
00606   
00607    TXGIVE_INIT();
00608    return 1;  
00609 }

void PythiaProducer::clear ( void   )  [private]

Definition at line 360 of file PythiaProducer.cc.

Referenced by ~PythiaProducer().

00360                            {
00361  
00362 }

void PythiaProducer::endRun ( Run r,
const EventSetup es 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 364 of file PythiaProducer.cc.

References extCrossSect, extFilterEff, edm::TauolaInterface::print(), edm::Run::put(), pypars, tauola_, and useTauola_.

00364                                                           {
00365  
00366  double cs = pypars.pari[0]; // cross section in mb
00367  auto_ptr<GenInfoProduct> giprod (new GenInfoProduct());
00368  giprod->set_cross_section(cs);
00369  giprod->set_external_cross_section(extCrossSect);
00370  giprod->set_filter_efficiency(extFilterEff);
00371  r.put(giprod);
00372 
00373  call_pystat(1);
00374   if ( useTauola_ ) {
00375     tauola_.print();
00376     //call_pretauola(1); // print TAUOLA decay statistics output
00377   }
00378 
00379 }

void PythiaProducer::produce ( Event e,
const EventSetup es 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 381 of file PythiaProducer.cc.

References funct::abs(), call_pygive(), call_pylist(), GenMuonPlsPt100GeV_cfg::cout, doubleParticle, emax, emin, lat::endl(), eta, etamax, etamin, edm::EventID::event(), eventNumber_, evt, funct::exp(), edm::PtYDistributor::firePt(), edm::PtYDistributor::fireY(), fPtYGenerator, gluinoHadronsEnabled, edm::Event::id(), imposeProperTimes_, kinedata, funct::log(), maxEventsToPrint_, particleID, phi, phimax, phimin, pi, edm::TauolaInterface::processEvent(), ptmax, ptmin, edm::Event::put(), PY1ENT, PYCOMP, pydat1, pydat2, pydat3, PYEXEC, PYGLFR, pyint1, PYMASS, pypars, pyr_(), PYSTFR, pythiaHepMCVerbosity_, pythiaPylistVerbosity_, funct::sin(), funct::sqrt(), stopHadronsEnabled, t, funct::tan(), tauola_, useTauola_, vbegin, vend, x, y, and z.

00381                                                             {
00382 
00383     auto_ptr<HepMCProduct> bare_product(new HepMCProduct());  
00384 
00385     //********                                         
00386     //  
00387    if(particleID) 
00388       {    
00389         int dum;
00390         double pi = 3.1415927;
00391         int ip = 1;
00392         double ee=0,the=0,eta=0;
00393         double pmass = PYMASS(particleID);
00394         double phi = (phimax-phimin)*pyr_(&dum)+phimin; 
00395 
00396         if(kinedata.size() < 1){  // no kinematics input specified, use flat distribution, pt and eta
00397           double pt  = (ptmax-ptmin)*pyr_(&dum)+ptmin;
00398           double e   = (emax-emin)*pyr_(&dum)+emin;
00399           eta = (etamax-etamin)*pyr_(&dum)+etamin;
00400           the = 2.*atan(exp(-eta));
00401           if ( emin > pmass && emax > pmass ) { // generate single particle distribution flat in energy
00402             ee = e;
00403         } else { // generate single particle distribution flat in pt
00404           double pe = pt/sin(the);
00405           ee = sqrt(pe*pe+pmass*pmass);
00406         }
00407       } else { // kinematics from input file, pt and y
00408      double pt  = fPtYGenerator->firePt();
00409      double y = fPtYGenerator->fireY();
00410      double u = exp(y);
00411      ee = 0.5*sqrt(pmass*pmass+pt*pt)*(u*u+1)/u;
00412      double pz = sqrt(ee*ee-pt*pt-pmass*pmass);
00413      if(y<0) pz = -pz;
00414        the = atan(pt/pz);
00415      if(pz < 0) the = pi + the;
00416        eta = -log(tan(the/2));
00417    }
00418 /*
00419    cout <<" pt = " << pt 
00420         <<" eta = " << eta 
00421         <<" the = " << the 
00422         <<" pe = " << pe 
00423         <<" phi = " << phi 
00424         <<" pmass = " << pmass 
00425         <<" ee = " << ee << endl;
00426 */
00427 
00428         phi = phi * (3.1415927/180.);
00429 
00430         PY1ENT(ip, particleID, ee, the, phi);
00431 
00432         if(doubleParticle)
00433           {
00434             ip = ip + 1;
00435             //int particleID2 = -1 * particleID;
00436             int pythiaCode = PYCOMP(particleID);
00437             int has_antipart = pydat2.kchg[3-1][pythiaCode-1];
00438             int particleID2 = has_antipart ? -1 * particleID : particleID;
00439             the = 2.*atan(exp(eta));
00440             phi  = phi + 3.1415927;
00441             if (phi > 2.* 3.1415927) {phi = phi - 2.* 3.1415927;}         
00442             PY1ENT(ip, particleID2, ee, the, phi);
00443           }
00444         PYEXEC();
00445       } else {
00446           if(!gluinoHadronsEnabled && !stopHadronsEnabled)
00447           {
00448              call_pyevnt();      // generate one event with Pythia
00449           }
00450           else
00451           {
00452              call_pygive("MSTJ(14)=-1");
00453              call_pyevnt();      // generate one event with Pythia
00454              call_pygive("MSTJ(14)=1");
00455              if(gluinoHadronsEnabled)  PYGLFR();
00456              if(stopHadronsEnabled)  PYSTFR();
00457           }
00458 
00459       }
00460 
00461     if ( useTauola_ ) {
00462       tauola_.processEvent();
00463       //call_pretauola(0); // generate tau decays with TAUOLA
00464     }
00465 
00466     // convert to stdhep format
00467     //
00468     call_pyhepc( 1 );
00469     
00470     // convert stdhep (hepevt) to hepmc
00471     //
00472     //HepMC::GenEvent* evt = conv2.getGenEventfromHEPEVT();
00473     HepMC::GenEvent* evt = conv2.read_next_event();
00474 
00475     // fix for 1-part events
00476     if ( particleID ) evt->set_beam_particles(0,0);
00477 
00478     evt->set_signal_process_id(pypars.msti[0]);
00479     evt->set_event_scale(pypars.pari[16]);
00480     ++eventNumber_;
00481     evt->set_event_number(eventNumber_);
00482 
00483     // int id1 = pypars.msti[14];
00484     // int id2 = pypars.msti[15];
00485     int id1 = pyint1.mint[14];
00486     int id2 = pyint1.mint[15];
00487     if ( id1 == 21 ) id1 = 0;
00488     if ( id2 == 21 ) id2 = 0; 
00489     double x1 = pyint1.vint[40];
00490     double x2 = pyint1.vint[41];  
00491     double Q  = pyint1.vint[50];
00492     double pdf1 = pyint1.vint[38];
00493     pdf1 /= x1 ;
00494     double pdf2 = pyint1.vint[39];
00495     pdf2 /= x2 ;
00496     evt->set_pdf_info( HepMC::PdfInfo(id1,id2,x1,x2,Q,pdf1,pdf2) ) ;
00497     
00498     evt->weights().push_back( pyint1.vint[96] );
00499 
00500     if (imposeProperTimes_ || pydat1.mstj[21]==3 || pydat1.mstj[21]==4 ) {
00501       int dumm;
00502       HepMC::GenEvent::vertex_const_iterator vbegin = evt->vertices_begin();
00503       HepMC::GenEvent::vertex_const_iterator vend = evt->vertices_end();
00504       HepMC::GenEvent::vertex_const_iterator vitr = vbegin;
00505       for (; vitr != vend; ++vitr ) {
00506             HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(HepMC::children);
00507             HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(HepMC::children);
00508             HepMC::GenVertex::particle_iterator pitr = pbegin;
00509             for (; pitr != pend; ++pitr) {
00510                   if ((*pitr)->end_vertex()) continue;
00511                   if ((*pitr)->status()!=1) continue;
00512                   int pdgcode= abs((*pitr)->pdg_id());
00513                   // Do nothing if the particle is not expected to decay
00514                   if (pydat3.mdcy[0][PYCOMP(pdgcode)-1]!=1) continue;
00515 
00516                   double ctau = pydat2.pmas[3][PYCOMP(pdgcode)-1];
00517                   HepMC::FourVector mom = (*pitr)->momentum();
00518                   HepMC::FourVector vin = (*vitr)->position();
00519                   double x = 0.;
00520                   double y = 0.;
00521                   double z = 0.;
00522                   double t = 0.;
00523                   bool decayInRange = false;
00524                   while (!decayInRange) {
00525                         double unif_rand = pyr_(&dumm);
00526                         // Value of 0 is excluded, so following line is OK
00527                         double proper_length = - ctau * log(unif_rand);
00528                         double factor = proper_length/mom.m();
00529                         x = vin.x() + factor * mom.px();
00530                         y = vin.y() + factor * mom.py();
00531                         z = vin.z() + factor * mom.pz();
00532                         t = vin.t() + factor * mom.e();
00533                         // Decay must be happen outside a cylindrical region
00534                         if (pydat1.mstj[21]==4) {
00535                               if (sqrt(x*x+y*y)>pydat1.parj[72] || abs(z)>pydat1.parj[73]) decayInRange = true;
00536                         // Decay must be happen outside a given sphere
00537                         } else if (pydat1.mstj[21]==3) {
00538                               if (sqrt(x*x+y*y+z*z)>pydat1.parj[71]) decayInRange = true;
00539                         // Decay is always OK otherwise
00540                         } else {
00541                               decayInRange = true;
00542                         }
00543                   }
00544                   
00545                   HepMC::GenVertex* vdec = new HepMC::GenVertex(HepMC::FourVector(x,y,z,t));
00546                   evt->add_vertex(vdec);
00547                   vdec->add_particle_in((*pitr));
00548             }
00549       }
00550     }
00551     
00552     
00553     //******** Verbosity ********
00554     
00555     if(e.id().event() <= maxEventsToPrint_ &&
00556        (pythiaPylistVerbosity_ || pythiaHepMCVerbosity_)) {
00557 
00558       // Prints PYLIST info
00559       if(pythiaPylistVerbosity_) {
00560         call_pylist(pythiaPylistVerbosity_);
00561       }
00562       
00563       // Prints HepMC event
00564       if(pythiaHepMCVerbosity_) {
00565         cout << "Event process = " << pypars.msti[0] << endl 
00566         << "----------------------" << endl;
00567         evt->print();
00568       }
00569     }
00570     
00571     
00572     //evt = reader_->fillCurrentEventData(); 
00573     //********                                      
00574 
00575     if(evt)  bare_product->addHepMCData(evt );
00576 
00577     e.put(bare_product);
00578 
00579     return;
00580 }


Member Data Documentation

bool edm::PythiaProducer::doubleParticle [private]

Definition at line 81 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::emax [private]

Definition at line 86 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::emin [private]

Definition at line 86 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::etamax [private]

Definition at line 84 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::etamin [private]

Definition at line 84 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

int edm::PythiaProducer::eventNumber_ [private]

Definition at line 102 of file PythiaProducer.h.

Referenced by produce().

HepMC::GenEvent* edm::PythiaProducer::evt [private]

Definition at line 58 of file PythiaProducer.h.

Referenced by produce().

double edm::PythiaProducer::extCrossSect [private]

Definition at line 76 of file PythiaProducer.h.

Referenced by endRun().

double edm::PythiaProducer::extFilterEff [private]

Definition at line 77 of file PythiaProducer.h.

Referenced by endRun().

std::string edm::PythiaProducer::fBeam1 [private]

Definition at line 62 of file PythiaProducer.h.

Referenced by PythiaProducer().

std::string edm::PythiaProducer::fBeam2 [private]

Definition at line 63 of file PythiaProducer.h.

Referenced by PythiaProducer().

double edm::PythiaProducer::fCOMEnergy [private]

Definition at line 64 of file PythiaProducer.h.

Referenced by PythiaProducer().

std::string edm::PythiaProducer::fFrame [private]

Definition at line 61 of file PythiaProducer.h.

Referenced by PythiaProducer().

bool edm::PythiaProducer::flatEnergy [private]

Definition at line 88 of file PythiaProducer.h.

PtYDistributor* edm::PythiaProducer::fPtYGenerator [private]

Definition at line 101 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

CLHEP::HepRandomEngine& edm::PythiaProducer::fRandomEngine [private]

Definition at line 99 of file PythiaProducer.h.

Referenced by PythiaProducer().

CLHEP::RandFlat* edm::PythiaProducer::fRandomGenerator [private]

Definition at line 100 of file PythiaProducer.h.

Referenced by PythiaProducer().

bool edm::PythiaProducer::gluinoHadronsEnabled [private]

Definition at line 97 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

bool edm::PythiaProducer::imposeProperTimes_ [private]

Impose proper times for pions/kaons at generator level.

Definition at line 71 of file PythiaProducer.h.

Referenced by produce().

std::string edm::PythiaProducer::kinedata [private]

Definition at line 82 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

unsigned int edm::PythiaProducer::maxEventsToPrint_ [private]

Events to print if verbosity.

Definition at line 73 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

int edm::PythiaProducer::particleID [private]

Definition at line 80 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::phimax [private]

Definition at line 85 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::phimin [private]

Definition at line 85 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::ptmax [private]

Definition at line 83 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

double edm::PythiaProducer::ptmin [private]

Definition at line 83 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

bool edm::PythiaProducer::pythiaHepMCVerbosity_ [private]

HepMC verbosity flag.

Definition at line 69 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

unsigned int edm::PythiaProducer::pythiaPylistVerbosity_ [private]

Pythia PYLIST Verbosity flag.

Definition at line 67 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

bool edm::PythiaProducer::stopHadronsEnabled [private]

Definition at line 96 of file PythiaProducer.h.

Referenced by produce(), and PythiaProducer().

TauolaInterface edm::PythiaProducer::tauola_ [private]

Definition at line 94 of file PythiaProducer.h.

Referenced by endRun(), produce(), and PythiaProducer().

bool edm::PythiaProducer::useExternalGenerators_ [private]

Definition at line 91 of file PythiaProducer.h.

Referenced by PythiaProducer().

bool edm::PythiaProducer::useTauola_ [private]

Definition at line 92 of file PythiaProducer.h.

Referenced by endRun(), produce(), and PythiaProducer().

bool edm::PythiaProducer::useTauolaPolarization_ [private]

Definition at line 93 of file PythiaProducer.h.

Referenced by PythiaProducer().

double edm::PythiaProducer::ymax [private]

Definition at line 87 of file PythiaProducer.h.

Referenced by PythiaProducer().

double edm::PythiaProducer::ymin [private]

Definition at line 87 of file PythiaProducer.h.

Referenced by PythiaProducer().


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