ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSLateralShapeParametrizationFixedHitChain.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "CLHEP/Random/RandGaussZiggurat.h"
9#include "TMath.h"
10
11//=============================================
12//======= TFCSLateralShapeParametrizationFixedHitChain =========
13//=============================================
14
19
24
27 TFCSSimulationState &simulstate, const TFCSTruthState *truth,
28 const TFCSExtrapolationState *extrapol, bool success) const {
29
30 (void)success; // unused parameter
31 (void)truth; // unused parameter
32 (void)extrapol; // unused parameter
33
34 int nhit_signed = simulstate.getAuxInfo<int>("FCSHitChainNHits"_FCShash);
35
36 if (nhit_signed < 0) {
38 "The number of hits to simulate is not defined - aborting simulation!");
39 return true;
40 }
41
42 unsigned int nhit = static_cast<unsigned int>(nhit_signed);
43
44 long unsigned int current_hit = hit.idx();
45
46 // Take care of layer energy updating.
47 // Needed for the phi modulation!
48 bool done = current_hit >= nhit;
49 if (!done) {
50 double sumEhit = 0;
51 if (simulstate.hasAuxInfo("FCSFixedHitChainEnergySum"_FCShash) &&
52 hit.idx() > 0) {
53 sumEhit =
54 simulstate.getAuxInfo<double>("FCSFixedHitChainEnergySum"_FCShash);
55 }
56
57 sumEhit += hit.E();
58 simulstate.setAuxInfo<double>("FCSFixedHitChainEnergySum"_FCShash, sumEhit);
59 } else {
60
61 if (!simulstate.hasAuxInfo("FCSFixedHitChainEnergySum"_FCShash)) {
62 simulstate.setAuxInfo<double>("FCSFixedHitChainEnergySum"_FCShash, 0.);
63 }
64
65 double old_energy = simulstate.E(calosample());
66 double new_energy =
67 simulstate.getAuxInfo<double>("FCSFixedHitChainEnergySum"_FCShash);
68
69 double energy_difference = new_energy - old_energy;
70
71 simulstate.set_E(simulstate.E() + energy_difference);
72 simulstate.set_E(calosample(), new_energy);
73
74 if (simulstate.E() > std::numeric_limits<double>::epsilon()) {
75 simulstate.set_Efrac(calosample(), new_energy / simulstate.E());
76 }
77 simulstate.setAuxInfo<double>("FCSFixedHitChainEnergySum"_FCShash, 0.);
78 }
79
80 return done;
81}
#define ATH_MSG_ERROR(x)
TFCSLateralShapeParametrizationFixedHitChain(const char *name=nullptr, const char *title=nullptr)
virtual bool check_all_hits_simulated(TFCSLateralShapeParametrizationHitBase::Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol, bool success) const override
TFCSLateralShapeParametrizationHitChain(const char *name=nullptr, const char *title=nullptr)
void set_E(int sample, double Esample)
bool hasAuxInfo(std::uint32_t index) const
const T getAuxInfo(std::uint32_t index) const
void set_Efrac(int sample, double Efracsample)
void setAuxInfo(std::uint32_t index, const T &val)