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 118 of file CaloTopoClusterFromTowerHelpers.cxx.

119 {
120  // input
121  if ( pClus == nullptr ) { return false; }
122 
123  // get cell links
124  const CaloClusterCellLink* clk = pClus->getCellLinks();
125  if ( clk == nullptr || clk->size() == 0 ) { return false; }
126 
127  // accumulator object ////////////////////////////////////////////////
128  CaloClusterSignalAccumulator accum; // Strict enforcement of valid cell pointers! //
129  // accumulate cells ////////////////////////////////////////////////
130  bool retflg(true);
131  auto citer(clk->begin());
132  while ( citer != clk->end() && retflg ) {
133  if ( *citer != nullptr ) { retflg = cellAccumulator(**citer,accum,citer.weight(),onlyKine); } ++citer; }
134  if ( !retflg ) { return false; }
135 
136  // set cluster kinematics: energy & mass
137  pClus->setE(accum.cluster.accumE);
138  pClus->setM(0.);
139 
140  // set cluster kinematics: directions
141  if ( accum.cluster.accumAbsE != 0. ) {
142  double invPosNorm(1./accum.cluster.accumAbsE);
143  pClus->setEta(accum.cluster.accumEta*invPosNorm);
144  pClus->setPhi(CaloPhiRange::fix(accum.cluster.accumPhi*invPosNorm));
145  } else {
146  pClus->setEta(0.);
147  pClus->setPhi(0.);
148  }
149 
150  // bail out if only global kinematice to be updated
151  if ( onlyKine ) { return true; }
152 
153  // set cluster kinematics: time
154  if ( accum.cluster.accumTimeNorm != 0. ) {
155  pClus->setTime(accum.cluster.accumTime/accum.cluster.accumTimeNorm);
156  } else {
157  pClus->setTime(0.);
158  }
159 
160  // set sampling pattern
161  uint32_t samplingPattern(0);
162  for ( int i(0); i<(int)CaloSampling::Unknown; ++i ) {
163  if ( accum.sampling.presenceInSample[i] ) { samplingPattern |= (0x1U<<i); }
164  if ( samplingPattern != pClus->samplingPattern() ) {
165  pClus->clearSamplingData();
166  pClus->setSamplingPattern(samplingPattern,true);
167  }
168  }
169 
170  // set sampling variables
171  for ( int i(0); i<(int)CaloSampling::Unknown; ++i ) {
172  if ( accum.sampling.presenceInSample[i] ) {
174  pClus->setEnergy(sam,accum.sampling.energyInSample[i]);
175  double enorm(accum.sampling.posNormInSample[i]);
176  double eta(accum.sampling.etaInSample[i]);
177  double phi(accum.sampling.phiInSample[i]);
178  if ( enorm != 0. ) {
179  pClus->setEta(sam,eta/enorm);
180  pClus->setPhi(sam,CaloPhiRange::fix(phi/enorm));
181  } else {
182  pClus->setEta(sam,eta);
183  pClus->setPhi(sam,CaloPhiRange::fix(phi));
184  }
185  pClus->setEmax(sam,accum.sampling.maxEnergyInSample[i]);
186  pClus->setEtamax(sam,accum.sampling.etaMaxEnergyInSample[i]);
187  pClus->setPhimax(sam,accum.sampling.phiMaxEnergyInSample[i]);
188  } // check if sampling is in cluster
189  } // loop on samplings
190 
191  return true;
192 }

◆ cellAccumulator()

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

Definition at line 23 of file CaloTopoClusterFromTowerHelpers.cxx.

24 {
26  // Collecting Kinematics //
28 
29 
30  // required info
31  const CaloDetDescrElement* dde = rcell.caloDDE(); if ( dde == nullptr ) { return false; }
32  // energy and weights
33  accum.cluster.cellWeight = weight;
34  accum.cluster.cellAbsWeight = std::fabs(accum.cluster.cellWeight);
35  accum.cluster.cellE = accum.cluster.cellWeight*rcell.e();
36  accum.cluster.cellAbsE = accum.cluster.cellAbsWeight*std::fabs(rcell.e());
37  // direction
38  double celleta(dde->eta());
39  double cellphi(dde->phi());
40  // energy sum and normalizations
41  accum.cluster.accumE += accum.cluster.cellE;
42  accum.cluster.accumAbsE += accum.cluster.cellAbsE;
43  if ( accum.cluster.firstCell ) {
44  accum.cluster.phiSeed = cellphi; accum.cluster.firstCell = false;
45  } else {
46  cellphi = proxim(cellphi,accum.cluster.phiSeed);
47  }
48  accum.cluster.accumPhi += accum.cluster.cellAbsE*cellphi;
49  accum.cluster.accumEta += accum.cluster.cellAbsE*celleta;
50  // kine kinmatic updates done
51  if ( onlyKine ) return true;
52 
54  // Sampling Quantities //
56 
57  // check if cell has valid sampling
59  int isam((int)sam);
60  int fsam((int)CaloSampling::Unknown);
61  if ( isam < 0 || isam >= fsam ) { return false; }
62 
63  // mark sampling in cluster
64  accum.sampling.presenceInSample[isam] = true;
65 
66  // collecting in samples
67  accum.sampling.energyInSample[isam] += accum.cluster.cellE;
68  accum.sampling.posNormInSample[isam] += accum.cluster.cellAbsE;
69  accum.sampling.etaInSample[isam] += accum.cluster.cellAbsE*celleta;
70  accum.sampling.phiInSample[isam] += accum.cluster.cellAbsE*cellphi;
71 
72  // maximum energies in samplings
73  if ( accum.cluster.cellE > accum.sampling.maxEnergyInSample[isam] ) {
74  accum.sampling.maxEnergyInSample[isam] = accum.cluster.cellE;
75  accum.sampling.etaMaxEnergyInSample[isam] = celleta;
76  accum.sampling.phiMaxEnergyInSample[isam] = cellphi;
77  }
78 
79  // counting cells in barrel and endcap
80  if ( accum.cluster.cellE != 0. && accum.cluster.cellWeight != 0. ) {
81  switch (sam) {
83  case CaloSampling::EME1:
84  case CaloSampling::EME2:
85  case CaloSampling::EME3:
86  case CaloSampling::HEC0:
87  case CaloSampling::HEC1:
88  case CaloSampling::HEC2:
89  case CaloSampling::HEC3:
93  case CaloSampling::MINIFCAL0:
94  case CaloSampling::MINIFCAL1:
95  case CaloSampling::MINIFCAL2:
96  case CaloSampling::MINIFCAL3:
97  accum.cluster.nEndcap++;
98  break;
99  default:
100  accum.cluster.nBarrel++;
101  break;
102  }
103 
104  // time where available
105  if ( sam != CaloSampling::PreSamplerB && sam != CaloSampling::PreSamplerE ) {
106  unsigned int pmask = dde->is_tile() ? 0x8080 : 0x2000;
107  // is time defined?
108  if ( rcell.provenance() & pmask ) {
109  double tnorm(accum.cluster.cellAbsE*accum.cluster.cellWeight*rcell.e()); // sign of weight preserved!
110  accum.cluster.accumTime += tnorm*rcell.time();
111  accum.cluster.accumTimeNorm += tnorm;
112  } // cell ok for time
113  } // sampling contributes to time
114  } // cell has energy and weight != 0
115  return true;
116 }

◆ fmtMsg()

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

Definition at line 13 of file CaloTopoClusterFromTowerHelpers.cxx.

13  {
14  char buffer[1024];
15  va_list args;
16  va_start(args,fmt);
17  vsprintf(buffer,fmt,args);
18  va_end(args);
19  return std::string(buffer);
20 }
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::CaloCluster_v1::clearSamplingData
void clearSamplingData()
Clear the sampling data.
Definition: CaloCluster_v1.cxx:717
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:317
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:526
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:338
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
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:571
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
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:597
CaloRec::Helpers::cellAccumulator
bool cellAccumulator(const CaloCell &rcell, CaloClusterSignalAccumulator &accum, double weight, bool onlyKine=false)
Definition: CaloTopoClusterFromTowerHelpers.cxx:23
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
lumiFormat.i
int i
Definition: lumiFormat.py:92
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:305
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:905
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
fmt
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:556
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:584
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:541
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:864
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
xAOD::CaloCluster_v1::setM
void setM(flt_t)
Set Mass for the current signal state.
Definition: CaloCluster_v1.cxx:424