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

◆ findLastSelf()

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

Definition at line 44 of file read_particles_from_HepMC.cc.

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

Referenced by readParticlesFromHepMC().

44  {
45  if (!x->end_vertex())
46  return x;
47 
48  for (HepMC::GenVertex::particle_iterator p = x->end_vertex()->particles_begin(HepMC::children);
49  p != x->end_vertex()->particles_end(HepMC::children);
50  ++p) {
51  if ((*p)->pdg_id() == x->pdg_id())
52  return findLastSelf(*p);
53  }
54 
55  return x;
56 }
HepMC::GenParticle * findLastSelf(HepMC::GenParticle *x)
float x

◆ getDaughters()

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, createTree::pp, cmsswSequenceInfo::tp, and x.

Referenced by readParticlesFromHepMC().

8  {
9  std::vector<SimpleParticle> *daughters = new std::vector<SimpleParticle>();
10  if (!x->end_vertex())
11  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();
15  p != x->end_vertex()->particles_out_const_end();
16  ++p) {
18  HepMC::FourVector mm = pp->momentum();
19 
20  // If the daughter of 'x' has its end vertex - recursively read
21  // all of its daughters.
22  if (pp->end_vertex() && pp->pdg_id() != 111) {
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  SimpleParticle tp(mm.px(), mm.py(), mm.pz(), mm.e(), pp->pdg_id());
31  daughters->push_back(tp);
32  }
33  }
34 
35  return daughters;
36 }
std::vector< SimpleParticle > * getDaughters(HepMC::GenParticle *x)
float x

◆ isFirst()

bool isFirst ( HepMC::GenParticle *  x)
inline

Definition at line 58 of file read_particles_from_HepMC.cc.

References AlCaHLTBitMon_ParallelJobs::p, parents, and x.

Referenced by readParticlesFromHepMC().

58  {
59  for (HepMC::GenVertex::particle_iterator p = x->production_vertex()->particles_begin(HepMC::parents);
60  p != x->production_vertex()->particles_end(HepMC::parents);
61  ++p) {
62  if (x->pdg_id() == (*p)->pdg_id())
63  return false;
64  }
65  return true;
66 }
TPRegexp parents
Definition: eve_filter.cc:21
float x

◆ readParticlesFromHepMC()

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