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

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

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

254  {
255 
256  const GenParticleRefVector& daughterRefs = mother->daughterRefVector();
257 
258  for(GenParticleRefVector::const_iterator d = daughterRefs.begin(); d != daughterRefs.end(); ++d) {
259 
260  if( (status==0 || (*d)->status() == status) &&
261  (pdgId==0 || std::abs((*d)->pdgId()) == pdgId) ) {
262 
263  products.push_back(*d);
264  }
265  else
266  getGenDecayProducts(*d, products, status, pdgId);
267  }
268 
269 }
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
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:64
tuple status
Definition: ntuplemaker.py:245
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::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), HLT_25ns14e33_v1_cff::etaMax, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), cmsHarvester::index, reco::GenParticle::isPromptDecayed(), WDecay::kMuon, 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 edmStreamStallGrapher::t.

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

Member Data Documentation

double HLTTauMCProducer::etaMax
private

Definition at line 53 of file HLTTauMCProducer.h.

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

Definition at line 52 of file HLTTauMCProducer.h.

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

Definition at line 48 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCElectron_
private

Definition at line 50 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCMuon_
private

Definition at line 51 of file HLTTauMCProducer.h.

double HLTTauMCProducer::ptMinMCTau_
private

Definition at line 49 of file HLTTauMCProducer.h.