TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
GenMatching.h
1 #ifndef _TIMBER_GENMATCHING
2 #define _TIMBER_GENMATCHING
3 #include <map>
4 #include <algorithm>
5 #include <numeric>
6 #include <math.h>
7 #include <cstdlib>
8 #include "common.h"
9 #include <Math/Vector4D.h>
10 #include <Math/VectorUtil.h>
11 
12 using namespace ROOT::VecOps;
13 using LVector = ROOT::Math::PtEtaPhiMVector;
14 
15 namespace GenMatching {
23  bool BitChecker(const int &bit, int &number);
24 
27  extern std::map <int, std::string> PDGIds;
28 
31  extern std::map <std::string, int> GenParticleStatusFlags;
32 }
33 
38 class Particle {
39  public:
40  bool flag = true;
41  int index;
42  std::map <std::string, int> statusFlags;
44  std::vector<int> childIndex;
45  LVector vect;
47  int pdgId;
48  int status;
52  Particle();
60  template <class T>
61  Particle(int i, T p) :
62  vect(LVector(p.pt, p.eta, p.phi, p.mass)), index(i), genPartIdxMother(p.genPartIdxMother),
63  pdgId(p.pdgId), status(p.status) {
64  SetStatusFlags(p.statusFlags);
65  };
71  void AddParent(int idx);
77  void AddChild(int idx);
83  int GetParent();
89  std::vector<int> GetChild();
96  float DeltaR(LVector input_vector);
101  void SetStatusFlags(int flags);
106  int GetStatusFlag(std::string flagName);
114  std::map< std::string, bool> CompareToVector(LVector vect);
115 };
116 
117 
124 {
125  private:
126  std::vector<Particle> _nodes;
127  std::vector<Particle*> _heads;
128  // std::vector<int> _storedIndexes;
129 
130  bool _matchParticleToString(Particle* particle, std::string string);
131  std::vector<Particle*> _runChain(Particle* node, std::vector<std::string> chain);
132 
133  Particle _noneParticle;
134 
135  public:
141  GenParticleTree(int nParticles);
147  Particle* AddParticle(Particle particle);
156  template <class T>
157  Particle* AddParticle(int index, T p) {
158  Particle particle(index, p);
159  return AddParticle(particle);
160  }
166  std::vector<Particle*> GetParticles() {
167  std::vector<Particle*> out;
168  for (int inode = 0; inode<_nodes.size(); inode++) {
169  out.push_back(&_nodes[inode]);
170  }
171  return out;
172  }
179  std::vector<Particle*> GetChildren(Particle* particle);
186  Particle* GetParent(Particle* particle);
193  std::vector<std::vector<Particle*>> FindChain(std::string chainstring);
194 };
195 #endif
std::vector< Particle * > GetParticles()
Get the list of particle objects.
Definition: GenMatching.h:166
int index
Definition: GenMatching.h:41
Particle(int i, T p)
Construct a new Particle object with TIMBER collection struct as input.
Definition: GenMatching.h:61
C++ class. Stores identifying features of a particle in the GenPart collection.
Definition: GenMatching.h:38
C++ class. Constructs tree by adding particles. Establish relationships between particles (parent...
Definition: GenMatching.h:123
int pdgId
Definition: GenMatching.h:47
LVector vect
Definition: GenMatching.h:45
int parentIndex
Definition: GenMatching.h:43
std::vector< int > childIndex
Definition: GenMatching.h:44
int status
Definition: GenMatching.h:48
std::map< std::string, int > statusFlags
Definition: GenMatching.h:42
Particle * AddParticle(int index, T p)
Add particle to tree.
Definition: GenMatching.h:157
int genPartIdxMother
Definition: GenMatching.h:46
Definition: GenMatching.h:15