Fork me on GitHub

source: git/classes/DelphesClasses.cc@ cc8716b

Last change on this file since cc8716b was cc8716b, checked in by GitHub <noreply@…>, 3 years ago

Update to handle CMS endcap muon detector showers for long-lived particles (#103)

Co-authored-by: christinaw97 <christina.wang@…>

  • Property mode set to 100644
File size: 15.2 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 XFirstHit(0), YFirstHit(0), ZFirstHit(0),
236 Nclusters(0.0),
237 dNdx(0.0),
238 TrackResolution(0),
239 NCharged(0),
240 NNeutrals(0),
241 NeutralEnergyFraction(0), // charged energy fraction
242 ChargedEnergyFraction(0), // neutral energy fraction
243 Beta(0),
244 BetaStar(0),
245 MeanSqDeltaR(0),
246 PTD(0),
247 NTimeHits(-1),
248 IsolationVar(-999),
249 IsolationVarRhoCorr(-999),
250 SumPtCharged(-999),
251 SumPtNeutral(-999),
252 SumPtChargedPU(-999),
253 SumPt(-999),
254 ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
255 NSubJetsTrimmed(0),
256 NSubJetsPruned(0),
257 NSubJetsSoftDropped(0),
258 ExclYmerge23(0),
259 ExclYmerge34(0),
260 ExclYmerge45(0),
261 ExclYmerge56(0),
262 ParticleDensity(0),
263 fFactory(0),
264 fArray(0)
265{
266 int i;
267 Edges[0] = 0.0;
268 Edges[1] = 0.0;
269 Edges[2] = 0.0;
270 Edges[3] = 0.0;
271 FracPt[0] = 0.0;
272 FracPt[1] = 0.0;
273 FracPt[2] = 0.0;
274 FracPt[3] = 0.0;
275 FracPt[4] = 0.0;
276 Tau[0] = 0.0;
277 Tau[1] = 0.0;
278 Tau[2] = 0.0;
279 Tau[3] = 0.0;
280 Tau[4] = 0.0;
281
282 SoftDroppedJet.SetXYZT(0.0, 0.0, 0.0, 0.0);
283 SoftDroppedSubJet1.SetXYZT(0.0, 0.0, 0.0, 0.0);
284 SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
285
286 for(i = 0; i < 5; ++i)
287 {
288 TrimmedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
289 PrunedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
290 SoftDroppedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
291 }
292}
293
294//------------------------------------------------------------------------------
295
296void Candidate::AddCandidate(Candidate *object)
297{
298 if(!fArray) fArray = fFactory->NewArray();
299 fArray->Add(object);
300}
301
302//------------------------------------------------------------------------------
303
304TObjArray *Candidate::GetCandidates()
305{
306 if(!fArray) fArray = fFactory->NewArray();
307 return fArray;
308}
309
310//------------------------------------------------------------------------------
311
312Bool_t Candidate::Overlaps(const Candidate *object) const
313{
314 const Candidate *candidate;
315
316 if(object->GetUniqueID() == GetUniqueID()) return kTRUE;
317
318 if(fArray)
319 {
320 TIter it(fArray);
321 while((candidate = static_cast<Candidate *>(it.Next())))
322 {
323 if(candidate->Overlaps(object)) return kTRUE;
324 }
325 }
326
327 if(object->fArray)
328 {
329 TIter it(object->fArray);
330 while((candidate = static_cast<Candidate *>(it.Next())))
331 {
332 if(candidate->Overlaps(this)) return kTRUE;
333 }
334 }
335
336 return kFALSE;
337}
338
339//------------------------------------------------------------------------------
340
341TObject *Candidate::Clone(const char *newname) const
342{
343 Candidate *object = fFactory->NewCandidate();
344 Copy(*object);
345 return object;
346}
347
348//------------------------------------------------------------------------------
349
350void Candidate::Copy(TObject &obj) const
351{
352 Candidate &object = static_cast<Candidate &>(obj);
353 Candidate *candidate;
354
355 object.PID = PID;
356 object.Status = Status;
357 object.M1 = M1;
358 object.M2 = M2;
359 object.D1 = D1;
360 object.D2 = D2;
361 object.Charge = Charge;
362 object.Mass = Mass;
363 object.IsPU = IsPU;
364 object.IsRecoPU = IsRecoPU;
365 object.IsConstituent = IsConstituent;
366 object.IsFromConversion = IsFromConversion;
367 object.ClusterIndex = ClusterIndex;
368 object.ClusterNDF = ClusterNDF;
369 object.ClusterSigma = ClusterSigma;
370 object.SumPT2 = SumPT2;
371 object.BTVSumPT2 = BTVSumPT2;
372 object.GenDeltaZ = GenDeltaZ;
373 object.GenSumPT2 = GenSumPT2;
374 object.Flavor = Flavor;
375 object.FlavorAlgo = FlavorAlgo;
376 object.FlavorPhys = FlavorPhys;
377 object.BTag = BTag;
378 object.BTagAlgo = BTagAlgo;
379 object.BTagPhys = BTagPhys;
380 object.TauTag = TauTag;
381 object.TauWeight = TauWeight;
382 object.Eem = Eem;
383 object.Ehad = Ehad;
384 object.Etrk = Etrk;
385 object.Edges[0] = Edges[0];
386 object.Edges[1] = Edges[1];
387 object.Edges[2] = Edges[2];
388 object.Edges[3] = Edges[3];
389 object.DeltaEta = DeltaEta;
390 object.DeltaPhi = DeltaPhi;
391 object.Momentum = Momentum;
392 object.Position = Position;
393 object.InitialPosition = InitialPosition;
394 object.DecayPosition = DecayPosition;
395 object.PositionError = PositionError;
396 object.Area = Area;
397 object.L = L;
398 object.ErrorT = ErrorT;
399 object.D0 = D0;
400 object.ErrorD0 = ErrorD0;
401 object.DZ = DZ;
402 object.ErrorDZ = ErrorDZ;
403 object.P = P;
404 object.ErrorP = ErrorP;
405 object.C = C;
406 object.ErrorC = ErrorC;
407 object.PT = PT;
408 object.ErrorPT = ErrorPT;
409 object.CtgTheta = CtgTheta;
410 object.ErrorCtgTheta = ErrorCtgTheta;
411 object.Phi = Phi;
412 object.ErrorPhi = ErrorPhi;
413 object.Xd = Xd;
414 object.Yd = Yd;
415 object.Zd = Zd;
416 object.XFirstHit = XFirstHit;
417 object.YFirstHit = YFirstHit;
418 object.ZFirstHit = ZFirstHit;
419 object.Nclusters = Nclusters;
420 object.dNdx = dNdx;
421 object.TrackResolution = TrackResolution;
422 object.NCharged = NCharged;
423 object.NNeutrals = NNeutrals;
424 object.NeutralEnergyFraction = NeutralEnergyFraction;
425 object.ChargedEnergyFraction = ChargedEnergyFraction;
426 object.Beta = Beta;
427 object.BetaStar = BetaStar;
428 object.MeanSqDeltaR = MeanSqDeltaR;
429 object.PTD = PTD;
430 object.NTimeHits = NTimeHits;
431 object.IsolationVar = IsolationVar;
432 object.IsolationVarRhoCorr = IsolationVarRhoCorr;
433 object.SumPtCharged = SumPtCharged;
434 object.SumPtNeutral = SumPtNeutral;
435 object.SumPtChargedPU = SumPtChargedPU;
436 object.SumPt = SumPt;
437 object.ClusterIndex = ClusterIndex;
438 object.ClusterNDF = ClusterNDF;
439 object.ClusterSigma = ClusterSigma;
440 object.SumPT2 = SumPT2;
441
442 object.FracPt[0] = FracPt[0];
443 object.FracPt[1] = FracPt[1];
444 object.FracPt[2] = FracPt[2];
445 object.FracPt[3] = FracPt[3];
446 object.FracPt[4] = FracPt[4];
447 object.Tau[0] = Tau[0];
448 object.Tau[1] = Tau[1];
449 object.Tau[2] = Tau[2];
450 object.Tau[3] = Tau[3];
451 object.Tau[4] = Tau[4];
452
453 object.TrimmedP4[0] = TrimmedP4[0];
454 object.TrimmedP4[1] = TrimmedP4[1];
455 object.TrimmedP4[2] = TrimmedP4[2];
456 object.TrimmedP4[3] = TrimmedP4[3];
457 object.TrimmedP4[4] = TrimmedP4[4];
458 object.PrunedP4[0] = PrunedP4[0];
459 object.PrunedP4[1] = PrunedP4[1];
460 object.PrunedP4[2] = PrunedP4[2];
461 object.PrunedP4[3] = PrunedP4[3];
462 object.PrunedP4[4] = PrunedP4[4];
463 object.SoftDroppedP4[0] = SoftDroppedP4[0];
464 object.SoftDroppedP4[1] = SoftDroppedP4[1];
465 object.SoftDroppedP4[2] = SoftDroppedP4[2];
466 object.SoftDroppedP4[3] = SoftDroppedP4[3];
467 object.SoftDroppedP4[4] = SoftDroppedP4[4];
468
469 object.NSubJetsTrimmed = NSubJetsTrimmed;
470 object.NSubJetsPruned = NSubJetsPruned;
471 object.NSubJetsSoftDropped = NSubJetsSoftDropped;
472
473 object.SoftDroppedJet = SoftDroppedJet;
474 object.SoftDroppedSubJet1 = SoftDroppedSubJet1;
475 object.SoftDroppedSubJet2 = SoftDroppedSubJet2;
476 object.TrackCovariance = TrackCovariance;
477 object.fFactory = fFactory;
478 object.fArray = 0;
479
480 // copy cluster timing info
481 copy(ECalEnergyTimePairs.begin(), ECalEnergyTimePairs.end(), back_inserter(object.ECalEnergyTimePairs));
482
483 if(fArray && fArray->GetEntriesFast() > 0)
484 {
485 TIter itArray(fArray);
486 TObjArray *array = object.GetCandidates();
487 while((candidate = static_cast<Candidate *>(itArray.Next())))
488 {
489 array->Add(candidate);
490 }
491 }
492}
493
494//------------------------------------------------------------------------------
495
496void Candidate::Clear(Option_t *option)
497{
498 int i;
499 SetUniqueID(0);
500 ResetBit(kIsReferenced);
501 PID = 0;
502 Status = 0;
503 M1 = -1;
504 M2 = -1;
505 D1 = -1;
506 D2 = -1;
507 Charge = 0;
508 Mass = 0.0;
509 IsPU = 0;
510 IsRecoPU = 0;
511 IsConstituent = 0;
512 IsFromConversion = 0;
513 Flavor = 0;
514 FlavorAlgo = 0;
515 FlavorPhys = 0;
516 BTag = 0;
517 BTagAlgo = 0;
518 BTagPhys = 0;
519 TauTag = 0;
520 TauWeight = 0.0;
521 Eem = 0.0;
522 Ehad = 0.0;
523 Etrk = 0.0;
524 Edges[0] = 0.0;
525 Edges[1] = 0.0;
526 Edges[2] = 0.0;
527 Edges[3] = 0.0;
528 DeltaEta = 0.0;
529 DeltaPhi = 0.0;
530 Momentum.SetXYZT(0.0, 0.0, 0.0, 0.0);
531 Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
532 InitialPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
533 DecayPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
534 Area.SetXYZT(0.0, 0.0, 0.0, 0.0);
535 TrackCovariance.Zero();
536 L = 0.0;
537 ErrorT = 0.0;
538 D0 = 0.0;
539 ErrorD0 = 0.0;
540 DZ = 0.0;
541 ErrorDZ = 0.0;
542 P = 0.0;
543 ErrorP = 0.0;
544 C = 0.0;
545 ErrorC = 0.0;
546 PT = 0.0;
547 ErrorPT = 0.0;
548 CtgTheta = 0.0;
549 ErrorCtgTheta = 0.0;
550 Phi = 0.0;
551 ErrorPhi = 0.0;
552 Xd = 0.0;
553 Yd = 0.0;
554 Zd = 0.0;
555 XFirstHit = 0.0;
556 YFirstHit = 0.0;
557 ZFirstHit = 0.0;
558 Nclusters = 0.0;
559 dNdx = 0.0;
560 TrackResolution = 0.0;
561 NCharged = 0;
562 NNeutrals = 0;
563 Beta = 0.0;
564 BetaStar = 0.0;
565 MeanSqDeltaR = 0.0;
566 PTD = 0.0;
567
568 NTimeHits = 0;
569 ECalEnergyTimePairs.clear();
570
571 IsolationVar = -999;
572 IsolationVarRhoCorr = -999;
573 SumPtCharged = -999;
574 SumPtNeutral = -999;
575 SumPtChargedPU = -999;
576 SumPt = -999;
577
578 ClusterIndex = -1;
579 ClusterNDF = -99;
580 ClusterSigma = 0.0;
581 SumPT2 = 0.0;
582 BTVSumPT2 = 0.0;
583 GenDeltaZ = 0.0;
584 GenSumPT2 = 0.0;
585
586 FracPt[0] = 0.0;
587 FracPt[1] = 0.0;
588 FracPt[2] = 0.0;
589 FracPt[3] = 0.0;
590 FracPt[4] = 0.0;
591 Tau[0] = 0.0;
592 Tau[1] = 0.0;
593 Tau[2] = 0.0;
594 Tau[3] = 0.0;
595 Tau[4] = 0.0;
596
597 SoftDroppedJet.SetXYZT(0.0, 0.0, 0.0, 0.0);
598 SoftDroppedSubJet1.SetXYZT(0.0, 0.0, 0.0, 0.0);
599 SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
600
601 for(i = 0; i < 5; ++i)
602 {
603 TrimmedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
604 PrunedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
605 SoftDroppedP4[i].SetXYZT(0.0, 0.0, 0.0, 0.0);
606 }
607
608 NSubJetsTrimmed = 0;
609 NSubJetsPruned = 0;
610 NSubJetsSoftDropped = 0;
611
612 fArray = 0;
613}
Note: See TracBrowser for help on using the repository browser.