CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeneratorTau.cc
Go to the documentation of this file.
2 
4  LorentzVector suckVector = getVisibleFourVector();
5  LorentzVector suckNuVector = this->p4() - suckVector;
6  return angleFinder(suckVector, suckNuVector);
7 }
8 
10  return static_cast<const Candidate*>(theLeadTrack_);
11 }
12 
14  std::vector<const reco::GenParticle*>::const_iterator thePion =
15  genChargedPions_.begin();
16  double maxPt = 0;
17  const reco::GenParticle* output = NULL;
18  for (; thePion != genChargedPions_.end(); ++thePion) {
19  if ((*thePion)->pt() > maxPt) {
20  maxPt = (*thePion)->pt();
21  output = (*thePion);
22  }
23  }
25  return output;
26 }
27 
29  const std::vector<const reco::GenParticle*>& theCollection) const {
30  double output = 0;
31  std::vector<const reco::GenParticle*>::const_iterator theObject =
32  theCollection.begin();
33  for (; theObject != theCollection.end(); ++theObject) {
34  if (output < angleFinder(theLeadTrack_->p4(), (*theObject)->p4()))
35  output = angleFinder(theLeadTrack_->p4(), (*theObject)->p4());
36  }
37  return output;
38 }
39 
42 }
43 
46 }
47 
49  const reco::GenParticle* theTau) {
50  //return kUndefined if not a tau
51  if (theTau == NULL || std::abs(theTau->pdgId()) != 15
52  || theTau->status() != 2)
53  return kUndefined;
54 
56 
57  //counters to determine decay type (adapted from Ricardo's code)
58  int numElectrons = 0;
59  int numMuons = 0;
60  int numChargedPions = 0;
61  int numNeutralPions = 0;
62  int numNeutrinos = 0;
63  int numOtherParticles = 0;
64 
66  std::vector<const reco::GenParticle* > pdgDecayProductTypes;
67 
68  GeneratorTau::decayToPDGClassification(theTau, pdgDecayProductTypes);
69 
70  for (std::vector<const reco::GenParticle* >::const_iterator decayProduct =
71  pdgDecayProductTypes.begin();
72  decayProduct != pdgDecayProductTypes.end(); ++decayProduct) {
73  int pdg_id = std::abs( (*decayProduct)->pdgId() );
74  //edm::LogInfo("GeneratorTau") << "Has decay product w/ PDG ID: " << pdg_id;
75  if (pdg_id == 11) numElectrons++;
76  else if (pdg_id == 13) numMuons++;
77  else if (pdg_id == 211) numChargedPions++;
78  else if (pdg_id == 111) numNeutralPions++;
79  else if (pdg_id == 12 ||
80  pdg_id == 14 ||
81  pdg_id == 16) numNeutrinos++;
82  else if (pdg_id != 22)
83  numOtherParticles++;
84  }
85  output = kOther;
86 
87  //determine tauDecayMode
88  if ( numOtherParticles == 0 ){
89  if ( numElectrons == 1 ){
90  //--- tau decays into electrons
91  output = kElectron;
92  } else if ( numMuons == 1 ){
93  //--- tau decays into muons
94  output = kMuon;
95  } else {
96  //--- hadronic tau decays
97  switch ( numChargedPions ){
98  case 1 :
99  switch ( numNeutralPions ){
100  case 0 :
101  output = kOneProng0pi0;
102  break;
103  case 1 :
104  output = kOneProng1pi0;
105  break;
106  case 2 :
107  output = kOneProng2pi0;
108  break;
109  }
110  break;
111  case 3 :
112  switch ( numNeutralPions ){
113  case 0 :
114  output = kThreeProng0pi0;
115  break;
116  case 1 :
117  output = kThreeProng1pi0;
118  break;
119  }
120  break;
121  }
122  }
123  }
124  return output;
125 }
126 
128  void
129 GeneratorTau::decayToPDGClassification(const reco::GenParticle* theParticle, std::vector<const reco::GenParticle* >& container)
130 {
132  if (theParticle)
133  {
134  //edm::LogInfo("Debug") << "It's non-null";
135  int pdgId = std::abs(theParticle->pdgId());
136  //edm::LogInfo("Debug") << "PDGID = " << pdgId << " Status = " << theStatus;
137  if (theParticle->status() == 1 || pdgId == 211 || pdgId == 111 || pdgId == 11 || pdgId == 13)
138  {
139  //edm::LogInfo("Debug") << "Adding to container...";
140  container.push_back(theParticle);
141  //add neutral pions and this step....
142  if (pdgId == 111)
143  genNeutralPions_.push_back(theParticle);
144  }
145  else
146  {
147  unsigned int nDaughters = theParticle->numberOfDaughters();
148  for (size_t dIter = 0; dIter < nDaughters; ++dIter)
149  {
150  const Candidate * daughter = theParticle->daughter(dIter);
151  //edm::LogInfo("Debug") << "Recursing on daughter with PDG: " << daughter->pdgId();
152  GeneratorTau::decayToPDGClassification(static_cast<const reco::GenParticle*>(daughter), container);
153  }
154 
155  }
156  }
157 }
158 
159 
160  void
161 GeneratorTau::computeStableDecayProducts(const reco::GenParticle* theParticle, std::vector<const reco::GenParticle *>& container)
162 {
163  if (theParticle)
164  {
165  if (theParticle->status() == 1) //status = 1 indicates final state particle
166  {
167  //edm::LogInfo("GeneratorTau") << "computeStableDecayProducts: Found a final state daughter with status: " << theParticle->status() << " Num stable decay products so far: " << container.size();
168  container.push_back(theParticle);
169  }
170  else
171  {
172  unsigned int nDaughters = theParticle->numberOfDaughters();
173  for (size_t dIter = 0; dIter < nDaughters; ++dIter)
174  {
175  const Candidate * daughter = theParticle->daughter(dIter);
176  //edm::LogInfo("Debug") << "Recursing on daughter with PDG: " << daughter->pdgId();
177  GeneratorTau::computeStableDecayProducts(static_cast<const reco::GenParticle*>(daughter), container);
178  }
179  }
180  }
181 }
182 
184 {
185 }
186 
187 
188  void
190 {
191  //make sure this tau really decays
193  aFinalStateTau_ = false;
194 
195  //get Decaymode
196  //edm::LogInfo("GeneratorTau") << "Computing decay mode..";
198 
199  //make sure it is a real tau decay
200  if (theDecayMode_ != kUndefined) {
201  aFinalStateTau_ = true;
202  //edm::LogInfo("GeneratorTau") << "Found decay type: " << theDecayMode_ << ", computing stable decay products.";
203  //get the stable decay products
205  //from the stable products, fill the lists
206  //edm::LogInfo("GeneratorTau") << "Found " << stableDecayProducts_.size() << " stable decay products, filtering.";
207  for (std::vector<const reco::GenParticle*>::const_iterator iter = stableDecayProducts_.begin();
208  iter != stableDecayProducts_.end();
209  ++iter)
210  {
211  //fill vectors
212  int pdg_id = std::abs( (*iter)->pdgId() );
213  if (pdg_id == 16 || pdg_id == 12 || pdg_id == 14)
214  genNus_.push_back( (*iter) );
215  else {
216  visibleDecayProducts_.push_back( (*iter) );
217  if (pdg_id == 211 || (*iter)->charge() != 0)
218  genChargedPions_.push_back( (*iter) );
219  else if (pdg_id == 22)
220  genGammas_.push_back( (*iter) );
221  }
222  }
223  // find the lead charged object
225  }
226 }
227 
228 
229 
230 std::vector<LorentzVector>
232  const std::vector<const reco::GenParticle*>& theList) const {
233  std::vector<LorentzVector> output;
234  std::vector<const reco::GenParticle*>::const_iterator theParticle;
235  for (theParticle = theList.begin();
236  theParticle != theList.end(); ++theParticle) {
237  output.push_back( (*theParticle)->p4() );
238  }
239  return output;
240 }
241 
242 std::vector<const reco::Candidate*>
244  std::vector<const reco::Candidate*> output;
245  std::vector<const GenParticle*>::const_iterator iter;
246  for (iter = genChargedPions_.begin(); iter != genChargedPions_.end(); ++iter)
247  output.push_back(static_cast<const reco::Candidate*>(*iter));
248  return output;
249 }
250 
251 std::vector<const reco::Candidate*>
253  std::vector<const reco::Candidate*> output;
254  std::vector<const GenParticle*>::const_iterator iter;
255  for (iter = genNeutralPions_.begin(); iter != genNeutralPions_.end(); ++iter)
256  output.push_back(static_cast<const reco::Candidate*>(*iter));
257  return output;
258 }
259 
260 std::vector<const reco::Candidate*>
262  std::vector<const reco::Candidate*> output;
263  std::vector<const GenParticle*>::const_iterator iter;
264  for (iter = genGammas_.begin(); iter != genGammas_.end(); ++iter)
265  output.push_back(static_cast<const reco::Candidate*>(*iter));
266  return output;
267 }
268 
269 std::vector<const reco::Candidate*>
271  std::vector<const reco::Candidate*> output;
272  std::vector<const GenParticle*>::const_iterator iter;
273  for (iter = stableDecayProducts_.begin();
274  iter != stableDecayProducts_.end(); ++iter)
275  output.push_back(static_cast<const reco::Candidate*>(*iter));
276  return output;
277 }
278 
279 std::vector<const reco::Candidate*> GeneratorTau::getGenNu() const {
280  std::vector<const reco::Candidate*> output;
281  std::vector<const GenParticle*>::const_iterator iter;
282  for (iter = genNus_.begin(); iter != genNus_.end(); ++iter)
283  output.push_back(static_cast<const reco::Candidate*>(*iter));
284  return output;
285 }
286 
287 std::vector<LorentzVector> GeneratorTau::getChargedPions() const {
289 }
290 
291 std::vector<LorentzVector> GeneratorTau::getGammas() const {
293 }
294 
295 std::vector<LorentzVector> GeneratorTau::getVisibleFourVectors() const {
297 }
298 
301  std::vector<LorentzVector> tempForSum = getVisibleFourVectors();
302  for (std::vector<LorentzVector>::iterator iter = tempForSum.begin();
303  iter != tempForSum.end(); ++iter)
304  output += (*iter);
305  return output;
306 }
307 
tauDecayModeEnum theDecayMode_
Definition: GeneratorTau.h:88
std::vector< const reco::Candidate * > getGenGammas() const
std::vector< const reco::GenParticle * > genNus_
Definition: GeneratorTau.h:85
float getChargedOpeningAngle() const
Definition: GeneratorTau.cc:40
std::vector< const reco::GenParticle * > genNeutralPions_
Definition: GeneratorTau.h:82
std::vector< LorentzVector > convertMCVectorToLorentzVectors(const std::vector< const reco::GenParticle * > &theList) const
int aFinalStateTau_
Definition: GeneratorTau.h:89
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual int pdgId() const GCC11_FINAL
PDG identifier.
const reco::GenParticle * theLeadTrack_
Definition: GeneratorTau.h:86
tauDecayModeEnum computeDecayMode(const reco::GenParticle *)
Definition: GeneratorTau.cc:48
#define NULL
Definition: scimark2.h:8
std::vector< LorentzVector > getChargedPions() const
std::vector< LorentzVector > getVisibleFourVectors() const
LorentzVector getVisibleFourVector() const
tuple numMuons
Definition: patZpeak.py:40
float getGammaOpeningAngle() const
Definition: GeneratorTau.cc:44
virtual int status() const GCC11_FINAL
status word
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< const reco::GenParticle * > genGammas_
Definition: GeneratorTau.h:83
Angle< LorentzVector > angleFinder
Definition: GeneratorTau.h:75
float getVisNuAngle() const
Definition: GeneratorTau.cc:3
std::vector< const reco::Candidate * > getStableDecayProducts() const
std::vector< LorentzVector > getGammas() const
std::vector< const reco::Candidate * > getGenNeutralPions() const
Candidate()
default constructor
Definition: Candidate.h:58
void decayToPDGClassification(const reco::GenParticle *, std::vector< const reco::GenParticle * > &)
Return list of stable &amp; &quot;semi-stable&quot; tau decay products (e.g. decay the rhos)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
const reco::Candidate * getLeadTrack() const
Definition: GeneratorTau.cc:9
void computeStableDecayProducts(const reco::GenParticle *, std::vector< const reco::GenParticle * > &)
std::vector< const reco::GenParticle * > stableDecayProducts_
Definition: GeneratorTau.h:84
std::vector< const reco::Candidate * > getGenChargedPions() const
const reco::GenParticle * findLeadTrack()
Definition: GeneratorTau.cc:13
std::vector< const reco::Candidate * > getGenNu() const
std::vector< const reco::GenParticle * > genChargedPions_
Definition: GeneratorTau.h:81
std::vector< const reco::GenParticle * > visibleDecayProducts_
Definition: GeneratorTau.h:80
float getOpeningAngle(const std::vector< const reco::GenParticle * > &aCollection) const
Definition: GeneratorTau.cc:28