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 ()
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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)
 
- 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 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.

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

36 {}

Member Function Documentation

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

Definition at line 275 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.

276  {
277 
278  const GenParticleRefVector& daughterRefs = mother->daughterRefVector();
279 
280  for(GenParticleRefVector::const_iterator d = daughterRefs.begin(); d != daughterRefs.end(); ++d) {
281 
282  if( (status==0 || (*d)->status() == status) &&
283  (pdgId==0 || std::abs((*d)->pdgId()) == pdgId) ) {
284 
285  products.push_back(*d);
286  }
287  else
288  getGenDecayProducts(*d, products, status, pdgId);
289  }
290 
291 }
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 38 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(), diffTreeTool::index, 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.

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

Member Data Documentation

double HLTTauMCProducer::etaMax
private

Definition at line 57 of file HLTTauMCProducer.h.

double HLTTauMCProducer::etaMin
private

Definition at line 57 of file HLTTauMCProducer.h.

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

Definition at line 56 of file HLTTauMCProducer.h.

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

Definition at line 51 of file HLTTauMCProducer.h.

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

Definition at line 52 of file HLTTauMCProducer.h.

double HLTTauMCProducer::phiMax
private

Definition at line 57 of file HLTTauMCProducer.h.

double HLTTauMCProducer::phiMin
private

Definition at line 57 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCElectron_
private

Definition at line 54 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCMuon_
private

Definition at line 55 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCTau_
private

Definition at line 53 of file HLTTauMCProducer.h.