CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HLTTauMCProducer Class Reference

#include <HLTTauMCProducer.h>

Inheritance diagram for HLTTauMCProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HLTTauMCProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HLTTauMCProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  tauDecayModes {
  kElectron, kMuon, kOneProng0pi0, kOneProng1pi0,
  kOneProng2pi0, kThreeProng0pi0, kThreeProng1pi0, kOther,
  kUndefined
}
 

Private Member Functions

void getGenDecayProducts (const reco::GenParticleRef &, reco::GenParticleRefVector &, int status=1, int pdgId=0)
 

Private Attributes

double etaMax
 
double etaMin
 
std::vector< int > m_PDG_
 
edm::EDGetTokenT< reco::GenParticleCollectionMC_
 
edm::EDGetTokenT< reco::GenMETCollectionMCMET_
 
double phiMax
 
double phiMin
 
double ptMinMCElectron_
 
double ptMinMCMuon_
 
double ptMinMCTau_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 33 of file HLTTauMCProducer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

HLTTauMCProducer::HLTTauMCProducer ( const edm::ParameterSet mc)
explicit

Definition at line 7 of file HLTTauMCProducer.cc.

References ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, edm::ParameterSet::getUntrackedParameter(), AlignmentTrackSelector_cfi::phiMax, and AlignmentTrackSelector_cfi::phiMin.

7  {
8  // One Parameter Set per Collection
9 
10  MC_ = consumes<GenParticleCollection>(mc.getUntrackedParameter<edm::InputTag>("GenParticles"));
11  MCMET_ = consumes<GenMETCollection>(mc.getUntrackedParameter<edm::InputTag>("GenMET"));
12  ptMinMCTau_ = mc.getUntrackedParameter<double>("ptMinTau", 5.);
13  ptMinMCMuon_ = mc.getUntrackedParameter<double>("ptMinMuon", 2.);
14  ptMinMCElectron_ = mc.getUntrackedParameter<double>("ptMinElectron", 5.);
15  m_PDG_ = mc.getUntrackedParameter<std::vector<int>>("BosonID");
16  etaMin = mc.getUntrackedParameter<double>("EtaMin", -2.5);
17  etaMax = mc.getUntrackedParameter<double>("EtaMax", 2.5);
18  phiMin = mc.getUntrackedParameter<double>("PhiMin", -3.15);
19  phiMax = mc.getUntrackedParameter<double>("PhiMax", 3.15);
20 
21  produces<LorentzVectorCollection>("LeptonicTauLeptons");
22  produces<LorentzVectorCollection>("LeptonicTauElectrons");
23  produces<LorentzVectorCollection>("LeptonicTauMuons");
24  produces<LorentzVectorCollection>("HadronicTauOneProng");
25  produces<LorentzVectorCollection>("HadronicTauThreeProng");
26  produces<LorentzVectorCollection>("HadronicTauOneAndThreeProng");
27  produces<LorentzVectorCollection>("TauOther");
28  produces<LorentzVectorCollection>("Neutrina");
29  produces<LorentzVectorCollection>("MET");
30  produces<std::vector<int>>("Mothers");
31 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::GenMETCollection > MCMET_
std::vector< int > m_PDG_
edm::EDGetTokenT< reco::GenParticleCollection > MC_
HLTTauMCProducer::~HLTTauMCProducer ( )
override

Definition at line 33 of file HLTTauMCProducer.cc.

33 {}

Member Function Documentation

void HLTTauMCProducer::getGenDecayProducts ( const reco::GenParticleRef mother,
reco::GenParticleRefVector products,
int  status = 1,
int  pdgId = 0 
)
private

Definition at line 265 of file HLTTauMCProducer.cc.

References funct::abs(), edm::RefVector< C, T, F >::begin(), edmIntegrityCheck::d, edm::RefVector< C, T, F >::end(), edm::RefVector< C, T, F >::push_back(), and mps_update::status.

268  {
269  const GenParticleRefVector &daughterRefs = mother->daughterRefVector();
270 
271  for (GenParticleRefVector::const_iterator d = daughterRefs.begin(); d != daughterRefs.end(); ++d) {
272  if ((status == 0 || (*d)->status() == status) && (pdgId == 0 || std::abs((*d)->pdgId()) == pdgId)) {
273  products.push_back(*d);
274  } else
275  getGenDecayProducts(*d, products, status, pdgId);
276  }
277 }
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
void getGenDecayProducts(const reco::GenParticleRef &, reco::GenParticleRefVector &, int status=1, int pdgId=0)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
void HLTTauMCProducer::produce ( edm::Event iEvent,
const edm::EventSetup iES 
)
override

Definition at line 35 of file HLTTauMCProducer.cc.

References funct::abs(), edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, HepMCValidationHelper::genMet(), GenHFHadronMatcher_cfi::genParticles, edm::Event::getByToken(), reco::GenParticle::isPromptDecayed(), edm::HandleBase::isValid(), WDecay::kMuon, nanoDQM_cfi::MET, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, HiggsValidation_cfi::pdg_id, reco::LeafCandidate::pdgId(), AlignmentTrackSelector_cfi::phiMax, AlignmentTrackSelector_cfi::phiMin, pi, edm::Event::put(), and lumiQTWidget::t.

35  {
36  // All the code from HLTTauMCInfo is here :-)
37 
38  unique_ptr<LorentzVectorCollection> product_Electrons(new LorentzVectorCollection);
39  unique_ptr<LorentzVectorCollection> product_Muons(new LorentzVectorCollection);
40  unique_ptr<LorentzVectorCollection> product_Leptons(new LorentzVectorCollection);
41  unique_ptr<LorentzVectorCollection> product_OneProng(new LorentzVectorCollection);
42  unique_ptr<LorentzVectorCollection> product_ThreeProng(new LorentzVectorCollection);
43  unique_ptr<LorentzVectorCollection> product_OneAndThreeProng(new LorentzVectorCollection);
44  unique_ptr<LorentzVectorCollection> product_Other(new LorentzVectorCollection);
45  unique_ptr<LorentzVectorCollection> product_Neutrina(new LorentzVectorCollection);
46  unique_ptr<LorentzVectorCollection> product_MET(new LorentzVectorCollection);
47  unique_ptr<std::vector<int>> product_Mothers(new std::vector<int>);
48 
50  iEvent.getByToken(MC_, genParticles);
51 
52  if (!genParticles.isValid())
53  return;
54 
55  // Look for MET
57  iEvent.getByToken(MCMET_, genMet);
58  LorentzVector MET(0., 0., 0., 0.);
59  if (genMet.isValid()) {
60  MET = LorentzVector(genMet->front().px(), genMet->front().py(), 0, genMet->front().pt());
61  }
62  product_MET->push_back(MET);
63 
64  // Look for primary bosons
65  // It is not guaranteed that primary bosons are stored in event history.
66  // Is it really needed when check if taus from the boson is removed?
67  // Kept for backward compatibility
68  for (GenParticleCollection::const_iterator p = genParticles->begin(); p != genParticles->end(); ++p) {
69  // Check the PDG ID
70  bool pdg_ok = false;
71  for (size_t pi = 0; pi < m_PDG_.size(); ++pi) {
72  if (abs((*p).pdgId()) == m_PDG_[pi] && ((*p).isHardProcess() || (*p).status() == 3)) {
73  pdg_ok = true;
74  // cout<<" Bsoson particles: "<< (*p).pdgId()<< " " <<(*p).status() << "
75  // "<< pdg_ok<<endl;
76  break;
77  }
78  }
79 
80  // Check if the boson is one of interest and if there is a valid vertex
81  if (pdg_ok) {
82  product_Mothers->push_back((*p).pdgId());
83 
84  TLorentzVector Boson((*p).px(), (*p).py(), (*p).pz(), (*p).energy());
85  }
86  } // End of search for the bosons
87 
88  // Look for taus
89  GenParticleRefVector allTaus;
90  unsigned index = 0;
91  for (GenParticleCollection::const_iterator p = genParticles->begin(); p != genParticles->end(); ++p, ++index) {
92  const GenParticle &genP = *p;
93  // accept only isPromptDecayed() particles
94  if (!genP.isPromptDecayed())
95  continue;
96  // check if it is tau, i.e. if |pdgId|=15
97  if (std::abs(genP.pdgId()) == 15) {
98  GenParticleRef genRef(genParticles, index);
99  // check if it is the last tau in decay/radiation chain
100  GenParticleRefVector daugTaus;
101  getGenDecayProducts(genRef, daugTaus, 0, 15);
102  if (daugTaus.empty())
103  allTaus.push_back(genRef);
104  }
105  }
106 
107  // Find stable tau decay products and build visible taus
108  for (GenParticleRefVector::const_iterator t = allTaus.begin(); t != allTaus.end(); ++t) {
109  // look for all stable (status=1) decay products
110  GenParticleRefVector decayProducts;
111  getGenDecayProducts(*t, decayProducts, 1);
112 
113  // build visible taus and recognize decay mode
114  if (!decayProducts.empty()) {
115  LorentzVector Visible_Taus(0., 0., 0., 0.);
116  LorentzVector TauDecayProduct(0., 0., 0., 0.);
117  LorentzVector Neutrino(0., 0., 0., 0.);
118 
119  int numElectrons = 0;
120  int numMuons = 0;
121  int numChargedPions = 0;
122  int numNeutralPions = 0;
123  int numPhotons = 0;
124  int numNeutrinos = 0;
125  int numOtherParticles = 0;
126 
127  for (GenParticleRefVector::const_iterator pit = decayProducts.begin(); pit != decayProducts.end(); ++pit) {
128  int pdg_id = abs((*pit)->pdgId());
129  if (pdg_id == 11)
130  numElectrons++;
131  else if (pdg_id == 13)
132  numMuons++;
133  else if (pdg_id == 211 || pdg_id == 321)
134  numChargedPions++; // Count both pi+ and K+
135  else if (pdg_id == 111 || pdg_id == 130 || pdg_id == 310)
136  numNeutralPions++; // Count both pi0 and K0_L/S
137  else if (pdg_id == 12 || pdg_id == 14 || pdg_id == 16) {
138  numNeutrinos++;
139  if (pdg_id == 16) {
140  Neutrino.SetPxPyPzE((*pit)->px(), (*pit)->py(), (*pit)->pz(), (*pit)->energy());
141  }
142  } else if (pdg_id == 22)
143  numPhotons++;
144  else {
145  numOtherParticles++;
146  }
147 
148  if (pdg_id != 12 && pdg_id != 14 && pdg_id != 16) {
149  TauDecayProduct.SetPxPyPzE((*pit)->px(), (*pit)->py(), (*pit)->pz(), (*pit)->energy());
150  Visible_Taus += TauDecayProduct;
151  }
152  // cout<< "This has to be the same: " << (*pit)->pdgId()
153  //<< " "<< (*pit)->status()<< " mother: "<< (*pit)->mother()->pdgId() <<
154  // endl;
155  }
156 
157  int tauDecayMode = kOther;
158 
159  if (numOtherParticles == 0) {
160  if (numElectrons == 1) {
161  //--- tau decays into electrons
162  tauDecayMode = kElectron;
163  } else if (numMuons == 1) {
164  //--- tau decays into muons
165  tauDecayMode = kMuon;
166  } else {
167  //--- hadronic tau decays
168  switch (numChargedPions) {
169  case 1:
170  if (numNeutralPions != 0) {
171  tauDecayMode = kOther;
172  break;
173  }
174  switch (numPhotons) {
175  case 0:
176  tauDecayMode = kOneProng0pi0;
177  break;
178  case 2:
179  tauDecayMode = kOneProng1pi0;
180  break;
181  case 4:
182  tauDecayMode = kOneProng2pi0;
183  break;
184  default:
185  tauDecayMode = kOther;
186  break;
187  }
188  break;
189  case 3:
190  if (numNeutralPions != 0) {
191  tauDecayMode = kOther;
192  break;
193  }
194  switch (numPhotons) {
195  case 0:
196  tauDecayMode = kThreeProng0pi0;
197  break;
198  case 2:
199  tauDecayMode = kThreeProng1pi0;
200  break;
201  default:
202  tauDecayMode = kOther;
203  break;
204  }
205  break;
206  }
207  }
208  }
209 
210  // cout<< "So we have a: " << tauDecayMode <<endl;
211  if (tauDecayMode == kElectron) {
212  if ((Visible_Taus.eta() > etaMin && Visible_Taus.eta() < etaMax && Visible_Taus.phi() > phiMin &&
213  Visible_Taus.phi() < phiMax) &&
214  (Visible_Taus.pt() > ptMinMCElectron_)) {
215  product_Electrons->push_back(Visible_Taus);
216  product_Leptons->push_back(Visible_Taus);
217  }
218  } else if (tauDecayMode == kMuon) {
219  if ((Visible_Taus.eta() > etaMin && Visible_Taus.eta() < etaMax && Visible_Taus.phi() > phiMin &&
220  Visible_Taus.phi() < phiMax) &&
221  (Visible_Taus.pt() > ptMinMCMuon_)) {
222  product_Muons->push_back(Visible_Taus);
223  product_Leptons->push_back(Visible_Taus);
224  }
225  } else if (tauDecayMode == kOneProng0pi0 || tauDecayMode == kOneProng1pi0 || tauDecayMode == kOneProng2pi0) {
226  if ((Visible_Taus.eta() > etaMin && Visible_Taus.eta() < etaMax && Visible_Taus.phi() > phiMin &&
227  Visible_Taus.phi() < phiMax) &&
228  (Visible_Taus.pt() > ptMinMCTau_)) {
229  product_OneProng->push_back(Visible_Taus);
230  product_OneAndThreeProng->push_back(Visible_Taus);
231  product_Neutrina->push_back(Neutrino);
232  }
233  } else if (tauDecayMode == kThreeProng0pi0 || tauDecayMode == kThreeProng1pi0) {
234  if ((Visible_Taus.eta() > etaMin && Visible_Taus.eta() < etaMax && Visible_Taus.phi() > phiMin &&
235  Visible_Taus.phi() < phiMax) &&
236  (Visible_Taus.pt() > ptMinMCTau_)) {
237  product_ThreeProng->push_back(Visible_Taus);
238  product_OneAndThreeProng->push_back(Visible_Taus);
239  product_Neutrina->push_back(Neutrino);
240  }
241  } else if (tauDecayMode == kOther) {
242  if ((Visible_Taus.eta() > etaMin && Visible_Taus.eta() < etaMax && Visible_Taus.phi() > phiMin &&
243  Visible_Taus.phi() < phiMax) &&
244  (Visible_Taus.pt() > ptMinMCTau_)) {
245  product_Other->push_back(Visible_Taus);
246  }
247  }
248  }
249  }
250 
251  iEvent.put(std::move(product_Leptons), "LeptonicTauLeptons");
252  iEvent.put(std::move(product_Electrons), "LeptonicTauElectrons");
253  iEvent.put(std::move(product_Muons), "LeptonicTauMuons");
254  iEvent.put(std::move(product_OneProng), "HadronicTauOneProng");
255  iEvent.put(std::move(product_ThreeProng), "HadronicTauThreeProng");
256  iEvent.put(std::move(product_OneAndThreeProng), "HadronicTauOneAndThreeProng");
257  iEvent.put(std::move(product_Other), "TauOther");
258  iEvent.put(std::move(product_Neutrina), "Neutrina");
259  iEvent.put(std::move(product_MET), "MET");
260  iEvent.put(std::move(product_Mothers), "Mothers");
261 }
int pdgId() const final
PDG identifier.
edm::EDGetTokenT< reco::GenMETCollection > MCMET_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< int > m_PDG_
edm::EDGetTokenT< reco::GenParticleCollection > MC_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:104
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
const Double_t pi
void getGenDecayProducts(const reco::GenParticleRef &, reco::GenParticleRefVector &, int status=1, int pdgId=0)
Definition: MET.h:42
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZTLorentzVector LorentzVector
bool isValid() const
Definition: HandleBase.h:74
std::vector< LorentzVector > LorentzVectorCollection
bool isPromptDecayed() const
Definition: GenParticle.h:58
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
def move(src, dest)
Definition: eostools.py:511
math::PtEtaPhiELorentzVectorF LorentzVector

Member Data Documentation

double HLTTauMCProducer::etaMax
private

Definition at line 61 of file HLTTauMCProducer.h.

double HLTTauMCProducer::etaMin
private

Definition at line 61 of file HLTTauMCProducer.h.

std::vector<int> HLTTauMCProducer::m_PDG_
private

Definition at line 60 of file HLTTauMCProducer.h.

edm::EDGetTokenT<reco::GenParticleCollection> HLTTauMCProducer::MC_
private

Definition at line 55 of file HLTTauMCProducer.h.

edm::EDGetTokenT<reco::GenMETCollection> HLTTauMCProducer::MCMET_
private

Definition at line 56 of file HLTTauMCProducer.h.

double HLTTauMCProducer::phiMax
private

Definition at line 61 of file HLTTauMCProducer.h.

double HLTTauMCProducer::phiMin
private

Definition at line 61 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCElectron_
private

Definition at line 58 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCMuon_
private

Definition at line 59 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCTau_
private

Definition at line 57 of file HLTTauMCProducer.h.