CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~HLTTauMCProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
std::vector< int > m_PDG_
 
edm::EDGetTokenT
< reco::GenParticleCollection
MC_
 
edm::EDGetTokenT
< reco::GenMETCollection
MCMET_
 
double ptMinMCElectron_
 
double ptMinMCMuon_
 
double ptMinMCTau_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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 HLT_25ns14e33_v1_cff::etaMax, and edm::ParameterSet::getUntrackedParameter().

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  etaMax = mc.getUntrackedParameter<double>("EtaMax",2.5);
19 
20  produces<LorentzVectorCollection>("LeptonicTauLeptons");
21  produces<LorentzVectorCollection>("LeptonicTauElectrons");
22  produces<LorentzVectorCollection>("LeptonicTauMuons");
23  produces<LorentzVectorCollection>("HadronicTauOneProng");
24  produces<LorentzVectorCollection>("HadronicTauThreeProng");
25  produces<LorentzVectorCollection>("HadronicTauOneAndThreeProng");
26  produces<LorentzVectorCollection>("TauOther");
27  produces<LorentzVectorCollection>("Neutrina");
28  produces<LorentzVectorCollection>("MET");
29  produces<std::vector<int> >("Mothers");
30 
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 ( )

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 272 of file HLTTauMCProducer.cc.

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

273  {
274 
275  const GenParticleRefVector& daughterRefs = mother->daughterRefVector();
276 
277  for(GenParticleRefVector::const_iterator d = daughterRefs.begin(); d != daughterRefs.end(); ++d) {
278 
279  if( (status==0 || (*d)->status() == status) &&
280  (pdgId==0 || std::abs((*d)->pdgId()) == pdgId) ) {
281 
282  products.push_back(*d);
283  }
284  else
285  getGenDecayProducts(*d, products, status, pdgId);
286  }
287 
288 }
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
tuple d
Definition: ztail.py:151
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&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
tuple status
Definition: ntuplemaker.py:245
void HLTTauMCProducer::produce ( edm::Event iEvent,
const edm::EventSetup iES 
)
virtual

Implements edm::EDProducer.

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(), HLT_25ns14e33_v1_cff::etaMax, HepMCValidationHelper::genMet(), genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), cmsHarvester::index, reco::GenParticle::isPromptDecayed(), edm::HandleBase::isValid(), WDecay::kMuon, HLT_25ns14e33_v3_cff::MET, patZpeak::numMuons, AlCaHLTBitMon_ParallelJobs::p, reco::LeafCandidate::pdgId(), pi, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), edm::RefVector< C, T, F >::size(), and tree::t.

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

Member Data Documentation

double HLTTauMCProducer::etaMax
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::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.