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/TauolaInterface/interface/read_particles_from_HepMC.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

Definition at line 46 of file read_particles_from_HepMC.cc.

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

Referenced by findLastSelf(), and readParticlesFromHepMC().

47 {
48  if(!x->end_vertex()) return x;
49 
50  for(HepMC::GenVertex::particle_iterator p = x->end_vertex()->particles_begin(HepMC::children); p!=x->end_vertex()->particles_end(HepMC::children); ++p)
51  {
52  if( (*p)->pdg_id()==x->pdg_id() ) return findLastSelf( *p );
53  }
54 
55  return x;
56 }
HepMC::GenParticle * findLastSelf(HepMC::GenParticle *x)
T x() const
Cartesian x coordinate.
std::vector<SimpleParticle>* getDaughters ( HepMC::GenParticle *  x)
inline

Definition at line 8 of file read_particles_from_HepMC.cc.

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

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

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

Definition at line 58 of file read_particles_from_HepMC.cc.

References AlCaHLTBitMon_ParallelJobs::p, and parents.

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

Read HepMC::GenEvent.

Read HepMC event from data file and return particles needed for tau spin weight calculation.

This routine is prepared for use with files generated by Pythia8. Fills:

'X' - Heavy particle (W+/-, H+/-, H, Z) 'tau' - first tau

'tau_daughters' - daughters of 'tau' 'tau2_daughters' - daughters of 'tau2' or empty list, if 'tau2' is nu_tau.

Returns: 0 - event processed correctly 1 - empty event or no decay found in the event

Definition at line 87 of file read_particles_from_HepMC.cc.

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

Referenced by TauSpinnerCMS::produce().

88 {
89  if(event==NULL) return 1;
90 
91  // Exctract particles from event
92  HepMC::GenParticle *hX=NULL, *hTau=NULL, *hTau2=NULL;
93 
94  for(HepMC::GenEvent::particle_const_iterator it = event->particles_begin(); it!=event->particles_end(); ++it)
95  {
96  int pdgid = (*it)->pdg_id();
97  if(
98  (
99  abs(pdgid)==37 ||
100  pdgid ==25 ||
101  abs(pdgid)==24 ||
102  pdgid ==23
103  ) &&
104  (*it)->end_vertex() &&
105  (*it)->end_vertex()->particles_out_size()>=2
106  )
107  {
108  hX = *it;
109  HepMC::GenParticle *LhX=hX;
110  if(!isFirst(hX)) continue;
111  findLastSelf(LhX);
112  hTau = hTau2 = NULL;
113 
114  for(HepMC::GenVertex::particle_iterator it2 = LhX->end_vertex()->particles_begin(HepMC::children); it2!=LhX->end_vertex()->particles_end(HepMC::children); ++it2)
115  {
116  if (abs( (*it2)->pdg_id() )==15 && (*it2)->end_vertex() ){
117  if(!hTau) hTau = *it2;
118  else if(!hTau2) hTau2 = *it2;
119  else
120  {
121  std::cout<<"TauSpiner: three taus in one decay"<<std::endl;
122  return 1;
123  }
124  }
125  if (abs( (*it2)->pdg_id() )==16 )
126  {
127  if(!hTau2) hTau2 = *it2;
128  else
129  {
130  std::cout<<"TauSpiner: two neutrinos or two taus and neutrino in one decay"<<std::endl;
131  return 1;
132  }
133  }
134  }
135  if(hTau && hTau2) break;
136 
137  }
138  }
139 
140  if(!hX) return 1;
141 
142  if(!hTau || !hTau2)
143  {
144  //std::cout<<"TauSpiner: boson found but no proper tau pair or tau + neutrino found."<<std::endl;
145  return 1;
146  }
147 
148  // Check for self-decaying taus
149  hTau = findLastSelf(hTau);
150  hTau2 = findLastSelf(hTau2);
151 
152  // Fill SimpleParticles from HepMC particles
153  X.setPx(hX->momentum().px());
154  X.setPy(hX->momentum().py());
155  X.setPz(hX->momentum().pz());
156  X.setE (hX->momentum().e ());
157  X.setPdgid(hX->pdg_id());
158 
159  tau.setPx(hTau->momentum().px());
160  tau.setPy(hTau->momentum().py());
161  tau.setPz(hTau->momentum().pz());
162  tau.setE (hTau->momentum().e ());
163  tau.setPdgid(hTau->pdg_id());
164 
165  tau2.setPx(hTau2->momentum().px());
166  tau2.setPy(hTau2->momentum().py());
167  tau2.setPz(hTau2->momentum().pz());
168  tau2.setE (hTau2->momentum().e ());
169  tau2.setPdgid(hTau2->pdg_id());
170 
171  // Create list of tau daughters
172  std::vector<SimpleParticle> *buf = getDaughters(hTau);
173  tau_daughters.clear();
174  tau_daughters.insert(tau_daughters.end(),buf->begin(),buf->end());
175 
176  delete buf;
177 
178  // Second particle can be 2nd tau. In that case - read its daughters.
179  // Otherwise it is nu_tau~
180  buf = getDaughters(hTau2);
181  tau2_daughters.clear();
182  tau2_daughters.insert(tau2_daughters.end(),buf->begin(),buf->end());
183 
184  delete buf;
185 
186  return 0;
187 }
HepMC::GenParticle * findLastSelf(HepMC::GenParticle *x)
isFirst
Definition: cuy.py:417
#define X(str)
Definition: MuonsGrabber.cc:48
#define NULL
Definition: scimark2.h:8
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
tuple cout
Definition: gather_cfg.py:121
std::vector< SimpleParticle > * getDaughters(HepMC::GenParticle *x)