Fork me on GitHub

source: git/classes/DelphesClasses.cc @ 4d7014e

ImprovedOutputFileTiming
Last change on this file since 4d7014e was 4d7014e, checked in by Michele Selvaggi <michele.selvaggi@…>, 12 months ago

added PFcandidate class

  • Property mode set to 100644
File size: 12.5 KB
Line 
1/*
2 *  Delphes: a framework for fast simulation of a generic collider experiment
3 *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
4 *
5 *  This program is free software: you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation, either version 3 of the License, or
8 *  (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 *
21 *  Definition of classes to be stored in the root tree.
22 *  Function CompareXYZ sorts objects by the variable XYZ that MUST be
23 *  present in the data members of the root tree class of the branch.
24 *
25 *  \author P. Demin - UCL, Louvain-la-Neuve
26 *
27 */
28
29#include "classes/DelphesClasses.h"
30
31#include "classes/DelphesFactory.h"
32#include "classes/SortableObject.h"
33
34CompBase *GenParticle::fgCompare = 0;
35CompBase *Photon::fgCompare = CompPT<Photon>::Instance();
36CompBase *Electron::fgCompare = CompPT<Electron>::Instance();
37CompBase *Muon::fgCompare = CompPT<Muon>::Instance();
38CompBase *Jet::fgCompare = CompPT<Jet>::Instance();
39CompBase *Track::fgCompare = CompPT<Track>::Instance();
40CompBase *Tower::fgCompare = CompE<Tower>::Instance();
41CompBase *ParticleFlowCandidate::fgCompare = CompE<ParticleFlowCandidate>::Instance();
42CompBase *HectorHit::fgCompare = CompE<HectorHit>::Instance();
43CompBase *Vertex::fgCompare = CompSumPT2<Vertex>::Instance();
44CompBase *Candidate::fgCompare = CompMomentumPt<Candidate>::Instance();
45
46//------------------------------------------------------------------------------
47
48TLorentzVector GenParticle::P4() const
49{
50  TLorentzVector vec;
51  vec.SetPxPyPzE(Px, Py, Pz, E);
52  return vec;
53}
54
55//------------------------------------------------------------------------------
56
57TLorentzVector MissingET::P4() const
58{
59  TLorentzVector vec;
60  vec.SetPtEtaPhiM(MET, Eta, Phi, 0.0);
61  return vec;
62}
63
64//------------------------------------------------------------------------------
65
66TLorentzVector Photon::P4() const
67{
68  TLorentzVector vec;
69  vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
70  return vec;
71}
72
73//------------------------------------------------------------------------------
74
75TLorentzVector Electron::P4() const
76{
77  TLorentzVector vec;
78  vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
79  return vec;
80}
81
82//------------------------------------------------------------------------------
83
84TLorentzVector Muon::P4() const
85{
86  TLorentzVector vec;
87  vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
88  return vec;
89}
90
91//------------------------------------------------------------------------------
92
93TLorentzVector Jet::P4() const
94{
95  TLorentzVector vec;
96  vec.SetPtEtaPhiM(PT, Eta, Phi, Mass);
97  return vec;
98}
99
100//------------------------------------------------------------------------------
101
102TLorentzVector Track::P4() const
103{
104  TLorentzVector vec;
105  vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
106  return vec;
107}
108
109//------------------------------------------------------------------------------
110
111TLorentzVector Tower::P4() const
112{
113  TLorentzVector vec;
114  vec.SetPtEtaPhiM(ET, Eta, Phi, 0.0);
115  return vec;
116}
117
118//------------------------------------------------------------------------------
119
120TLorentzVector ParticleFlowCandidate::P4() const
121{
122  TLorentzVector vec;
123  vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
124  return vec;
125}
126
127//------------------------------------------------------------------------------
128
129Candidate::Candidate() :
130  PID(0), Status(0), M1(-1), M2(-1), D1(-1), D2(-1),
131  Charge(0), Mass(0.0),
132  IsPU(0), IsRecoPU(0), IsConstituent(0), IsFromConversion(0),
133  Flavor(0), FlavorAlgo(0), FlavorPhys(0),
134  BTag(0), BTagAlgo(0), BTagPhys(0),
135  TauTag(0), TauWeight(0.0), Eem(0.0), Ehad(0.0),
136  DeltaEta(0.0), DeltaPhi(0.0),
137  Momentum(0.0, 0.0, 0.0, 0.0),
138  Position(0.0, 0.0, 0.0, 0.0),
139  InitialPosition(0.0, 0.0, 0.0, 0.0),
140  PositionError(0.0, 0.0, 0.0, 0.0),
141  Area(0.0, 0.0, 0.0, 0.0),
142  L(0),
143  D0(0), ErrorD0(0),
144  DZ(0), ErrorDZ(0),
145  P(0), ErrorP(0),
146  PT(0), ErrorPT(0),
147  CtgTheta(0), ErrorCtgTheta(0),
148  Phi(0), ErrorPhi(0),
149  Xd(0), Yd(0), Zd(0),
150  TrackResolution(0),
151  NCharged(0),
152  NNeutrals(0),
153  Beta(0),
154  BetaStar(0),
155  MeanSqDeltaR(0),
156  PTD(0),
157  NTimeHits(-1),
158  IsolationVar(-999),
159  IsolationVarRhoCorr(-999),
160  SumPtCharged(-999),
161  SumPtNeutral(-999),
162  SumPtChargedPU(-999),
163  SumPt(-999),
164  ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
165  NSubJetsTrimmed(0),
166  NSubJetsPruned(0),
167  NSubJetsSoftDropped(0),
168  ExclYmerge23(0),
169  ExclYmerge34(0),
170  ExclYmerge45(0),
171  ExclYmerge56(0),
172  fFactory(0),
173  fArray(0)
174{
175  int i;
176  Edges[0] = 0.0;
177  Edges[1] = 0.0;
178  Edges[2] = 0.0;
179  Edges[3] = 0.0;
180  FracPt[0] = 0.0;
181  FracPt[1] = 0.0;
182  FracPt[2] = 0.0;
183  FracPt[3] = 0.0;
184  FracPt[4] = 0.0;
185  Tau[0] = 0.0;
186  Tau[1] = 0.0;
187  Tau[2] = 0.0;
188  Tau[3] = 0.0;
189  Tau[4] = 0.0;
190
191  SoftDroppedJet.SetXYZT(0.0, 0.0, 0.0, 0.0);
192  SoftDroppedSubJet1.SetXYZT(0.0, 0.0, 0.0, 0.0);
193  SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
194
195  for(i = 0; i < 5; ++i)
196  {
197    TrimmedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
198    PrunedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
199    SoftDroppedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
200  }
201}
202
203//------------------------------------------------------------------------------
204
205void Candidate::AddCandidate(Candidate *object)
206{
207  if(!fArray) fArray = fFactory->NewArray();
208  fArray->Add(object);
209}
210
211//------------------------------------------------------------------------------
212
213TObjArray *Candidate::GetCandidates()
214{
215  if(!fArray) fArray = fFactory->NewArray();
216  return fArray;
217}
218
219//------------------------------------------------------------------------------
220
221Bool_t Candidate::Overlaps(const Candidate *object) const
222{
223  const Candidate *candidate;
224
225  if(object->GetUniqueID() == GetUniqueID()) return kTRUE;
226
227  if(fArray)
228  {
229    TIter it(fArray);
230    while((candidate = static_cast<Candidate *>(it.Next())))
231    {
232      if(candidate->Overlaps(object)) return kTRUE;
233    }
234  }
235
236  if(object->fArray)
237  {
238    TIter it(object->fArray);
239    while((candidate = static_cast<Candidate *>(it.Next())))
240    {
241      if(candidate->Overlaps(this)) return kTRUE;
242    }
243  }
244
245  return kFALSE;
246}
247
248//------------------------------------------------------------------------------
249
250TObject *Candidate::Clone(const char *newname) const
251{
252  Candidate *object = fFactory->NewCandidate();
253  Copy(*object);
254  return object;
255}
256
257//------------------------------------------------------------------------------
258
259void Candidate::Copy(TObject &obj) const
260{
261  Candidate &object = static_cast<Candidate &>(obj);
262  Candidate *candidate;
263
264  object.PID = PID;
265  object.Status = Status;
266  object.M1 = M1;
267  object.M2 = M2;
268  object.D1 = D1;
269  object.D2 = D2;
270  object.Charge = Charge;
271  object.Mass = Mass;
272  object.IsPU = IsPU;
273  object.IsRecoPU = IsRecoPU;
274  object.IsConstituent = IsConstituent;
275  object.IsFromConversion = IsFromConversion;
276  object.ClusterIndex = ClusterIndex;
277  object.ClusterNDF = ClusterNDF;
278  object.ClusterSigma = ClusterSigma;
279  object.SumPT2 = SumPT2;
280  object.BTVSumPT2 = BTVSumPT2;
281  object.GenDeltaZ = GenDeltaZ;
282  object.GenSumPT2 = GenSumPT2;
283  object.Flavor = Flavor;
284  object.FlavorAlgo = FlavorAlgo;
285  object.FlavorPhys = FlavorPhys;
286  object.BTag = BTag;
287  object.BTagAlgo = BTagAlgo;
288  object.BTagPhys = BTagPhys;
289  object.TauTag = TauTag;
290  object.TauWeight = TauWeight;
291  object.Eem = Eem;
292  object.Ehad = Ehad;
293  object.Edges[0] = Edges[0];
294  object.Edges[1] = Edges[1];
295  object.Edges[2] = Edges[2];
296  object.Edges[3] = Edges[3];
297  object.DeltaEta = DeltaEta;
298  object.DeltaPhi = DeltaPhi;
299  object.Momentum = Momentum;
300  object.Position = Position;
301  object.InitialPosition = InitialPosition;
302  object.PositionError = PositionError;
303  object.Area = Area;
304  object.L = L;
305  object.ErrorT = ErrorT;
306  object.D0 = D0;
307  object.ErrorD0 = ErrorD0;
308  object.DZ = DZ;
309  object.ErrorDZ = ErrorDZ;
310  object.P = P;
311  object.ErrorP = ErrorP;
312  object.PT = PT;
313  object.ErrorPT = ErrorPT;
314  object.CtgTheta = CtgTheta;
315  object.ErrorCtgTheta = ErrorCtgTheta;
316  object.Phi = Phi;
317  object.ErrorPhi = ErrorPhi;
318  object.Xd = Xd;
319  object.Yd = Yd;
320  object.Zd = Zd;
321  object.TrackResolution = TrackResolution;
322  object.NCharged = NCharged;
323  object.NNeutrals = NNeutrals;
324  object.Beta = Beta;
325  object.BetaStar = BetaStar;
326  object.MeanSqDeltaR = MeanSqDeltaR;
327  object.PTD = PTD;
328  object.NTimeHits = NTimeHits;
329  object.IsolationVar = IsolationVar;
330  object.IsolationVarRhoCorr = IsolationVarRhoCorr;
331  object.SumPtCharged = SumPtCharged;
332  object.SumPtNeutral = SumPtNeutral;
333  object.SumPtChargedPU = SumPtChargedPU;
334  object.SumPt = SumPt;
335  object.ClusterIndex = ClusterIndex;
336  object.ClusterNDF = ClusterNDF;
337  object.ClusterSigma = ClusterSigma;
338  object.SumPT2 = SumPT2;
339
340  object.FracPt[0] = FracPt[0];
341  object.FracPt[1] = FracPt[1];
342  object.FracPt[2] = FracPt[2];
343  object.FracPt[3] = FracPt[3];
344  object.FracPt[4] = FracPt[4];
345  object.Tau[0] = Tau[0];
346  object.Tau[1] = Tau[1];
347  object.Tau[2] = Tau[2];
348  object.Tau[3] = Tau[3];
349  object.Tau[4] = Tau[4];
350
351  object.TrimmedP4[0] = TrimmedP4[0];
352  object.TrimmedP4[1] = TrimmedP4[1];
353  object.TrimmedP4[2] = TrimmedP4[2];
354  object.TrimmedP4[3] = TrimmedP4[3];
355  object.TrimmedP4[4] = TrimmedP4[4];
356  object.PrunedP4[0] = PrunedP4[0];
357  object.PrunedP4[1] = PrunedP4[1];
358  object.PrunedP4[2] = PrunedP4[2];
359  object.PrunedP4[3] = PrunedP4[3];
360  object.PrunedP4[4] = PrunedP4[4];
361  object.SoftDroppedP4[0] = SoftDroppedP4[0];
362  object.SoftDroppedP4[1] = SoftDroppedP4[1];
363  object.SoftDroppedP4[2] = SoftDroppedP4[2];
364  object.SoftDroppedP4[3] = SoftDroppedP4[3];
365  object.SoftDroppedP4[4] = SoftDroppedP4[4];
366
367  object.NSubJetsTrimmed = NSubJetsTrimmed;
368  object.NSubJetsPruned = NSubJetsPruned;
369  object.NSubJetsSoftDropped = NSubJetsSoftDropped;
370
371  object.SoftDroppedJet = SoftDroppedJet;
372  object.SoftDroppedSubJet1 = SoftDroppedSubJet1;
373  object.SoftDroppedSubJet2 = SoftDroppedSubJet2;
374
375  object.fFactory = fFactory;
376  object.fArray = 0;
377
378  // copy cluster timing info
379  copy(ECalEnergyTimePairs.begin(), ECalEnergyTimePairs.end(), back_inserter(object.ECalEnergyTimePairs));
380
381  if(fArray && fArray->GetEntriesFast() > 0)
382  {
383    TIter itArray(fArray);
384    TObjArray *array = object.GetCandidates();
385    while((candidate = static_cast<Candidate *>(itArray.Next())))
386    {
387      array->Add(candidate);
388    }
389  }
390}
391
392//------------------------------------------------------------------------------
393
394void Candidate::Clear(Option_t *option)
395{
396  int i;
397  SetUniqueID(0);
398  ResetBit(kIsReferenced);
399  PID = 0;
400  Status = 0;
401  M1 = -1;
402  M2 = -1;
403  D1 = -1;
404  D2 = -1;
405  Charge = 0;
406  Mass = 0.0;
407  IsPU = 0;
408  IsRecoPU = 0;
409  IsConstituent = 0;
410  IsFromConversion = 0;
411  Flavor = 0;
412  FlavorAlgo = 0;
413  FlavorPhys = 0;
414  BTag = 0;
415  BTagAlgo = 0;
416  BTagPhys = 0;
417  TauTag = 0;
418  TauWeight = 0.0;
419  Eem = 0.0;
420  Ehad = 0.0;
421  Edges[0] = 0.0;
422  Edges[1] = 0.0;
423  Edges[2] = 0.0;
424  Edges[3] = 0.0;
425  DeltaEta = 0.0;
426  DeltaPhi = 0.0;
427  Momentum.SetXYZT(0.0, 0.0, 0.0, 0.0);
428  Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
429  InitialPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
430  Area.SetXYZT(0.0, 0.0, 0.0, 0.0);
431  L = 0.0;
432  ErrorT = 0.0;
433  D0 = 0.0;
434  ErrorD0 = 0.0;
435  DZ = 0.0;
436  ErrorDZ = 0.0;
437  P = 0.0;
438  ErrorP = 0.0;
439  PT = 0.0;
440  ErrorPT = 0.0;
441  CtgTheta = 0.0;
442  ErrorCtgTheta = 0.0;
443  Phi = 0.0;
444  ErrorPhi = 0.0;
445  Xd = 0.0;
446  Yd = 0.0;
447  Zd = 0.0;
448  TrackResolution = 0.0;
449  NCharged = 0;
450  NNeutrals = 0;
451  Beta = 0.0;
452  BetaStar = 0.0;
453  MeanSqDeltaR = 0.0;
454  PTD = 0.0;
455
456  NTimeHits = 0;
457  ECalEnergyTimePairs.clear();
458
459  IsolationVar = -999;
460  IsolationVarRhoCorr = -999;
461  SumPtCharged = -999;
462  SumPtNeutral = -999;
463  SumPtChargedPU = -999;
464  SumPt = -999;
465
466  ClusterIndex = -1;
467  ClusterNDF = -99;
468  ClusterSigma = 0.0;
469  SumPT2 = 0.0;
470  BTVSumPT2 = 0.0;
471  GenDeltaZ = 0.0;
472  GenSumPT2 = 0.0;
473
474  FracPt[0] = 0.0;
475  FracPt[1] = 0.0;
476  FracPt[2] = 0.0;
477  FracPt[3] = 0.0;
478  FracPt[4] = 0.0;
479  Tau[0] = 0.0;
480  Tau[1] = 0.0;
481  Tau[2] = 0.0;
482  Tau[3] = 0.0;
483  Tau[4] = 0.0;
484
485  SoftDroppedJet.SetXYZT(0.0, 0.0, 0.0, 0.0);
486  SoftDroppedSubJet1.SetXYZT(0.0, 0.0, 0.0, 0.0);
487  SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
488
489  for(i = 0; i < 5; ++i)
490  {
491    TrimmedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
492    PrunedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
493    SoftDroppedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
494  }
495
496  NSubJetsTrimmed = 0;
497  NSubJetsPruned = 0;
498  NSubJetsSoftDropped = 0;
499
500  fArray = 0;
501}
Note: See TracBrowser for help on using the repository browser.