Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:35:04

0001 #ifndef __InputGenJetsParticleSelector__
0002 #define __InputGenJetsParticleSelector__
0003 
0004 /* \class InputGenJetsParticleSelector
0005  * 
0006  * Selects particles for the GenJet input.
0007  * Deselect specified particles, also radiation from resoances.
0008  * Or only select partonic final state.
0009  * The algorithm is based on code of Christophe Saout. 
0010  *
0011  * \author: Andreas Oehler
0012  * 
0013  * 
0014  */
0015 
0016 #include "DataFormats/Provenance/interface/Provenance.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0019 #include "DataFormats/Candidate/interface/Candidate.h"
0020 
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 
0023 #include "FWCore/Framework/interface/global/EDProducer.h"
0024 #include "DataFormats/Common/interface/EDProductfwd.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 
0027 class InputGenJetsParticleSelector : public edm::global::EDProducer<> {
0028   // collection type
0029 public:
0030   typedef std::vector<bool> ParticleBitmap;
0031   typedef std::vector<const reco::Candidate *> ParticleVector;
0032 
0033   InputGenJetsParticleSelector(const edm::ParameterSet &);
0034   ~InputGenJetsParticleSelector() override;
0035   // select object from a collection and
0036   // possibly event content
0037   void produce(edm::StreamID, edm::Event &evt, const edm::EventSetup &evtSetup) const override;
0038 
0039   bool getPartonicFinalState() const { return partonicFinalState; }
0040   bool getExcludeResonances() const { return excludeResonances; }
0041   bool getTausAndJets() const { return tausAsJets; }
0042   double getPtMin() const { return ptMin; }
0043   const std::vector<unsigned int> &getIgnoredParticles() const { return ignoreParticleIDs; }
0044 
0045   void setPartonicFinalState(bool flag = true) { partonicFinalState = flag; }
0046   void setExcludeResonances(bool flag = true) { excludeResonances = flag; }
0047   void setTausAsJets(bool flag = true) { tausAsJets = flag; }
0048   void setPtMin(double ptMin) { this->ptMin = ptMin; }
0049   bool isParton(int pdgId) const;
0050   static bool isHadron(int pdgId);
0051   static bool isResonance(int pdgId);
0052 
0053   bool isIgnored(int pdgId) const;
0054   bool hasPartonChildren(ParticleBitmap &invalid, const ParticleVector &p, const reco::Candidate *particle) const;
0055 
0056   enum ResonanceState { kNo = 0, kDirect, kIndirect };
0057   ResonanceState fromResonance(ParticleBitmap &invalid, const ParticleVector &p, const reco::Candidate *particle) const;
0058 
0059   // iterators over selected objects: collection begin
0060 
0061 private:
0062   //container selected_;  //container required by selector
0063   InputGenJetsParticleSelector() {}  //should not be used!
0064 
0065   edm::InputTag inTag;
0066   edm::InputTag prunedInTag;
0067   int testPartonChildren(ParticleBitmap &invalid, const ParticleVector &p, const reco::Candidate *particle) const;
0068 
0069   std::vector<unsigned int> ignoreParticleIDs;
0070   std::vector<unsigned int> excludeFromResonancePids;
0071   void setExcludeFromResonancePids(const std::vector<unsigned int> &particleIDs);
0072   void setIgnoredParticles(const std::vector<unsigned int> &particleIDs);
0073   bool isExcludedFromResonance(int pdgId) const;
0074 
0075   bool partonicFinalState;
0076   bool excludeResonances;
0077   bool tausAsJets;
0078   bool isMiniAOD;
0079   double ptMin;
0080 
0081   edm::EDGetTokenT<reco::CandidateView> input_genpartcoll_token_;
0082   edm::EDGetTokenT<reco::CandidateView> input_prunedgenpartcoll_token_;
0083 };
0084 
0085 #endif