CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
read_particles_from_HepMC.cc File Reference
#include "GeneratorInterface/ExternalDecays/interface/read_particles_from_HepMC.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

HepMC::GenParticle * findLastSelf (HepMC::GenParticle *x)
 
std::vector< SimpleParticle > * getDaughters (HepMC::GenParticle *x)
 
bool isFirst (HepMC::GenParticle *x)
 
int readParticlesFromHepMC (const HepMC::GenEvent *event, SimpleParticle &X, SimpleParticle &tau, SimpleParticle &tau2, std::vector< SimpleParticle > &tau_daughters, std::vector< SimpleParticle > &tau2_daughters)
 

Function Documentation

HepMC::GenParticle* findLastSelf ( HepMC::GenParticle *  x)
inline

Find last self

Recursively finds the last particle with the same PDG ID on the list of its decay products

Definition at line 48 of file read_particles_from_HepMC.cc.

References findLastSelf(), AlCaHLTBitMon_ParallelJobs::p, and x.

Referenced by findLastSelf(), and readParticlesFromHepMC().

49 {
50  if(!x->end_vertex()) return x;
51 
52  for(HepMC::GenVertex::particle_iterator p = x->end_vertex()->particles_begin(HepMC::children); p!=x->end_vertex()->particles_end(HepMC::children); ++p)
53  {
54  if( (*p)->pdg_id()==x->pdg_id() ) return findLastSelf( *p );
55  }
56 
57  return x;
58 }
HepMC::GenParticle * findLastSelf(HepMC::GenParticle *x)
Definition: DDAxes.h:10
std::vector<SimpleParticle>* getDaughters ( HepMC::GenParticle *  x)
inline

Get daughters of HepMC::GenParticle

Recursively searches for final-state daughters of 'x'

Definition at line 10 of file read_particles_from_HepMC.cc.

References configurableAnalysis::GenParticle, getDaughters(), AlCaHLTBitMon_ParallelJobs::p, and createTree::pp.

Referenced by getDaughters(), CandMatcherBase< C1, C2 >::initMaps(), and readParticlesFromHepMC().

11 {
12  std::vector<SimpleParticle> *daughters = new std::vector<SimpleParticle>();
13  if(!x->end_vertex()) return daughters;
14 
15  // Check decay products of 'x'
16  for(HepMC::GenVertex::particles_out_const_iterator p = x->end_vertex()->particles_out_const_begin(); p!=x->end_vertex()->particles_out_const_end(); ++p)
17  {
19  HepMC::FourVector mm = pp->momentum();
20 
21  // If the daughter of 'x' has its end vertex - recursively read
22  // all of its daughters.
23  if( pp->end_vertex() && pp->pdg_id()!=111)
24  {
25  std::vector<SimpleParticle> *sub_daughters = getDaughters(pp);
26  daughters->insert(daughters->end(),sub_daughters->begin(),sub_daughters->end());
27 
28  delete sub_daughters;
29  }
30  // Otherwise - add this particle to the list of daughters.
31  else if(pp->pdg_id()!=x->pdg_id())
32  {
33  SimpleParticle tp( mm.px(), mm.py(), mm.pz(), mm.e(), pp->pdg_id() );
34  daughters->push_back(tp);
35  }
36  }
37 
38  return daughters;
39 }
tuple pp
Definition: createTree.py:15
std::vector< TauSpinner::SimpleParticle > * getDaughters(HepMC::GenParticle *x)
Definition: DDAxes.h:10
bool isFirst ( HepMC::GenParticle *  x)
inline

Definition at line 60 of file read_particles_from_HepMC.cc.

References AlCaHLTBitMon_ParallelJobs::p, and parents.

60  {
61  for(HepMC::GenVertex::particle_iterator p = x->production_vertex()->particles_begin(HepMC::parents); p!=x->production_vertex()->particles_end(HepMC::parents); ++p){
62  if(x->pdg_id()==(*p)->pdg_id()) return false;
63  }
64  return true;
65 }
TPRegexp parents
Definition: eve_filter.cc:24
Definition: DDAxes.h:10
int readParticlesFromHepMC ( const HepMC::GenEvent *  event,
SimpleParticle &  X,
SimpleParticle &  tau,
SimpleParticle &  tau2,
std::vector< SimpleParticle > &  tau_daughters,
std::vector< SimpleParticle > &  tau2_daughters 
)

Definition at line 89 of file read_particles_from_HepMC.cc.

References funct::abs(), findLastSelf(), configurableAnalysis::GenParticle, getDaughters(), cuy::isFirst, and NULL.

90 {
91  if(event==NULL) return 1;
92 
93  // Exctract particles from event
94  HepMC::GenParticle *hX=NULL, *hTau=NULL, *hTau2=NULL;
95 
96  for(HepMC::GenEvent::particle_const_iterator it = event->particles_begin(); it!=event->particles_end(); ++it)
97  {
98  int pdgid = (*it)->pdg_id();
99  if(
100  (
101  abs(pdgid)==37 ||
102  pdgid ==25 ||
103  abs(pdgid)==24 ||
104  pdgid ==23
105  ) &&
106  (*it)->end_vertex() &&
107  (*it)->end_vertex()->particles_out_size()>=2
108  )
109  {
110  hX = *it;
111  HepMC::GenParticle *LhX=hX;
112  if(!isFirst(hX)) continue;
113  findLastSelf(LhX);
114  hTau = hTau2 = NULL;
115 
116  for(HepMC::GenVertex::particle_iterator it2 = LhX->end_vertex()->particles_begin(HepMC::children); it2!=LhX->end_vertex()->particles_end(HepMC::children); ++it2)
117  {
118  if (abs( (*it2)->pdg_id() )==15 && (*it2)->end_vertex() ){
119  if(!hTau) hTau = *it2;
120  else if(!hTau2) hTau2 = *it2;
121  else
122  {
123  edm::LogInfo("TauSpinnerCMSSW::read_particles_from_HepMC") << "TauSpiner: three taus in one decay" << std::endl;
124  //std::cout<<"TauSpiner: three taus in one decay"<<std::endl;
125  return 1;
126  }
127  }
128  if (abs( (*it2)->pdg_id() )==16 )
129  {
130  if(!hTau2) hTau2 = *it2;
131  else
132  {
133  edm::LogInfo("TauSpinnerCMSSW::read_particles_from_HepMC") << "TauSpiner: two neutrinos or two taus and neutrino in one decay"
134  << std::endl;
135  //std::cout<<"TauSpiner: two neutrinos or two taus and neutrino in one decay"<<std::endl;
136  return 1;
137  }
138  }
139  }
140  if(hTau && hTau2) break;
141 
142  }
143  }
144 
145  if(!hX) return 1;
146 
147  if(!hTau || !hTau2)
148  {
149  //edm::LogInfo("TauSpinnerCMSSW::read_particles_from_HepMC") << "TauSpiner: boson found but no proper tau pair or tau + neutrino found."<<std::endl;
150  //std::cout<<"TauSpiner: boson found but no proper tau pair or tau + neutrino found."<<std::endl;
151  return 1;
152  }
153 
154  // Check for self-decaying taus
155  hTau = findLastSelf(hTau);
156  hTau2 = findLastSelf(hTau2);
157 
158  // Fill SimpleParticles from HepMC particles
159  X.setPx(hX->momentum().px());
160  X.setPy(hX->momentum().py());
161  X.setPz(hX->momentum().pz());
162  X.setE (hX->momentum().e ());
163  X.setPdgid(hX->pdg_id());
164 
165  tau.setPx(hTau->momentum().px());
166  tau.setPy(hTau->momentum().py());
167  tau.setPz(hTau->momentum().pz());
168  tau.setE (hTau->momentum().e ());
169  tau.setPdgid(hTau->pdg_id());
170 
171  tau2.setPx(hTau2->momentum().px());
172  tau2.setPy(hTau2->momentum().py());
173  tau2.setPz(hTau2->momentum().pz());
174  tau2.setE (hTau2->momentum().e ());
175  tau2.setPdgid(hTau2->pdg_id());
176 
177  // Create list of tau daughters
178  std::vector<SimpleParticle> *buf = getDaughters(hTau);
179  tau_daughters.clear();
180  tau_daughters.insert(tau_daughters.end(),buf->begin(),buf->end());
181 
182  delete buf;
183 
184  // Second particle can be 2nd tau. In that case - read its daughters.
185  // Otherwise it is nu_tau~
186  buf = getDaughters(hTau2);
187  tau2_daughters.clear();
188  tau2_daughters.insert(tau2_daughters.end(),buf->begin(),buf->end());
189 
190  delete buf;
191 
192  return 0;
193 }
HepMC::GenParticle * findLastSelf(HepMC::GenParticle *x)
isFirst
Definition: cuy.py:417
#define X(str)
Definition: MuonsGrabber.cc:48
#define NULL
Definition: scimark2.h:8
std::vector< TauSpinner::SimpleParticle > * getDaughters(HepMC::GenParticle *x)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past