CMS 3D CMS Logo

edm::TauolaInterface Class Reference

#include <GeneratorInterface/CommonInterface/interface/TauolaInterface.h>

List of all members.

Public Member Functions

void disablePolarizationEffects ()
void enablePolarizationEffects ()
void initialize ()
void print ()
void processEvent ()
 TauolaInterface ()
 ~TauolaInterface ()

Private Member Functions

int decayUnstableHadrons (int numGenParticles_beforeTAUOLA, int numGenParticles_afterTAUOLA)
void setDecayVertex (int numGenParticles_beforeTAUOLA, int numGenParticles_afterTAUOLA)

Private Attributes

int keypol_
int version_

Static Private Attributes

static int debug_ = 0
static const int maxNumberParticles = 4000


Detailed Description

Definition at line 17 of file TauolaInterface.h.


Constructor & Destructor Documentation

TauolaInterface::TauolaInterface (  ) 

Definition at line 28 of file TauolaInterface.cc.

References keypol_, and version_.

00029 {
00030 //--- per default,
00031 //    use TAUOLA package customized for CMS by Serge Slabospitsky 
00032   version_ = 1;
00033 
00034 //--- per default,
00035 //    enable polarization effects in tau lepton decays
00036   keypol_ = 1;
00037   
00038   // switch_photos_ = 0 ;
00039 }

TauolaInterface::~TauolaInterface (  ) 

Definition at line 41 of file TauolaInterface.cc.

00042 {}


Member Function Documentation

int TauolaInterface::decayUnstableHadrons ( int  numGenParticles_beforeTAUOLA,
int  numGenParticles_afterTAUOLA 
) [private]

Definition at line 337 of file TauolaInterface.cc.

References funct::abs(), call_pydecy(), GenMuonPlsPt100GeV_cfg::cout, debug_, lat::endl(), maxNumberParticles, and pyjets.

Referenced by processEvent().

00338 {
00339 //-------------------------------------------------------------------------------
00340 //          further decay of unstable hadrons produced in tau decay
00341 //-------------------------------------------------------------------------------
00342 
00343 //--- check if all particles resulting from tau decay are stable; 
00344 //    keep iterating as long as n12 > n11 
00345 //    (some decay products are unstable)
00346   int nFirst = numGenParticles_beforeTAUOLA + 1;
00347   int nLast = numGenParticles_afterTAUOLA;
00348   while ( nLast > nFirst && nLast < maxNumberParticles ) {
00349     if ( debug_ > 1 ) {
00350       std::cout << "before calling PYDECY:" << std::endl;
00351       std::cout << " nFirst = " << nFirst << std::endl;
00352       std::cout << " nLast = " << nLast << std::endl;
00353     }
00354 
00355     for ( int iParticle = nFirst; iParticle <= nLast; ++iParticle ) {
00356       int particleStatus = pyjets.k[0][iParticle - 1];
00357       if ( debug_ > 1 ) {
00358         std::cout << "genParticle[" << iParticle << "] status = " << particleStatus << std::endl;
00359       }
00360 
00361 //--- check that particle is "currently existing"
00362 //    and not e.g. a documentation line summarizing event level information
00363       if ( particleStatus > 0 &&
00364            particleStatus < 10 ) {
00365         int particleType = abs(pyjets.k[1][iParticle - 1]);
00366         
00367         if ( debug_ > 1 ) {
00368           std::cout << "genParticle[" << iParticle << "] type = " << particleType << std::endl;
00369         }
00370 
00371         if ( particleType >= 100 ) {
00372           if ( particleType != 211 &&   // PI+- 
00373                particleType != 321 &&   // K+- 
00374                particleType != 130 &&   // KL 
00375                particleType != 310 ) {  // KS
00376             if ( debug_ > 1 ) std::cout << "calling PYDECY for genParticle[" << iParticle << "]" << std::endl;
00377             call_pydecy(iParticle);
00378           }
00379         }
00380       }
00381     }
00382 
00383     nFirst = nLast + 1;
00384     nLast = pyjets.n;
00385 
00386     if ( debug_ > 1 ) {
00387       std::cout << "after calling PYDECY:" << std::endl;
00388       std::cout << " nFirst = " << nFirst << std::endl;
00389       std::cout << " nLast = " << nLast << std::endl;
00390     }
00391 
00392 //--- mark particles that did not decay within the CMS detector volume
00393 //    as undecayed
00394     for ( int iParticle = nFirst; iParticle <= nLast; ++iParticle ) {
00395       int particleStatus = pyjets.k[0][iParticle - 1];
00396       int particleType = abs(pyjets.k[1][iParticle - 1]);
00397       int particleDaughters = pyjets.k[3][iParticle - 1];
00398       if ( particleStatus == 4 &&
00399            particleType >= 100 &&
00400            particleDaughters == 0 ) {
00401         if ( debug_ > 1 ) std::cout << "setting status = 1 for genParticle[" << iParticle << "]" << std::endl;
00402         pyjets.k[0][iParticle - 1] = 1;
00403       }
00404     }
00405   }
00406 
00407 //--- return last index of particle resulting from tau decay
00408 //    (including direct and indirect decay products)
00409   return nLast;
00410 }

void edm::TauolaInterface::disablePolarizationEffects (  )  [inline]

Definition at line 29 of file TauolaInterface.h.

References keypol_.

Referenced by edm::MadGraphProducer::init(), edm::MadGraphSource::MadGraphSource(), edm::PythiaProducer::PythiaProducer(), and edm::PythiaSource::PythiaSource().

00029 { keypol_ = 0; }

void edm::TauolaInterface::enablePolarizationEffects (  )  [inline]

Definition at line 28 of file TauolaInterface.h.

References keypol_.

Referenced by edm::MadGraphProducer::init(), edm::MadGraphSource::MadGraphSource(), edm::PythiaProducer::PythiaProducer(), and edm::PythiaSource::PythiaSource().

00028 { keypol_ = 1; }

void TauolaInterface::initialize (  ) 

Definition at line 44 of file TauolaInterface.cc.

References call_pycomp(), call_pygive(), call_tauola(), call_tauola_srs(), call_taurep(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), keypol_, ki_taumod_, mode, and version_.

Referenced by edm::MadGraphProducer::init(), edm::MadGraphSource::MadGraphSource(), edm::PythiaProducer::PythiaProducer(), and edm::PythiaSource::PythiaSource().

00045 {
00046 //--- initialization of TAUOLA package;
00047 //    to be called **before** the event loop
00048 
00049 //--- check if TAUOLA tau decays are disabled
00050   if ( ki_taumod_.mdtau <= -1 ) return;
00051 
00052 //--- disable tau decays in PYTHIA
00053   std::cout << "----------------------------------------------" << std::endl;
00054   std::cout << "Disabling tau decays in Pythia" << std::endl;
00055   int pdgCode = 15;
00056   int pythiaCode = call_pycomp(pdgCode);
00057   char parameter[20];
00058   sprintf(parameter, "MDCY(%i,1)=0", pythiaCode);
00059   std::cout << "pythiaCode = " << pythiaCode << std::endl;
00060   std::cout << "strlen(parameter) = " << strlen(parameter) << std::endl;
00061   call_pygive(parameter, strlen(parameter));
00062   std::cout << "----------------------------------------------" << std::endl;
00063 
00064 //--- initialize TAUOLA
00065   std::cout << "----------------------------------------------" << std::endl;
00066   std::cout << "Initializing Tauola" << std::endl;
00067   int mode = -1;
00068   switch ( version_ ) {
00069   case 0 :
00070     call_tauola(mode, keypol_);
00071     break;
00072   case 1 :
00073     call_taurep(-2);
00074     // libra.ifphot = switch_photos_ ;
00075     call_tauola_srs(mode, keypol_);
00076     break;
00077   }
00078   std::cout << "----------------------------------------------" << std::endl;
00079 }

void TauolaInterface::print ( void   ) 

Definition at line 176 of file TauolaInterface.cc.

References call_tauola(), call_tauola_srs(), keypol_, mode, and version_.

Referenced by edm::MadGraphSource::endRun(), edm::PythiaProducer::endRun(), edm::MadGraphProducer::endRun(), and edm::PythiaSource::endRun().

00177 {
00178 //--- print event generation statistics
00179 //    and branching fraction information of TAUOLA
00180   int mode = 1;
00181   switch ( version_ ) {
00182   case 0 :
00183     call_tauola(mode, keypol_);
00184     break;
00185   case 1 : 
00186     call_tauola_srs(mode, keypol_);
00187     break;
00188   }
00189 }

void TauolaInterface::processEvent (  ) 

Definition at line 81 of file TauolaInterface.cc.

References call_ihepdim(), call_pyhepc_t(), call_tauola(), call_tauola_srs(), GenMuonPlsPt100GeV_cfg::cout, debug_, decayUnstableHadrons(), dummy, lat::endl(), keypol_, mode, pyjets, setDecayVertex(), and version_.

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

00082 {
00083   if ( debug_ ) {
00084     std::cout << "<TauolaInterface::processEvent>: begin of event processing..." << std::endl;
00085   }
00086 
00087 //--- convert PYJETS to HEPEVT common block structure
00088   if ( debug_ ) std::cout << "converting PYJETS to HEPEVT common block structure..." << std::endl;
00089   switch ( version_ ) {
00090   case 0 :
00091     call_pyhepc( 1 );
00092     break;
00093   case 1 : 
00094     call_pyhepc_t( 1 );
00095     break;
00096   }
00097 
00098 //--- determine number of entries in HEPEVT common block **before** calling TAUOLA
00099   if ( debug_ ) std::cout << "determining number of generated particles **before** calling TAUOLA..." << std::endl;
00100   int dummy = -1;
00101   int numGenParticles_beforeTAUOLA = call_ihepdim(dummy);
00102 
00103 //--- decay tau leptons with TAUOLA
00104   if ( debug_ ) std::cout << "calling TAUOLA..." << std::endl;
00105   int mode = 0;
00106   switch ( version_ ) {
00107   case 0 :
00108     call_tauola(mode, keypol_);
00109     break;
00110   case 1 : 
00111     call_tauola_srs(mode, keypol_);
00112     break;
00113   }
00114     
00115 //--- determine number of entries in HEPEVT common block **after** calling TAUOLA
00116   if ( debug_ ) std::cout << "determining number of generated particles **after** calling TAUOLA..." << std::endl;
00117   //int dummy = -1;
00118   int numGenParticles_afterTAUOLA = call_ihepdim(dummy);
00119 
00120 
00121 //--- convert back HEPEVT to PYJETS common block structure
00122   if ( debug_ ) std::cout << "converting back HEPEVT to PYJETS common block structure..." << std::endl;
00123   switch ( version_ ) {
00124   case 0 :
00125     call_pyhepc( 2 );
00126     break;
00127   case 1 : 
00128     call_pyhepc_t( 2 );
00129     break;
00130   }
00131 
00132 //--- simulated further decay of unstable hadrons 
00133 //    produced in tau decay
00134   if ( debug_ ) std::cout << "decaying unstable hadrons produced in tau decay..." << std::endl;
00135 
00136   int numGenParticles_afterUnstableHadronDecays = decayUnstableHadrons(numGenParticles_beforeTAUOLA, numGenParticles_afterTAUOLA);
00137 
00138 
00139 //--- set production vertex for tau decay products,
00140 //    taking into account tau lifetime of c tau = 87 um
00141   if ( debug_ ) std::cout << "setting decay vertex of tau lepton and production vertices of decay products..." << std::endl;
00142   //setDecayVertex(numGenParticles_beforeTAUOLA, numGenParticles_afterTAUOLA);
00143   setDecayVertex(numGenParticles_beforeTAUOLA, numGenParticles_afterUnstableHadronDecays);
00144 
00145 //--- simulated further decay of unstable hadrons 
00146 //    produced in tau decay
00147 //  if ( debug_ ) std::cout << "decaying unstable hadrons produced in tau decay..." << std::endl;
00148 //  decayUnstableHadrons(numGenParticles_beforeTAUOLA, numGenParticles_afterTAUOLA);
00149 
00150 
00151 //--- print list of particles
00152   if ( debug_ > 1 ) {
00153     int nFirst = numGenParticles_beforeTAUOLA;
00154     int nLast = pyjets.n;
00155     for ( int iParticle = (nFirst + 1); iParticle <= nLast; ++iParticle ) {
00156       std::cout << "genParticle #" << iParticle << std::endl;
00157       std::cout << " type = " 
00158                 << pyjets.k[1][iParticle - 1] << std::endl;
00159       std::cout << " p(Px,Py,Pz,E) = {" 
00160                 << pyjets.p[0][iParticle - 1] << ","
00161                 << pyjets.p[1][iParticle - 1] << ","
00162                 << pyjets.p[2][iParticle - 1] << ","
00163                 << pyjets.p[3][iParticle - 1] << "}" << std::endl;
00164       std::cout << " v(x,y,z) = {" 
00165                 << pyjets.v[0][iParticle - 1] << ","
00166                 << pyjets.v[1][iParticle - 1] << ","
00167                 << pyjets.v[2][iParticle - 1] << "}" << std::endl;
00168     }
00169   }
00170 
00171   if ( debug_ ) {
00172     std::cout << "<TauolaInterface::processEvent>: end of event processing..." << std::endl;
00173   }
00174 }

void TauolaInterface::setDecayVertex ( int  numGenParticles_beforeTAUOLA,
int  numGenParticles_afterTAUOLA 
) [private]

Definition at line 191 of file TauolaInterface.cc.

References funct::abs(), call_pycomp(), call_pyr(), TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ct, debug_, lat::endl(), i, funct::log(), maxNumberParticles, pydat2, pyjets, pypars, and funct::sqrt().

Referenced by processEvent().

00192 {
00193 //-------------------------------------------------------------------------------
00194 //               set production vertex for tau decay products,
00195 //             taking tau lifetime of c tau = 87 um into account
00196 //-------------------------------------------------------------------------------
00197 
00198   int numDocumentationLines = pypars.msti[3];
00199 
00200   if ( debug_ > 1 ) {
00201     std::cout << "numGenParticles_beforeTAUOLA = " << numGenParticles_beforeTAUOLA << std::endl;
00202     std::cout << "numGenParticles_afterTAUOLA = " << numGenParticles_afterTAUOLA << std::endl;
00203     std::cout << "numDocumentationLines = " << numDocumentationLines << std::endl;
00204   }
00205 
00206 //--- check that index given for first particle resulting from tau decay is valid
00207 //    and in particular does not point into documentation lines at beginning of PYJETS common block
00208   if ( numGenParticles_beforeTAUOLA <= numDocumentationLines ) {
00209     std::cerr << "Error in <TauolaInterface::setDecayVertex>: index of first particle in PYJETS common block less than number of documentation lines !" << std::endl;
00210     return;
00211   }
00212 
00213 //--- temporary storage of particle decay vertices;
00214 //    reset for each event
00215   double particleDecayVertex[4][maxNumberParticles];
00216   for ( int i = 0; i < 4; ++i ) {
00217     for ( int iParticle = 1; iParticle <= maxNumberParticles; ++iParticle ) {
00218       particleDecayVertex[i][iParticle] = 0.;
00219     }
00220   }
00221 
00222   int nFirst = numDocumentationLines + 1;
00223   int nLast = numGenParticles_afterTAUOLA;
00224 
00225   for ( int iParticle = nFirst; iParticle <= nLast; ++iParticle ) {
00226     int particleStatus = pyjets.k[0][iParticle - 1];
00227     if ( debug_ > 1 ) {
00228       std::cout << "genParticle[" << iParticle << "] status = " << particleStatus << std::endl;
00229     }
00230 
00231 //--- check that particle is "currently existing"
00232 //    and not e.g. a documentation line summarizing event level information
00233 //    if ( particleStatus > 0 &&
00234 //         particleStatus < 10 ) {
00235     if ( particleStatus == 1 ||
00236          particleStatus == 11 ) {
00237       int particleType = abs(pyjets.k[1][iParticle - 1]);
00238       int particleType_PYTHIA = call_pycomp(particleType);
00239       
00240       if ( debug_ > 1 ) {
00241         std::cout << "genParticle[" << iParticle << "] type = " << particleType << std::endl;
00242       }
00243 
00244 //--- do not touch particles not associated to tau decays
00245       if ( particleType != 15 && iParticle <= numGenParticles_beforeTAUOLA ) continue;
00246 
00247 //--- set production vertex 
00248 //    for daughter particles resulting from tau decay
00249 //    to decay vertex of their mother
00250       for ( int i = 0; i < 4; ++i ) {
00251         if ( particleType != 15 ) {
00252           int indexParticleMother_i = pyjets.k[2][iParticle - 1];
00253           
00254           if ( indexParticleMother_i > iParticle ) {
00255             std::cerr << "Error in <TauolaInterface::setDecayVertex>: daughter found before mother particle in PYJETS common block !" << std::endl;
00256           } 
00257           
00258           if ( debug_ > 1 ) {
00259             if ( i == 0 ) std::cout << " --> setting production vertex for genParticle[" << iParticle << "]" 
00260                                     << " to decay vertex of genParticle[" << indexParticleMother_i << "]" << std::endl;
00261           }
00262 
00263           double particleProductionVertex_i = particleDecayVertex[i][indexParticleMother_i - 1];
00264           pyjets.v[i][iParticle - 1] = particleProductionVertex_i;
00265         }
00266       }
00267 
00268 //-------------------------------------------------------------------------------
00269 //  for unstable particles, randomly choose lifetime and determine decay vertex 
00270 //-------------------------------------------------------------------------------
00271 
00272       if ( particleStatus == 11 ) {
00273 
00274 //--- set time after which particle decayed in its restframe
00275 //    (prob = exp(-t/lifetime) ==> t = -lifetime * log(prob),
00276 //     with prob randomly chosen from flat distribution between zero and one)
00277         double lifetime = pydat2.pmas[3][particleType_PYTHIA - 1];
00278         double u = call_pyr(0); // random number generated by PYTHIA
00279         double ct = -lifetime*log(u); // time (in particle rest frame) after which particle decayed
00280         pyjets.v[4][iParticle - 1] = ct;
00281         
00282         if ( debug_ > 1 ) {
00283           std::cout << "lifetime = " << lifetime << std::endl;
00284           std::cout << "u = " << u << std::endl;
00285           std::cout << "ct = " << ct << std::endl;
00286         }
00287 
00288 //--- set decay vertex
00289 //    (first three coordinates = x,y,z;
00290 //     fourth coordinate = time after which particle decayed in laboratory frame;
00291 //     see e.g.
00292 //       https://cepa.fnal.gov/psm/simulation/mcgen/lund/pythia_manual/pythia6.3/pythia6301/node35.html
00293 //     for description of the PYTHIA common block structures)
00294 //
00295         for ( int i = 0; i < 4; ++i ) {
00296           double particleProductionVertex_i = pyjets.v[i][iParticle - 1];
00297 
00298 //--- set decay vertex = production vertex + ct*v*gamma,
00299 //    with 
00300 //      v = unit vector in particle direction 
00301 //    and 
00302 //      gamma = E/m Lorentz boost factor
00303 //          
00304           double particleMomentum_i = pyjets.p[i][iParticle - 1];
00305           double particleEnergy = pyjets.p[3][iParticle - 1];
00306           double particleMass = pyjets.p[4][iParticle - 1];
00307           if ( particleEnergy >= particleMass && particleMass > 0. ) {
00308             double particleMomentum = sqrt(particleEnergy*particleEnergy - particleMass*particleMass);
00309             
00310             double particleDecayVertex_i = particleProductionVertex_i + ct*(particleMomentum_i/particleMomentum)*(particleEnergy/particleMass);
00311             
00312             if ( debug_ > 1 ) {
00313               if ( i == 0 ) {
00314                 std::cout << "particleEnergy = " << particleEnergy << std::endl;
00315                 std::cout << "particleMass = " << particleMass << std::endl;
00316                 std::cout << "particleMomentum = " << particleMomentum << std::endl;
00317               }
00318               std::cout << "particleMomentum_" << i << " = " << particleMomentum_i << std::endl;
00319               if ( i == 0 ) std::cout << " --> setting decay vertex of genParticle[" << iParticle << "]" << std::endl;
00320               std::cout << "particleDecayVertex[" << i << "] = " << particleDecayVertex_i << std::endl;
00321             }
00322             
00323             particleDecayVertex[i][iParticle - 1] = particleDecayVertex_i;
00324           } else {
00325             if ( particleMass == 0 ) 
00326               std::cerr << "Error in <TauolaInterface::setDecayVertex>: mass of unstable particle cannot be zero !" << std::endl;
00327             else
00328               std::cerr << "Error in <TauolaInterface::setDecayVertex>: energy of tau lepton cannot be smaller than its mass !" << std::endl;
00329             continue;
00330           }
00331         }
00332       }
00333     } 
00334   }
00335 }


Member Data Documentation

int TauolaInterface::debug_ = 0 [static, private]

Definition at line 73 of file TauolaInterface.h.

Referenced by decayUnstableHadrons(), processEvent(), and setDecayVertex().

int edm::TauolaInterface::keypol_ [private]

Definition at line 63 of file TauolaInterface.h.

Referenced by disablePolarizationEffects(), enablePolarizationEffects(), initialize(), print(), processEvent(), and TauolaInterface().

const int edm::TauolaInterface::maxNumberParticles = 4000 [static, private]

Definition at line 70 of file TauolaInterface.h.

Referenced by decayUnstableHadrons(), and setDecayVertex().

int edm::TauolaInterface::version_ [private]

Definition at line 58 of file TauolaInterface.h.

Referenced by initialize(), print(), processEvent(), and TauolaInterface().


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