ATLAS Offline Software
Loading...
Searching...
No Matches
PFO_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
7#include "AthLinks/ElementLink.h"
8
9
10// Local include(s):
13
14namespace xAOD {
15
18 switch (type){
20 const static SG::AuxElement::Accessor<std::vector<ElementLink<IParticleContainer > > > acc_cc("pfo_ClusterLinks");
21 return &acc_cc;
23 const static SG::AuxElement::Accessor<std::vector<ElementLink<IParticleContainer > > > acc_tp("pfo_TrackLinks");
24 return &acc_tp;
25 // Note - clients should NEVER set both links to TauShot and HadroniCaloCluster - Tau WG agreed they NEVER will do such a thing (and they are only client)
28 const static SG::AuxElement::Accessor<std::vector<ElementLink<IParticleContainer > > > acc_ts("pfo_TauShotLinks");
29 return &acc_ts;
31 const static SG::AuxElement::Accessor<std::vector<ElementLink<IParticleContainer > > > acc_cpfo("pfo_Charged");
32 return &acc_cpfo;
34 const static SG::AuxElement::Accessor<std::vector<ElementLink<IParticleContainer > > > acc_npfo("pfo_Neutral");
35 return &acc_npfo;
38 return &acc_tt;
39 }//switch
40 return nullptr;
41 }//getAccessor
42 };
43
46
48 this->makePrivateStore(other);
49 }
50
51
52 double PFO_v1::pt() const {
53
54 const static ConstAccessor<float> accPt("pt");
55 float pt = accPt(*this);
56
57 return pt;
58 }
59
60 double PFO_v1::eta() const {
61
62 const static ConstAccessor<float> accEta("eta");
63 float eta = accEta(*this);
64 return eta;
65 }
66
67 double PFO_v1::phi() const {
68
69 const static ConstAccessor<float> accPhi("phi");
70 float phi = accPhi(*this);
71 return phi;
72 }
73
74 double PFO_v1::m() const {
75
76 const static ConstAccessor<float> accM("m");
77 float M = accM(*this);
78 return M;
79 }
80
81 double PFO_v1::e() const {
82
83 const static ConstAccessor<float> accPt("pt");
84 float pt = accPt(*this);
85
86 if (pt < 0.0) return -genvecP4().E();
87 else return genvecP4().E();
88 }
89
90 double PFO_v1::rapidity() const {
91
92 return genvecP4().Rapidity();
93 }
94
97 p4.SetPtEtaPhiM( pt(), eta(), phi(),m());
98 return p4;
99 }
100
102 return GenVecFourMom_t( pt(), eta(), phi(),m());
103 }
104
105
108
109 const static Accessor<float> accPt("pt");
110 accPt(*this) = vec.Pt();
111
112 const static Accessor<float> accEta("eta");
113 accEta(*this) = vec.Eta();
114
115 const static Accessor<float> accPhi("phi");
116 accPhi(*this) = vec.Phi();
117
118 const static Accessor<float> accM("m");
119 accM(*this) = vec.M();
120
121 }
122
124 void PFO_v1::setP4(float pt, float eta, float phi, float m) {
125
126 const static Accessor<float> accPt("pt");
127 accPt(*this) = pt;
128
129 const static Accessor<float> accEta("eta");
130 accEta(*this) = eta;
131
132 const static Accessor<float> accPhi("phi");
133 accPhi(*this) = phi;
134
135 const static Accessor<float> accM("m");
136 accM(*this) = m;
137 }
138
139
140 Type::ObjectType PFO_v1::type() const {
141 return Type::ParticleFlow;
142 }
143
145
146 if (this->isCharged()) return p4();
147
149
150 //change to use pt, eta, phi ,e
151 const static ConstAccessor<float> accPt("ptEM");
152 const static ConstAccessor<float> accEta("eta");
153 const static ConstAccessor<float> accPhi("phi");
154 const static ConstAccessor<float> accM("mEM");
155
156 p4EM.SetPtEtaPhiM(accPt(*this), accEta(*this), accPhi(*this), accM(*this));
157 return p4EM;
158 }
159
161
162 if (this->isCharged()) return genvecP4();
163
164 //change to use pt, eta, phi ,e
165 const static ConstAccessor<float> accPt("ptEM");
166 const static ConstAccessor<float> accEta("eta");
167 const static ConstAccessor<float> accPhi("phi");
168 const static ConstAccessor<float> accM("mEM");
169
170 return GenVecFourMom_t(accPt(*this), accEta(*this), accPhi(*this), accM(*this));
171 }
172
174 const static Accessor<float> accPt("ptEM");
175 accPt(*this) = p4EM.Pt();
176
177 const static Accessor<float> accEta("eta");
178 accEta(*this) = p4EM.Eta();
179
180 const static Accessor<float> accPhi("phi");
181 accPhi(*this) = p4EM.Phi();
182
183 const static Accessor<float> accM("mEM");
184 accM(*this) = p4EM.M();
185
186 }
187
188 void PFO_v1::setP4EM(float pt, float eta, float phi, float m) {
189
190 const static Accessor<float> accPt("ptEM");
191 accPt(*this) = pt;
192
193 const static Accessor<float> accEta("eta");
194 accEta(*this) = eta;
195
196 const static Accessor<float> accPhi("phi");
197 accPhi(*this) = phi;
198
199 const static Accessor<float> accM("mEM");
200 accM(*this) = m;
201
202 }
203
204 double PFO_v1::ptEM() const {
205
206 if (this->isCharged()) return this->pt();
207
208 const static ConstAccessor<float> accPt("ptEM");
209 float pt = accPt(*this);
210
211 return pt;
212 }
213
214 // JM: this seem to be idetical to eta(), right?
215 double PFO_v1::etaEM() const {
216 return eta();
217 }
218
219 // JM: this seem to be idetical to phi(), right?
220 double PFO_v1::phiEM() const {
221 return phi();
222 }
223
224 double PFO_v1::mEM() const {
225
226 if (this->isCharged()) return this->m();
227 const static ConstAccessor<float> accM("mEM");
228 float M = accM(*this);
229
230 return M;
231 }
232
233 double PFO_v1::eEM() const {
234
235 if (this->isCharged()) return this->e();
236
237 const static ConstAccessor<float> accPt("ptEM");
238 float pt = accPt(*this);
239
240 if (pt < 0.0) return -p4EM().E();
241 else return p4EM().E();
242 }
243
244
245 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(PFO_v1, float, bdtPi0Score, setBDTPi0Score)
246 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(PFO_v1, float, centerMag, setCenterMag)
248
249 // Define function to avoid issues due to numeric precision when comparing pFO charge to zero
250 // Discussed in https://its.cern.ch/jira/browse/ATLJETMET-796
252 return (fabs(this->charge())>1e-6);
253 }
254
256
257 template<> void PFO_v1::setAttribute(const std::string& AttributeType, const xAOD::PFODetails::PFOLeptonType& anAttribute){
258 uint16_t uint16_variable = static_cast<uint16_t>(anAttribute);
259 this->setAttribute<uint16_t>(AttributeType, uint16_variable);
260 }
261
262 template<> bool PFO_v1::attribute(const std::string& AttributeType, xAOD::PFODetails::PFOLeptonType& anAttribute) const {
263 bool isValid = false;
264 uint16_t internalAttribute;
265 isValid = attribute<uint16_t>(AttributeType,internalAttribute);
266 if (!isValid) return false;
267 else{
268 anAttribute = static_cast<xAOD::PFODetails::PFOLeptonType>(internalAttribute);
269 return true;
270 }
271
272 }
273
274 template<> void PFO_v1::setAttribute(PFODetails::PFOAttributes AttributeType, const float& anAttribute) {
275 if (this->isJetETMissFloatForCompression(AttributeType)){
276 float dummy = anAttribute*s_floatCompressionFactor;
277 const static int maxIntSize = 1000000000;
278 int internalAttribute = maxIntSize;
279 if (dummy < 0) internalAttribute *= -1;//if we had a large -ve energy, then we should set the max size to a -ve value
280 if (dummy < maxIntSize && dummy > -maxIntSize) internalAttribute = static_cast<int>(dummy);
281 setAttribute<int>(AttributeType, internalAttribute);
282 }
283 else {
284 float internalAttribute = anAttribute;
285 (*(PFOAttributesAccessor_v1<float>::constAccessor(AttributeType)))(*this) = internalAttribute;
286 }
287 }
288
289 template<> bool PFO_v1::attribute(PFODetails::PFOAttributes AttributeType, float& anAttribute) const {
290 bool isValid = false;
291 if (this->isJetETMissFloatForCompression(AttributeType)){
292 int internalAttribute;
293 isValid = attribute<int>(AttributeType,internalAttribute);
294 if (isValid && 0 != internalAttribute) anAttribute = static_cast<float>(internalAttribute)/s_floatCompressionFactor;
295 else anAttribute = 0.0;
296 return isValid;
297 }
298 else{
300 //check if accessor pointer is NULL
301 if( ! p_acc ) { return false ;}
302 //check if variable is avaialable
303 if( ! p_acc->isAvailable( *this ) ) return false;
304 //set variable and return true
305 anAttribute =( *p_acc )( *this );
306 return true;
307
308 }
309 return isValid;
310 }
311
313 switch (AttributeType) {
314 case PFODetails::PFOAttributes::eflowRec_LATERAL:
315 case PFODetails::PFOAttributes::eflowRec_LONGITUDINAL:
316 case PFODetails::PFOAttributes::eflowRec_SECOND_R:
317 case PFODetails::PFOAttributes::eflowRec_CENTER_LAMBDA:
318 case PFODetails::PFOAttributes::eflowRec_FIRST_ENG_DENS:
319 case PFODetails::PFOAttributes::eflowRec_ENG_FRAC_MAX:
320 case PFODetails::PFOAttributes::eflowRec_ISOLATION:
321 case PFODetails::PFOAttributes::eflowRec_ENG_BAD_CELLS:
322 case PFODetails::PFOAttributes::eflowRec_N_BAD_CELLS:
323 case PFODetails::PFOAttributes::eflowRec_BADLARQ_FRAC:
324 case PFODetails::PFOAttributes::eflowRec_ENG_POS:
325 case PFODetails::PFOAttributes::eflowRec_SIGNIFICANCE:
326 case PFODetails::PFOAttributes::eflowRec_AVG_LAR_Q:
327 case PFODetails::PFOAttributes::eflowRec_AVG_TILE_Q:
328 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EM:
329 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EM3:
330 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC0:
331 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC:
332 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_Tile0:
333 case PFODetails::PFOAttributes::eflowRec_TIMING:
334 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_PreSamplerB:
335 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EMB1:
336 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EMB2:
337 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EMB3:
338 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_PreSamplerE:
339 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EME1:
340 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EME2:
341 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EME3:
342 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC1:
343 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC2:
344 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC3:
345 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileBar0:
346 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileBar1:
347 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileBar2:
348 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileGap1:
349 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileGap2:
350 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileGap3:
351 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileExt0:
352 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileExt1:
353 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileExt2:
354 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_FCAL0:
355 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_FCAL1:
356 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_FCAL2:
357 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL0:
358 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL1:
359 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL2:
360 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL3:
361 return true;
362 default:
363 return false;
364 }
365 }
366
367
369
370
371
372 template<> void PFO_v1::setAttribute(PFODetails::PFOAttributes AttributeType, const double& anAttribute) {
373 float internalAttribute = static_cast<float>(anAttribute);
374 setAttribute<float>(AttributeType, internalAttribute);
375 }
376
377 template<> bool PFO_v1::attribute(PFODetails::PFOAttributes AttributeType, double& anAttribute) const {
378
379 float internalAttribute;
380 bool isValid = attribute<float>(AttributeType,internalAttribute);
381 if (isValid) anAttribute = static_cast<double>(internalAttribute);
382 return isValid;
383
384 }
385
386 template<> void PFO_v1::setAttribute(const std::string& AttributeType, const double& anAttribute) {
387
388 float internalAttribute = static_cast<float>(anAttribute);
389 setAttribute<float>(AttributeType, internalAttribute);
390
391 }
392
393 template<> bool PFO_v1::attribute(const std::string& AttributeType, double& anAttribute) const {
394
395 float internalAttribute;
396 bool isValid = attribute<float>(AttributeType,internalAttribute);
397 if (isValid) anAttribute = static_cast<float>(internalAttribute);
398 return isValid;
399
400 }
401
402 bool PFO_v1::getClusterMoment(float& theMoment, xAOD::CaloCluster::MomentType momentType) const {
403
404 const xAOD::CaloCluster *theCluster = this->cluster(0);
405
406 double myMoment = -99.0;
407
408 if (theCluster){
409 bool gotMoment = theCluster->retrieveMoment( momentType, myMoment);
410 //if cluster does not have the moment, check if the PFO stored it - this can happen due to the way we redirect the ElementLinks to clusters in PFONeutralCreatorAlgorithm
411 if (!gotMoment) return getClusterMomentFromPFO(theMoment,momentType);
412 else if (gotMoment) {
413 theMoment = static_cast<float>(myMoment);
414 return true;
415 }
416 }
417 else return getClusterMomentFromPFO(theMoment,momentType);
418
419 return false;
420
421 }
422
423 bool PFO_v1::getClusterMomentFromPFO(float& theMoment, xAOD::CaloCluster::MomentType momentType) const{
425 bool haveGotAttributeInMap = this->getAttributeName_FromClusterMoment(myAttribute,momentType);
426 if (!haveGotAttributeInMap) return false;
427 else {
428 bool isRetrieved = this->attribute(myAttribute, theMoment);
429 return isRetrieved;
430 }
431 }
432
434
435 if (momentType == xAOD::CaloCluster::ENG_FRAC_CORE) {
437 return true;
438 }
439 else if (momentType == xAOD::CaloCluster::FIRST_ENG_DENS) {
441 return true;
442 }
443 else if (momentType == xAOD::CaloCluster::CENTER_LAMBDA) {
445 return true;
446 }
447 else if (momentType == xAOD::CaloCluster::SECOND_R) {
449 return true;
450 }
451 else if (momentType == xAOD::CaloCluster::DELTA_ALPHA) {
453 return true;
454 }
455 else if (momentType == xAOD::CaloCluster::LATERAL) {
457 return true;
458 }
459 else if (momentType == xAOD::CaloCluster::LONGITUDINAL) {
461 return true;
462 }
463 else if (momentType == xAOD::CaloCluster::SECOND_LAMBDA) {
465 return true;
466 }
467 else if (momentType == xAOD::CaloCluster::ISOLATION) {
469 return true;
470 }
471 else if (momentType == xAOD::CaloCluster::ENG_FRAC_MAX) {
473 return true;
474 }
475 else if (momentType == xAOD::CaloCluster::ENG_BAD_CELLS) {
477 return true;
478 }
479 else if (momentType == xAOD::CaloCluster::N_BAD_CELLS) {
481 return true;
482 }
483 else if (momentType == xAOD::CaloCluster::BADLARQ_FRAC) {
485 return true;
486 }
487 else if (momentType == xAOD::CaloCluster::ENG_POS) {
489 return true;
490 }
491 else if (momentType == xAOD::CaloCluster::SIGNIFICANCE) {
493 return true;
494 }
495 else if (momentType == xAOD::CaloCluster::CELL_SIGNIFICANCE) {
497 return true;
498 }
499 else if (momentType == xAOD::CaloCluster::CELL_SIG_SAMPLING) {
501 return true;
502 }
503 else if (momentType == xAOD::CaloCluster::AVG_LAR_Q) {
505 return true;
506 }
507 else if (momentType == xAOD::CaloCluster::AVG_TILE_Q) {
509 return true;
510 }
511 else if (momentType == xAOD::CaloCluster::EM_PROBABILITY){
513 return true;
514 }
515 else if (momentType == xAOD::CaloCluster::ENG_CALIB_TOT){
517 return true;
518 }
519 else if (momentType == xAOD::CaloCluster::ENG_CALIB_FRAC_EM){
521 return true;
522 }
523 else if (momentType == xAOD::CaloCluster::ENG_CALIB_FRAC_HAD){
525 return true;
526 }
527 else if (momentType == xAOD::CaloCluster::ENG_CALIB_FRAC_REST){
529 return true;
530 }
531
532 else return false;
533
534 }
535
537 const static Accessor<ElementLink<xAOD::VertexContainer> > acc("pfo_vertex");
538 acc(*this) = theVertexLink;
539 acc(*this).toPersistent();
540 return true;
541 }
542
545 this->convertLink(myTrackLink,theTrack);
546 return this->setAssociatedParticleLink(PFODetails::Track, myTrackLink);
547 }
548
551 this->convertLink(myClusterLink,theCluster);
552 return this->setAssociatedParticleLink(PFODetails::CaloCluster, myClusterLink);
553 }
554
557 this->convertLink(myClusterLink,theCluster);
558 return this->addAssociatedParticleLink(PFODetails::CaloCluster, myClusterLink);
559 }
560
562 std::vector<ElementLink<xAOD::IParticleContainer> > theLinks(1,theParticle);
563 return this->setAssociatedParticleLinks(ParticleType,theLinks);
564 }
565
567 std::vector<ElementLink<xAOD::IParticleContainer> > theLinks(1,theParticle);
568 this->setAssociatedParticleLinks(ParticleType,theLinks);
569 }
570
573 if (!p_acc) return false;
574 else{
575 if (!p_acc->isAvailable(*this)) return false;
576 else{
577 std::vector<ElementLink<IParticleContainer> > storedContainer = (*p_acc)(*this);
578 storedContainer.push_back(theParticle);
579 (*p_acc)(*this) = storedContainer;
580 return true;
581 }
582 }
583 }
584
586
588 std::vector<ElementLink<IParticleContainer> > storedContainer = acc(*this);
589
591 newLink.setElement(*theParticle);
592 newLink.setStorableObject(theParticle.getStorableObjectRef());
593 newLink.toPersistent();
594 storedContainer.push_back(newLink);
595
596 acc(*this) = storedContainer;
597
598 }
599
601
603 if (!p_acc) return false;
604 else{
605 (*p_acc)(*this) = theParticles;
606 return true;
607 }
608 }
609
610 bool PFO_v1::associatedParticles(PFODetails::PFOParticleType ParticleType, std::vector<const IParticle*>& theParticles ) const{
611
613 if (!p_acc) return false;
614 else{
615 if (!p_acc->isAvailable(*this)) return false;
616 else{
617 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
618 std::vector<ElementLink<IParticleContainer> >::const_iterator firstLink = theLinks.begin();
619 for (; firstLink != theLinks.end(); ++firstLink) {
620 if ( (*firstLink).isValid()) theParticles.push_back(**firstLink);
621 else theParticles.push_back(nullptr);
622 }
623 return true;
624 }
625 }
626
627 }
628
629 void PFO_v1::setAssociatedParticleLinks(const std::string& ParticleType, const std::vector<ElementLink<IParticleContainer> >& theParticles) {
630
631 //Given we do not know in advance in the POOL convertors about these containers, we set toPersistent() internally here.
632
633 std::vector<ElementLink<IParticleContainer> > storedContainer;
634 std::vector<ElementLink<IParticleContainer> >::const_iterator firstParticle = theParticles.begin();
635 for (; firstParticle != theParticles.end(); ++firstParticle){
636 ElementLink<xAOD::IParticleContainer> myLink = *firstParticle;
637 myLink.toPersistent();
638 storedContainer.push_back( myLink );
639 }
640
642 acc(*this) = storedContainer;
643 }
644
645 bool PFO_v1::associatedParticles(const std::string& ParticleType, std::vector<const IParticle*>& theParticles ) const{
647 if (!acc.isAvailable(*this)) return false;
648 else{
649 const std::vector<ElementLink<IParticleContainer> >& theLinks = acc(*this);
650 std::vector<ElementLink<IParticleContainer> >::const_iterator firstLink = theLinks.begin();
651 for (; firstLink != theLinks.end(); ++firstLink) {
652 if ( (*firstLink).isValid()) theParticles.push_back(**firstLink);
653 else theParticles.push_back(nullptr);
654 }
655 return true;
656 }
657 }
658
659 unsigned int PFO_v1::nCaloCluster() const {
661 if (!p_acc) return 0;
662 else if (!p_acc->isAvailable(*this)) {return 0;}
663 else{
664 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
665 return theLinks.size();
666 }
667 }
668
669 const CaloCluster* PFO_v1::cluster(unsigned int index) const {
670
672 if (!p_acc) return nullptr;
673 else if (!p_acc->isAvailable(*this)) {return nullptr;}
674 else {
675 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
676 if(index<theLinks.size()) {
677 ElementLink<IParticleContainer> theLink = theLinks[index];
678 if (theLink.isValid()){
679 const IParticle *theParticle = *theLink;
680 if (nullptr == theParticle) return nullptr;
681 else if (Type::CaloCluster == theParticle->type()) return static_cast<const CaloCluster*>(theParticle);
682 else return nullptr;
683 }
684 else return nullptr;
685 }
686 else return nullptr;
687 }
688
689 }
690
691 const TrackParticle* PFO_v1::track(unsigned int index) const {
692
694 if (!p_acc) return nullptr;
695 else if (!p_acc->isAvailable(*this)) {return nullptr;}
696 else {
697 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
698 if(index<theLinks.size()) {
699 ElementLink<IParticleContainer> theLink = theLinks[index];
700 if (theLink.isValid()){
701 const IParticle *theParticle = *theLinks[index];
702 if (nullptr == theParticle) return nullptr;
703 else if (Type::TrackParticle == theParticle->type()) return static_cast<const TrackParticle*>(theParticle);
704 else return nullptr;
705 }
706 else return nullptr;
707 }
708 else return nullptr;
709 }
710 }
711
713 const static ConstAccessor<ElementLink<xAOD::VertexContainer> > acc("pfo_vertex");
714 if (!acc.isAvailable(*this)) return nullptr;
715 else{
716 const ElementLink<xAOD::VertexContainer>& tempVertexLink = acc(*this);
717 if (tempVertexLink.isValid()) return *acc(*this);
718 else return nullptr;
719 }
720 }
721
722 TLorentzVector PFO_v1::GetVertexCorrectedFourVec(const xAOD::Vertex& vertexToCorrectTo) const{
723 TVector3 theVertexVector(vertexToCorrectTo.x(), vertexToCorrectTo.y(), vertexToCorrectTo.z());
724 return GetVertexCorrectedFourVec(theVertexVector);
725 }
726
727 TLorentzVector PFO_v1::GetVertexCorrectedFourVec(const TVector3& vertexToCorrectTo) const{
728
729 TLorentzVector theNewVector(0.0,0.0,0.0,0.0);
730 theNewVector.SetPtEtaPhiM(this->pt(), this->eta(), this->phi(), this->m());
731
732 this->VertexCorrectTheFourVector(vertexToCorrectTo,theNewVector);
733 return theNewVector;
734
735 }
736
737 TLorentzVector PFO_v1::GetVertexCorrectedEMFourVec(const xAOD::Vertex& vertexToCorrectTo) const{
738 TVector3 theVertexVector(vertexToCorrectTo.x(), vertexToCorrectTo.y(), vertexToCorrectTo.z());
739 return GetVertexCorrectedEMFourVec(theVertexVector);
740 }
741
742 TLorentzVector PFO_v1::GetVertexCorrectedEMFourVec(const TVector3& vertexToCorrectTo) const{
743
744 TLorentzVector theNewVector(0.0,0.0,0.0,0.0);
745 theNewVector.SetPtEtaPhiM(this->ptEM(), this->etaEM(), this->phiEM(), this->mEM());
746
747 this->VertexCorrectTheFourVector(vertexToCorrectTo,theNewVector);
748 return theNewVector;
749
750 }
751
752 void PFO_v1::VertexCorrectTheFourVector(const TVector3& vertexToCorrectTo, TLorentzVector& theFourVector) const{
753
754 float clusterEta = theFourVector.Eta();
755 float centerMag = this->centerMag();
756
757 float radius = centerMag/cosh(clusterEta);
758
759 float EtaVertexCorrection = 0.0, PhiVertexCorrection = 0.0;
760 float clusterPhi = theFourVector.Phi();
761
762 if (radius > 1.0 && centerMag > 1e-3){
763 EtaVertexCorrection = (-vertexToCorrectTo.Z()/cosh(clusterEta) + (vertexToCorrectTo.X()*cos(clusterPhi) + vertexToCorrectTo.Y()*sin(clusterPhi))*tanh(clusterEta))/radius;
764 PhiVertexCorrection = (vertexToCorrectTo.X()*sin(clusterPhi) - vertexToCorrectTo.Y()*cos(clusterPhi))/radius;
765 }
766
767 float etaVertexCorrected = clusterEta + EtaVertexCorrection;
768 float p = std::sqrt(theFourVector.E()*theFourVector.E()-theFourVector.M()*theFourVector.M());
769 float ptVertexCorrected = p/cosh(etaVertexCorrected);
770 theFourVector.SetPtEtaPhiM(ptVertexCorrected, etaVertexCorrected, clusterPhi + PhiVertexCorrection, theFourVector.M());
771
772 }
773
775
776 //setup known links for persistification, if they exist
777 //if you added your own consituents the links will not be correctly persistified
778
779 //clusters
781 if (p_accClusters){
782 const Accessor<std::vector<ElementLink<IParticleContainer > > >& accClusters = *p_accClusters;
783 if ( accClusters.isAvailableWritable(*this) ){
784 std::vector<ElementLink<IParticleContainer> >& theClusterLinks = accClusters(*this);
785 std::vector< ElementLink< IParticleContainer > >::iterator firstClus = theClusterLinks.begin();
786 std::vector< ElementLink< IParticleContainer > >::iterator lastClus = theClusterLinks.end();
787 for (; firstClus != lastClus; ++firstClus) firstClus->toPersistent();
788 }
789 }
790
791 //tracks
793 if (p_accTracks){
794 const Accessor<std::vector<ElementLink<IParticleContainer > > >& accTracks = *p_accTracks;
795 if ( accTracks.isAvailableWritable(*this) ){
796 std::vector<ElementLink<IParticleContainer> >& theTrackLinks = accTracks(*this);
797 std::vector< ElementLink< IParticleContainer > >::iterator firstTrack = theTrackLinks.begin();
798 std::vector< ElementLink< IParticleContainer > >::iterator lastTrack = theTrackLinks.end();
799 for (; firstTrack != lastTrack; ++firstTrack) firstTrack->toPersistent();
800
801 }
802 }
803
804 //shots
806 if (p_accShots){
807 const Accessor<std::vector<ElementLink<IParticleContainer > > >& accShots = *p_accShots;
808 if ( accShots.isAvailableWritable(*this) ){
809 std::vector<ElementLink<IParticleContainer> >& theShotLinks = accShots(*this);
810 std::vector< ElementLink< IParticleContainer > >::iterator firstShot = theShotLinks.begin();
811 std::vector< ElementLink< IParticleContainer > >::iterator lastShot = theShotLinks.end();
812 for (; firstShot != lastShot; ++firstShot) firstShot->toPersistent();
813 }
814 }
815
816 }
817
818
819} // namespace xAOD
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
std::vector< size_t > vec
ParticleType
Definition TruthClasses.h:8
const_iterator begin() const
bool isAvailableWritable(ELT &e) const
Test to see if this variable exists in the store and is writable.
void makePrivateStore()
Create a new (empty) private store for this object.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
MomentType
Enums to identify different moments.
@ DELTA_ALPHA
Angular shower axis deviation ( ) from IP-to-Center.
@ AVG_TILE_Q
Sum(E_cell_Tile^2 Q_cell_Tile)/Sum(E_cell_Tile^2)
@ SECOND_LAMBDA
Second Moment in .
@ CELL_SIGNIFICANCE
Cell significance = E/sig of the cell with the largest |E|/sig.
@ CELL_SIG_SAMPLING
CaloSample of the cell with the largest |E|/sig.
@ EM_PROBABILITY
Classification probability to be em-like.
@ LATERAL
Normalized lateral moment.
@ N_BAD_CELLS
number of bad cells
@ LONGITUDINAL
Normalized longitudinal moment.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ AVG_LAR_Q
Sum(E_cell_LAr^2 Q_cell_LAr)/Sum(E_cell_LAr^2)
@ SECOND_R
Second Moment in .
@ FIRST_ENG_DENS
First Moment in E/V.
@ ENG_FRAC_CORE
Energy fraction of the sum of the hottest cells in each sampling.
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
@ SIGNIFICANCE
Cluster significance.
@ ENG_CALIB_FRAC_REST
Calibration Hit energy inside the cluster caused by other particles.
@ ENG_CALIB_FRAC_EM
Calibration Hit energy inside the cluster caused by e/gamma/pi0.
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
@ ENG_CALIB_TOT
Calibration Hit energy inside the cluster.
@ ENG_CALIB_FRAC_HAD
Calibration Hit energy inside the cluster caused by charged pi+ and pi-.
@ ENG_POS
Total positive Energy of this cluster.
@ BADLARQ_FRAC
Energy fraction of LAr cells with quality larger than a given cut.
@ ISOLATION
Energy weighted fraction of non-clustered perimeter cells.
IParticle()=default
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
TLorentzVector FourMom_t
Definition of the 4-momentum type.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Class describing a particle flow object.
Definition PFO_v1.h:35
bool setTrackLink(const ElementLink< xAOD::TrackParticleContainer > &theTrack)
Set a track constituent - does NOT append to existing container.
Definition PFO_v1.cxx:543
unsigned int nCaloCluster() const
Find out how many CaloCluster are linked.
Definition PFO_v1.cxx:659
virtual double ptEM() const
get EM scale pt
Definition PFO_v1.cxx:204
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector version.
Definition PFO_v1.cxx:101
bool getAttributeName_FromClusterMoment(xAOD::PFODetails::PFOAttributes &myAttribute, xAOD::CaloCluster::MomentType &momentType) const
Map from cluster moment name onto PFOAttribute name.
Definition PFO_v1.cxx:433
bool addClusterLink(const ElementLink< xAOD::CaloClusterContainer > &theCluster)
Add a cluster constituent appends to existing container.
Definition PFO_v1.cxx:555
void setAttribute(PFODetails::PFOAttributes AttributeType, const T &anAttribute)
Set a PFO Variable via enum - overwrite is allowed.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > GenVecFourMom_t
Base 4 Momentum type (GenVector version)
Definition PFO_v1.h:71
bool getClusterMoment(float &theMoment, xAOD::CaloCluster::MomentType momentType) const
Accessor for cluster moments.
Definition PFO_v1.cxx:402
PFO_v1()
Default constructor.
Definition PFO_v1.cxx:44
virtual double rapidity() const
The true rapidity (y) of the particle.
Definition PFO_v1.cxx:90
bool isCharged() const
is a charged PFO
Definition PFO_v1.cxx:251
bool setAssociatedParticleLinks(PFODetails::PFOParticleType ParticleType, const std::vector< ElementLink< IParticleContainer > > &theParticles)
Set a vector of PFO constituent particle types via enum - overwrite is allowed.
Definition PFO_v1.cxx:600
TLorentzVector GetVertexCorrectedFourVec(const xAOD::Vertex &vertexToCorrectTo) const
Correct 4-vector to point at a vertex.
Definition PFO_v1.cxx:722
bool setClusterLink(const ElementLink< xAOD::CaloClusterContainer > &theCluster)
Set a cluster constituent - does NOT append to existing container.
Definition PFO_v1.cxx:549
float centerMag() const
get CenterMag moment needed for vertex correction
static const int s_floatCompressionFactor
this defines the factor to compress floats by
Definition PFO_v1.h:203
FourMom_t p4EM() const
get EM scale 4-vector
Definition PFO_v1.cxx:144
GenVecFourMom_t genvecP4EM() const
get EM scale 4-vector
Definition PFO_v1.cxx:160
virtual double eEM() const
get EM scale energy
Definition PFO_v1.cxx:233
bool associatedParticles(PFODetails::PFOParticleType ParticleType, std::vector< const IParticle * > &theParticles) const
get a vector of PFO constituent particle types via enum
Definition PFO_v1.cxx:610
bool isJetETMissFloatForCompression(xAOD::PFODetails::PFOAttributes AttributeType) const
Performs a check as to whether a variable should be compressed.
Definition PFO_v1.cxx:312
void VertexCorrectTheFourVector(const TVector3 &vertexToCorrectTo, TLorentzVector &theFourVector) const
This does the vertex correction of neutral PFO.
Definition PFO_v1.cxx:752
void convertLink(ElementLink< IParticleContainer > &IParticleLink, const ElementLink< T > &templateLink)
Convert a generic link to an IParticleLink - perhaps this will go in a dedicated helper tool?
bool getClusterMomentFromPFO(float &theMoment, xAOD::CaloCluster::MomentType momentType) const
Gives access to cluster moments direct from the PFO - getClusterMoment calls this,...
Definition PFO_v1.cxx:423
const TrackParticle * track(unsigned int index) const
Retrieve a const pointer to a Rec::TrackParticle.
Definition PFO_v1.cxx:691
virtual double etaEM() const
get EM scale eta
Definition PFO_v1.cxx:215
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition PFO_v1.cxx:95
void setP4(const FourMom_t &vec)
set the 4-vec
Definition PFO_v1.cxx:107
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition PFO_v1.cxx:60
TLorentzVector GetVertexCorrectedEMFourVec(const xAOD::Vertex &vertexToCorrectTo) const
Correct EM scale 4-vector to point at a vertex.
Definition PFO_v1.cxx:737
bool setAssociatedParticleLink(PFODetails::PFOParticleType ParticleType, const ElementLink< IParticleContainer > &theParticle)
Set an IParticle constituent via enum - does NOT append to existing container.
Definition PFO_v1.cxx:561
void toPersistent()
prepare all links for persistification
Definition PFO_v1.cxx:774
virtual double m() const
The invariant mass of the particle.
Definition PFO_v1.cxx:74
void setP4EM(const FourMom_t &p4EM)
set EM scale 4-vector
Definition PFO_v1.cxx:173
const xAOD::Vertex * vertex() const
Retrieve a const pointer to the xAOD::Vertex a charged PFO is associated to.
Definition PFO_v1.cxx:712
bool addAssociatedParticleLink(PFODetails::PFOParticleType ParticleType, const ElementLink< IParticleContainer > &theParticle)
Add an IParticle constituent via enum - appends to existing container.
Definition PFO_v1.cxx:571
virtual double phiEM() const
get EM scale phi
Definition PFO_v1.cxx:220
virtual double e() const
The total energy of the particle.
Definition PFO_v1.cxx:81
virtual double mEM() const
get EM scale mass
Definition PFO_v1.cxx:224
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition PFO_v1.cxx:67
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition PFO_v1.cxx:140
bool setVertexLink(const ElementLink< xAOD::VertexContainer > &theVertexLink)
Set a vertex link.
Definition PFO_v1.cxx:536
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition PFO_v1.cxx:52
const CaloCluster * cluster(unsigned int index) const
Retrieve a const pointer to a CaloCluster.
Definition PFO_v1.cxx:669
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
Definition index.py:1
PFOLeptonType
This enum is used to label the lepton type of the neutral PFO.
PFOParticleType
This enum is used to label the associated particles to the PFO object.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
setBGCode setTAP setLVL2ErrorBits bool
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
setWord1 uint16_t
JetConstituentVector::iterator iterator
static const SG::AuxElement::Accessor< T > * constAccessor(xAOD::PFODetails::PFOAttributes variable)
static const SG::AuxElement::Accessor< std::vector< ElementLink< IParticleContainer > > > * getAccessor(PFODetails::PFOParticleType type)
Definition PFO_v1.cxx:17