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
 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
 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
 
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

std::vector< reco::GenParticle * > getGenStableDecayProducts (const reco::GenParticle *particle)
 

Private Attributes

double etaMax
 
std::vector< int > m_PDG_
 
edm::EDGetTokenT
< reco::GenParticleCollection
MC_
 
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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 30 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 edm::ParameterSet::getUntrackedParameter().

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

Definition at line 31 of file HLTTauMCProducer.cc.

31 { }

Member Function Documentation

std::vector< reco::GenParticle * > HLTTauMCProducer::getGenStableDecayProducts ( const reco::GenParticle particle)
private

Definition at line 237 of file HLTTauMCProducer.cc.

References funct::abs().

238 {
239  std::vector<GenParticle*> decayProducts;
240  decayProducts.clear();
241 
242  // std::cout << " Are we ever here?: "<< (*particle).numberOfDaughters() << std::endl;
243  for ( GenParticle::const_iterator daughter_particle = (*particle).begin();daughter_particle != (*particle).end(); ++daughter_particle ){
244 
245  int pdg_id = abs((*daughter_particle).pdgId());
246 
247 // // check if particle is stable
248  if ( pdg_id == 11 || pdg_id == 12 || pdg_id == 13 || pdg_id == 14 || pdg_id == 16 || pdg_id == 111 || pdg_id == 211 ){
249  // stable particle, identified by pdg code
250  decayProducts.push_back((reco::GenParticle*) &(* daughter_particle));
251  }
252  else {
253 // // unstable particle, identified by non-zero decay vertex
254  std::vector<GenParticle*> addDecayProducts = getGenStableDecayProducts((reco::GenParticle*) &(*daughter_particle));
255  for ( std::vector<GenParticle*>::const_iterator adddaughter_particle = addDecayProducts.begin(); adddaughter_particle != addDecayProducts.end(); ++adddaughter_particle ){
256  decayProducts.push_back((*adddaughter_particle));
257  }
258  }
259  }
260  return decayProducts;
261 }
std::vector< reco::GenParticle * > getGenStableDecayProducts(const reco::GenParticle *particle)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void HLTTauMCProducer::produce ( edm::Event iEvent,
const edm::EventSetup iES 
)
virtual

Implements edm::EDProducer.

Definition at line 33 of file HLTTauMCProducer.cc.

References funct::abs(), edm::HandleBase::clear(), genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), WDecay::kMuon, patZpeak::numMuons, AlCaHLTBitMon_ParallelJobs::p, pi, and edm::Event::put().

34 {
35  //All the code from HLTTauMCInfo is here :-)
36 
37  auto_ptr<LorentzVectorCollection> product_Electrons(new LorentzVectorCollection);
38  auto_ptr<LorentzVectorCollection> product_Muons(new LorentzVectorCollection);
39  auto_ptr<LorentzVectorCollection> product_Leptons(new LorentzVectorCollection);
40  auto_ptr<LorentzVectorCollection> product_OneProng(new LorentzVectorCollection);
41  auto_ptr<LorentzVectorCollection> product_ThreeProng(new LorentzVectorCollection);
42  auto_ptr<LorentzVectorCollection> product_OneAndThreeProng(new LorentzVectorCollection);
43  auto_ptr<LorentzVectorCollection> product_Other(new LorentzVectorCollection);
44  auto_ptr<LorentzVectorCollection> product_Neutrina(new LorentzVectorCollection);
45  auto_ptr<std::vector<int> > product_Mothers(new std::vector<int>);
46 
48  iEvent.getByToken(MC_, genParticles);
49 
50  GenParticleCollection::const_iterator p = genParticles->begin();
51 
52  for (;p != genParticles->end(); ++p ) {
53  //Check the PDG ID
54  bool pdg_ok = true;
55  for(size_t pi =0;pi<m_PDG_.size();++pi)
56  {
57  if(abs((*p).pdgId())== m_PDG_[pi] && abs((*p).status()) == 3 ){
58  pdg_ok = true;
59  // cout<<" Bsoson particles: "<< (*p).pdgId()<< " " <<(*p).status() << " "<< pdg_ok<<endl;
60  }
61  }
62 
63  // Check if the boson is one of interest and if there is a valid vertex
64  if( pdg_ok )
65  {
66  product_Mothers->push_back((*p).pdgId());
67 
68  std::vector<GenParticle*> decayProducts;
69 
70  TLorentzVector Boson((*p).px(),(*p).py(),(*p).pz(),(*p).energy());
71 
72  for (GenParticle::const_iterator BosonIt=(*p).begin(); BosonIt != (*p).end(); BosonIt++){
73  // cout<<" Dparticles: "<< (*BosonIt).pdgId() << " "<< (*BosonIt).status()<<endl;
74 
75  if (abs((*BosonIt).pdgId()) == 15 && ((*BosonIt).status()==3)) //if it is a Tau and decayed
76  {
77  decayProducts.clear();
78  // cout<<" Boson daugther particles: "<< (*BosonIt).pdgId() << " "<< (*BosonIt).status()<< endl;
79  for (GenParticle::const_iterator TauIt = (*BosonIt).begin(); TauIt != (*BosonIt).end(); TauIt++) {
80  // cout<<" Tau daughter particles: "<< (*TauIt).pdgId() << " "<< (*TauIt).status()<<endl;
81 
82  if (abs((*TauIt).pdgId()) == 15 && ((*TauIt).status()==2)) //if it is a Tau and decayed
83  {
84  decayProducts = getGenStableDecayProducts((reco::GenParticle*) & (*TauIt));
85  // for (GenParticle::const_iterator TauIt2 = (*TauIt).begin(); TauIt2 != (*TauIt).end(); TauIt2++) {
86  // cout<<" Real Tau particles: "<< (*TauIt2).pdgId() << " "<< (*TauIt2).status()<< " mother: "<< (*TauIt2).mother()->pdgId() << endl;
87  // }
88  }
89  }
90 
91 
92  if ( !decayProducts.empty() )
93  {
94 
95  LorentzVector Visible_Taus(0.,0.,0.,0.);
96  LorentzVector TauDecayProduct(0.,0.,0.,0.);
97  LorentzVector Neutrino(0.,0.,0.,0.);
98 
99  int numElectrons = 0;
100  int numMuons = 0;
101  int numChargedPions = 0;
102  int numNeutralPions = 0;
103  int numNeutrinos = 0;
104  int numOtherParticles = 0;
105 
106 
107  for (std::vector<GenParticle*>::iterator pit = decayProducts.begin(); pit != decayProducts.end(); pit++)
108  {
109  int pdg_id = abs((*pit)->pdgId());
110  if (pdg_id == 11) numElectrons++;
111  else if (pdg_id == 13) numMuons++;
112  else if (pdg_id == 211) numChargedPions++;
113  else if (pdg_id == 111) numNeutralPions++;
114  else if (pdg_id == 12 ||
115  pdg_id == 14 ||
116  pdg_id == 16) {
117  numNeutrinos++;
118  if (pdg_id == 16) {
119  Neutrino.SetPxPyPzE((*pit)->px(),(*pit)->py(),(*pit)->pz(),(*pit)->energy());
120  }
121  }
122  else if (pdg_id != 22) {
123  numOtherParticles++;
124  }
125 
126  if (pdg_id != 12 &&
127  pdg_id != 14 &&
128  pdg_id != 16){
129  TauDecayProduct.SetPxPyPzE((*pit)->px(),(*pit)->py(),(*pit)->pz(),(*pit)->energy());
130  Visible_Taus+=TauDecayProduct;
131  }
132  // cout<< "This has to be the same: " << (*pit)->pdgId() << " "<< (*pit)->status()<< " mother: "<< (*pit)->mother()->pdgId() << endl;
133  }
134 
135  int tauDecayMode = kOther;
136 
137  if ( numOtherParticles == 0 ){
138  if ( numElectrons == 1 ){
139  //--- tau decays into electrons
140  tauDecayMode = kElectron;
141  } else if ( numMuons == 1 ){
142  //--- tau decays into muons
143  tauDecayMode = kMuon;
144  } else {
145  //--- hadronic tau decays
146  switch ( numChargedPions ){
147  case 1 :
148  switch ( numNeutralPions ){
149  case 0 :
150  tauDecayMode = kOneProng0pi0;
151  break;
152  case 1 :
153  tauDecayMode = kOneProng1pi0;
154  break;
155  case 2 :
156  tauDecayMode = kOneProng2pi0;
157  break;
158  }
159  break;
160  case 3 :
161  switch ( numNeutralPions ){
162  case 0 :
163  tauDecayMode = kThreeProng0pi0;
164  break;
165  case 1 :
166  tauDecayMode = kThreeProng1pi0;
167  break;
168  }
169  break;
170  }
171  }
172  }
173 
174 
175  // cout<< "So we have a: " << tauDecayMode <<endl;
176 
177  if(tauDecayMode == kElectron)
178  {
179  if((abs(Visible_Taus.eta())<etaMax)&&(Visible_Taus.pt()>ptMinMCElectron_)){
180  product_Electrons->push_back(Visible_Taus);
181  product_Leptons->push_back(Visible_Taus);
182  }
183  }
184  else if (tauDecayMode == kMuon)
185  {
186 
187  if((abs(Visible_Taus.eta())<etaMax)&&(Visible_Taus.pt()>ptMinMCMuon_)){
188  product_Muons->push_back(Visible_Taus);
189  product_Leptons->push_back(Visible_Taus);
190  }
191  }
192  else if(tauDecayMode == kOneProng0pi0 ||
193  tauDecayMode == kOneProng1pi0 ||
194  tauDecayMode == kOneProng2pi0 )
195  {
196  if ((abs(Visible_Taus.eta()) < etaMax) && (Visible_Taus.pt() > ptMinMCTau_)){
197  product_OneProng->push_back(Visible_Taus);
198  product_OneAndThreeProng->push_back(Visible_Taus);
199  product_Neutrina->push_back(Neutrino);
200  }
201  }
202  else if (tauDecayMode == kThreeProng0pi0 ||
203  tauDecayMode == kThreeProng1pi0 )
204  {
205  if((abs(Visible_Taus.eta())<etaMax)&&(Visible_Taus.pt()>ptMinMCTau_)) {
206  product_ThreeProng->push_back(Visible_Taus);
207  product_OneAndThreeProng->push_back(Visible_Taus);
208  product_Neutrina->push_back(Neutrino);
209  }
210  }
211  else if (tauDecayMode == kOther)
212  {
213  if((abs(Visible_Taus.eta())<etaMax)&&(Visible_Taus.pt()>ptMinMCTau_)) {
214  product_Other->push_back(Visible_Taus);
215  }
216  }
217  }
218  }
219  }
220  //
221  }
222  }
223  iEvent.put(product_Leptons,"LeptonicTauLeptons");
224  iEvent.put(product_Electrons,"LeptonicTauElectrons");
225  iEvent.put(product_Muons,"LeptonicTauMuons");
226  iEvent.put(product_OneProng,"HadronicTauOneProng");
227  iEvent.put(product_ThreeProng,"HadronicTauThreeProng");
228  iEvent.put(product_OneAndThreeProng,"HadronicTauOneAndThreeProng");
229  iEvent.put(product_Other, "TauOther");
230  iEvent.put(product_Neutrina,"Neutrina");
231  iEvent.put(product_Mothers,"Mothers");
232 
233 
234 }
std::vector< reco::GenParticle * > getGenStableDecayProducts(const reco::GenParticle *particle)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< int > m_PDG_
edm::EDGetTokenT< reco::GenParticleCollection > MC_
const Double_t pi
tuple numMuons
Definition: patZpeak.py:40
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< LorentzVector > LorentzVectorCollection
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9

Member Data Documentation

double HLTTauMCProducer::etaMax
private

Definition at line 52 of file HLTTauMCProducer.h.

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

Definition at line 51 of file HLTTauMCProducer.h.

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

Definition at line 47 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCElectron_
private

Definition at line 49 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCMuon_
private

Definition at line 50 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCTau_
private

Definition at line 48 of file HLTTauMCProducer.h.