ExRootClasses.h
Go to the documentation of this file.
1 #ifndef EXROOTCLASSES_H
2 #define EXROOTCLASSES_H
3 
22 // Dependencies (#includes)
23 
24 #include "TRef.h"
25 #include "TObject.h"
26 #include "TRefArray.h"
27 
28 #include "TMath.h"
29 
30 //---------------------------------------------------------------------------
31 
32 class TCompare
33 {
34 public:
35  virtual Bool_t IsSortable(const TObject *) const { return kTRUE; }
36  virtual Int_t Compare(const TObject *obj1, const TObject *obj2) const = 0;
37 };
38 
39 //---------------------------------------------------------------------------
40 
41 class TSortableObject: public TObject
42 {
43 public:
44 
45  Bool_t IsSortable() const { return GetCompare() ? GetCompare()->IsSortable(this) : kFALSE; }
46  Int_t Compare(const TObject *obj) const { return GetCompare()->Compare(this, obj); }
47 
48  virtual const TCompare *GetCompare() const = 0;
49 
50  ClassDef(TSortableObject, 1)
51 };
52 
53 //---------------------------------------------------------------------------
54 
55 class TRootWeight: public TObject
56 {
57 public:
58  Double_t Weight; // weight for the event
59 
60  ClassDef(TRootWeight, 1)
61 };
62 
63 //---------------------------------------------------------------------------
64 
65 class TRootLHEFEvent: public TObject
66 {
67 public:
68 
69  Long64_t Number; // event number
70 
71  Int_t Nparticles; // number of particles in the event | hepup.NUP
72  Int_t ProcessID; // subprocess code for the event | hepup.IDPRUP
73 
74  Double_t Weight; // weight for the event | hepup.XWGTUP
75  Double_t ScalePDF; // scale in GeV used in the calculation of the PDFs in the event | hepup.SCALUP
76  Double_t CouplingQED; // value of the QED coupling used in the event | hepup.AQEDUP
77  Double_t CouplingQCD; // value of the QCD coupling used in the event | hepup.AQCDUP
78 
79  ClassDef(TRootLHEFEvent, 2)
80 };
81 
82 //---------------------------------------------------------------------------
83 
85 {
86 public:
87 
88  Int_t PID; // particle HEP ID number | hepup.IDUP[number]
89  Int_t Status; // particle status code | hepup.ISTUP[number]
90  Int_t Mother1; // index for the particle first mother | hepup.MOTHUP[number][0]
91  Int_t Mother2; // index for the particle last mother | hepup.MOTHUP[number][1]
92  Int_t ColorLine1; // index for the particle color-line | hepup.ICOLUP[number][0]
93  Int_t ColorLine2; // index for the particle anti-color-line | hepup.ICOLUP[number][1]
94 
95  Double_t Px; // particle momentum vector (x component) | hepup.PUP[number][0]
96  Double_t Py; // particle momentum vector (y component) | hepup.PUP[number][1]
97  Double_t Pz; // particle momentum vector (z component) | hepup.PUP[number][2]
98  Double_t E; // particle energy | hepup.PUP[number][3]
99  Double_t M; // particle mass | hepup.PUP[number][4]
100 
101  Double_t PT; // particle transverse momentum
102  Double_t Eta; // particle pseudorapidity
103  Double_t Phi; // particle azimuthal angle
104 
105  Double_t Rapidity; // particle rapidity
106 
107  Double_t LifeTime; // particle invariant lifetime
108  // (c*tau, distance from production to decay in mm)
109  // | hepup.VTIMUP[number]
110 
111  Double_t Spin; // cosine of the angle between the particle spin vector
112  // and the decaying particle 3-momentum,
113  // specified in the lab frame. | hepup.SPINUP[number]
114 
115  static TCompare *fgCompare;
116  const TCompare *GetCompare() const { return fgCompare; }
117 
118  ClassDef(TRootLHEFParticle, 2)
119 };
120 
121 //---------------------------------------------------------------------------
122 
123 class TRootGenEvent: public TObject
124 {
125 public:
126 
127  Long64_t Number; // event number | hepevt.nevhep
128 
129  ClassDef(TRootGenEvent, 1)
130 };
131 
132 //---------------------------------------------------------------------------
133 
135 {
136 public:
137  Int_t PID; // particle HEP ID number | hepevt.idhep[number]
138  Int_t Status; // particle status | hepevt.isthep[number]
139  Int_t M1; // particle 1st mother | hepevt.jmohep[number][0] - 1
140  Int_t M2; // particle 2nd mother | hepevt.jmohep[number][1] - 1
141  Int_t D1; // particle 1st daughter | hepevt.jdahep[number][0] - 1
142  Int_t D2; // particle 2nd daughter | hepevt.jdahep[number][1] - 1
143 
144  Double_t E; // particle energy | hepevt.phep[number][3]
145  Double_t Px; // particle momentum vector (x component) | hepevt.phep[number][0]
146  Double_t Py; // particle momentum vector (y component) | hepevt.phep[number][1]
147  Double_t Pz; // particle momentum vector (z component) | hepevt.phep[number][2]
148 
149  Double_t PT; // particle transverse momentum
150  Double_t Eta; // particle pseudorapidity
151  Double_t Phi; // particle azimuthal angle
152 
153  Double_t Rapidity; // particle rapidity
154 
155  Double_t T; // particle vertex position (t component) | hepevt.vhep[number][3]
156  Double_t X; // particle vertex position (x component) | hepevt.vhep[number][0]
157  Double_t Y; // particle vertex position (y component) | hepevt.vhep[number][1]
158  Double_t Z; // particle vertex position (z component) | hepevt.vhep[number][2]
159 
160  static TCompare *fgCompare;
161  const TCompare *GetCompare() const { return fgCompare; }
162 
163  ClassDef(TRootGenParticle, 1)
164 };
165 
166 //---------------------------------------------------------------------------
167 
169 {
170 public:
171 
172  Double_t E; // jet energy
173  Double_t Px; // jet momentum vector (x component)
174  Double_t Py; // jet momentum vector (y component)
175  Double_t Pz; // jet momentum vector (z component)
176 
177  Double_t PT; // jet transverse momentum
178  Double_t Eta; // jet pseudorapidity
179  Double_t Phi; // jet azimuthal angle
180 
181  Double_t Rapidity; // jet rapidity
182 
183  Double_t Mass; // jet invariant mass
184 
185  static TCompare *fgCompare;
186  const TCompare *GetCompare() const { return fgCompare; }
187 
188  ClassDef(TRootGenJet, 1)
189 };
190 
191 //---------------------------------------------------------------------------
192 
193 class TRootEvent: public TObject
194 {
195 public:
196 
197  Long64_t Number; // event number
198  Int_t Trigger; // trigger word
199 
200  ClassDef(TRootEvent, 1)
201 };
202 
203 //---------------------------------------------------------------------------
204 
205 class TRootMissingET: public TObject
206 {
207 public:
208  Double_t MET; // mising transverse energy
209  Double_t Phi; // mising energy azimuthal angle
210 
211  ClassDef(TRootMissingET, 1)
212 };
213 
214 //---------------------------------------------------------------------------
215 
217 {
218 public:
219 
220  Double_t PT; // photon transverse momentum
221  Double_t Eta; // photon pseudorapidity
222  Double_t Phi; // photon azimuthal angle
223 
224  Double_t EhadOverEem; // ratio of the hadronic versus electromagnetic energy
225  // deposited in the calorimeter
226 
227  static TCompare *fgCompare;
228  const TCompare *GetCompare() const { return fgCompare; }
229 
230  ClassDef(TRootPhoton, 2)
231 };
232 
233 //---------------------------------------------------------------------------
234 
236 {
237 public:
238 
239  Double_t PT; // electron transverse momentum
240  Double_t Eta; // electron pseudorapidity
241  Double_t Phi; // electron azimuthal angle
242 
243  Double_t Charge; // electron charge
244 
245  Double_t Ntrk; // number of tracks associated with the electron
246 
247  Double_t EhadOverEem; // ratio of the hadronic versus electromagnetic energy
248  // deposited in the calorimeter
249 
250  static TCompare *fgCompare;
251  const TCompare *GetCompare() const { return fgCompare; }
252 
253  ClassDef(TRootElectron, 2)
254 };
255 
256 //---------------------------------------------------------------------------
257 
259 {
260 public:
261 
262  Double_t PT; // muon transverse momentum
263  Double_t Eta; // muon pseudorapidity
264  Double_t Phi; // muon azimuthal angle
265 
266  Double_t Charge; // muon charge
267 
268  Double_t Ntrk; // number of tracks associated with the muon
269 
270  Double_t PTiso; // sum of tracks transverse momentum within a cone of radius R=0.4
271  // centered on the muon (excluding the muon itself)
272 
273  Double_t ETiso; // ratio of ET in a 3x3 calorimeter cells array around the muon
274  // (including the muon's cell) to the muon PT
275 
276  Int_t JetIndex; // index of the closest jet
277 
278  static TCompare *fgCompare;
279  const TCompare *GetCompare() const { return fgCompare; }
280 
281  ClassDef(TRootMuon, 2)
282 };
283 
284 //---------------------------------------------------------------------------
285 
287 {
288 public:
289 
290  Double_t PT; // tau transverse momentum
291  Double_t Eta; // tau pseudorapidity
292  Double_t Phi; // tau azimuthal angle
293 
294  Double_t Charge; // tau charge
295 
296  Double_t Ntrk; // number of charged tracks associated with the tau
297 
298  Double_t EhadOverEem; // ratio of the hadronic versus electromagnetic energy
299  // deposited in the calorimeter
300 
301  static TCompare *fgCompare;
302  const TCompare *GetCompare() const { return fgCompare; }
303 
304  ClassDef(TRootTau, 2)
305 };
306 
307 //---------------------------------------------------------------------------
308 
310 {
311 public:
312 
313  Double_t PT; // jet transverse momentum
314  Double_t Eta; // jet pseudorapidity
315  Double_t Phi; // jet azimuthal angle
316 
317  Double_t Mass; // jet invariant mass
318 
319  Double_t Ntrk; // number of tracks associated with the jet
320 
321  Double_t BTag; // 1 or 2 for a jet that has been tagged as containing a heavy quark
322 
323  Double_t EhadOverEem; // ratio of the hadronic versus electromagnetic energy
324  // deposited in the calorimeter
325 
326  Int_t Index; // jet index in the LHC Olympics file
327 
328  static TCompare *fgCompare;
329  const TCompare *GetCompare() const { return fgCompare; }
330 
331  ClassDef(TRootJet, 2)
332 };
333 
334 //---------------------------------------------------------------------------
335 // Standard Comparison Criteria: E, ET, PT, DeltaR
336 //---------------------------------------------------------------------------
337 
338 template <typename T>
339 class TCompareE: public TCompare
340 {
341  TCompareE() {}
342 public:
343  static TCompareE *Instance()
344  {
345  static TCompareE single;
346  return &single;
347  }
348 
349  Int_t Compare(const TObject *obj1, const TObject *obj2) const
350  {
351  auto t1 = static_cast<const T*>(obj1);
352  auto t2 = static_cast<const T*>(obj2);
353  if(t1->E > t2->E)
354  return -1;
355  else if(t1->E < t2->E)
356  return 1;
357  else
358  return 0;
359  }
360 };
361 
362 //---------------------------------------------------------------------------
363 
364 template <typename T>
365 class TComparePT: public TCompare
366 {
367  TComparePT() {}
368 public:
370  {
371  static TComparePT single;
372  return &single;
373  }
374 
375  Int_t Compare(const TObject *obj1, const TObject *obj2) const
376  {
377  auto t1 = static_cast<const T*>(obj1);
378  auto t2 = static_cast<const T*>(obj2);
379  if(t1->PT > t2->PT)
380  return -1;
381  else if(t1->PT < t2->PT)
382  return 1;
383  else
384  return 0;
385  }
386 };
387 
388 //---------------------------------------------------------------------------
389 
390 template <typename T>
391 class TCompareET: public TCompare
392 {
393  TCompareET() {}
394 public:
396  {
397  static TCompareET single;
398  return &single;
399  }
400 
401  Int_t Compare(const TObject *obj1, const TObject *obj2) const
402  {
403  auto t1 = static_cast<const T*>(obj1);
404  auto t2 = static_cast<const T*>(obj2);
405  if(t1->ET > t2->ET)
406  return -1;
407  else if(t1->ET < t2->ET)
408  return 1;
409  else
410  return 0;
411  }
412 };
413 
414 //---------------------------------------------------------------------------
415 
416 template <typename T1, typename T2>
418 {
419  TCompareDeltaR(const T2 *obj = 0) : fObj(obj) {}
420 
421  Double_t DeltaPhi(Double_t phi1, Double_t phi2)
422  {
423  auto phi = TMath::Abs(phi1 - phi2);
424  return (phi <= TMath::Pi()) ? phi : (2.0*TMath::Pi()) - phi;
425  }
426 
427  Double_t Sqr(Double_t x) { return x*x; }
428 
429  Double_t SumSqr(Double_t a, Double_t b)
430  {
431  auto aAbs = TMath::Abs(a);
432  auto bAbs = TMath::Abs(b);
433  if(aAbs > bAbs) return aAbs * TMath::Sqrt(1.0 + Sqr(bAbs / aAbs));
434  else return (bAbs == 0) ? 0.0 : bAbs * TMath::Sqrt(1.0 + Sqr(aAbs / bAbs));
435  };
436 
437  const T2 *fObj;
438 
439 public:
440  static TCompareDeltaR *Instance(const T2 *obj = 0)
441  {
442  static TCompareDeltaR single(obj);
443  return &single;
444  }
445 
446  void SetObject(const T2 *obj) { fObj = obj; }
447 
448  Int_t Compare(const TObject *obj1, const TObject *obj2) const
449  {
450  Double_t eta[3], phi[3], deltaR[2];
451  auto t1 = static_cast<const T1*>(obj1);
452  auto t2 = static_cast<const T1*>(obj2);
453 
454  eta[0] = fObj->Eta;
455  phi[0] = fObj->Phi;
456 
457  eta[1] = t1->Eta;
458  phi[1] = t1->Phi;
459 
460  eta[2] = t2->Eta;
461  phi[2] = t2->Phi;
462 
463  deltaR[0] = SumSqr(TMath::Abs(eta[0] - eta[1]), DeltaPhi(phi[0], phi[1]));
464  deltaR[1] = SumSqr(TMath::Abs(eta[0] - eta[2]), DeltaPhi(phi[0], phi[2]));
465 
466  if(deltaR[0] < deltaR[1])
467  return -1;
468  else if(deltaR[0] > deltaR[1])
469  return 1;
470  else
471  return 0;
472  }
473 };
474 
477 #endif // EXROOTCLASSES_H
478 
479 
Definition: ExRootClasses.h:41
Double_t Phi
Definition: ExRootClasses.h:209
Definition: ExRootClasses.h:193
Long64_t Number
Definition: ExRootClasses.h:197
Long64_t Number
Definition: ExRootClasses.h:69
Bool_t IsSortable() const
Definition: ExRootClasses.h:45
Int_t Compare(const TObject *obj) const
Definition: ExRootClasses.h:46
static TCompareDeltaR * Instance(const T2 *obj=0)
Definition: ExRootClasses.h:440
Definition: ExRootClasses.h:309
static TCompare * fgCompare
Definition: ExRootClasses.h:328
Double_t Mass
Definition: ExRootClasses.h:183
Double_t Eta
Definition: ExRootClasses.h:150
Definition: ExRootClasses.h:84
const TCompare * GetCompare() const
Definition: ExRootClasses.h:302
Definition: ExRootClasses.h:216
Double_t Eta
Definition: ExRootClasses.h:178
Double_t Z
Definition: ExRootClasses.h:158
Definition: ExRootClasses.h:123
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: ExRootClasses.h:349
Double_t Weight
Definition: ExRootClasses.h:58
Double_t Weight
Definition: ExRootClasses.h:74
Double_t EhadOverEem
Definition: ExRootClasses.h:298
Double_t Eta
Definition: ExRootClasses.h:221
static TCompare * fgCompare
Definition: ExRootClasses.h:301
Double_t BTag
Definition: ExRootClasses.h:321
Double_t Pz
Definition: ExRootClasses.h:147
Double_t PT
Definition: ExRootClasses.h:290
Double_t PT
Definition: ExRootClasses.h:313
Definition: ExRootClasses.h:391
Double_t EhadOverEem
Definition: ExRootClasses.h:224
Int_t Mother2
Definition: ExRootClasses.h:91
Double_t Ntrk
Definition: ExRootClasses.h:319
Definition: ExRootClasses.h:365
virtual Int_t Compare(const TObject *obj1, const TObject *obj2) const =0
Int_t PID
Definition: ExRootClasses.h:137
static TComparePT * Instance()
Definition: ExRootClasses.h:369
Double_t E
Definition: ExRootClasses.h:172
Int_t D2
Definition: ExRootClasses.h:142
Double_t Spin
Definition: ExRootClasses.h:111
Double_t PT
Definition: ExRootClasses.h:239
Double_t Eta
Definition: ExRootClasses.h:314
Double_t CouplingQED
Definition: ExRootClasses.h:76
Double_t E
Definition: ExRootClasses.h:98
Double_t Ntrk
Definition: ExRootClasses.h:296
Double_t M
Definition: ExRootClasses.h:99
Double_t Eta
Definition: ExRootClasses.h:102
Double_t Y
Definition: ExRootClasses.h:157
Double_t PT
Definition: ExRootClasses.h:220
Double_t Charge
Definition: ExRootClasses.h:243
Int_t ColorLine1
Definition: ExRootClasses.h:92
static TCompare * fgCompare
Definition: ExRootClasses.h:115
Double_t Rapidity
Definition: ExRootClasses.h:153
Double_t PT
Definition: ExRootClasses.h:149
Double_t EhadOverEem
Definition: ExRootClasses.h:247
Definition: ExRootClasses.h:258
const TCompare * GetCompare() const
Definition: ExRootClasses.h:161
Definition: ExRootClasses.h:205
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: ExRootClasses.h:375
Double_t Phi
Definition: ExRootClasses.h:222
Double_t ScalePDF
Definition: ExRootClasses.h:75
Double_t Px
Definition: ExRootClasses.h:145
Double_t LifeTime
Definition: ExRootClasses.h:107
Int_t ColorLine2
Definition: ExRootClasses.h:93
Int_t JetIndex
Definition: ExRootClasses.h:276
Definition: ExRootClasses.h:286
Double_t Py
Definition: ExRootClasses.h:174
Int_t ProcessID
Definition: ExRootClasses.h:72
Double_t Ntrk
Definition: ExRootClasses.h:245
Definition: ExRootClasses.h:134
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: ExRootClasses.h:448
Definition: ExRootClasses.h:417
Int_t D1
Definition: ExRootClasses.h:141
static TCompare * fgCompare
Definition: ExRootClasses.h:160
Int_t Status
Definition: ExRootClasses.h:138
Double_t Px
Definition: ExRootClasses.h:95
Double_t Charge
Definition: ExRootClasses.h:294
Double_t Phi
Definition: ExRootClasses.h:315
Definition: ExRootClasses.h:32
Double_t Charge
Definition: ExRootClasses.h:266
Double_t Eta
Definition: ExRootClasses.h:263
Double_t Phi
Definition: ExRootClasses.h:292
Double_t Rapidity
Definition: ExRootClasses.h:181
Double_t X
Definition: ExRootClasses.h:156
virtual Bool_t IsSortable(const TObject *) const
Definition: ExRootClasses.h:35
Long64_t Number
Definition: ExRootClasses.h:127
Double_t Rapidity
Definition: ExRootClasses.h:105
Double_t E
Definition: ExRootClasses.h:144
Double_t Px
Definition: ExRootClasses.h:173
Double_t Phi
Definition: ExRootClasses.h:151
Double_t Eta
Definition: ExRootClasses.h:240
Int_t Trigger
Definition: ExRootClasses.h:198
Double_t PT
Definition: ExRootClasses.h:177
Double_t Ntrk
Definition: ExRootClasses.h:268
Double_t T
Definition: ExRootClasses.h:155
const TCompare * GetCompare() const
Definition: ExRootClasses.h:186
Double_t ETiso
Definition: ExRootClasses.h:273
Double_t Mass
Definition: ExRootClasses.h:317
Int_t M1
Definition: ExRootClasses.h:139
void SetObject(const T2 *obj)
Definition: ExRootClasses.h:446
Int_t Status
Definition: ExRootClasses.h:89
Double_t Py
Definition: ExRootClasses.h:96
Double_t Pz
Definition: ExRootClasses.h:97
Int_t Mother1
Definition: ExRootClasses.h:90
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: ExRootClasses.h:401
static TCompareE * Instance()
Definition: ExRootClasses.h:343
Int_t Index
Definition: ExRootClasses.h:326
const TCompare * GetCompare() const
Definition: ExRootClasses.h:116
Double_t Phi
Definition: ExRootClasses.h:103
Int_t PID
Definition: ExRootClasses.h:88
Double_t Eta
Definition: ExRootClasses.h:291
const TCompare * GetCompare() const
Definition: ExRootClasses.h:228
Double_t Phi
Definition: ExRootClasses.h:264
Definition: ExRootClasses.h:235
Int_t Nparticles
Definition: ExRootClasses.h:71
Double_t EhadOverEem
Definition: ExRootClasses.h:323
const TCompare * GetCompare() const
Definition: ExRootClasses.h:329
Definition: ExRootClasses.h:65
static TCompare * fgCompare
Definition: ExRootClasses.h:227
Double_t CouplingQCD
Definition: ExRootClasses.h:77
const TCompare * GetCompare() const
Definition: ExRootClasses.h:251
Double_t Py
Definition: ExRootClasses.h:146
constexpr double Pi()
Constant .
Definition: Si.hh:46
Double_t Phi
Definition: ExRootClasses.h:241
Int_t M2
Definition: ExRootClasses.h:140
Definition: ExRootClasses.h:168
static TCompare * fgCompare
Definition: ExRootClasses.h:278
static TCompare * fgCompare
Definition: ExRootClasses.h:185
Double_t PT
Definition: ExRootClasses.h:101
Definition: ExRootClasses.h:55
const TCompare * GetCompare() const
Definition: ExRootClasses.h:279
Double_t PTiso
Definition: ExRootClasses.h:270
Double_t PT
Definition: ExRootClasses.h:262
static TCompareET * Instance()
Definition: ExRootClasses.h:395
Definition: ExRootClasses.h:339
Double_t Pz
Definition: ExRootClasses.h:175
Double_t MET
Definition: ExRootClasses.h:208
Double_t Phi
Definition: ExRootClasses.h:179
static TCompare * fgCompare
Definition: ExRootClasses.h:250