Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:34

0001 
0002 /**
0003  * This is a Pythia8-specific parton selector that selects all partons that don't have other partons as daughters, i.e., partons
0004  * from the end of the parton showering sequence. An explanation of the particle status codes returned by Pythia8 can be found in
0005  * Pythia8 online manual (http://home.thep.lu.se/~torbjorn/pythia81html/ParticleProperties.html).
0006  */
0007 
0008 #include "PhysicsTools/JetMCAlgos/interface/Pythia8PartonSelector.h"
0009 #include "PhysicsTools/JetMCUtils/interface/CandMCTag.h"
0010 
0011 Pythia8PartonSelector::Pythia8PartonSelector() {}
0012 
0013 Pythia8PartonSelector::~Pythia8PartonSelector() {}
0014 
0015 void Pythia8PartonSelector::run(const edm::Handle<reco::GenParticleCollection>& particles,
0016                                 std::unique_ptr<reco::GenParticleRefVector>& partons) {
0017   // loop over particles and select partons
0018   for (reco::GenParticleCollection::const_iterator it = particles->begin(); it != particles->end(); ++it) {
0019     int status = it->status();
0020     if (status == 1)
0021       continue;  // skip stable particles
0022     if (status == 2)
0023       continue;  // skip decayed Standard Model hadrons and leptons
0024     if (!CandMCTagUtils::isParton(*it))
0025       continue;  // skip particle if not a parton
0026 
0027     // check if the parton has other partons as daughters
0028     int nparton_daughters = 0;
0029     for (unsigned i = 0; i < it->numberOfDaughters(); ++i) {
0030       if (CandMCTagUtils::isParton(*(it->daughter(i))))
0031         ++nparton_daughters;
0032     }
0033 
0034     if (nparton_daughters == 0)
0035       partons->push_back(reco::GenParticleRef(particles, it - particles->begin()));
0036   }
0037 
0038   return;
0039 }