CMS 3D CMS Logo

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

Definition at line 46 of file read_particles_from_HepMC.cc.

References class-composition::children, AlCaHLTBitMon_ParallelJobs::p, and x.

Referenced by 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)
std::vector<TauSpinner::SimpleParticle>* getDaughters ( HepMC::GenParticle *  x)
inline

Definition at line 8 of file read_particles_from_HepMC.cc.

References BPhysicsValidation_cfi::daughters, GenParticle::GenParticle, AlCaHLTBitMon_ParallelJobs::p, and createTree::pp.

Referenced by 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 }
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.

Referenced by readParticlesFromHepMC().

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:21
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().