CMS 3D CMS Logo

GenVisTauProducer.cc
Go to the documentation of this file.
15 
16 #include <vector>
17 #include <iostream>
18 
20 public:
22  : src_(consumes<reco::GenJetCollection>(params.getParameter<edm::InputTag>("src"))),
23  srcGenParticles_(consumes<reco::GenParticleCollection>(params.getParameter<edm::InputTag>("srcGenParticles"))),
24  pTComparator_() {
25  produces<reco::GenParticleCollection>();
26  }
27 
28  ~GenVisTauProducer() override {}
29 
30  void produce(edm::StreamID id, edm::Event& evt, const edm::EventSetup& es) const override {
32  evt.getByToken(src_, genTauJets);
33 
36  size_t numGenParticles = genParticles->size();
37 
38  auto genVisTaus = std::make_unique<reco::GenParticleCollection>();
39 
40  for (const auto& genTauJet : *genTauJets) {
41  std::string decayMode_string = JetMCTagUtils::genTauDecayMode(genTauJet);
42  // CV: store hadronic tau decays only
43  if (decayMode_string == "electron" || decayMode_string == "muon")
44  continue;
46  if (decayMode_string == "oneProng0Pi0")
48  else if (decayMode_string == "oneProng1Pi0")
50  else if (decayMode_string == "oneProng2Pi0")
52  else if (decayMode_string == "threeProng0Pi0")
54  else if (decayMode_string == "threeProng1Pi0")
56  else
58 
59  int pdgId = (genTauJet.charge() > 0) ? -15 : +15;
60 
61  // CV: store decayMode in status flag of GenParticle object
62  reco::GenParticle genVisTau(genTauJet.charge(), genTauJet.p4(), genTauJet.vertex(), pdgId, decayMode, true);
63 
64  // CV: find tau lepton "mother" particle
65  for (size_t idxGenParticle = 0; idxGenParticle < numGenParticles; ++idxGenParticle) {
66  const reco::GenParticle& genTau = (*genParticles)[idxGenParticle];
67  if (abs(genTau.pdgId()) == 15 && genTau.status() == 2) {
68  reco::Candidate::LorentzVector daughterVisP4;
69  for (const reco::GenParticleRef& daughter : genTau.daughterRefVector()) {
70  int abs_pdgId = abs(daughter->pdgId());
71  // CV: skip neutrinos
72  if (abs_pdgId == 12 || abs_pdgId == 14 || abs_pdgId == 16)
73  continue;
74  daughterVisP4 += daughter->p4();
75  }
76  double dR2 = deltaR2(daughterVisP4, genVisTau);
77  if (dR2 < 1.e-4) {
78  genVisTau.addMother(reco::GenParticleRef(genParticles, idxGenParticle));
79  break;
80  }
81  }
82  }
83 
84  genVisTaus->push_back(genVisTau);
85  }
86 
87  std::sort(genVisTaus->begin(), genVisTaus->end(), pTComparator_);
88  evt.put(std::move(genVisTaus));
89  }
90 
91  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
93  desc.add<edm::InputTag>("src")->setComment("collection of visible gen taus (as reco::GenJetCollection)");
94  desc.add<edm::InputTag>("srcGenParticles")->setComment("collections of gen particles");
95  descriptions.add("genVisTaus", desc);
96  }
97 
98 private:
102 };
103 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
GenJetCollection.h
reco::PFTau::kNull
Definition: PFTau.h:39
reco::PFTau::kOneProng1PiZero
Definition: PFTau.h:41
GreaterByPt< reco::GenParticle >
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
reco::LeafCandidate::status
int status() const final
status word
Definition: LeafCandidate.h:180
reco::GenJetCollection
std::vector< GenJet > GenJetCollection
collection of GenJet objects
Definition: GenJetCollection.h:14
reco::GenParticle
Definition: GenParticle.h:21
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::EDGetTokenT< reco::GenJetCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
reco::PFTau::kOneProng2PiZero
Definition: PFTau.h:42
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PtComparator.h
reco::PFTau::kOneProng0PiZero
Definition: PFTau.h:40
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::PFTau::kRareDecayMode
Definition: PFTau.h:55
edm::Handle< reco::GenJetCollection >
edm::Ref< GenParticleCollection >
GenParticle.h
MakerMacros.h
GenVisTauProducer::produce
void produce(edm::StreamID id, edm::Event &evt, const edm::EventSetup &es) const override
Definition: GenVisTauProducer.cc:30
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GenParticleFwd.h
GenVisTauProducer::GenVisTauProducer
GenVisTauProducer(const edm::ParameterSet &params)
Definition: GenVisTauProducer.cc:21
GenVisTauProducer::srcGenParticles_
const edm::EDGetTokenT< reco::GenParticleCollection > srcGenParticles_
Definition: GenVisTauProducer.cc:100
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
ParameterSetDescription.h
GenVisTauProducer
Definition: GenVisTauProducer.cc:19
taus_cff.decayMode
decayMode
Definition: taus_cff.py:58
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
reco::LeafCandidate::pdgId
int pdgId() const final
PDG identifier.
Definition: LeafCandidate.h:176
reco::PFTau::kThreeProng1PiZero
Definition: PFTau.h:51
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
edm::EventSetup
Definition: EventSetup.h:57
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
reco::PFTau::kThreeProng0PiZero
Definition: PFTau.h:50
GenVisTauProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GenVisTauProducer.cc:91
reco::CompositeRefCandidateT::daughterRefVector
const daughters & daughterRefVector() const
references to daughtes
Definition: CompositeRefCandidateT.h:71
PFTau.h
GenVisTauProducer::src_
const edm::EDGetTokenT< reco::GenJetCollection > src_
Definition: GenVisTauProducer.cc:99
GenJet.h
GenVisTauProducer::pTComparator_
const GreaterByPt< reco::GenParticle > pTComparator_
Definition: GenVisTauProducer.cc:101
taus_cff.genVisTaus
genVisTaus
Definition: taus_cff.py:181
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
View.h
ParameterSet.h
JetMCTag.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
EDProducer.h
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
GenVisTauProducer::~GenVisTauProducer
~GenVisTauProducer() override
Definition: GenVisTauProducer.cc:28
JetMCTagUtils::genTauDecayMode
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:70
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37