ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterKineHelper Class Reference

#include <CaloClusterKineHelper.h>

Collaboration diagram for CaloClusterKineHelper:

Static Public Member Functions

static void calculateKine (xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
 Helper class to calculate cluster kinematics based on cells.

Detailed Description

Definition at line 13 of file CaloClusterKineHelper.h.

Member Function Documentation

◆ calculateKine()

void CaloClusterKineHelper::calculateKine ( xAOD::CaloCluster * clu,
const bool useweight = true,
const bool updateLayers = true,
const bool useGPUCriteria = false )
static

Helper class to calculate cluster kinematics based on cells.

Author
Walter Lampl Walte.nosp@m.r.La.nosp@m.mpl@c.nosp@m.ern..nosp@m.ch Calculate cluster kinematics from contained cells

Definition at line 223 of file CaloClusterKineHelper.cxx.

223 {
224 //static CaloPhiRange range;
225
226 // update global kinematics
227 //
228 // for the update of the position the normalization is not a trival
229 // thing. The previous implementation used the sum of weighted
230 // energies as normalization. This leads to unphysical eta and phi
231 // values in case negative energies are added in. The new algorithm
232 // takes therefore |E| instead of E which gives the same eta and phi
233 // as before for the 2 cases where all cells are negative or all
234 // cells are positive. In the mixed case it will give the direction
235 // of activity in the calorimeter.
236
237 const CaloClusterCellLink* cccl=clu->getCellLinks();
238 if (!cccl || cccl->size()==0) return; //Do nothing if no cells
239
240 double posNorm = 0;
241 int nBarrel = 0;
242 int nEndcap = 0;
243 double timeNorm = 0.;
244
245 std::array<double,CaloSampling::Unknown> posSamNorm{};
246
247 CellAccum accum (posNorm, posSamNorm, nBarrel, nEndcap, timeNorm, useGPUCriteria);
248 //accum.theNewPhi = clu->phi(); //????
249 if (useweight)
250 accumCells (cccl, accum, AccumWeight(), useGPUCriteria);
251 else
252 accumCells (cccl, accum, AccumNoWeight(), useGPUCriteria);
253
254 if ( posNorm != 0. ) {
255 double inorm = 1 / posNorm;
256 clu->setEta(accum.theNewEta * inorm);
257 clu->setPhi(CaloPhiRange::fix(accum.theNewPhi * inorm));
258 }
259 else {
260 clu->setEta(0);
261 clu->setPhi(0);
262 }
263
264 clu->setE(accum.theNewEnergy);
265 clu->setM(0.0);
266
267 if ( timeNorm != 0. ) {
268 clu->setTime(accum.theNewTime/timeNorm);
269 // note that standard deviation of cell time distribution is >= 0.
270 // (no particular accommodation for <x^2> < <x><x>!)
271 // clu->setSecondTime(std::sqrt(std::max(accum.theNewSecondTime/timeNorm-clu->time()*clu->time(),0.)));
272 // consistency with other second moments: store variance!
273 clu->setSecondTime(accum.theNewSecondTime/timeNorm-clu->time()*clu->time());
274 } else {
275 clu->setTime(0.);
276 clu->setSecondTime(0.);
277 }
278
279
280 //Set Sampling pattern:
281 uint32_t samplingPattern=0;
282 for(int i=0;i<(int)CaloSampling::Unknown;i++) {
283 if (accum.PresenceInSample[i])
284 samplingPattern |= (0x1U<<i);
285 }
286 if (samplingPattern!=clu->samplingPattern()) {
287 //Clear sampling data (if there is any): Invalidated if the sampling pattern has changed
288 clu->clearSamplingData();
289 clu->setSamplingPattern(samplingPattern);
290 }
291
293 // Check Sampling Variable Updates //
295
296 if ( !updateLayers ) return;
297
298 //First loop over samplings
299 for(int i=0;i<(int)CaloSampling::Unknown;i++) {
300 if ( !accum.PresenceInSample[i] ) continue; // check sampling bit
301 if ( posSamNorm[i] != 0 ) {
302 const double inorm = 1 / posSamNorm[i];
303 accum.EtaInSample[i] *= inorm;
304 accum.PhiInSample[i] = CaloPhiRange::fix (accum.PhiInSample[i] * inorm);
305 }
306 }//End loop over sampling
307
308 //Second loop over samplings
309 //Set(Engery/Eta/Phi) methods only allowed once m_samplingPattern is final!
310 for(int i=0;i<(int)CaloSampling::Unknown;i++) {
311 if ( !accum.PresenceInSample[i] ) continue;
312 // check sampling bit
314 clu->setEnergy(sam,accum.EnergyInSample[i]);
315 // clu->setNCellsPerSampling(sam, accum.NCellsInSample[i]);
316 clu->setEta(sam,accum.EtaInSample[i]);
317 clu->setPhi(sam,accum.PhiInSample[i]);
318
319 clu->setEmax(sam,accum.MaxEnergyInSample[i]);
320 clu->setEtamax(sam,accum.EtaMaxEnergyInSample[i]);
321 clu->setPhimax(sam,accum.PhiMaxEnergyInSample[i]);
322 }
323
324 }
static double fix(double phi)
void setSecondTime(flt_t stime)
Set second moment of cell timing distribution.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
flt_t time() const
Access cluster time.
void setTime(flt_t)
Set cluster time.
bool setPhimax(const CaloSample sampling, const float phiMax)
Set the phi of the cell with the highest energy in a particular sampling.
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool setEmax(const CaloSample sampling, const float eMax)
Set the Energy of the cell with the highest energy in a particular sampling.
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.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
bool setEtamax(const CaloSample sampling, const float etaMax)
Set the eta of the cell with the highest energy in a particular sampling.
void clearSamplingData()
Clear the sampling data.
unsigned samplingPattern() const
Access to sampling pattern (one bit per sampling) (Method may be removed later)
void setM(flt_t)
Set Mass for the current signal state.
setEventNumber uint32_t

The documentation for this class was generated from the following files: