CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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

Definition at line 44 of file read_particles_from_HepMC.cc.

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

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

Definition at line 8 of file read_particles_from_HepMC.cc.

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

Referenced by getDaughters(), and 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 }
tuple pp
Definition: createTree.py:17
std::vector< TauSpinner::SimpleParticle > * getDaughters(HepMC::GenParticle *x)
float 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);
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
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().