0016 /**0017 \class TopDecaySubset TopDecaySubset.h "TopQuarkAnalysis/TopEventProducers/interface/TopDecaySubset.h" 0018 0019 \brief Module to produce the subset of generator particles directly contained in top decay chains 0020 0021 The module produces the subset of generator particles directly contained in top decay chains. The 0022 particles are saved as a collection of reco::GenParticles. Depending on the configuration of the module, 0023 the 4-vector kinematics can be taken from the status-3 particles (ME before parton showering) or from 0024 the status-2 particles (after parton showering), additionally radiated gluons may be considered during 0025 the creation of the subset or not. 0026 */ 0027 0028 0029 class TopDecaySubset : public edm::EDProducer { 0030 0031 public: 0032 /// supported modes to fill the new vectors 0033 /// of gen particles 0034 enum FillMode {kStable, kME}; 0035 /// classification of potential shower types 0036 enum ShowerModel{kStart=-1, kNone, kPythia, kHerwig, kPythia8, kSherpa}; 0037 /// supported modes to run the code 0038 enum RunMode {kRun1, kRun2}; 0039 0040 /// default constructor 0041 explicit TopDecaySubset(const edm::ParameterSet& cfg); 0042 /// default destructor 0043 ~TopDecaySubset() override; 0044 /// write output into the event 0045 void produce(edm::Event& event, const edm::EventSetup& setup) override; 0046 0047 private: 0048 /// find top quarks in list of input particles 0049 std::vector<const reco::GenParticle*> findTops(const reco::GenParticleCollection& parts); 0050 /// find primal top quarks (top quarks from the hard interaction) 0051 /// for Pythia6 this is identical to findDecayingTops 0052 std::vector<const reco::GenParticle*> findPrimalTops(const reco::GenParticleCollection& parts); 0053 /// find decaying top quarks (quarks that decay to qW) 0054 /// for Pythia6 this is identical to findPrimalTops 0055 std::vector<const reco::GenParticle*> findDecayingTops(const reco::GenParticleCollection& parts); 0056 /// find W bosons that come from top quark decays 0057 /// for Pythia6 this is identical to findDecayingW 0058 const reco::GenParticle* findPrimalW(const reco::GenParticle* top); 0059 /// find W bosons that come from top quark decays and decay themselves (end of the MC chain) 0060 /// for Pythia6 this is identical to findPrimalW 0061 // const reco::GenParticle* findDecayingW(const reco::GenParticle* top); 0062 /// find the last particle in a (potentially) long chain of state transitions 0063 /// e.g. top[status==22]-> top[status==44 -> top[status==44] -> 0064 /// top[status==44] -> top[status==62] 0065 /// this function would pick the top with status 62 0066 const reco::GenParticle* findLastParticleInChain(const reco::GenParticle* p); 0067 /// check the decay chain for the used shower model 0068 ShowerModel checkShowerModel(const std::vector<const reco::GenParticle*>& tops) const; 0069 ShowerModel checkShowerModel(edm::Event& event); 0070 /// check whether W bosons are contained in the original gen particle listing 0071 void checkWBosons(std::vector<const reco::GenParticle*>& tops) const; 0072 /// fill output vector for full decay chain 0073 void fillListing(const std::vector<const reco::GenParticle*>& tops, reco::GenParticleCollection& target); 0074 /// fill output vector for full decay chain 0075 void fillListing(const std::vector<const reco::GenParticle*>& primalTops, 0076 const std::vector<const reco::GenParticle*>& decayingTops, 0077 reco::GenParticleCollection& target); 0078 0079 /// clear references 0080 void clearReferences(); 0081 /// fill references for output vector 0082 void fillReferences(const reco::GenParticleRefProd& refProd, reco::GenParticleCollection& target); 0083 /// calculate lorentz vector from input (dedicated to top reconstruction) 0084 reco::Particle::LorentzVector p4(const std::vector<const reco::GenParticle*>::const_iterator top, int statusFlag); 0085 /// calculate lorentz vector from input 0086 reco::Particle::LorentzVector p4(const reco::GenParticle::const_iterator part, int statusFlag); 0087 /// recursively fill vector for all further decay particles of a given particle 0088 void addDaughters(int& idx, const reco::GenParticle::const_iterator part, reco::GenParticleCollection& target, bool recursive=true); 0089 /// fill vector including all radiations from quarks originating from W/top 0090 void addRadiation(int& idx, const reco::GenParticle::const_iterator part, reco::GenParticleCollection& target); 0091 void addRadiation(int& idx, const reco::GenParticle* part, reco::GenParticleCollection& target); 0092 0093 private: 0094 /// input tag for the genParticle source 0095 edm::EDGetTokenT<reco::GenParticleCollection> srcToken_; 0096 /// input tag for the genEventInfo source 0097 edm::EDGetTokenT<GenEventInfoProduct> genEventInfo_srcToken_; 0098 /// add radiation or not? 0099 bool addRadiation_; 0100 /// print the whole list of input particles or not? 0101 /// mode of decaySubset creation 0102 FillMode fillMode_; 0103 /// parton shower mode (filled in checkShowerModel) 0104 ShowerModel showerModel_; 0105 /// run mode (Run1 || Run2) 0106 RunMode runMode_; 0107 0108 /// index in new evt listing of parts with daughters; 0109 /// has to be set to -1 in produce to deliver consistent 0110 /// results! 0111 int motherPartIdx_; 0112 /// management of daughter indices for fillRefs 0113 std::map<int,std::vector<int> > refs_; 0114 };