9 #include "CaloGeoHelpers/CaloSampling.h"
29 CellAccum (
double& the_posNorm,
30 std::array<double,CaloSampling::Unknown>& the_posSamNorm,
34 const bool useGPUCriteria =
false)
40 EtaMaxEnergyInSample(),
41 PhiMaxEnergyInSample(),
50 posNorm (the_posNorm),
51 posSamNorm (the_posSamNorm),
52 nBarrel (the_nBarrel),
53 nEndcap (the_nEndcap),
54 timeNorm (the_timeNorm)
58 MaxEnergyInSample[
i] = std::numeric_limits<double>::lowest();
72 double theNewSecondTime;
79 std::array<double,CaloSampling::Unknown>& posSamNorm;
100 template <
class WEIGHT>
108 double fabsweight = fabs (
weight);
110 double theEnergyNoWeight =
cell.e();
114 double theAbsEnergy =
weight * fabs(theEnergyNoWeight);
117 accum.PresenceInSample[sam] =
true;
118 double cellEta = dde->
eta();
119 double cellPhi = dde->
phi();
125 if (accum.phi0 < -900) {
126 thePhi = accum.phi0 = cellPhi;
129 thePhi =
proxim (cellPhi, accum.phi0);
131 accum.theNewEta += theAbsEnergy * cellEta;
132 accum.theNewPhi += theAbsEnergy * thePhi;
133 if (useGPUCriteria) {
134 if ( accum.MaxEnergyInSample[sam] <
theEnergy || (accum.MaxEnergyInSample[sam] ==
theEnergy && accum.maxCell < (
int) cellIt.
index()) ) {
135 accum.MaxEnergyInSample[sam] =
theEnergy;
136 accum.EtaMaxEnergyInSample[sam] = cellEta;
137 accum.PhiMaxEnergyInSample[sam] = cellPhi;
138 accum.maxCell = (
int) cellIt.
index();
142 if ( accum.MaxEnergyInSample[sam] <
theEnergy ) {
143 accum.MaxEnergyInSample[sam] =
theEnergy;
144 accum.EtaMaxEnergyInSample[sam] = cellEta;
145 accum.PhiMaxEnergyInSample[sam] = cellPhi;
149 accum.posSamNorm[sam] += theAbsEnergy;
150 accum.posNorm += theAbsEnergy;
152 accum.EtaInSample[sam] += theAbsEnergy * cellEta;
153 accum.PhiInSample[sam] += theAbsEnergy * thePhi;
170 case CaloSampling::MINIFCAL0:
171 case CaloSampling::MINIFCAL1:
172 case CaloSampling::MINIFCAL2:
173 case CaloSampling::MINIFCAL3:
185 unsigned int pmask = dde->
is_tile() ? 0x8080 : 0x2000;
188 if (
cell.provenance() & pmask ) {
190 double theTimeNorm = fabsweight *
theEnergy * theEnergyNoWeight;
191 accum.theNewTime += theTimeNorm *
cell.time();
192 accum.theNewSecondTime += theTimeNorm *
cell.time() *
cell.time();
193 accum.timeNorm += theTimeNorm;
200 template <
class WEIGHT>
202 void accumCells (
const CaloClusterCellLink* cccl, CellAccum& accum,
const WEIGHT&
w,
const bool useGPUCriteria =
false) {
213 for (;
it!=it_e;++
it) {
215 accumCell(
it,accum,
w, useGPUCriteria);
238 if (!cccl || cccl->
size()==0)
return;
243 double timeNorm = 0.;
245 std::array<double,CaloSampling::Unknown> posSamNorm{};
247 CellAccum accum (posNorm, posSamNorm, nBarrel, nEndcap, timeNorm, useGPUCriteria);
250 accumCells (cccl, accum, AccumWeight(), useGPUCriteria);
252 accumCells (cccl, accum, AccumNoWeight(), useGPUCriteria);
254 if ( posNorm != 0. ) {
255 double inorm = 1 / posNorm;
256 clu->
setEta(accum.theNewEta * inorm);
264 clu->
setE(accum.theNewEnergy);
267 if ( timeNorm != 0. ) {
268 clu->
setTime(accum.theNewTime/timeNorm);
283 if (accum.PresenceInSample[
i])
284 samplingPattern |= (0x1U<<
i);
296 if ( !updateLayers )
return;
300 if ( !accum.PresenceInSample[
i] )
continue;
301 if ( posSamNorm[
i] != 0 ) {
302 const double inorm = 1 / posSamNorm[
i];
303 accum.EtaInSample[
i] *= inorm;
311 if ( !accum.PresenceInSample[
i] )
continue;
316 clu->
setEta(sam,accum.EtaInSample[
i]);
317 clu->
setPhi(sam,accum.PhiInSample[
i]);
319 clu->
setEmax(sam,accum.MaxEnergyInSample[
i]);
320 clu->
setEtamax(sam,accum.EtaMaxEnergyInSample[
i]);
321 clu->
setPhimax(sam,accum.PhiMaxEnergyInSample[
i]);
326 #endif //not XAOD_ANALYSIS
327 #endif //not SIMULATIONBASE