00001
00002
00003 #ifndef XAODCALOEVENT_VERSIONS_CALOCLUSTER_V1_H
00004 #define XAODCALOEVENT_VERSIONS_CALOCLUSTER_V1_H
00005
00006
00007 extern "C" {
00008 # include <stdint.h>
00009 }
00010 #include <bitset>
00011
00012
00013 #include "xAODBase/IParticle.h"
00014
00015
00016 #include "CaloGeoHelpers/CaloSampling.h"
00017
00018 #include "xAODCaloEvent/CaloClusterBadChannelData.h"
00019
00020 #ifndef XAOD_ANALYSIS
00021 #include "AthLinks/ElementLink.h"
00022 #include "CaloEvent/CaloClusterCellLinkContainer.h"
00023 #include "CaloEvent/CaloRecoStatus.h"
00024 #endif // not XAOD_ANALYSIS
00025
00026
00027 #ifdef XAOD_ANALYSIS
00028 class CaloClusterCellLink {};
00029 typedef unsigned CaloRecoStatus;
00030 #endif // XAOD_ANALYSIS
00031
00032 class CaloClusterChangeSignalState;
00033
00034 namespace xAOD {
00035
00043 class CaloCluster_v1 : public IParticle {
00044 friend class ::CaloClusterChangeSignalState;
00045
00046 public:
00047
00048 typedef float flt_t;
00049
00050 typedef CaloSampling::CaloSample CaloSample;
00051
00054
00056 enum ClusterSize {
00057
00058 SW_55ele = 1,
00059 SW_35ele = 2,
00060 SW_37ele = 3,
00061
00062 SW_55gam = 4,
00063 SW_35gam = 5,
00064 SW_37gam = 6,
00065
00066 SW_55Econv = 7,
00067 SW_35Econv = 8,
00068 SW_37Econv = 9,
00069
00070 SW_softe = 10,
00071
00072 Topo_420 = 11,
00073 Topo_633 = 12,
00074
00075 SW_7_11 = 13,
00076 CSize_Unknown = 99
00077 };
00078
00084 enum MomentType {
00085 FIRST_PHI = 101,
00086 FIRST_ETA = 102,
00087 SECOND_R = 201,
00088 SECOND_LAMBDA = 202,
00089
00090 DELTA_PHI = 301,
00092 DELTA_THETA = 302,
00094 DELTA_ALPHA = 303,
00095 CENTER_X = 401,
00096 CENTER_Y = 402,
00097 CENTER_Z = 403,
00098
00099 CENTER_MAG = 404,
00100 CENTER_LAMBDA = 501,
00101 LATERAL = 601,
00102 LONGITUDINAL = 602,
00103 ENG_FRAC_EM = 701,
00104 ENG_FRAC_MAX = 702,
00105
00106 ENG_FRAC_CORE = 703,
00107 FIRST_ENG_DENS = 804,
00108 SECOND_ENG_DENS = 805,
00109
00110 ISOLATION = 806,
00112 ENG_BAD_CELLS = 807,
00113 N_BAD_CELLS = 808,
00114
00115 N_BAD_CELLS_CORR = 809,
00117 BAD_CELLS_CORR_E = 813,
00119 BADLARQ_FRAC = 821,
00120 ENG_POS = 822,
00121 SIGNIFICANCE = 823,
00122
00123 CELL_SIGNIFICANCE = 824,
00125 CELL_SIG_SAMPLING = 825,
00127 AVG_LAR_Q = 826,
00129 AVG_TILE_Q = 827,
00131 ENG_BAD_HV_CELLS = 828,
00132 N_BAD_HV_CELLS = 829,
00133 EM_PROBABILITY = 900,
00134 HAD_WEIGHT = 901,
00135 OOC_WEIGHT = 902,
00136 DM_WEIGHT = 903,
00137
00138 TILE_CONFIDENCE_LEVEL = 904,
00139
00140 VERTEX_FRACTION = 1000,
00141 NVERTEX_FRACTION = 1001,
00143 ETACALOFRAME = 1100,
00144 PHICALOFRAME = 1101,
00145 ETA1CALOFRAME = 1102,
00146 PHI1CALOFRAME = 1103,
00147 ETA2CALOFRAME = 1104,
00148 PHI2CALOFRAME = 1105,
00149
00151 ENG_CALIB_TOT = 10001,
00152 ENG_CALIB_OUT_L = 10010,
00156 ENG_CALIB_OUT_M = 10011,
00160 ENG_CALIB_OUT_T = 10012,
00164 ENG_CALIB_DEAD_L = 10020,
00167 ENG_CALIB_DEAD_M = 10021,
00170 ENG_CALIB_DEAD_T = 10022,
00173
00174 ENG_CALIB_EMB0 = 10030,
00176 ENG_CALIB_EME0 = 10031,
00178 ENG_CALIB_TILEG3 = 10032,
00180 ENG_CALIB_DEAD_TOT = 10040,
00183 ENG_CALIB_DEAD_EMB0 = 10041,
00186 ENG_CALIB_DEAD_TILE0 = 10042,
00188 ENG_CALIB_DEAD_TILEG3 = 10043,
00191 ENG_CALIB_DEAD_EME0 = 10044,
00194 ENG_CALIB_DEAD_HEC0 = 10045,
00197 ENG_CALIB_DEAD_FCAL = 10046,
00199 ENG_CALIB_DEAD_LEAKAGE = 10047,
00202 ENG_CALIB_DEAD_UNCLASS = 10048,
00204 ENG_CALIB_FRAC_EM = 10051,
00207 ENG_CALIB_FRAC_HAD = 10052,
00209 ENG_CALIB_FRAC_REST = 10053
00210 };
00211
00213 enum State {
00214 UNKNOWN = -1,
00215 UNCALIBRATED = 0,
00216 CALIBRATED = 1,
00217 ALTCALIBRATED = 2,
00218 NSTATES = 3
00219 };
00220
00222
00224 CaloCluster_v1();
00225
00227 CaloCluster_v1(const CaloCluster_v1& other);
00228
00230 virtual ~CaloCluster_v1();
00231
00233 CaloCluster_v1& operator=(const xAOD::CaloCluster_v1& other);
00234
00237
00239 virtual double pt() const;
00241 virtual double eta() const;
00243 virtual double phi() const;
00245 virtual double m() const;
00247 virtual double e() const;
00249 virtual double rapidity() const;
00250
00252 typedef IParticle::FourMom_t FourMom_t;
00253
00255 virtual const FourMom_t& p4() const;
00256
00257 const FourMom_t& p4(const State s) const;
00258
00260 virtual Type::ObjectType type() const;
00262
00266 double et() const;
00267
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 public:
00282
00286 float eSample(const CaloSample sampling) const;
00288 float etaSample(const CaloSample sampling) const;
00290 float phiSample(const CaloSample sampling) const;
00291
00293 float energy_max(const CaloSample sampling) const;
00296 float etamax(const CaloSample sampling) const;
00299 float phimax(const CaloSample sampling) const;
00300
00302 float etasize(const CaloSample sampling) const;
00304 float phisize(const CaloSample sampling) const;
00305
00306
00307
00308
00309
00315 float energyBE(const unsigned layer) const;
00316
00322 float etaBE(const unsigned layer) const;
00328 float phiBE(const unsigned layer) const;
00329
00330
00332 bool setEnergy(const CaloSample sampling, const float e);
00334 bool setEta(const CaloSample sampling, const float eta);
00336 bool setPhi(const CaloSample sampling, const float phi );
00337
00339 bool setEmax(const CaloSample sampling, const float eMax );
00341 bool setEtamax(const CaloSample sampling, const float etaMax );
00343 bool setPhimax(const CaloSample sampling, const float phiMax );
00345 bool setEtasize(const CaloSample sampling, const float etaSize );
00347 bool setPhisize(const CaloSample sampling, const float phiSize );
00348
00349
00350
00351
00352
00354
00358 void insertMoment( MomentType type, double value );
00359
00361 bool retrieveMoment( MomentType type, double& value ) const;
00362
00364 double getMomentValue( MomentType type) const;
00365
00367
00368
00369
00373 void setEta0(flt_t);
00375 flt_t eta0() const;
00376
00378 void setPhi0(flt_t);
00380 flt_t phi0() const;
00381
00383 void setTime(flt_t);
00385 flt_t time() const;
00386
00388 unsigned samplingPattern() const;
00390 void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false);
00391
00393 void clearSamplingData();
00394
00395 unsigned nSamples() const;
00396
00398 bool hasSampling(const CaloSample s) const;
00399
00400
00402 ClusterSize clusterSize() const;
00404 void setClusterSize(const ClusterSize);
00405
00407 bool inBarrel() const;
00409 bool inEndcap() const;
00410
00412
00416 void setE(flt_t);
00418 void setEta(flt_t);
00420 void setPhi(flt_t);
00422 void setM(flt_t);
00423
00425
00429 flt_t rawE() const;
00431 void setRawE(flt_t);
00433 flt_t rawEta() const;
00435 void setRawEta(flt_t);
00437 flt_t rawPhi() const;
00439 void setRawPhi(flt_t);
00441 flt_t rawM() const;
00443 void setRawM(flt_t);
00444
00446 flt_t altE() const;
00448 void setAltE(flt_t);
00450 flt_t altEta() const;
00452 void setAltEta(flt_t);
00454 flt_t altPhi() const;
00456 void setAltPhi(flt_t);
00458 flt_t altM() const;
00460 void setAltM(flt_t);
00461
00463 flt_t calE() const;
00465 void setCalE(flt_t);
00467 flt_t calEta() const;
00469 void setCalEta(flt_t);
00471 flt_t calPhi() const;
00473 void setCalPhi(flt_t);
00475 flt_t calM() const;
00477 void setCalM(flt_t);
00478 #ifndef XAOD_ANALYSIS
00479 private:
00480 #endif
00482 bool setSignalState(const State s) const;
00483 public:
00485 State signalState() const {return m_signalState;}
00486
00488 double pt(const State s) const;
00489
00491 double e(const State s) const;
00492
00494 double eta(const State s) const;
00495
00497 double phi(const State s) const;
00498
00500
00501
00503 unsigned int getClusterEtaSize() const;
00504
00506 unsigned int getClusterPhiSize() const;
00507
00508 void setBadChannelList(const CaloClusterBadChannelList& bcl);
00509 const CaloClusterBadChannelList& badChannelList() const;
00510
00511
00512
00513
00514
00515 private:
00517 unsigned m_samplingPattern;
00519 mutable FourMom_t m_p4[xAOD::CaloCluster_v1::NSTATES];
00521 mutable std::bitset<xAOD::CaloCluster_v1::NSTATES> m_p4Cached;
00522
00523 mutable double m_pt[xAOD::CaloCluster_v1::NSTATES];
00525 mutable std::bitset<xAOD::CaloCluster_v1::NSTATES> m_ptCached;
00526
00528 mutable State m_signalState;
00530 CaloClusterCellLink* m_cellLinks;
00531
00533 bool m_ownCellLinks;
00534
00536 CaloRecoStatus m_recoStatus;
00537
00538 unsigned sampVarIdx(const CaloSample) const;
00539
00540 float getSamplVarFromAcc(Accessor<std::vector<float > >& acc,
00541 const CaloSample sampling, const float errorvalue=-999) const;
00542
00543 bool setSamplVarFromAcc(Accessor<std::vector<float> >& acc,
00544 const CaloSample sampling, const float value);
00545 public:
00546 #ifndef XAOD_ANALYSIS
00547
00551 void addCellLink(CaloClusterCellLink* CCCL) {
00552 if (m_ownCellLinks && m_cellLinks) {
00553
00554 delete m_cellLinks;
00555 }
00556
00557 m_cellLinks=CCCL;
00558 m_ownCellLinks=true;
00559 }
00565
00566
00572 bool setLink(CaloClusterCellLinkContainer* CCCL,
00573 IProxyDictWithPool* sg = nullptr);
00574
00578 const CaloClusterCellLink* getCellLinks() const;
00579
00583 CaloClusterCellLink* getCellLinks() {
00584 return m_cellLinks;
00585 }
00586
00592 bool addCell(const unsigned index, const double weight) {
00593 if (!m_cellLinks) return false;
00594 return m_cellLinks->addCell(index,weight);
00595 }
00596
00603 bool removeCell(const CaloCell* ptr);
00604
00605
00609 size_t size() const {return getCellLinks()->size();}
00610
00612 typedef CaloClusterCellLink::const_iterator const_cell_iterator;
00613
00614 const_cell_iterator cell_begin() const {
00615 const CaloClusterCellLink* links=getCellLinks();
00616 if (!links)
00617 return CaloClusterCellLink::dummyIt;
00618 else
00619 return links->begin();
00620 }
00621 const_cell_iterator cell_end() const {
00622 const CaloClusterCellLink* links=getCellLinks();
00623 if (!links)
00624 return CaloClusterCellLink::dummyIt;
00625 else
00626 return getCellLinks()->end();
00627 }
00628
00630 typedef CaloClusterCellLink::iterator cell_iterator;
00631
00632 cell_iterator cell_begin() { return getCellLinks()->begin();}
00633 cell_iterator cell_end() { return getCellLinks()->end();}
00634
00636 typedef const_cell_iterator const_iterator;
00637 typedef cell_iterator iterator;
00638 const_iterator begin() const { return cell_begin(); }
00639 const_iterator end() const { return cell_end(); }
00640 iterator begin() { return cell_begin(); }
00641 iterator end() { return cell_end(); }
00642
00647 void reweightCell(cell_iterator it, const double weight) {it.reweight(weight);}
00648
00652 CaloRecoStatus& recoStatus() {return m_recoStatus;}
00653
00657 const CaloRecoStatus& recoStatus() const {return m_recoStatus;}
00659
00660 #endif
00661
00663 void toPersistent();
00664
00665 };
00666
00667
00668 inline double CaloCluster_v1::et() const {
00669 if (this->m()==0)
00670 return this->pt();
00671 else
00672 return this->p4().Et();
00673 }
00674
00675 inline unsigned CaloCluster_v1::samplingPattern() const {
00676 return m_samplingPattern;
00677 }
00678
00679 inline unsigned CaloCluster_v1::sampVarIdx(const CaloCluster_v1::CaloSample s) const {
00680 const uint32_t& pattern= m_samplingPattern;
00681
00682 if ((pattern & (0x1U << s))==0)
00683 return CaloSampling::Unknown;
00684 else {
00685 if (s==0) return 0;
00686 return __builtin_popcount(pattern << (32-s));
00687
00688
00689
00690
00691 }
00692 }
00693
00694
00695 inline unsigned CaloCluster_v1::nSamples() const {
00696 const uint32_t pattern=samplingPattern();
00697 return __builtin_popcount(pattern);
00698 }
00699
00700
00701 inline bool CaloCluster_v1::hasSampling(const CaloSample s) const {
00702 const unsigned pattern=samplingPattern();
00703 return (pattern & (0x1U<<(uint32_t)s));
00704 }
00705
00706
00707 inline bool CaloCluster_v1::inBarrel() const {
00708 return (m_samplingPattern & CaloSampling::barrelPattern());
00709 }
00710
00711
00712 inline bool CaloCluster_v1::inEndcap() const {
00713 return (m_samplingPattern & CaloSampling::endcapPattern());
00714 }
00715
00716
00717 inline double CaloCluster_v1::getMomentValue( CaloCluster_v1::MomentType type) const {
00718 double value=-999;
00719 this->retrieveMoment(type,value);
00720 return value;
00721 }
00722
00723 }
00724
00725 #endif // XAODCALOEVENT_VERSIONS_CALOCLUSTER_V1_H