ATLAS Offline Software
Loading...
Searching...
No Matches
CaloRec::Helpers Namespace Reference

Classes

struct  CaloClusterSignalAccumulator
 Cache for data accumulator. More...

Typedefs

Types
typedef std::array< double, CaloSampling::Unknown > valarray_t
 Array accommodating data for samplings.
typedef std::vector< bool > boolarray_t
 Vector of flags indicating sampling contribution.

Functions

Messaging

Message formatter

std::string fmtMsg (const char *fmt,...)
Cluster building and refinement

Accumulator function

This function fills the CaloClusterSignalAccumulator object. It is invoked for each cell in a cluster.

Parameters
rcellreference to non-modifiable CaloCell object
accumreference to modifiable CaloClusterSignalAccumulator object
weightweight of cell contribution
onlyKineupdate only global cluster kinematics when true, else update all cluster variables
bool cellAccumulator (const CaloCell &rcell, CaloClusterSignalAccumulator &accum, double weight, bool onlyKine=false)
bool calculateKine (xAOD::CaloCluster *pClus, bool onlyKine=false)
 Kinematic updates.

Typedef Documentation

◆ boolarray_t

typedef std::vector<bool> CaloRec::Helpers::boolarray_t

Vector of flags indicating sampling contribution.

Definition at line 36 of file CaloTopoClusterFromTowerHelpers.h.

◆ valarray_t

typedef std::array<double,CaloSampling::Unknown> CaloRec::Helpers::valarray_t

Array accommodating data for samplings.

Definition at line 35 of file CaloTopoClusterFromTowerHelpers.h.

Function Documentation

◆ calculateKine()

bool CaloRec::Helpers::calculateKine ( xAOD::CaloCluster * pClus,
bool onlyKine = false )

Kinematic updates.

This function updates the kinematics of a cluster e.g. after calibration

Parameters
pCluspointer to modifiable cluster object
onlyKineupdate only global cluster kinematics when true, else update all cluster variables

Definition at line 119 of file CaloTopoClusterFromTowerHelpers.cxx.

120{
121 // Tell clang to optimize assuming that FP operations may trap.
123
124 // input
125 if ( pClus == nullptr ) { return false; }
126
127 // get cell links
128 const CaloClusterCellLink* clk = pClus->getCellLinks();
129 if ( clk == nullptr || clk->size() == 0 ) { return false; }
130
131 // accumulator object ////////////////////////////////////////////////
132 CaloClusterSignalAccumulator accum; // Strict enforcement of valid cell pointers! //
133 // accumulate cells ////////////////////////////////////////////////
134 bool retflg(true);
135 auto citer(clk->begin());
136 while ( citer != clk->end() && retflg ) {
137 if ( *citer != nullptr ) { retflg = cellAccumulator(**citer,accum,citer.weight(),onlyKine); } ++citer; }
138 if ( !retflg ) { return false; }
139
140 // set cluster kinematics: energy & mass
141 pClus->setE(accum.cluster.accumE);
142 pClus->setM(0.);
143
144 // set cluster kinematics: directions
145 if ( accum.cluster.accumAbsE != 0. ) {
146 double invPosNorm(1./accum.cluster.accumAbsE);
147 pClus->setEta(accum.cluster.accumEta*invPosNorm);
148 pClus->setPhi(CaloPhiRange::fix(accum.cluster.accumPhi*invPosNorm));
149 } else {
150 pClus->setEta(0.);
151 pClus->setPhi(0.);
152 }
153
154 // bail out if only global kinematics to be updated
155 if ( onlyKine ) { return true; }
156
157 // set cluster kinematics: time
158 if ( accum.cluster.accumTimeNorm != 0. ) {
159 pClus->setTime(accum.cluster.accumTime/accum.cluster.accumTimeNorm);
160 } else {
161 pClus->setTime(0.);
162 }
163
164 // set sampling pattern
165 uint32_t samplingPattern(0);
166 for ( int i(0); i<(int)CaloSampling::Unknown; ++i ) {
167 if ( accum.sampling.presenceInSample[i] ) { samplingPattern |= (0x1U<<i); }
168 if ( samplingPattern != pClus->samplingPattern() ) {
169 pClus->clearSamplingData();
170 pClus->setSamplingPattern(samplingPattern,true);
171 }
172 }
173
174 // set sampling variables
175 for ( int i(0); i<(int)CaloSampling::Unknown; ++i ) {
176 if ( accum.sampling.presenceInSample[i] ) {
178 pClus->setEnergy(sam,accum.sampling.energyInSample[i]);
179 double enorm(accum.sampling.posNormInSample[i]);
180 double eta(accum.sampling.etaInSample[i]);
181 double phi(accum.sampling.phiInSample[i]);
182 if ( enorm != 0. ) {
183 pClus->setEta(sam,eta/enorm);
184 pClus->setPhi(sam,CaloPhiRange::fix(phi/enorm));
185 } else {
186 pClus->setEta(sam,eta);
187 pClus->setPhi(sam,CaloPhiRange::fix(phi));
188 }
189 pClus->setEmax(sam,accum.sampling.maxEnergyInSample[i]);
190 pClus->setEtamax(sam,accum.sampling.etaMaxEnergyInSample[i]);
191 pClus->setPhimax(sam,accum.sampling.phiMaxEnergyInSample[i]);
192 } // check if sampling is in cluster
193 } // loop on samplings
194
195 return true;
196}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
static double fix(double phi)
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
void setTime(flt_t)
Set cluster time.
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 setEnergy(const CaloSample sampling, const float e)
Set energy for a given sampling. Returns false if the sample isn't part of the cluster.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
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.
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.
bool cellAccumulator(const CaloCell &rcell, CaloClusterSignalAccumulator &accum, double weight, bool onlyKine=false)
setEventNumber uint32_t
#define CXXUTILS_TRAPPING_FP
Definition trapping_fp.h:24

◆ cellAccumulator()

bool CaloRec::Helpers::cellAccumulator ( const CaloCell & rcell,
CaloClusterSignalAccumulator & accum,
double weight,
bool onlyKine = false )

Definition at line 24 of file CaloTopoClusterFromTowerHelpers.cxx.

25{
27 // Collecting Kinematics //
29
30
31 // required info
32 const CaloDetDescrElement* dde = rcell.caloDDE(); if ( dde == nullptr ) { return false; }
33 // energy and weights
34 accum.cluster.cellWeight = weight;
35 accum.cluster.cellAbsWeight = std::fabs(accum.cluster.cellWeight);
36 accum.cluster.cellE = accum.cluster.cellWeight*rcell.e();
37 accum.cluster.cellAbsE = accum.cluster.cellAbsWeight*std::fabs(rcell.e());
38 // direction
39 double celleta(dde->eta());
40 double cellphi(dde->phi());
41 // energy sum and normalizations
42 accum.cluster.accumE += accum.cluster.cellE;
43 accum.cluster.accumAbsE += accum.cluster.cellAbsE;
44 if ( accum.cluster.firstCell ) {
45 accum.cluster.phiSeed = cellphi; accum.cluster.firstCell = false;
46 } else {
47 cellphi = proxim(cellphi,accum.cluster.phiSeed);
48 }
49 accum.cluster.accumPhi += accum.cluster.cellAbsE*cellphi;
50 accum.cluster.accumEta += accum.cluster.cellAbsE*celleta;
51 // kine kinmatic updates done
52 if ( onlyKine ) return true;
53
55 // Sampling Quantities //
57
58 // check if cell has valid sampling
60 int isam((int)sam);
61 int fsam((int)CaloSampling::Unknown);
62 if ( isam < 0 || isam >= fsam ) { return false; }
63
64 // mark sampling in cluster
65 accum.sampling.presenceInSample[isam] = true;
66
67 // collecting in samples
68 accum.sampling.energyInSample[isam] += accum.cluster.cellE;
69 accum.sampling.posNormInSample[isam] += accum.cluster.cellAbsE;
70 accum.sampling.etaInSample[isam] += accum.cluster.cellAbsE*celleta;
71 accum.sampling.phiInSample[isam] += accum.cluster.cellAbsE*cellphi;
72
73 // maximum energies in samplings
74 if ( accum.cluster.cellE > accum.sampling.maxEnergyInSample[isam] ) {
75 accum.sampling.maxEnergyInSample[isam] = accum.cluster.cellE;
76 accum.sampling.etaMaxEnergyInSample[isam] = celleta;
77 accum.sampling.phiMaxEnergyInSample[isam] = cellphi;
78 }
79
80 // counting cells in barrel and endcap
81 if ( accum.cluster.cellE != 0. && accum.cluster.cellWeight != 0. ) {
82 switch (sam) {
83 case CaloSampling::PreSamplerE:
84 case CaloSampling::EME1:
85 case CaloSampling::EME2:
86 case CaloSampling::EME3:
87 case CaloSampling::HEC0:
88 case CaloSampling::HEC1:
89 case CaloSampling::HEC2:
90 case CaloSampling::HEC3:
91 case CaloSampling::FCAL0:
92 case CaloSampling::FCAL1:
93 case CaloSampling::FCAL2:
94 case CaloSampling::MINIFCAL0:
95 case CaloSampling::MINIFCAL1:
96 case CaloSampling::MINIFCAL2:
97 case CaloSampling::MINIFCAL3:
98 accum.cluster.nEndcap++;
99 break;
100 default:
101 accum.cluster.nBarrel++;
102 break;
103 }
104
105 // time where available
106 if ( sam != CaloSampling::PreSamplerB && sam != CaloSampling::PreSamplerE ) {
107 unsigned int pmask = dde->is_tile() ? 0x8080 : 0x2000;
108 // is time defined?
109 if ( rcell.provenance() & pmask ) {
110 double tnorm(accum.cluster.cellAbsE*accum.cluster.cellWeight*rcell.e()); // sign of weight preserved!
111 accum.cluster.accumTime += tnorm*rcell.time();
112 accum.cluster.accumTimeNorm += tnorm;
113 } // cell ok for time
114 } // sampling contributes to time
115 } // cell has energy and weight != 0
116 return true;
117}
float time() const
get time (data member)
Definition CaloCell.h:368
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
uint16_t provenance() const
get provenance (data member)
Definition CaloCell.h:354
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
double proxim(double b, double a)
Definition proxim.h:17
boolarray_t presenceInSample
Flag for presens of sampling in cluster.
valarray_t posNormInSample
Positive (absolute) normalization energy.

◆ fmtMsg()

std::string CaloRec::Helpers::fmtMsg ( const char * fmt,
... )

Definition at line 14 of file CaloTopoClusterFromTowerHelpers.cxx.

14 {
15 char buffer[1024];
16 va_list args;
17 va_start(args,fmt);
18 vsprintf(buffer,fmt,args);
19 va_end(args);
20 return std::string(buffer);
21}
const char *const fmt