ATLAS Offline Software
Typedefs | Functions | Variables
xAOD::CaloClusterDetails Namespace Reference

Typedefs

using CaloSample = CaloSampling::CaloSample
 

Functions

bool hasSampling (const CaloSample s, const std::uint32_t samplingPattern)
 Checks if certain smapling contributes to cluster. More...
 
unsigned sampVarIdx (const CaloSample s, const std::uint32_t samplingPattern)
 
float getSamplVar (const CaloSample sampling, const std::uint32_t samplingPattern, const std::span< const float > vec, const float errorvalue=defaultErrorValue)
 
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. More...
 
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. More...
 
float phiBE (const unsigned sample, const std::uint32_t samplingPattern, const std::span< const float > e_sampl, const std::span< const float > phi_sampl)
 

Variables

constexpr float defaultErrorValue = -999
 the default error code to return in case of error More...
 

Typedef Documentation

◆ CaloSample

Definition at line 40 of file CaloClusterDetails.h.

Function Documentation

◆ energyBE()

float xAOD::CaloClusterDetails::energyBE ( const unsigned  sample,
const std::uint32_t  samplingPattern,
const std::span< const float e_sampl 
)
inline

Get the energy in one layer of the EM Calo.

Parameters
layerLayer between 0 (Presampler) and 3 (Back)
Returns
energy Works for both, barrel and endcap

Definition at line 87 of file CaloClusterDetails.h.

87  {
88  if (sample>3) return defaultErrorValue;
91  double energy=0;
92  if (hasSampling(barrelSample, samplingPattern)) {
93  energy+=getSamplVar(barrelSample,samplingPattern,e_sampl); //Check for errorcode? Should not happen...
94  }
95  if (hasSampling(endcapSample, samplingPattern)) {
96  energy+=getSamplVar(endcapSample,samplingPattern,e_sampl);
97  }
98  return energy;
99  }

◆ etaBE()

float xAOD::CaloClusterDetails::etaBE ( const unsigned  sample,
const std::uint32_t  samplingPattern,
const std::span< const float e_sampl,
const std::span< const float eta_sampl 
)
inline

Get the eta in one layer of the EM Calo.

Parameters
layerLayer between 0 (Presampler) and 3 (Back)
Returns
energy Works for both, barrel and endcap

Definition at line 107 of file CaloClusterDetails.h.

107  {
108  if (sample>3) {return defaultErrorValue;}
111  const bool haveBarrel=hasSampling(barrelSample, samplingPattern);
112  const bool haveEndcap=hasSampling(endcapSample, samplingPattern);
113  if (haveBarrel && haveEndcap) {
114  //cluster spans barren and endcap
115  float eBarrel=getSamplVar(barrelSample,samplingPattern,e_sampl); //Check for errorcode? Should not happen...
116  float eEndcap=getSamplVar(endcapSample,samplingPattern,e_sampl);
117 
118  float etaBarrel=getSamplVar(barrelSample,samplingPattern,eta_sampl);
119  float etaEndcap=getSamplVar(endcapSample,samplingPattern,eta_sampl);
120  float eSum=eBarrel + eEndcap;
121  if (eSum > 100 /*MeV*/) {
122  //E-weighted average ...
123  if ((eBarrel > 0 && eEndcap > 0) || (eBarrel < 0 && eEndcap < 0))
124  return (eBarrel * etaBarrel + eEndcap * etaEndcap) / eSum;
125  else if (eBarrel > 0)
126  return etaBarrel;
127  else
128  return etaEndcap;
129  }//else eSum==0 case, should never happen
130  return (0.5 * (etaBarrel + etaEndcap));
131  }
132  if (haveBarrel) {
133  return getSamplVar(barrelSample,samplingPattern,eta_sampl);
134  }
135  if (haveEndcap) {
136  return getSamplVar(endcapSample,samplingPattern,eta_sampl);
137  }
138 
139  //Should never reach this point ...
140  return defaultErrorValue;
141  }

◆ getSamplVar()

float xAOD::CaloClusterDetails::getSamplVar ( const CaloSample  sampling,
const std::uint32_t  samplingPattern,
const std::span< const float vec,
const float  errorvalue = defaultErrorValue 
)
inline

Definition at line 72 of file CaloClusterDetails.h.

72  {
73  const unsigned idx=sampVarIdx(sampling, samplingPattern);
74  if (idx<vec.size() ) {
75  return vec[idx];
76  }
77 
78  //std::cout <<Sampling " << sampling << ", Pattern=" << std::hex <<m_samplingPattern << std::dec << ", index=" << idx << " size=" << vec.size() << std::endl;
79  return errorvalue;
80  }

◆ hasSampling()

bool xAOD::CaloClusterDetails::hasSampling ( const CaloSample  s,
const std::uint32_t  samplingPattern 
)
inline

Checks if certain smapling contributes to cluster.

Definition at line 52 of file CaloClusterDetails.h.

52  {
53  return (samplingPattern & (0x1U<<(std::uint32_t)s));
54  }

◆ phiBE()

float xAOD::CaloClusterDetails::phiBE ( const unsigned  sample,
const std::uint32_t  samplingPattern,
const std::span< const float e_sampl,
const std::span< const float phi_sampl 
)
inline

Definition at line 145 of file CaloClusterDetails.h.

145  {
146  if (sample>3) {return defaultErrorValue;}
149  const bool haveBarrel=hasSampling(barrelSample, samplingPattern);
150  const bool haveEndcap=hasSampling(endcapSample, samplingPattern);
151  if (haveBarrel && haveEndcap) {
152  //cluster spans barren and endcap
153  float eBarrel=getSamplVar(barrelSample, samplingPattern, e_sampl); //Check for errorcode? Should not happen...
154  float eEndcap=getSamplVar(endcapSample, samplingPattern, e_sampl);
155  float eSum=eBarrel+eEndcap;
156  float phiBarrel=getSamplVar(barrelSample, samplingPattern, phi_sampl);
157  float phiEndcap=getSamplVar(endcapSample, samplingPattern, phi_sampl);
158  if (eSum != 0.0) {
159  if ((eBarrel > 0 && eEndcap > 0) || (eBarrel < 0 && eEndcap < 0)) {
160  float phiSum = eSum * phiBarrel + eEndcap * CaloPhiRange::diff(phiEndcap, phiBarrel);
161  return CaloPhiRange::fix(phiSum / eSum);
162  } else if (eBarrel > 0)
163  return phiBarrel;
164  else
165  return phiEndcap;
166  }
167  // energy==0 case, should never happen
168  return CaloPhiRange::fix(0.5 * (phiBarrel + phiEndcap));
169  }
170  if (haveBarrel) {
171  return getSamplVar(barrelSample, samplingPattern, phi_sampl);
172  }
173  if (haveEndcap) {
174  return getSamplVar(endcapSample, samplingPattern, phi_sampl);
175  }
176 
177  //Should never reach this point ...
178  return defaultErrorValue;
179  }

◆ sampVarIdx()

unsigned xAOD::CaloClusterDetails::sampVarIdx ( const CaloSample  s,
const std::uint32_t  samplingPattern 
)
inline

Definition at line 57 of file CaloClusterDetails.h.

57  {
58  //std::cout << "Pattern=" << std::hex << pattern << std::dec << ", Sampling=" << s << std::endl;
59  if ((samplingPattern & (0x1U << s)) == 0) {
60  return CaloSampling::Unknown;
61  }
62  if (s == 0) {
63  return 0;
64  } // shifting a 32-bit int by 32 bits is undefined behavior!
65  return std::popcount(samplingPattern << (32 - s));
66  // Explanation: Need to get the number of bit (=samples) before the sampling in question
67  // Shift to the left, so bits after the sampling in question fall off the 32bit integer
68  // Then use popcount to count the numbers of 1 in the rest
69  }

Variable Documentation

◆ defaultErrorValue

constexpr float xAOD::CaloClusterDetails::defaultErrorValue = -999
constexpr

the default error code to return in case of error

FIXME: This value is currently taken from the xAOD::CaloCluster class, and should be changed to a more sensible value in the future.

Definition at line 48 of file CaloClusterDetails.h.

xAOD::CaloClusterDetails::hasSampling
bool hasSampling(const CaloSample s, const std::uint32_t samplingPattern)
Checks if certain smapling contributes to cluster.
Definition: CaloClusterDetails.h:52
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
xAOD::CaloClusterDetails::sampVarIdx
unsigned sampVarIdx(const CaloSample s, const std::uint32_t samplingPattern)
Definition: CaloClusterDetails.h:57
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
xAOD::CaloClusterDetails::getSamplVar
float getSamplVar(const CaloSample sampling, const std::uint32_t samplingPattern, const std::span< const float > vec, const float errorvalue=defaultErrorValue)
Definition: CaloClusterDetails.h:72
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
CaloSample
CaloCell_ID::CaloSample CaloSample
Definition: CaloCellCollector.cxx:18
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
xAOD::CaloClusterDetails::defaultErrorValue
constexpr float defaultErrorValue
the default error code to return in case of error
Definition: CaloClusterDetails.h:48
CaloPhiRange::diff
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Definition: CaloPhiRange.cxx:22