ATLAS Offline Software
Classes
CaloRec::Helpers Namespace Reference

Classes

struct  CaloClusterSignalAccumulator
 Cache for data accumulator. More...
 

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

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 }

◆ 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) {
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:
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 }

◆ 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 }
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
CXXUTILS_TRAPPING_FP
#define CXXUTILS_TRAPPING_FP
Definition: trapping_fp.h:24
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:47
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
xAOD::CaloCluster_v1::clearSamplingData
void clearSamplingData()
Clear the sampling data.
Definition: CaloCluster_v1.cxx:671
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
proxim
double proxim(double b, double a)
Definition: proxim.h:17
CaloCell_ID_FCS::FCAL1
@ FCAL1
Definition: FastCaloSim_CaloCell_ID.h:41
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:327
fmt
const char *const fmt
Definition: TripleGaussCollFit.cxx:84
CaloCell_ID_FCS::HEC2
@ HEC2
Definition: FastCaloSim_CaloCell_ID.h:29
xAOD::CaloCluster_v1::setSamplingPattern
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
Definition: CaloCluster_v1.cxx:81
xAOD::CaloCluster_v1::setEnergy
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.
Definition: CaloCluster_v1.cxx:519
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:348
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:362
xAOD::CaloCluster_v1::setTime
void setTime(flt_t)
Set cluster time.
xAOD::CaloCluster_v1::setEmax
bool setEmax(const CaloSample sampling, const float eMax)
Set the Energy of the cell with the highest energy in a particular sampling.
Definition: CaloCluster_v1.cxx:564
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
xAOD::CaloCluster_v1::setE
void setE(flt_t)
Definition: CaloCluster_v1.cxx:375
xAOD::CaloCluster_v1::setPhimax
bool setPhimax(const CaloSample sampling, const float phiMax)
Set the phi of the cell with the highest energy in a particular sampling.
Definition: CaloCluster_v1.cxx:590
CaloRec::Helpers::cellAccumulator
bool cellAccumulator(const CaloCell &rcell, CaloClusterSignalAccumulator &accum, double weight, bool onlyKine=false)
Definition: CaloTopoClusterFromTowerHelpers.cxx:24
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:11
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:315
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:859
CaloDetDescrElement::is_tile
bool is_tile() const
cell belongs to Tile
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:442
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
CaloCell_ID_FCS::HEC0
@ HEC0
Definition: FastCaloSim_CaloCell_ID.h:27
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
xAOD::CaloCluster_v1::setPhi
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
Definition: CaloCluster_v1.cxx:549
xAOD::CaloCluster_v1::setEtamax
bool setEtamax(const CaloSample sampling, const float etaMax)
Set the eta of the cell with the highest energy in a particular sampling.
Definition: CaloCluster_v1.cxx:577
CaloCell_ID_FCS::FCAL2
@ FCAL2
Definition: FastCaloSim_CaloCell_ID.h:42
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
xAOD::CaloCluster_v1::setEta
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
Definition: CaloCluster_v1.cxx:534
CaloCell_ID_FCS::HEC3
@ HEC3
Definition: FastCaloSim_CaloCell_ID.h:30
xAOD::CaloCluster_v1::samplingPattern
unsigned samplingPattern() const
Access to sampling pattern (one bit per sampling) (Method may be removed later)
Definition: CaloCluster_v1.h:867
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
xAOD::CaloCluster_v1::setM
void setM(flt_t)
Set Mass for the current signal state.
Definition: CaloCluster_v1.cxx:424