ATLAS Offline Software
Loading...
Searching...
No Matches
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.
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.
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.
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

Typedef Documentation

◆ CaloSample

Function Documentation

◆ energyBE()

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

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;
89 const CaloSample barrelSample=(CaloSample)(CaloSampling::PreSamplerB+sample);
90 const CaloSample endcapSample=(CaloSample)(CaloSampling::PreSamplerE+sample);
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 }
bool hasSampling(const CaloSample s, const std::uint32_t samplingPattern)
Checks if certain smapling contributes to cluster.
float getSamplVar(const CaloSample sampling, const std::uint32_t samplingPattern, const std::span< const float > vec, const float errorvalue=defaultErrorValue)
constexpr float defaultErrorValue
the default error code to return in case of error
CaloSampling::CaloSample CaloSample

◆ 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 )
inlinenodiscard

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;}
109 const CaloSample barrelSample=(CaloSample)(CaloSampling::PreSamplerB+sample);
110 const CaloSample endcapSample=(CaloSample)(CaloSampling::PreSamplerE+sample);
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 }
CaloCell_ID::CaloSample CaloSample

◆ getSamplVar()

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

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 }
std::vector< size_t > vec
unsigned sampVarIdx(const CaloSample s, const std::uint32_t samplingPattern)

◆ hasSampling()

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

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 )
inlinenodiscard

Definition at line 145 of file CaloClusterDetails.h.

145 {
146 if (sample>3) {return defaultErrorValue;}
147 const CaloSample barrelSample=(CaloSample)(CaloSampling::PreSamplerB+sample);
148 const CaloSample endcapSample=(CaloSample)(CaloSampling::PreSamplerE+sample);
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 }
static double fix(double phi)
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.

◆ sampVarIdx()

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

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

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.