Fork me on GitHub

source: git/classes/DelphesClasses.cc@ 29b722a

Last change on this file since 29b722a was d612dec, checked in by christinaw97 <christina.wang@…>, 3 years ago

Merge branch 'master' of github.com:Christinaw97/delphes into HEAD

  • Property mode set to 100644
File size: 15.0 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#include "classes/DelphesFactory.h"
31#include "classes/SortableObject.h"
32
33CompBase *GenParticle::fgCompare = 0;
34CompBase *Photon::fgCompare = CompPT<Photon>::Instance();
35CompBase *Electron::fgCompare = CompPT<Electron>::Instance();
36CompBase *Muon::fgCompare = CompPT<Muon>::Instance();
37
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();
45CompBase *CscCluster::fgCompare = CompE<CscCluster>::Instance();
46
47//------------------------------------------------------------------------------
48
49TLorentzVector GenParticle::P4() const
50{
51 TLorentzVector vec;
52 vec.SetPxPyPzE(Px, Py, Pz, E);
53 return vec;
54}
55
56//------------------------------------------------------------------------------
57
58TLorentzVector MissingET::P4() const
59{
60 TLorentzVector vec;
61 vec.SetPtEtaPhiM(MET, Eta, Phi, 0.0);
62 return vec;
63}
64
65//------------------------------------------------------------------------------
66
67TLorentzVector Photon::P4() const
68{
69 TLorentzVector vec;
70 vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
71 return vec;
72}
73
74//------------------------------------------------------------------------------
75
76TLorentzVector Electron::P4() const
77{
78 TLorentzVector vec;
79 vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
80 return vec;
81}
82
83//------------------------------------------------------------------------------
84
85TLorentzVector Muon::P4() const
86{
87 TLorentzVector vec;
88 vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0);
89 return vec;
90}
91
92//------------------------------------------------------------------------------
93
94TLorentzVector Jet::P4() const
95{
96 TLorentzVector vec;
97 vec.SetPtEtaPhiM(PT, Eta, Phi, Mass);
98 return vec;
99}
100
101//------------------------------------------------------------------------------
102
103TLorentzVector Track::P4() const
104{
105 TLorentzVector vec;
106 vec.SetPtEtaPhiM(PT, Eta, Phi, Mass);
107 return vec;
108}
109
110//------------------------------------------------------------------------------
111
112TMatrixDSym Track::CovarianceMatrix() const
113{
114 TMatrixDSym Cv;
115 Cv.ResizeTo(5, 5);
116
117 // convert diagonal term to original units
118 Cv(0, 0)=TMath::Power(ErrorD0, 2.);
119 Cv(1, 1)=TMath::Power(ErrorPhi, 2.);
120 Cv(2, 2)=TMath::Power(ErrorC, 2.);
121 Cv(3, 3)=TMath::Power(ErrorDZ, 2.);
122 Cv(4, 4)=TMath::Power(ErrorCtgTheta, 2.);
123
124 // off diagonal terms
125 Cv(0, 1)=ErrorD0Phi;
126 Cv(0, 2)=ErrorD0C;
127 Cv(0, 3)=ErrorD0DZ;
128 Cv(0, 4)=ErrorD0CtgTheta;
129 Cv(1, 2)=ErrorPhiC;
130 Cv(1, 3)=ErrorPhiDZ;
131 Cv(1, 4)=ErrorPhiCtgTheta;
132 Cv(2, 3)=ErrorCDZ;
133 Cv(2, 4)=ErrorCCtgTheta;
134 Cv(3, 4)=ErrorDZCtgTheta;
135
136 Cv(1, 0)=Cv(0, 1);
137 Cv(2, 0)=Cv(0, 2);
138 Cv(3, 0)=Cv(0, 3);
139 Cv(4, 0)=Cv(0, 4);
140 Cv(2, 1)=Cv(1, 2);
141 Cv(3, 1)=Cv(1, 3);
142 Cv(4, 1)=Cv(1, 4);
143 Cv(3, 2)=Cv(2, 3);
144 Cv(4, 2)=Cv(2, 4);
145 Cv(4, 3)=Cv(3, 4);
146
147 return Cv;
148}
149
150
151//------------------------------------------------------------------------------
152
153TLorentzVector Tower::P4() const
154{
155 TLorentzVector vec;
156 vec.SetPtEtaPhiM(ET, Eta, Phi, 0.0);
157 return vec;
158}
159
160//------------------------------------------------------------------------------
161
162TLorentzVector ParticleFlowCandidate::P4() const
163{
164 TLorentzVector vec;
165 vec.SetPtEtaPhiM(PT, Eta, Phi, Mass);
166 return vec;
167}
168
169//------------------------------------------------------------------------------
170
171TMatrixDSym ParticleFlowCandidate::CovarianceMatrix() const
172{
173 TMatrixDSym Cv;
174 Cv.ResizeTo(5, 5);
175
176 // convert diagonal term to original units
177 Cv(0, 0)=TMath::Power(ErrorD0, 2.);
178 Cv(1, 1)=TMath::Power(ErrorPhi, 2.);
179 Cv(2, 2)=TMath::Power(ErrorC, 2.);
180 Cv(3, 3)=TMath::Power(ErrorDZ, 2.);
181 Cv(4, 4)=TMath::Power(ErrorCtgTheta, 2.);
182
183 // off diagonal terms
184 Cv(0, 1)=ErrorD0Phi;
185 Cv(0, 2)=ErrorD0C;
186 Cv(0, 3)=ErrorD0DZ;
187 Cv(0, 4)=ErrorD0CtgTheta;
188 Cv(1, 2)=ErrorPhiC;
189 Cv(1, 3)=ErrorPhiDZ;
190 Cv(1, 4)=ErrorPhiCtgTheta;
191 Cv(2, 3)=ErrorCDZ;
192 Cv(2, 4)=ErrorCCtgTheta;
193 Cv(3, 4)=ErrorDZCtgTheta;
194
195 Cv(1, 0)=Cv(0, 1);
196 Cv(2, 0)=Cv(0, 2);
197 Cv(3, 0)=Cv(0, 3);
198 Cv(4, 0)=Cv(0, 4);
199 Cv(2, 1)=Cv(1, 2);
200 Cv(3, 1)=Cv(1, 3);
201 Cv(4, 1)=Cv(1, 4);
202 Cv(3, 2)=Cv(2, 3);
203 Cv(4, 2)=Cv(2, 4);
204 Cv(4, 3)=Cv(3, 4);
205
206 return Cv;
207}
208
209//------------------------------------------------------------------------------
210
211Candidate::Candidate() :
212 PID(0), Status(0), M1(-1), M2(-1), D1(-1), D2(-1),
213 Charge(0), Mass(0.0),
214 IsPU(0), IsRecoPU(0), IsConstituent(0), IsFromConversion(0),
215 Flavor(0), FlavorAlgo(0), FlavorPhys(0),
216 BTag(0), BTagAlgo(0), BTagPhys(0),
217 TauTag(0), TauWeight(0.0), Eem(0.0), Ehad(0.0), Etrk(0.0),
218 DeltaEta(0.0), DeltaPhi(0.0),
219 Momentum(0.0, 0.0, 0.0, 0.0),
220 Position(0.0, 0.0, 0.0, 0.0),
221 InitialPosition(0.0, 0.0, 0.0, 0.0),
222 DecayPosition(0.0, 0.0, 0.0, 0.0),
223 PositionError(0.0, 0.0, 0.0, 0.0),
224 Area(0.0, 0.0, 0.0, 0.0),
225 TrackCovariance(5),
226 L(0),
227 D0(0), ErrorD0(0),
228 DZ(0), ErrorDZ(0),
229 P(0), ErrorP(0),
230 C(0), ErrorC(0),
231 PT(0), ErrorPT(0),
232 CtgTheta(0), ErrorCtgTheta(0),
233 Phi(0), ErrorPhi(0),
234 Xd(0), Yd(0), Zd(0),
235 Nclusters(0.0),
236 dNdx(0.0),
237 TrackResolution(0),
238 NCharged(0),
239 NNeutrals(0),
240 NeutralEnergyFraction(0), // charged energy fraction
241 ChargedEnergyFraction(0), // neutral energy fraction
242 Beta(0),
243 BetaStar(0),
244 MeanSqDeltaR(0),
245 PTD(0),
246 NTimeHits(-1),
247 IsolationVar(-999),
248 IsolationVarRhoCorr(-999),
249 SumPtCharged(-999),
250 SumPtNeutral(-999),
251 SumPtChargedPU(-999),
252 SumPt(-999),
253 ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
254 NSubJetsTrimmed(0),
255 NSubJetsPruned(0),
256 NSubJetsSoftDropped(0),
257 ExclYmerge23(0),
258 ExclYmerge34(0),
259 ExclYmerge45(0),
260 ExclYmerge56(0),
261 ParticleDensity(0),
262 fFactory(0),
263 fArray(0)
264{
265 int i;
266 Edges[0] = 0.0;
267 Edges[1] = 0.0;
268 Edges[2] = 0.0;
269 Edges[3] = 0.0;
270 FracPt[0] = 0.0;
271 FracPt[1] = 0.0;
272 FracPt[2] = 0.0;
273 FracPt[3] = 0.0;
274 FracPt[4] = 0.0;
275 Tau[0] = 0.0;
276 Tau[1] = 0.0;
277 Tau[2] = 0.0;
278 Tau[3] = 0.0;
279 Tau[4] = 0.0;
280
281 SoftDroppedJet.SetXYZT(0.0, 0.0, 0.0, 0.0);
282 SoftDroppedSubJet1.SetXYZT(0.0, 0.0, 0.0, 0.0);
283 SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
284
285 for(i = 0; i < 5; ++i)
286 {
287 TrimmedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
288 PrunedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
289 SoftDroppedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
290 }
291}
292
293//------------------------------------------------------------------------------
294
295void Candidate::AddCandidate(Candidate *object)
296{
297 if(!fArray) fArray = fFactory->NewArray();
298 fArray->Add(object);
299}
300
301//------------------------------------------------------------------------------
302
303TObjArray *Candidate::GetCandidates()
304{
305 if(!fArray) fArray = fFactory->NewArray();
306 return fArray;
307}
308
309//------------------------------------------------------------------------------
310
311Bool_t Candidate::Overlaps(const Candidate *object) const
312{
313 const Candidate *candidate;
314
315 if(object->GetUniqueID() == GetUniqueID()) return kTRUE;
316
317 if(fArray)
318 {
319 TIter it(fArray);
320 while((candidate = static_cast<Candidate *>(it.Next())))
321 {
322 if(candidate->Overlaps(object)) return kTRUE;
323 }
324 }
325
326 if(object->fArray)
327 {
328 TIter it(object->fArray);
329 while((candidate = static_cast<Candidate *>(it.Next())))
330 {
331 if(candidate->Overlaps(this)) return kTRUE;
332 }
333 }
334
335 return kFALSE;
336}
337
338//------------------------------------------------------------------------------
339
340TObject *Candidate::Clone(const char *newname) const
341{
342 Candidate *object = fFactory->NewCandidate();
343 Copy(*object);
344 return object;
345}
346
347//------------------------------------------------------------------------------
348
349void Candidate::Copy(TObject &obj) const
350{
351 Candidate &object = static_cast<Candidate &>(obj);
352 Candidate *candidate;
353
354 object.PID = PID;
355 object.Status = Status;
356 object.M1 = M1;
357 object.M2 = M2;
358 object.D1 = D1;
359 object.D2 = D2;
360 object.Charge = Charge;
361 object.Mass = Mass;
362 object.IsPU = IsPU;
363 object.IsRecoPU = IsRecoPU;
364 object.IsConstituent = IsConstituent;
365 object.IsFromConversion = IsFromConversion;
366 object.ClusterIndex = ClusterIndex;
367 object.ClusterNDF = ClusterNDF;
368 object.ClusterSigma = ClusterSigma;
369 object.SumPT2 = SumPT2;
370 object.BTVSumPT2 = BTVSumPT2;
371 object.GenDeltaZ = GenDeltaZ;
372 object.GenSumPT2 = GenSumPT2;
373 object.Flavor = Flavor;
374 object.FlavorAlgo = FlavorAlgo;
375 object.FlavorPhys = FlavorPhys;
376 object.BTag = BTag;
377 object.BTagAlgo = BTagAlgo;
378 object.BTagPhys = BTagPhys;
379 object.TauTag = TauTag;
380 object.TauWeight = TauWeight;
381 object.Eem = Eem;
382 object.Ehad = Ehad;
383 object.Etrk = Etrk;
384 object.Edges[0] = Edges[0];
385 object.Edges[1] = Edges[1];
386 object.Edges[2] = Edges[2];
387 object.Edges[3] = Edges[3];
388 object.DeltaEta = DeltaEta;
389 object.DeltaPhi = DeltaPhi;
390 object.Momentum = Momentum;
391 object.Position = Position;
392 object.InitialPosition = InitialPosition;
393 object.DecayPosition = DecayPosition;
394 object.PositionError = PositionError;
395 object.Area = Area;
396 object.L = L;
397 object.ErrorT = ErrorT;
398 object.D0 = D0;
399 object.ErrorD0 = ErrorD0;
400 object.DZ = DZ;
401 object.ErrorDZ = ErrorDZ;
402 object.P = P;
403 object.ErrorP = ErrorP;
404 object.C = C;
405 object.ErrorC = ErrorC;
406 object.PT = PT;
407 object.ErrorPT = ErrorPT;
408 object.CtgTheta = CtgTheta;
409 object.ErrorCtgTheta = ErrorCtgTheta;
410 object.Phi = Phi;
411 object.ErrorPhi = ErrorPhi;
412 object.Xd = Xd;
413 object.Yd = Yd;
414 object.Zd = Zd;
415 object.Nclusters = Nclusters;
416 object.dNdx = dNdx;
417 object.TrackResolution = TrackResolution;
418 object.NCharged = NCharged;
419 object.NNeutrals = NNeutrals;
420 object.NeutralEnergyFraction = NeutralEnergyFraction;
421 object.ChargedEnergyFraction = ChargedEnergyFraction;
422 object.Beta = Beta;
423 object.BetaStar = BetaStar;
424 object.MeanSqDeltaR = MeanSqDeltaR;
425 object.PTD = PTD;
426 object.NTimeHits = NTimeHits;
427 object.IsolationVar = IsolationVar;
428 object.IsolationVarRhoCorr = IsolationVarRhoCorr;
429 object.SumPtCharged = SumPtCharged;
430 object.SumPtNeutral = SumPtNeutral;
431 object.SumPtChargedPU = SumPtChargedPU;
432 object.SumPt = SumPt;
433 object.ClusterIndex = ClusterIndex;
434 object.ClusterNDF = ClusterNDF;
435 object.ClusterSigma = ClusterSigma;
436 object.SumPT2 = SumPT2;
437
438 object.FracPt[0] = FracPt[0];
439 object.FracPt[1] = FracPt[1];
440 object.FracPt[2] = FracPt[2];
441 object.FracPt[3] = FracPt[3];
442 object.FracPt[4] = FracPt[4];
443 object.Tau[0] = Tau[0];
444 object.Tau[1] = Tau[1];
445 object.Tau[2] = Tau[2];
446 object.Tau[3] = Tau[3];
447 object.Tau[4] = Tau[4];
448
449 object.TrimmedP4[0] = TrimmedP4[0];
450 object.TrimmedP4[1] = TrimmedP4[1];
451 object.TrimmedP4[2] = TrimmedP4[2];
452 object.TrimmedP4[3] = TrimmedP4[3];
453 object.TrimmedP4[4] = TrimmedP4[4];
454 object.PrunedP4[0] = PrunedP4[0];
455 object.PrunedP4[1] = PrunedP4[1];
456 object.PrunedP4[2] = PrunedP4[2];
457 object.PrunedP4[3] = PrunedP4[3];
458 object.PrunedP4[4] = PrunedP4[4];
459 object.SoftDroppedP4[0] = SoftDroppedP4[0];
460 object.SoftDroppedP4[1] = SoftDroppedP4[1];
461 object.SoftDroppedP4[2] = SoftDroppedP4[2];
462 object.SoftDroppedP4[3] = SoftDroppedP4[3];
463 object.SoftDroppedP4[4] = SoftDroppedP4[4];
464
465 object.NSubJetsTrimmed = NSubJetsTrimmed;
466 object.NSubJetsPruned = NSubJetsPruned;
467 object.NSubJetsSoftDropped = NSubJetsSoftDropped;
468
469 object.SoftDroppedJet = SoftDroppedJet;
470 object.SoftDroppedSubJet1 = SoftDroppedSubJet1;
471 object.SoftDroppedSubJet2 = SoftDroppedSubJet2;
472 object.TrackCovariance = TrackCovariance;
473 object.fFactory = fFactory;
474 object.fArray = 0;
475
476 // copy cluster timing info
477 copy(ECalEnergyTimePairs.begin(), ECalEnergyTimePairs.end(), back_inserter(object.ECalEnergyTimePairs));
478
479 if(fArray && fArray->GetEntriesFast() > 0)
480 {
481 TIter itArray(fArray);
482 TObjArray *array = object.GetCandidates();
483 while((candidate = static_cast<Candidate *>(itArray.Next())))
484 {
485 array->Add(candidate);
486 }
487 }
488}
489
490//------------------------------------------------------------------------------
491
492void Candidate::Clear(Option_t *option)
493{
494 int i;
495 SetUniqueID(0);
496 ResetBit(kIsReferenced);
497 PID = 0;
498 Status = 0;
499 M1 = -1;
500 M2 = -1;
501 D1 = -1;
502 D2 = -1;
503 Charge = 0;
504 Mass = 0.0;
505 IsPU = 0;
506 IsRecoPU = 0;
507 IsConstituent = 0;
508 IsFromConversion = 0;
509 Flavor = 0;
510 FlavorAlgo = 0;
511 FlavorPhys = 0;
512 BTag = 0;
513 BTagAlgo = 0;
514 BTagPhys = 0;
515 TauTag = 0;
516 TauWeight = 0.0;
517 Eem = 0.0;
518 Ehad = 0.0;
519 Etrk = 0.0;
520 Edges[0] = 0.0;
521 Edges[1] = 0.0;
522 Edges[2] = 0.0;
523 Edges[3] = 0.0;
524 DeltaEta = 0.0;
525 DeltaPhi = 0.0;
526 Momentum.SetXYZT(0.0, 0.0, 0.0, 0.0);
527 Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
528 InitialPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
529 DecayPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
530 Area.SetXYZT(0.0, 0.0, 0.0, 0.0);
531 TrackCovariance.Zero();
532 L = 0.0;
533 ErrorT = 0.0;
534 D0 = 0.0;
535 ErrorD0 = 0.0;
536 DZ = 0.0;
537 ErrorDZ = 0.0;
538 P = 0.0;
539 ErrorP = 0.0;
540 C = 0.0;
541 ErrorC = 0.0;
542 PT = 0.0;
543 ErrorPT = 0.0;
544 CtgTheta = 0.0;
545 ErrorCtgTheta = 0.0;
546 Phi = 0.0;
547 ErrorPhi = 0.0;
548 Xd = 0.0;
549 Yd = 0.0;
550 Zd = 0.0;
551 Nclusters = 0.0;
552 dNdx = 0.0;
553 TrackResolution = 0.0;
554 NCharged = 0;
555 NNeutrals = 0;
556 Beta = 0.0;
557 BetaStar = 0.0;
558 MeanSqDeltaR = 0.0;
559 PTD = 0.0;
560
561 NTimeHits = 0;
562 ECalEnergyTimePairs.clear();
563
564 IsolationVar = -999;
565 IsolationVarRhoCorr = -999;
566 SumPtCharged = -999;
567 SumPtNeutral = -999;
568 SumPtChargedPU = -999;
569 SumPt = -999;
570
571 ClusterIndex = -1;
572 ClusterNDF = -99;
573 ClusterSigma = 0.0;
574 SumPT2 = 0.0;
575 BTVSumPT2 = 0.0;
576 GenDeltaZ = 0.0;
577 GenSumPT2 = 0.0;
578
579 FracPt[0] = 0.0;
580 FracPt[1] = 0.0;
581 FracPt[2] = 0.0;
582 FracPt[3] = 0.0;
583 FracPt[4] = 0.0;
584 Tau[0] = 0.0;
585 Tau[1] = 0.0;
586 Tau[2] = 0.0;
587 Tau[3] = 0.0;
588 Tau[4] = 0.0;
589
590 SoftDroppedJet.SetXYZT(0.0, 0.0, 0.0, 0.0);
591 SoftDroppedSubJet1.SetXYZT(0.0, 0.0, 0.0, 0.0);
592 SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
593
594 for(i = 0; i < 5; ++i)
595 {
596 TrimmedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
597 PrunedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
598 SoftDroppedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
599 }
600
601 NSubJetsTrimmed = 0;
602 NSubJetsPruned = 0;
603 NSubJetsSoftDropped = 0;
604
605 fArray = 0;
606}
Note: See TracBrowser for help on using the repository browser.