ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCluster_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// System include(s):
6#include <cmath>
7#include <iostream>
8#include <array>
9#include <numeric>
10
11// EDM include(s):
14#include "AthLinks/ElementLink.h"
15
16// Local include(s):
20
21namespace xAOD {
22
30
31
35 m_cellLinks(nullptr),
38 setSignalState(other.signalState());
39 this->makePrivateStore(other);
40#if !(defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS))
41 const CaloClusterCellLink* links=other.getCellLinks();
42 if (links) {
43 this->addCellLink(std::make_unique<CaloClusterCellLink>(*links));
44 }
45 static const Accessor<ElementLink<CaloClusterCellLinkContainer> > accCellLinks("CellLink");
46 if (accCellLinks.isAvailable(*this)) { //In case an element link was copied by makePrivateStore, invalidate it
47 accCellLinks(*this).reset();
48 } //end if have element link to CaloClusterCellLink
49#endif // not defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS)
50 }
51
52
54 if (this == &other) {
55 return *this;
56 }
57
58 SG::AuxElement::operator=( other ); //Call assignment operator of base-class
59 m_recoStatus=other.m_recoStatus;
60 setSignalState(other.signalState());
61 m_samplingPattern=other.m_samplingPattern;
62 m_secondTime = other.m_secondTime;
63
64#if !(defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS))
65 const CaloClusterCellLink* links=other.getCellLinks();
66 if (links) {
67 this->addCellLink(std::make_unique<CaloClusterCellLink>(*links));
68 }
69 static const Accessor<ElementLink<CaloClusterCellLinkContainer> > accCellLinks("CellLink");
70 if (accCellLinks.isAvailable(*this)) { //In case an element link was copied by SG::AuxElement::operator=, invalidate it
71 accCellLinks(*this).reset();
72 } //end if have element link to CaloClusterCellLink
73#endif // not defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS)
74 return *this;
75 }
76
77
80
81 void CaloCluster_v1::setSamplingPattern( const unsigned sp, const bool clearSamplingVars) {
82
83 // Check sampling variables ....
84 static const Accessor< std::vector< float > > etaAcc( "eta_sampl" );
85 static const Accessor< std::vector< float > > phiAcc( "phi_sampl" );
86 static const Accessor< std::vector< float > > eAcc( "e_sampl" );
87 static const Accessor< std::vector< float > > emaxAcc( "emax_sampl" );
88 static const Accessor< std::vector< float > > etamaxAcc( "etamax_sampl" );
89 static const Accessor< std::vector< float > > phimaxAcc( "phimax_sampl" );
90 static const Accessor< std::vector< float > > etasizeAcc( "etasize_sampl" );
91 static const Accessor< std::vector< float > > phisizeAcc( "phisize_sampl" );
92
93 static const std::array< const Accessor< std::vector< float > >*, 8 > allAcc = {
94 { &etaAcc, &phiAcc, &eAcc, &emaxAcc, &phimaxAcc, &etamaxAcc, &etasizeAcc,
95 &phisizeAcc } };
96 for( const auto *a : allAcc ) {
97 if( a->isAvailable( *this ) ) {
98 if (!(*a)(*this).empty()) {
99 if (clearSamplingVars){
100 (*a)(*this).clear();
101 }
102 else{
103 std::cerr << "CaloCluster_v1 ERROR Attempt update sampling "
104 << "pattern while sampling variables are already set!"
105 << std::endl;
106 }
107 //std::abort();
108 }
109 }
110 }
111
113 }
114
115
121 double CaloCluster_v1::pt(const State s) const {
122 // Calculate the momentum of the object:
123 double theE = 0;
124 double theM = 0;
125 switch (s) {
126 case CALIBRATED:
127 theE=calE();
128 theM=calM();
129 break;
130 case UNCALIBRATED:
131 theE=rawE();
132 theM=rawM();
133 break;
134 case ALTCALIBRATED:
135 theE=altE();
136 theM=altM();
137 break;
138 default:
139 break;
140 }
141
142 double p = 0.0;
143 if( std::abs( theM ) < 0.00001 ) {
144 p = theE;
145 } else {
146 p = std::sqrt( theE * theE - theM * theM );
147 if( theE < 0 ) {
148 p = -p;
149 }
150 }
151
152 // Calculate sinTh:
153 double aEta = std::abs( eta(s) );
154 if( aEta > 710.0 ) {
155 aEta = 710.0;
156 }
157 const double sinTh = 1.0 / std::cosh( aEta );
158
159 // Calculate pT from these two:
160 return p * sinTh;
161 }
162
167 double CaloCluster_v1::e(const State s) const
168 {
169 switch (s) {
170 case CALIBRATED:
171 return calE();
172 break;
173 case UNCALIBRATED:
174 return rawE();
175 break;
176 case ALTCALIBRATED:
177 return altE();
178 break;
179 default:
180 return 0;
181 }
182 }
183
188 double CaloCluster_v1::eta(const State s) const
189 {
190 switch (s) {
191 case CALIBRATED:
192 return calEta();
193 break;
194 case UNCALIBRATED:
195 return rawEta();
196 break;
197 case ALTCALIBRATED:
198 return altEta();
199 break;
200 default:
201 return -999;
202 }
203 }
204
205
210 double CaloCluster_v1::phi(const State s) const
211 {
212 switch (s) {
213 case CALIBRATED:
214 return calPhi();
215 break;
216 case UNCALIBRATED:
217 return rawPhi();
218 break;
219 case ALTCALIBRATED:
220 return altPhi();
221 break;
222 default:
223 return -999;
224 }
225 }
226
230 double CaloCluster_v1::m(const State s) const {
231 switch (s) {
232 case CALIBRATED:
233 return calM();
234 break;
235 case UNCALIBRATED:
236 return rawM();
237 break;
238 case ALTCALIBRATED:
239 return altM();
240 break;
241 default:
242 return -999;
243 }
244 }
245
246
247 double CaloCluster_v1::pt() const {
248 return pt(m_signalState);
249 }
250
251 double CaloCluster_v1::eta() const
252 {
253 return eta (m_signalState);
254 }
255
256 double CaloCluster_v1::phi() const
257 {
258 return phi (m_signalState);
259 }
260
261 double CaloCluster_v1::m() const {
262 return m(m_signalState);
263 }
264
265 double CaloCluster_v1::e() const {
266 return e(m_signalState);
267 }
268
269
273
275 static const Accessor<xAOD::CaloClusterBadChannelList> accBCL("BadChannelList");
276 accBCL(*this)=bcl;
277 }
278
280 static const Accessor<xAOD::CaloClusterBadChannelList> accBCL("BadChannelList");
281 return accBCL(*this);
282 }
283
285 static const Accessor<CaloCluster_v1::flt_t> accRawE("rawE");
286 accRawE(*this)=value;
287 }
288
290 static const Accessor<CaloCluster_v1::flt_t> accRawEta("rawEta");
291 accRawEta(*this)=value;
292 }
293
295 static const Accessor<CaloCluster_v1::flt_t> accRawPhi("rawPhi");
296 accRawPhi(*this)=value;
297 }
298
300 static const Accessor<CaloCluster_v1::flt_t> accRawM("rawM");
301 accRawM(*this)=value;
302 }
303
304 //----------------------------------------------------------------
305
307 static const Accessor<CaloCluster_v1::flt_t> accCalE("calE");
308 accCalE(*this)=value;
309 }
310
312 static const Accessor<CaloCluster_v1::flt_t> accCalEta("calEta");
313 accCalEta(*this)=value;
314 }
315
317 static const Accessor<CaloCluster_v1::flt_t> accCalPhi("calPhi");
318 accCalPhi(*this)=value;
319 }
320
322 static const Accessor<CaloCluster_v1::flt_t> accCalM("calM");
323 accCalM(*this)=value;
324 }
325
326 //----------------------------------------------------------------
327
329 static const Accessor<CaloCluster_v1::flt_t> accAltE("altE");
330 accAltE(*this)=value;
331 }
332
334 static const Accessor<CaloCluster_v1::flt_t> accAltEta("altEta");
335 accAltEta(*this)=value;
336 }
337
339 static const Accessor<CaloCluster_v1::flt_t> accAltPhi("altPhi");
340 accAltPhi(*this)=value;
341 }
342
344 static const Accessor<CaloCluster_v1::flt_t> accAltM("altM");
345 accAltM(*this)=value;
346 }
347
352
357
362
363
365 static const Accessor<unsigned> acc("clusterSize");
366 return (CaloCluster_v1::ClusterSize)acc(*this);
367 }
368
370 static const Accessor<unsigned> acc("clusterSize");
371 acc(*this)=sc;
372 }
373
374
376 switch (m_signalState) {
377 case CALIBRATED:
378 return setCalE(theE);
379 break;
380 case UNCALIBRATED:
381 return setRawE(theE);
382 break;
383 case ALTCALIBRATED:
384 return setAltE(theE);
385 break;
386 default:
387 break;
388 }
389 }
390
392 switch (m_signalState) {
393 case CALIBRATED:
394 return setCalEta(theEta);
395 break;
396 case UNCALIBRATED:
397 return setRawEta(theEta);
398 break;
399 case ALTCALIBRATED:
400 return setAltEta(theEta);
401 break;
402 default:
403 break;
404 }
405 }
406
408 switch (m_signalState) {
409 case CALIBRATED:
410 return setCalPhi(thePhi);
411 break;
412 case UNCALIBRATED:
413 return setRawPhi(thePhi);
414 break;
415 case ALTCALIBRATED:
416 return setAltPhi(thePhi);
417 break;
418 default:
419 break;
420 }
421 }
422
423
425 switch (m_signalState) {
426 case CALIBRATED:
427 return setCalM(theM);
428 break;
429 case UNCALIBRATED:
430 return setRawM(theM);
431 break;
432 case ALTCALIBRATED:
433 return setAltM(theM);
434 break;
435 default:
436 break;
437 }
438 }
439
444
446 switch (s) {
447 case CALIBRATED:
448 return GenVecFourMom_t(pt(s),calEta(),calPhi(),calM());
449 case UNCALIBRATED:
450 return GenVecFourMom_t(pt(s),rawEta(),rawPhi(), rawM());
451 case ALTCALIBRATED:
452 return GenVecFourMom_t(pt(s),altEta(),altPhi(), altM());
453 default:
454 return GenVecFourMom_t();
455 }
456 }
460
462 return genvecP4().Rapidity();
463 }
464
468
469
472 switch(s) {
473 case CALIBRATED:
474 p4.SetPtEtaPhiM(pt(s),calEta(),calPhi(),calM());
475 break;
476 case UNCALIBRATED:
477 p4.SetPtEtaPhiM(pt(s),rawEta(),rawPhi(), rawM());
478 break;
479 case ALTCALIBRATED:
480 p4.SetPtEtaPhiM(pt(s),altEta(),altPhi(), altM());
481 break;
482 default:
483 break;
484 }
485 return p4;
486 }
487
488
489 Type::ObjectType CaloCluster_v1::type() const {
490 return Type::CaloCluster;
491 }
492
493
494 float CaloCluster_v1::getSamplVarFromAcc(const Accessor< std::vector <float > >& acc , const CaloSample sampling, const float errorvalue) const {
495 return CaloClusterDetails::getSamplVar(sampling,m_samplingPattern,acc(*this),errorvalue);
496 }
497
498 bool CaloCluster_v1::setSamplVarFromAcc(const Accessor< std::vector <float > >& acc, const CaloSample sampling, const float value) {
499 const unsigned idx=sampVarIdx(sampling);
500 std::vector<float>& vec=acc(*this);
501 //std::cout << "Set sampling var. Sampling " << sampling << ", index=" << idx << " size=" << vec.size() << std::endl;
502 if (idx==CaloSampling::Unknown) {
503 std::cout << "ERROR: Sampling #" << sampling << " is not part of this cluster!" << std::endl;
504 return false;
505 }
506
507 if (vec.size()<nSamples())
508 vec.resize(nSamples());
509 vec[idx]=value;
510 return true;
511 }
512
513
514 float CaloCluster_v1::eSample( CaloSample sampling ) const {
515 static const Accessor< std::vector <float > > eAcc("e_sampl");
516 return getSamplVarFromAcc(eAcc,sampling,0.0); //Return energy 0 in case of failure (eg. sampling not set)
517 }
518
519 bool CaloCluster_v1::setEnergy(const CaloSample sampling, const float theEnergy) {
520 static const Accessor< std::vector <float > > eAcc("e_sampl");
521 return setSamplVarFromAcc(eAcc,sampling,theEnergy);
522 }
523
524
525 float CaloCluster_v1::etaSample(const CaloSample sampling) const {
526 static const Accessor< std::vector <float > > etaAcc("eta_sampl");
527 if (!etaAcc.isAvailable( *this )){
528 return -999;
529 }
530
531 return getSamplVarFromAcc(etaAcc,sampling);
532 }
533
534 bool CaloCluster_v1::setEta(const CaloSample sampling, const float eta) {
535 static const Accessor< std::vector <float > > etaAcc("eta_sampl");
536 return setSamplVarFromAcc(etaAcc,sampling,eta);
537 }
538
539
540 float CaloCluster_v1::phiSample(const CaloSample sampling) const {
541 static const Accessor< std::vector <float > > phiAcc("phi_sampl");
542 if (!phiAcc.isAvailable( *this )){
543 return -999;
544 }
545
546 return getSamplVarFromAcc(phiAcc,sampling);
547 }
548
549 bool CaloCluster_v1::setPhi(const CaloSample sampling, const float phi) {
550 static const Accessor< std::vector <float > > phiAcc("phi_sampl");
551 return setSamplVarFromAcc(phiAcc,sampling,phi);
552 }
553
554
555
556 float CaloCluster_v1::energy_max(const CaloSample sampling) const {
557 static const Accessor< std::vector <float > > emaxAcc("emax_sampl");
558 if (!emaxAcc.isAvailable( *this )){
559 return 0.0;
560 }
561 return getSamplVarFromAcc(emaxAcc,sampling,0.0); //Return energy 0 in case of failure (eg. sampling not set)
562 }
563
564 bool CaloCluster_v1::setEmax(const CaloSample sampling, const float eMax ) {
565 static const Accessor< std::vector <float > > emaxAcc("emax_sampl");
566 return setSamplVarFromAcc(emaxAcc,sampling,eMax);
567 }
568
569 float CaloCluster_v1::etamax(const CaloSample sampling) const {
570 static const Accessor< std::vector <float > > etamaxAcc("etamax_sampl");
571 if (!etamaxAcc.isAvailable( *this )){
572 return -999;
573 }
574 return getSamplVarFromAcc(etamaxAcc,sampling);
575 }
576
577 bool CaloCluster_v1::setEtamax(const CaloSample sampling, const float etaMax ) {
578 static const Accessor< std::vector <float > > etamaxAcc("etamax_sampl");
579 return setSamplVarFromAcc(etamaxAcc,sampling,etaMax);
580 }
581
582 float CaloCluster_v1::phimax(const CaloSample sampling) const {
583 static const Accessor< std::vector <float > > phimaxAcc("phimax_sampl");
584 if (!phimaxAcc.isAvailable( *this )){
585 return -999;
586 }
587 return getSamplVarFromAcc(phimaxAcc,sampling);
588 }
589
590 bool CaloCluster_v1::setPhimax(const CaloSample sampling, const float phiMax ) {
591 static const Accessor< std::vector <float > > phimaxAcc("phimax_sampl");
592 return setSamplVarFromAcc(phimaxAcc,sampling,phiMax);
593 }
594
595
596 float CaloCluster_v1::etasize(const CaloSample sampling) const {
597 static const Accessor< std::vector <float > > etasizeAcc("etasize_sampl");
598 if (!etasizeAcc.isAvailable( *this )){
599 return -999;
600 }
601 return getSamplVarFromAcc(etasizeAcc, sampling);
602 }
603
604 bool CaloCluster_v1::setEtasize(const CaloSample sampling, const float etaSize ) {
605 static const Accessor< std::vector <float > > etasizeAcc("etasize_sampl");
606 return setSamplVarFromAcc(etasizeAcc,sampling,etaSize);
607 }
608
609 float CaloCluster_v1::phisize(const CaloSample sampling) const {
610 static const Accessor< std::vector <float > > phisizeAcc("phisize_sampl");
611 if (!phisizeAcc.isAvailable( *this )){
612 return -999;
613 }
614 return getSamplVarFromAcc(phisizeAcc,sampling);
615 }
616
617 bool CaloCluster_v1::setPhisize(const CaloSample sampling, const float phiSize ) {
618 static const Accessor< std::vector <float > > phisizeAcc("phisize_sampl");
619 return setSamplVarFromAcc(phisizeAcc,sampling,phiSize);
620 }
621
622
623 float CaloCluster_v1::energyBE(const unsigned sample) const {
624 static const Accessor< std::vector <float > > eAcc("e_sampl");
625 return CaloClusterDetails::energyBE(sample,m_samplingPattern,eAcc(*this));
626 }
627
628 float CaloCluster_v1::etaBE(const unsigned sample) const {
629 static const Accessor< std::vector <float > > eAcc("e_sampl");
630 static const Accessor< std::vector <float > > etaAcc("eta_sampl");
631 return CaloClusterDetails::etaBE(sample,m_samplingPattern,eAcc(*this),etaAcc(*this));
632 }
633
634 float CaloCluster_v1::phiBE(const unsigned sample) const {
635 static const Accessor< std::vector <float > > eAcc("e_sampl");
636 static const Accessor< std::vector <float > > phiAcc("phi_sampl");
637 return CaloClusterDetails::phiBE(sample,m_samplingPattern,eAcc(*this),phiAcc(*this));
638 }
639
640
642
643 static const Accessor< std::vector< float > > etaAcc( "eta_sampl" );
644 static const Accessor< std::vector< float > > phiAcc( "phi_sampl" );
645 static const Accessor< std::vector< float > > eAcc( "e_sampl" );
646 static const Accessor< std::vector< float > > emaxAcc( "emax_sampl" );
647 static const Accessor< std::vector< float > > etamaxAcc( "etamax_sampl" );
648 static const Accessor< std::vector< float > > phimaxAcc( "phimax_sampl" );
649 static const Accessor< std::vector< float > > etasizeAcc( "etasize_sampl" );
650 static const Accessor< std::vector< float > > phisizeAcc( "phisize_sampl" );
651
652 static const std::array< const Accessor< std::vector< float > >*, 8 > allAcc = {
653 { &etaAcc, &phiAcc, &eAcc, &emaxAcc, &phimaxAcc, &etamaxAcc,
654 &etasizeAcc, &phisizeAcc } };
655 for (const auto *a : allAcc) {
656 if (a->isAvailableWritable(*this)) {
657 (*a)(*this).clear();
658 }
659 }
660 }
661
662 bool CaloCluster_v1::retrieveMoment( MomentType type, double& value ) const {
663
664 // Get the moment accessor:
666 if (!acc){
667 return false;
668 }
669 // Check if the moment is available:
670 if( ! acc->isAvailable( *this ) ) {
671 return false;
672 }
673 // Retrieve the moment:
674 value = ( *acc )( *this );
675 return true;
676 }
677
680 if ( acc != nullptr ) { (*acc)(*this) = value; } // new protection needed non-scalar moment type!
681 }
682
685 // only implemented for one moment
686 if ( acc != nullptr ) { (*acc)(*this) = values; }
687 }
688
691 // only known moments of this type
692 if ( acc == nullptr || !acc->isAvailable(*this) ) { return false; }
693 // retrieve data
694 values = (*acc)(*this);
695 return true;
696 }
697
712
713 // Set the number of cells in a given sampling
715 const Accessor<ncells_store_t>* acc = momentContainerAccessorV1(NCELL_SAMPLING); // should always be valid!
716 // cast to cell counter type and limit value range
718 // check index and extend store if needed
719 size_t idx((size_t)samp);
720 if ( idx >= (*acc)(*this).size() ) { (*acc)(*this).resize(idx+1,0); }
721 // set counts
722 (*acc)(*this)[idx] = isInnerWheel ? setUpperCount<ncells_t>((*acc)(*this)[idx],nc) : setLowerCount<ncells_t>((*acc)(*this)[idx],nc);
723 }
724
725 // Retrieve the number of cells in a given sampling
728 //
729 if ( acc != nullptr && acc->isAvailable(*this) ) {
730 size_t idx((size_t)samp);
731 return ( idx < (*acc)(*this).size() ) // valid sampling
732 ? isInnerWheel // check if inner wheel cell count is requested
733 ? extractUpperCount<int>((*acc)(*this)[idx])
734 : extractLowerCount<int>((*acc)(*this)[idx])
735 : 0;
736 } else {
737 return 0;
738 }
739 }
740
741 // Get number of all cells
743 std::vector<int> ncells;
744 return getNumberCellsInSampling<std::vector<int> >(ncells) ? std::accumulate(ncells.begin(),ncells.end(),0) : 0;
745 }
746
748 const unsigned clustersize=clusterSize();
749 unsigned int size = 0;
750 if(clustersize==SW_55ele ||
751 clustersize==SW_55gam ||
752 clustersize==SW_55Econv){
753 size = 5;
754 }else if(clustersize==SW_35ele ||
755 clustersize==SW_37ele ||
756 clustersize==SW_35gam ||
757 clustersize==SW_37gam ||
758 clustersize==SW_35Econv ||
759 clustersize==SW_37Econv){
760 size = 3;
761 }else if(clustersize==SW_7_11){
762 size = 7;
763 }
764
765 return size;
766
767 }
768
770 const ClusterSize clustersize=clusterSize();
771 unsigned int size = 0;
772 if(clustersize==SW_55ele ||
773 clustersize==SW_55gam ||
774 clustersize==SW_55Econv ||
775 clustersize==SW_35ele ||
776 clustersize==SW_35gam ||
777 clustersize==SW_35Econv){
778 size = 5;
779 }else if(
780 clustersize==SW_37ele ||
781 clustersize==SW_37gam ||
782 clustersize==SW_37Econv){
783 size = 7;
784 }else if(clustersize==SW_7_11){
785 size = 11;
786 }
787 return size;
788 }
789
790
791
792
793
794
795#if !(defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS))
797 IProxyDict* sg /*= nullptr*/)
798 {
799 if (!m_cellLinks || !cccl){
800 return false;
801 }
802 cccl->push_back(m_cellLinks.release());//The links are now owned by the container
803 const size_t idx=cccl->size()-1; //Use index for speed
804 static const Accessor<ElementLink<CaloClusterCellLinkContainer> > accCellLinks("CellLink");
807 accCellLinks(*this)=el;
808 return true;
809 }
810 bool
812 const EventContext& ctx)
813 {
814 if (!m_cellLinks || !cccl) {
815 return false;
816 }
817 // The links are now owned by the container
818 cccl->push_back(m_cellLinks.release());
819 const size_t idx = cccl->size() - 1; // Use index for speed
821 accCellLinks("CellLink");
822 const CaloClusterCellLinkContainer& ref = *cccl;
824 accCellLinks(*this) = el;
825 return true;
826 }
827
830 {
831 if (m_cellLinks) {
832 return m_cellLinks.get();
833 }
834 static const Accessor<ElementLink<CaloClusterCellLinkContainer> > accCellLinks("CellLink");
835 if (!accCellLinks.isAvailable(*this)){
836 return nullptr;
837 }
838
839 const ElementLink<CaloClusterCellLinkContainer>& el=accCellLinks(*this);
840 if (el.isValid()){
841 return *el;
842 }
843
844 return nullptr;
845 }
846
847 bool CaloCluster_v1::removeCell(const CaloCell* ptrToDelete) {
848 //1. Get a ptr to the CaloClusterCellLink
850 if (!cccl){
851 return false; // No link found (expected for TopoClusters in xAOD files)
852 }
853 // 2. Remove cell
854 return cccl->removeCell(ptrToDelete);
855 }
856
857
858#endif // not defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS)
859
864
865#if !(defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS))
867 accCellLinks( "CellLink" );
868 if( accCellLinks.isAvailableWritable( *this ) ) {
869 accCellLinks( *this ).toPersistent();
870 }
871#endif // not defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS)
872
873 static const Accessor< ElementLink< xAOD::CaloClusterContainer_v1 > > accSisterCluster("SisterCluster");
874 if( accSisterCluster.isAvailableWritable( *this ) ) {
875 accSisterCluster( *this ).toPersistent();
876 }
877
878 // Return gracefully:
879 }
880
882 static const Accessor< ElementLink< xAOD::CaloClusterContainer_v1 > > accSisterCluster("SisterCluster");
883 if (!accSisterCluster.isAvailable(*this)){
884 return nullptr;
885 }
886 const ElementLink<CaloClusterContainer_v1>& el = accSisterCluster(*this);
887 if (el.isValid()) {
888 return *el;
889 }
890 return nullptr;
891 }
892
894 static const Accessor< ElementLink< xAOD::CaloClusterContainer_v1 > > accSisterCluster("SisterCluster");
896 if (!accSisterCluster.isAvailable(*this)){
897 return empty;
898 }
899 return accSisterCluster(*this);
900 }
901
903 {
904 static const Accessor< ElementLink<xAOD::CaloClusterContainer_v1 > > accSisterCluster("SisterCluster");
905 accSisterCluster(*this)=sister;
906 return true;
907 }
908
910
912 if ( m_secondTime < 0. ) {
913 double stime(0.); return this->retrieveMoment(SECOND_TIME,stime) ? stime : 0.;
914 } else {
915 return m_secondTime;
916 }
917 }
918
919#if !(defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS))
920size_t CaloCluster_v1::size() const {
922 if (!cl) return 0;
923 return cl->size();
924 }
925#endif // not defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS)
926
927} // namespace xAOD
const boost::regex ref(r_ef)
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
CaloPhiRange class declaration.
std::vector< size_t > vec
static Double_t sp
static Double_t a
static Double_t sc
static const Attributes_t empty
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
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.
AuxElement & operator=(const AuxElement &other)
Assignment.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Description of a calorimeter cluster.
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
void setRawEta(flt_t)
Set for signal state UNCALIBRATED.
ClusterSize clusterSize() const
Get cluster size.
void setAltPhi(flt_t)
Set for signal state ALTCALIBRATED.
const CaloCluster_v1 * getSisterCluster() const
Get a pointer to a 'sister' cluster (eg the non-calibrated counterpart)
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
flt_t rawE() const
CaloRecoStatus m_recoStatus
Reco status (transient only)
void setRawPhi(flt_t)
Set for signal state UNCALIBRATED.
void setSecondTime(flt_t stime)
Set second moment of cell timing distribution.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
ncells_store_t::value_type setUpperCount(ncells_store_t::value_type cdata, UNSIGNED cupper)
State
enum of possible signal states.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > GenVecFourMom_t
Base 4 Momentum type for calo.
unsigned m_samplingPattern
bit-pattern describing the calo samplings contributing to this cluster
unsigned sampVarIdx(const CaloSample) const
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters)
bool setSisterClusterLink(const ElementLink< CaloClusterContainer_v1 > &sister)
Set a link to a 'sister' cluster (eg the non-calibrated counterpart)
flt_t calPhi() const
Get in signal state CALIBRATED.
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
double m_secondTime
Second cell time moment (transient only)
float etasize(const CaloSample sampling) const
Returns cluster size in for a given sampling.
flt_t rawM() const
Get mass in signal state UNCALIBRATED.
void setAltM(flt_t)
Set mass for singal state ALTCALIBRATED.
bool setEtasize(const CaloSample sampling, const float etaSize)
Set the cluster size in for a given sampling.
std::unique_ptr< CaloClusterCellLink > m_cellLinks
Unique ptr to cell links.
float energy_max(const CaloSample sampling) const
Retrieve maximum cell energy in given sampling.
int numberCellsInSampling(const CaloSample samp, bool isInnerWheel=false) const
Returns number of cells in given sampling.
void addCellLink(CaloClusterCellLink *CCCL)
bool setSignalState(const State s)
Switch signal state.
CaloCluster_v1()
Default constructor.
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
virtual double m() const
The invariant mass of the particle.
void setRawE(flt_t)
Set Energy for signal state UNCALIBRATED.
void setCalPhi(flt_t)
Set for signal state CALIBRATED.
void setRawM(flt_t)
Set mass for singal state UNCALIBRATED.
uint8_t ncells_t
Type for number-of-cells-in-sampling counter.
virtual double eta() const
The pseudorapidity ( ) of the particle.
flt_t altPhi() const
Get in signal state ALTCALIBRATED.
flt_t rawPhi() const
Get in signal state UNCALIBRATED.
bool setPhisize(const CaloSample sampling, const float phiSize)
Set the cluster size in for a given sampling.
int numberCells() const
Return total number of cells in cluster.
void setAltEta(flt_t)
Set for signal state ALTCALIBRATED.
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
bool setSamplVarFromAcc(const Accessor< std::vector< float > > &acc, const CaloSample sampling, const float value)
flt_t rawEta() const
Get in signal state UNCALIBRATED.
unsigned int getClusterEtaSize() const
Get eta size from cluster size.
UNSIGNED extractUpperCount(ncells_store_t::value_type cdata) const
extract upper cell count from data
virtual double e() const
The total energy of the particle.
void insertMoment(MomentType type, double value)
virtual ~CaloCluster_v1()
Destructor.
flt_t altE() const
Get Energy in signal state ALTCALIBRATED.
void setCalEta(flt_t)
Set for signal state CALIBRATED.
void setClusterSize(const ClusterSize)
Get cluster size.
CCTYPE adjustToRange(UNSIGNED count) const
< reduce value range to min and max counts
bool setPhimax(const CaloSample sampling, const float phiMax)
Set the phi of the cell with the highest energy in a particular sampling.
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool setEmax(const CaloSample sampling, const float eMax)
Set the Energy of the cell with the highest energy in a particular sampling.
bool getNumberCellsInSampling(CDATA &cdata) const
Get number of cells for all sampling layer.
std::vector< uint16_t > ncells_store_t
Store type for number-of-cells-in-sampling counter.
float eSample(const CaloSample sampling) const
flt_t calEta() const
Get in signal state CALIBRATED.
ClusterSize
Enumeration to identify different cluster sizes.
flt_t secondTime() const
Access second moment of cell timing distribution.
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
bool setEnergy(const CaloSample sampling, const float e)
Set energy for a given sampling. Returns false if the sample isn't part of the cluster.
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
void toPersistent()
Function preparing the object to be persistified.
CaloCluster_v1 & operator=(const xAOD::CaloCluster_v1 &other)
Assignment operator.
float etamax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
CaloClusterCellLink * getOwnCellLinks()
Get a pointer to the owned CaloClusterCellLink object (non-const version)
void setAltE(flt_t)
Set Energy for signal state ALTCALIBRATED.
float getSamplVarFromAcc(const Accessor< std::vector< float > > &acc, const CaloSample sampling, const float errorvalue=CaloClusterDetails::defaultErrorValue) const
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector type.
MomentType
Enums to identify different moments.
@ NCELL_SAMPLING
Number of cells in sampling layer.
@ SECOND_TIME
Second moment of cell time distribution in cluster.
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double rapidity() const
The true rapidity (y) of the particle.
void setNumberCellsInSampling(CaloSampling::CaloSample samp, int ncells, bool isInnerWheel=false)
Set the number of cells in a sampling layer.
float phimax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
const ElementLink< xAOD::CaloClusterContainer_v1 > & getSisterClusterLink() const
Get a link to a 'sister' cluster (eg the non-calibrated counterpart)
ncells_store_t::value_type setLowerCount(ncells_store_t::value_type cdata, UNSIGNED clower)
flt_t calE() const
Geet Energy in signal state CALIBRATED.
UNSIGNED extractLowerCount(ncells_store_t::value_type cdata) const
extract lower cell count from data
bool setEtamax(const CaloSample sampling, const float etaMax)
Set the eta of the cell with the highest energy in a particular sampling.
void clearSamplingData()
Clear the sampling data.
void setCalE(flt_t)
Set Energy for signal state CALIBRATED.
bool removeCell(const CaloCell *ptr)
Method to remove a cell to the cluster (slow!) (Beware: Kinematics not updated!)
State m_signalState
Current signal state.
void setCalM(flt_t)
Set mass for singal state CALIBRATED.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
flt_t altEta() const
Get in signal state ALTCALIBRATED.
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
bool setLink(CaloClusterCellLinkContainer *CCCL, IProxyDict *sg=nullptr)
Set up an ElementLink to a CaloClusterCellLink object.
CaloSampling::CaloSample CaloSample
flt_t altM() const
Get mass in signal state ALTCALIBRATED.
unsigned nSamples() const
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
float phisize(const CaloSample sampling) const
Returns cluster size in for a given sampling.
void setBadChannelList(const CaloClusterBadChannelList &bcl)
const CaloClusterBadChannelList & badChannelList() const
flt_t calM() const
Get mass in signal state CALIBRATED.
unsigned int getClusterPhiSize() const
Get phi size from cluster size.
unsigned samplingPattern() const
Access to sampling pattern (one bit per sampling) (Method may be removed later)
void setM(flt_t)
Set Mass for the current signal state.
IParticle()=default
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
std::string stime()
return the current data and time
float getSamplVar(const CaloSample sampling, const std::uint32_t samplingPattern, const std::span< const float > vec, const float errorvalue=defaultErrorValue)
float phiBE(const unsigned sample, const std::uint32_t samplingPattern, const std::span< const float > e_sampl, const std::span< const float > phi_sampl)
float etaBE(const unsigned sample, const std::uint32_t samplingPattern, const std::span< const float > e_sampl, const std::span< const float > eta_sampl)
Get the eta in one layer of the EM Calo.
float energyBE(const unsigned sample, const std::uint32_t samplingPattern, const std::span< const float > e_sampl)
Get the energy in one layer of the EM Calo.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
std::vector< CaloClusterBadChannelData > CaloClusterBadChannelList
const SG::AuxElement::Accessor< xAOD::CaloCluster_v1::ncells_store_t > * momentContainerAccessorV1(xAOD::CaloCluster_v1::MomentType moment)
Helper function for managing cluster moment Accessor objects.
const SG::AuxElement::Accessor< float > * momentAccessorV1(xAOD::CaloCluster_v1::MomentType moment)
Helper function for managing cluster moment Accessor objects.
setRawEt rawPhi
static AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(EmTauRoI_v1, uint32_t, roiWord, setRoIWord) uint32_t EmTauRoI_v1 const SG::AuxElement::Accessor< std::vector< float > > values("thrValues")
This is a convenience function for accessing the threshold pattern part of the RoI.
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.