CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
read_particles_from_HepMC.h File Reference
#include "HepMC/GenEvent.h"
#include "HepMC/GenParticle.h"
#include "HepMC/IO_GenEvent.h"
#include "TauSpinner/SimpleParticle.h"
#include <vector>

Go to the source code of this file.

Functions

HepMC::GenParticle * findLastSelf (HepMC::GenParticle *x)
 
std::vector
< TauSpinner::SimpleParticle > * 
getDaughters (HepMC::GenParticle *x)
 
bool isFirst (HepMC::GenParticle *x)
 
int readParticlesFromHepMC (const HepMC::GenEvent *event, TauSpinner::SimpleParticle &X, TauSpinner::SimpleParticle &tau, TauSpinner::SimpleParticle &tau2, std::vector< TauSpinner::SimpleParticle > &tau_daughters, std::vector< TauSpinner::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<TauSpinner::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,
TauSpinner::SimpleParticle &  X,
TauSpinner::SimpleParticle &  tau,
TauSpinner::SimpleParticle &  tau2,
std::vector< TauSpinner::SimpleParticle > &  tau_daughters,
std::vector< TauSpinner::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

Referenced by TauSpinnerCMS::produce().