CMS 3D CMS Logo

edm::PythiaSource Class Reference

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

Inheritance diagram for edm::PythiaSource:

edm::GeneratedInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

List of all members.

Public Member Functions

void endRun (Run &r)
 PythiaSource (const ParameterSet &, const InputSourceDescription &)
 Constructor.
virtual ~PythiaSource ()
 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 bool produce (Event &e)

Private Attributes

double comenergy
bool doubleParticle
double emax
double emin
double etamax
double etamin
HepMC::GenEvent * evt
double extCrossSect
double extFilterEff
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
std::vector< intparticleIDs
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 PythiaSource.h.


Constructor & Destructor Documentation

PythiaSource::PythiaSource ( const ParameterSet pset,
const InputSourceDescription desc 
)

Constructor.

Definition at line 140 of file PythiaSource.cc.

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

00141                                                                  :
00142   GeneratedInputSource(pset, desc), evt(0), 
00143   pythiaPylistVerbosity_ (pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0)),
00144   pythiaHepMCVerbosity_ (pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false)),
00145   imposeProperTimes_ (pset.getUntrackedParameter<bool>("imposeProperTimes",false)),
00146   maxEventsToPrint_ (pset.getUntrackedParameter<int>("maxEventsToPrint",1)),
00147   extCrossSect(pset.getUntrackedParameter<double>("crossSection", -1.)),
00148   extFilterEff(pset.getUntrackedParameter<double>("filterEfficiency", -1.)),
00149   comenergy(pset.getUntrackedParameter<double>("comEnergy",14000.)),
00150   useExternalGenerators_(false),
00151   useTauola_(false),
00152   useTauolaPolarization_(false),
00153   stopHadronsEnabled(false), gluinoHadronsEnabled(false),
00154   fRandomEngine(getEngineReference())
00155 {
00156   
00157   // PYLIST Verbosity Level
00158   // Valid PYLIST arguments are: 1, 2, 3, 5, 7, 11, 12, 13
00159   pythiaPylistVerbosity_ = pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0);
00160   
00161   // HepMC event verbosity Level
00162   pythiaHepMCVerbosity_ = pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false);
00163 
00164   //Max number of events printed on verbosity level 
00165   maxEventsToPrint_ = pset.getUntrackedParameter<int>("maxEventsToPrint",0);
00166   
00167   particleID = pset.getUntrackedParameter<int>("ParticleID", 0);
00168 
00169   particleIDs = 
00170     pset.getUntrackedParameter<std::vector<int> >("ParticleIDs", 
00171                                                  std::vector<int>(0));
00172 
00173 // Initialize the random engine unconditionally!
00174   randomEngine = &fRandomEngine;
00175   fRandomGenerator = new CLHEP::RandFlat(fRandomEngine) ;
00176 
00177   if(particleID) {
00178 
00179     cout <<" Particle ID = " << particleID << endl; 
00180 
00181     doubleParticle = pset.getUntrackedParameter<bool>("DoubleParticle",true);
00182     cout <<" double back-to-back " << doubleParticle << endl; 
00183 
00184     kinedata = pset.getUntrackedParameter<string>("kinematicsFile","");
00185 
00186     ptmin = pset.getUntrackedParameter<double>("Ptmin",20.);
00187     ptmax = pset.getUntrackedParameter<double>("Ptmax",420.);
00188     cout <<" ptmin = " << ptmin <<" ptmax = " << ptmax << endl;
00189   
00190     emin = pset.getUntrackedParameter<double>("Emin",-1);
00191     emax = pset.getUntrackedParameter<double>("Emax",-1);
00192     if ( emin > 0 && emax > 0 ) {
00193       cout <<" emin = " << emin <<" emax = " << emax << endl;
00194     }
00195   
00196     if(kinedata.size() < 1){                                                                                 
00197        etamin = pset.getUntrackedParameter<double>("Etamin",0.);                                             
00198        etamax = pset.getUntrackedParameter<double>("Etamax",2.2);                                            
00199        cout <<" etamin = " << etamin <<" etamax = " << etamax << endl;
00200     }else{                                                                                                   
00201        ymin = pset.getUntrackedParameter<double>("ymin",0.);                                                 
00202        ymax = pset.getUntrackedParameter<double>("ymax",10.);                                                
00203        cout <<" ymin = " << ymin <<" ymax = " << ymax << endl;                                               
00204     }
00205       
00206     
00207     phimin = pset.getUntrackedParameter<double>("Phimin",0.);
00208     phimax = pset.getUntrackedParameter<double>("Phimax",360.);
00209     cout <<" phimin = " << phimin <<" phimax = " << phimax << endl;
00210 
00211     if(kinedata.size() > 0)
00212     {
00213        int ptbins = pset.getUntrackedParameter<int>("ptBinning",1000);
00214        int ybins = pset.getUntrackedParameter<int>("yBinning",50);
00215        fPtYGenerator = new PtYDistributor(kinedata, fRandomEngine, 
00216                                           ptmax, ptmin, ymax, ymin, ptbins, ybins);
00217     }
00218   } else if ( particleIDs.size() > 1 ) {
00219 
00220     // Here a simple jet with a number of particles of your choice
00221     // is to be generated. The particles are given an energy between 
00222     // 500 MeV and 1 GeV (flat/random), and are then boosted with 
00223     // a |beta|*E between Emin and Emax and with eta and phi in the
00224     // ranges given.
00225 
00226     // Boost absolute value
00227     emin = pset.getUntrackedParameter<double>("Emin",0.5);
00228     emax = pset.getUntrackedParameter<double>("Emax",2.0);
00229     
00230     // Boost absolute value
00231     ptmin = pset.getUntrackedParameter<double>("Pmin",20.);
00232     ptmax = pset.getUntrackedParameter<double>("Pmax",20.);
00233 
00234     // Boost pseudo-rapidity range
00235     etamin = pset.getUntrackedParameter<double>("Etamin",0.); 
00236     etamax = pset.getUntrackedParameter<double>("Etamax",2.2);
00237     
00238     // Boost phi range
00239     phimin = pset.getUntrackedParameter<double>("Phimin",-3.1415926536);
00240     phimax = pset.getUntrackedParameter<double>("Phimax",+3.1415926536);
00241 
00242   }
00243 
00244   // Set PYTHIA parameters in a single ParameterSet
00245   ParameterSet pythia_params = 
00246     pset.getParameter<ParameterSet>("PythiaParameters") ;
00247   
00248   // The parameter sets to be read (default, min bias, user ...) in the
00249   // proper order.
00250   vector<string> setNames = 
00251     pythia_params.getParameter<vector<string> >("parameterSets");
00252   
00253   // Loop over the sets
00254   for ( unsigned i=0; i<setNames.size(); ++i ) {
00255     
00256     string mySet = setNames[i];
00257     
00258     // Read the PYTHIA parameters for each set of parameters
00259     vector<string> pars = 
00260       pythia_params.getParameter<vector<string> >(mySet);
00261     
00262     if (mySet != "SLHAParameters" && mySet != "CSAParameters"){
00263     
00264     // Loop over all parameters and stop in case of mistake
00265     for( vector<string>::const_iterator  
00266            itPar = pars.begin(); itPar != pars.end(); ++itPar ) {
00267       static string sRandomValueSetting("MRPY(1)");
00268       if( 0 == itPar->compare(0,sRandomValueSetting.size(),sRandomValueSetting) ) {
00269         throw edm::Exception(edm::errors::Configuration,"PythiaError")
00270           <<" 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.";
00271       }
00272       if( ! call_pygive(*itPar) ) {
00273         throw edm::Exception(edm::errors::Configuration,"PythiaError") 
00274           <<" pythia did not accept the following \""<<*itPar<<"\"";
00275       }
00276     }
00277     } else if(mySet == "CSAParameters"){   
00278 
00279    // Read CSA parameter
00280   
00281    pars = pythia_params.getParameter<vector<string> >("CSAParameters");
00282 
00283    call_txgive_init();
00284   
00285   
00286    // Loop over all parameters and stop in case of a mistake
00287     for (vector<string>::const_iterator 
00288             itPar = pars.begin(); itPar != pars.end(); ++itPar) {
00289       call_txgive(*itPar); 
00290      
00291          } 
00292      
00293    } else if(mySet == "SLHAParameters"){   
00294 
00295    // Read SLHA parameter
00296   
00297    pars = pythia_params.getParameter<vector<string> >("SLHAParameters");
00298 
00299    // Loop over all parameters and stop in case of a mistake
00300     for (vector<string>::const_iterator 
00301             itPar = pars.begin(); itPar != pars.end(); ++itPar) {
00302       call_slhagive(*itPar); 
00303      
00304          } 
00305  
00306     call_slha_init(); 
00307   
00308   }
00309   }
00310 
00311    stopHadronsEnabled = pset.getUntrackedParameter<bool>("stopHadrons",false);
00312    gluinoHadronsEnabled = pset.getUntrackedParameter<bool>("gluinoHadrons",false);
00313 
00314   //Init names and pdg code of r-hadrons
00315    if(stopHadronsEnabled)  PYSTRHAD();
00316    if(gluinoHadronsEnabled)  PYGLRHAD();
00317 
00318   //In the future, we will get the random number seed on each event and tell 
00319   // pythia to use that new seed
00320   // The random engine has already been initialized.  DO NOT do it again!
00321 #ifdef NOTYET
00322   edm::Service<RandomNumberGenerator> rng;
00323   uint32_t seed = rng->mySeed();
00324   ostringstream sRandomSet;
00325   sRandomSet <<"MRPY(1)="<<seed;
00326   call_pygive(sRandomSet.str());
00327 #endif
00328   
00329   if(particleID || particleIDs.size() > 1 ) 
00330     {
00331       call_pyinit( "NONE", "p", "p", comenergy );
00332     } else {
00333       call_pyinit( "CMS", "p", "p", comenergy );
00334     }
00335 
00336   // TAUOLA, etc.
00337   //
00338   useExternalGenerators_ = pset.getUntrackedParameter<bool>("UseExternalGenerators",false);
00339 //  useTauola_ = pset.getUntrackedParameter<bool>("UseTauola", false);
00340 //  useTauolaPolarization_ = pset.getUntrackedParameter<bool>("UseTauolaPolarization", false);
00341   
00342   if ( useExternalGenerators_ ) {
00343  // read External Generator parameters
00344     ParameterSet ext_gen_params =
00345        pset.getParameter<ParameterSet>("ExternalGenerators") ;
00346     vector<string> extGenNames =
00347        ext_gen_params.getParameter< vector<string> >("parameterSets");
00348     for (unsigned int ip=0; ip<extGenNames.size(); ++ip )
00349     {
00350       string curSet = extGenNames[ip];
00351       ParameterSet gen_par_set =
00352          ext_gen_params.getUntrackedParameter< ParameterSet >(curSet);
00353 /*
00354      cout << "----------------------------------------------" << endl;
00355      cout << "Read External Generator parameter set "  << endl;
00356      cout << "----------------------------------------------" << endl;
00357 */
00358      if ( curSet == "Tauola" )
00359      {
00360         useTauola_ = true;
00361         if ( useTauola_ ) {
00362            cout << "--> use TAUOLA" << endl;
00363         } 
00364         useTauolaPolarization_ = gen_par_set.getParameter<bool>("UseTauolaPolarization");
00365         if ( useTauolaPolarization_ ) 
00366         {
00367            cout << "(Polarization effects enabled)" << endl;
00368            tauola_.enablePolarizationEffects();
00369         } 
00370         else 
00371         {
00372            cout << "(Polarization effects disabled)" << endl;
00373            tauola_.disablePolarizationEffects();
00374         }
00375         vector<string> cards = gen_par_set.getParameter< vector<string> >("InputCards");
00376         cout << "----------------------------------------------" << endl;
00377         cout << "Initializing Tauola" << endl;
00378         for( vector<string>::const_iterator
00379                 itPar = cards.begin(); itPar != cards.end(); ++itPar )
00380         {
00381            call_txgive(*itPar);
00382         }
00383         tauola_.initialize();
00384         //call_pretauola(-1); // initialize TAUOLA package for tau decays
00385      }
00386     }
00387     // cout << "----------------------------------------------" << endl;
00388   }
00389 
00390 
00391   cout << endl; // Stetically add for the output
00392   //********                                      
00393   
00394   produces<HepMCProduct>();
00395   produces<GenInfoProduct, edm::InRun>();
00396 }

PythiaSource::~PythiaSource (  )  [virtual]

Destructor.

Definition at line 399 of file PythiaSource.cc.

References clear().

00399                            {
00400   clear(); 
00401 }


Member Function Documentation

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

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

Definition at line 678 of file PythiaSource.cc.

References pydat1, and PYGIVE.

Referenced by produce(), and PythiaSource().

00678                                                  {
00679 
00680   int numWarn = pydat1.mstu[26]; //# warnings
00681   int numErr = pydat1.mstu[22];// # errors
00682   
00683 //call the fortran routine pygive with a fortran string
00684   PYGIVE( iParm.c_str(), iParm.length() );  
00685   //  PYGIVE( iParm );  
00686 //if an error or warning happens it is problem
00687   return pydat1.mstu[26] == numWarn && pydat1.mstu[22] == numErr;   
00688  
00689 }

bool PythiaSource::call_slha_init (  )  [private]

Definition at line 745 of file PythiaSource.cc.

References SLHA_INIT.

Referenced by PythiaSource().

00745                              {
00746   
00747    SLHA_INIT();
00748    return 1;  
00749 }

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

Definition at line 707 of file PythiaSource.cc.

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

Referenced by PythiaSource().

00707                                                    {
00708         if( iParm.find( "SLHAFILE", 0 ) != string::npos ) {
00709                 string::size_type start = iParm.find_first_of( "=" ) + 1;
00710                 string::size_type end = iParm.length() - 1;
00711                 string::size_type temp = iParm.find_first_of( "'", start );
00712                 if( temp != string::npos ) {
00713                         start = temp + 1;
00714                         end = iParm.find_last_of( "'" ) - 1;
00715                 } 
00716                 start = iParm.find_first_not_of( " ", start );
00717                 end = iParm.find_last_not_of( " ", end );               
00718                 string shortfile = iParm.substr( start, end - start + 1 );
00719                 string file;
00720                 if( shortfile[0] == '/' ) {
00721                         cout << "SLHA file given with absolut path." << endl;
00722                         file = shortfile;
00723                 } else {
00724                 //      try {
00725                                 FileInPath f1( shortfile );
00726                                 file = f1.fullPath();
00727                 //      } catch(...) {
00728                 //              cout << "SLHA file not in path. Trying anyway." << endl;
00729                 //              file = shortfile;
00730                 //      }
00731                 }
00732                 file = "SLHAFILE = '" + file + "'";
00733                 SLHAGIVE( file.c_str(), file.length() );
00734                 cout << "     " <<  file.c_str() << endl;
00735                 
00736         } else {
00737                 SLHAGIVE( iParm.c_str(), iParm.length() );
00738                 cout << "     " <<  iParm.c_str() << endl; 
00739         }
00740         return 1;
00741 }

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

Definition at line 692 of file PythiaSource.cc.

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

Referenced by PythiaSource().

00692                                                  {
00693   
00694    TXGIVE( iParm.c_str(), iParm.length() );
00695    cout << "     " <<  iParm.c_str() << endl; 
00696    return 1;  
00697 }

bool PythiaSource::call_txgive_init (  )  [private]

Definition at line 700 of file PythiaSource.cc.

References TXGIVE_INIT.

Referenced by PythiaSource().

00700                                {
00701   
00702    TXGIVE_INIT();
00703    return 1;  
00704 }

void PythiaSource::clear ( void   )  [private]

Definition at line 403 of file PythiaSource.cc.

Referenced by ~PythiaSource().

00403                          {
00404  
00405 }

void PythiaSource::endRun ( Run r  )  [virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 407 of file PythiaSource.cc.

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

00407                                  {
00408  
00409  double cs = pypars.pari[0]; // cross section in mb
00410  auto_ptr<GenInfoProduct> giprod (new GenInfoProduct());
00411  giprod->set_cross_section(cs);
00412  giprod->set_external_cross_section(extCrossSect);
00413  giprod->set_filter_efficiency(extFilterEff);
00414  r.put(giprod);
00415 
00416   call_pystat(1);
00417   if ( useTauola_ ) {
00418     tauola_.print();
00419     //call_pretauola(1); // print TAUOLA decay statistics output
00420   }
00421 
00422 }

bool PythiaSource::produce ( Event e  )  [private, virtual]

Implements edm::ConfigurableInputSource.

Definition at line 424 of file PythiaSource.cc.

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

00424                                     {
00425 
00426     auto_ptr<HepMCProduct> bare_product(new HepMCProduct());  
00427 
00428     //********                                         
00429     //  
00430    if(particleID) 
00431       {    
00432          double pi = 3.1415927;
00433          int ip = 1;  
00434          int dum;
00435          double ee=0,the=0,eta=0;
00436          double pmass = PYMASS(particleID);
00437          double phi = (phimax-phimin)*pyr_(&dum)+phimin; 
00438          
00439          if(kinedata.size() < 1){  // no kinematics input specified, use flat distribution, pt and eta         
00440             double pt  = (ptmax-ptmin)*pyr_(&dum)+ptmin;                                                 
00441             double e   = (emax-emin)*pyr_(&dum)+emin;
00442             eta = (etamax-etamin)*pyr_(&dum)+etamin;                                                      
00443             the = 2.*atan(exp(-eta));                                                                          
00444             if ( emin > pmass && emax > pmass ) { // generate single particle distribution flat in energy      
00445                ee = e;                                                                                         
00446             } else { // generate single particle distribution flat in pt                                       
00447                double pe = pt/sin(the);                                                                        
00448                ee = sqrt(pe*pe+pmass*pmass);                                                                   
00449             }                                                                                                  
00450          }else{ // kinematics from input file, pt and y                                                        
00451             double pt  = fPtYGenerator->firePt();                                                
00452             double y = fPtYGenerator->fireY();                                                       
00453             double u = exp(y);                                                                                 
00454             ee = 0.5*sqrt(pmass*pmass+pt*pt)*(u*u+1)/u;                                                        
00455             double pz = sqrt(ee*ee-pt*pt-pmass*pmass);                   
00456             if(y<0) pz = -pz;
00457             the = atan(pt/pz);                                                                                 
00458             if(pz < 0) the = pi + the;
00459             eta = -log(tan(the/2));                                                                            
00460          }                                 
00461          /*
00462            cout <<" pt = " << pt
00463            <<" eta = " << eta                                                                                  
00464            <<" the = " << the                                                                                  
00465            <<" pe = " << pe                                                                                    
00466            <<" phi = " << phi                                                                                  
00467            <<" pmass = " << pmass                                                                              
00468            <<" ee = " << ee << endl; 
00469         */
00470 
00471         phi = phi * (3.1415927/180.);
00472 
00473         PY1ENT(ip, particleID, ee, the, phi);
00474 
00475         if(doubleParticle)
00476           {
00477             ip = ip + 1;
00478 // Check if particle is its own anti-particle.
00479             // int particleID2 = -1 * particleID;
00480             int pythiaCode = PYCOMP(particleID);
00481             int has_antipart = pydat2.kchg[3-1][pythiaCode-1];
00482             int particleID2 = has_antipart ? -1 * particleID : particleID;          
00483             the = 2.*atan(exp(eta));
00484             phi  = phi + 3.1415927;
00485             if (phi > 2.* 3.1415927) {phi = phi - 2.* 3.1415927;}         
00486             PY1ENT(ip, particleID2, ee, the, phi);
00487           }
00488         PYEXEC();
00489 
00490       } else if ( particleIDs.size() > 1 ) { 
00491 
00492         // Initialize some variables
00493         int dum;
00494         int ip = 0;
00495         double px = 0;  
00496         double py = 0;
00497         double pz = 0;
00498         double pe = 0;
00499         // The particles in the "c.o.m. frame"
00500         for ( unsigned id=0; id<particleIDs.size(); ++id ) {
00501           ++ip;
00502           int pythiaCode = particleIDs[id];
00503           // Generate the particles with emin -> emax Fermi motion
00504           double e = emin + (emax-emin) * pyr_(&pythiaCode);
00505           // Any direction
00506           double phi = 2. * 3.1415927 * pyr_(&pythiaCode);
00507           double ctt = -1. + 2.*pyr_(&pythiaCode);
00508           double the = std::acos(ctt);
00509           // Add the entry in PYJETS
00510           PY1ENT(ip,pythiaCode,e,the,phi);
00511           // To compute the overall mass
00512           px += P(ip,1);
00513           py += P(ip,2);
00514           pz += P(ip,3);
00515           pe += P(ip,4);
00516         }
00517 
00518         // The boost
00519         // The overall mass
00520         double mm = std::sqrt(pe*pe-px*px-py*py-pz*pz);
00521         // The boost absolute value
00522         double pp = ptmin + (ptmax-ptmin)*pyr_(&dum);
00523         double ee = sqrt(pp*pp+mm*mm);
00524         // The boost direction
00525         double fhi = phimin + (phimax-phimin)*pyr_(&dum);
00526         double eta = etamin + (etamax-etamin)*pyr_(&dum);
00527         double tet = 2.*atan(exp(-eta));
00528         // betax, betay, betaz
00529         double betax = pp/ee * std::sin(tet) * std::cos(fhi);
00530         double betay = pp/ee * std::sin(tet) * std::sin(fhi);
00531         double betaz = pp/ee * std::cos(tet);
00532         // No rotation
00533         double rothe = 0.;
00534         double rophi = 0.;
00535         // Boost all particles
00536         int first = -1;
00537         int last = -1;
00538         PYROBO(first, last, rothe, rophi, betax, betay, betaz);
00539         // And now decay boosted particles
00540         PYEXEC();
00541 
00542       } else {
00543           if(!gluinoHadronsEnabled && !stopHadronsEnabled)
00544           {
00545              call_pyevnt();      // generate one event with Pythia
00546           }
00547           else
00548           {
00549              call_pygive("MSTJ(14)=-1");
00550              call_pyevnt();      // generate one event with Pythia
00551              call_pygive("MSTJ(14)=1");
00552              if(gluinoHadronsEnabled)  PYGLFR();
00553              if(stopHadronsEnabled)  PYSTFR();
00554           }
00555           
00556       }
00557 
00558     if ( useTauola_ ) {
00559       tauola_.processEvent();
00560       //call_pretauola(0); // generate tau decays with TAUOLA
00561     }
00562 
00563     // convert to stdhep format
00564     //
00565     call_pyhepc( 1 );
00566     
00567     // convert stdhep (hepevt) to hepmc
00568     //
00569     //HepMC::GenEvent* evt = conv.getGenEventfromHEPEVT();
00570     HepMC::GenEvent* evt = conv.read_next_event();
00571     
00572     // fix for 1-part events
00573     if ( particleID ) evt->set_beam_particles(0,0);
00574     
00575     evt->set_signal_process_id(pypars.msti[0]);
00576     evt->set_event_scale(pypars.pari[16]);
00577     evt->set_event_number(numberEventsInRun() - remainingEvents() - 1);
00578 
00579     // int id1 = pypars.msti[14];
00580     // int id2 = pypars.msti[15];
00581     int id1 = pyint1.mint[14];
00582     int id2 = pyint1.mint[15];
00583     if ( id1 == 21 ) id1 = 0;
00584     if ( id2 == 21 ) id2 = 0; 
00585     double x1 = pyint1.vint[40];
00586     double x2 = pyint1.vint[41];  
00587     double Q  = pyint1.vint[50];
00588     double pdf1 = pyint1.vint[38];
00589     pdf1 /= x1 ;
00590     double pdf2 = pyint1.vint[39];
00591     pdf2 /= x2 ;
00592     evt->set_pdf_info( HepMC::PdfInfo(id1,id2,x1,x2,Q,pdf1,pdf2) ) ;
00593     
00594     evt->weights().push_back( pyint1.vint[96] );
00595 
00596     if (imposeProperTimes_ || pydat1.mstj[21]==3 || pydat1.mstj[21]==4 ) {
00597       int dumm;
00598       HepMC::GenEvent::vertex_const_iterator vbegin = evt->vertices_begin();
00599       HepMC::GenEvent::vertex_const_iterator vend = evt->vertices_end();
00600       HepMC::GenEvent::vertex_const_iterator vitr = vbegin;
00601       for (; vitr != vend; ++vitr ) {
00602             HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(HepMC::children);
00603             HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(HepMC::children);
00604             HepMC::GenVertex::particle_iterator pitr = pbegin;
00605             for (; pitr != pend; ++pitr) {
00606                   if ((*pitr)->end_vertex()) continue;
00607                   if ((*pitr)->status()!=1) continue;
00608                   int pdgcode= abs((*pitr)->pdg_id());
00609                   // Do nothing if the particle is not expected to decay
00610                   if (pydat3.mdcy[0][PYCOMP(pdgcode)-1]!=1) continue;
00611 
00612                   double ctau = pydat2.pmas[3][PYCOMP(pdgcode)-1];
00613                   HepMC::FourVector mom = (*pitr)->momentum();
00614                   HepMC::FourVector vin = (*vitr)->position();
00615                   double x = 0.;
00616                   double y = 0.;
00617                   double z = 0.;
00618                   double t = 0.;
00619                   bool decayInRange = false;
00620                   while (!decayInRange) {
00621                         double unif_rand = pyr_(&dumm);
00622                         // Value of 0 is excluded, so following line is OK
00623                         double proper_length = - ctau * log(unif_rand);
00624                         double factor = proper_length/mom.m();
00625                         x = vin.x() + factor * mom.px();
00626                         y = vin.y() + factor * mom.py();
00627                         z = vin.z() + factor * mom.pz();
00628                         t = vin.t() + factor * mom.e();
00629                         // Decay must be happen outside a cylindrical region
00630                         if (pydat1.mstj[21]==4) {
00631                               if (sqrt(x*x+y*y)>pydat1.parj[72] || abs(z)>pydat1.parj[73]) decayInRange = true;
00632                         // Decay must be happen outside a given sphere
00633                         } else if (pydat1.mstj[21]==3) {
00634                               if (sqrt(x*x+y*y+z*z)>pydat1.parj[71]) decayInRange = true;
00635                         // Decay is always OK otherwise
00636                         } else {
00637                               decayInRange = true;
00638                         }
00639                   }
00640                   
00641                   HepMC::GenVertex* vdec = new HepMC::GenVertex(HepMC::FourVector(x,y,z,t));
00642                   evt->add_vertex(vdec);
00643                   vdec->add_particle_in((*pitr));
00644             }
00645       }
00646     }
00647     
00648     //******** Verbosity ********
00649     
00650     if(event() <= maxEventsToPrint_ &&
00651        (pythiaPylistVerbosity_ || pythiaHepMCVerbosity_)) {
00652 
00653       // Prints PYLIST info
00654       if(pythiaPylistVerbosity_) {
00655         call_pylist(pythiaPylistVerbosity_);
00656       }
00657       
00658       // Prints HepMC event
00659       if(pythiaHepMCVerbosity_) {
00660         cout << "Event process = " << pypars.msti[0] << endl 
00661         << "----------------------" << endl;
00662         evt->print();
00663       }
00664     }
00665     
00666     
00667     //evt = reader_->fillCurrentEventData(); 
00668     //********                                      
00669 
00670     if(evt)  bare_product->addHepMCData(evt );
00671 
00672     e.put(bare_product);
00673 
00674     return true;
00675 }


Member Data Documentation

double edm::PythiaSource::comenergy [private]

Definition at line 82 of file PythiaSource.h.

Referenced by PythiaSource().

bool edm::PythiaSource::doubleParticle [private]

Definition at line 77 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::emax [private]

Definition at line 83 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::emin [private]

Definition at line 83 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::etamax [private]

Definition at line 80 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::etamin [private]

Definition at line 80 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

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

Definition at line 59 of file PythiaSource.h.

Referenced by produce().

double edm::PythiaSource::extCrossSect [private]

Definition at line 71 of file PythiaSource.h.

Referenced by endRun().

double edm::PythiaSource::extFilterEff [private]

Definition at line 72 of file PythiaSource.h.

Referenced by endRun().

bool edm::PythiaSource::flatEnergy [private]

Definition at line 85 of file PythiaSource.h.

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

Definition at line 98 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

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

Definition at line 96 of file PythiaSource.h.

Referenced by PythiaSource().

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

Definition at line 97 of file PythiaSource.h.

Referenced by PythiaSource().

bool edm::PythiaSource::gluinoHadronsEnabled [private]

Definition at line 94 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

bool edm::PythiaSource::imposeProperTimes_ [private]

Impose proper times for pions/kaons at generator level.

Definition at line 66 of file PythiaSource.h.

Referenced by produce().

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

Definition at line 78 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

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

Events to print if verbosity.

Definition at line 68 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

int edm::PythiaSource::particleID [private]

Definition at line 75 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

std::vector<int> edm::PythiaSource::particleIDs [private]

Definition at line 76 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::phimax [private]

Definition at line 81 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::phimin [private]

Definition at line 81 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::ptmax [private]

Definition at line 79 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

double edm::PythiaSource::ptmin [private]

Definition at line 79 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

bool edm::PythiaSource::pythiaHepMCVerbosity_ [private]

HepMC verbosity flag.

Definition at line 64 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

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

Pythia PYLIST Verbosity flag.

Definition at line 62 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

bool edm::PythiaSource::stopHadronsEnabled [private]

Definition at line 93 of file PythiaSource.h.

Referenced by produce(), and PythiaSource().

TauolaInterface edm::PythiaSource::tauola_ [private]

Definition at line 91 of file PythiaSource.h.

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

bool edm::PythiaSource::useExternalGenerators_ [private]

Definition at line 88 of file PythiaSource.h.

Referenced by PythiaSource().

bool edm::PythiaSource::useTauola_ [private]

Definition at line 89 of file PythiaSource.h.

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

bool edm::PythiaSource::useTauolaPolarization_ [private]

Definition at line 90 of file PythiaSource.h.

Referenced by PythiaSource().

double edm::PythiaSource::ymax [private]

Definition at line 84 of file PythiaSource.h.

Referenced by PythiaSource().

double edm::PythiaSource::ymin [private]

Definition at line 84 of file PythiaSource.h.

Referenced by PythiaSource().


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