@@ -27,6 +27,7 @@ Generator3::Generator3(const ParameterSet &p)
2727 fPtransCut(p.getParameter<bool >(" ApplyPtransCut" )),
2828 fEtaCuts(p.getParameter<bool >(" ApplyEtaCuts" )),
2929 fPhiCuts(p.getParameter<bool >(" ApplyPhiCuts" )),
30+ fSlepton(p.getParameter<bool >(" IsSlepton" )),
3031 theMinPhiCut(p.getParameter<double >(" MinPhiCut" )), // in radians (CMS standard)
3132 theMaxPhiCut(p.getParameter<double >(" MaxPhiCut" )),
3233 theMinEtaCut(p.getParameter<double >(" MinEtaCut" )),
@@ -367,7 +368,7 @@ void Generator3::HepMC2G4(const HepMC3::GenEvent *evt_orig, G4Event *g4evt) {
367368 // Decay chain outside the fiducial cylinder defined by theRDecLenCut
368369 // are used for Geant4 tracking with predefined decay channel
369370 // In the case of decay in vacuum particle is not tracked by Geant4
370- } else if (2 == status && x2 * x2 + y2 * y2 >= theDecRCut2 && std::abs (z2) < Z_hector) {
371+ } else if (2 == status && x2 * x2 + y2 * y2 >= theDecRCut2 && ( fSlepton || std::abs (z2) < Z_hector) ) {
371372 toBeAdded = true ;
372373 if (verbose > 1 )
373374 edm::LogVerbatim (" SimG4CoreGenerator3" ) << " GenParticle barcode = " << pitr->id () << " passed case 2"
@@ -477,7 +478,14 @@ void Generator3::particleAssignDaughters(G4PrimaryParticle *g4p, HepMC3::GenPart
477478 LogDebug (" SimG4CoreGenerator3::::particleAssignDaughters" )
478479 << " Assigning a " << vpdec->pid () << " as daughter of a " << vp->pid () << " status=" << status;
479480
480- if ((status == 2 || (status == 23 && std::abs (vp->pid ()) == 1000015 ) || (status > 50 && status < 100 )) &&
481+ bool isInList;
482+ if (fSlepton ) {
483+ std::vector<int > fParticleList = {1000011 , 1000013 , 1000015 , 2000011 , 2000013 , 2000015 };
484+ isInList = (std::find (fParticleList .begin (), fParticleList .end (), std::abs (vp->pdg_id ())) != fParticleList .end ());
485+ } else {
486+ isInList = std::abs (vp->pdg_id ()) == 1000015 ;
487+ }
488+ if ((status == 2 || (status == 23 && isInList) || (status > 50 && status < 100 )) &&
481489 vpdec->end_vertex () != nullptr ) {
482490 double x2 = vpdec->end_vertex ()->position ().x ();
483491 double y2 = vpdec->end_vertex ()->position ().y ();
0 commit comments