ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSLateralShapeTuning.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8//=============================================
9//======= TFCSLateralShapeTuning ==============
10//=============================================
11
13 const char *title)
15
17 // clear parameter interpolation map and free memory
18 for (auto &p : m_parameterInterpol) {
19 delete p.second;
20 }
21 m_parameterInterpol.clear();
22}
23
25 const std::string &pathToModelParameters, int intMinEta, int intMaxEta) {
26 // get current calo layer
28
29 // load file containing model parameters
30 std::unique_ptr<TFile> modelParametersFile (TFile::Open(pathToModelParameters.c_str(), "READ"));
31 modelParametersFile->cd();
32
33 // set parameter model names depending on layer
34 std::vector<std::string> parameterModelNames;
35 if (layer == 1 || layer == 5)
36 parameterModelNames = {"a0", "a1", "a2", "a3"};
37 else if (layer == 2 || layer == 6)
38 parameterModelNames = {"eta_s", "phi_s"};
39
40 for (auto &parameterName : parameterModelNames) {
41
42 // interpolate the model parameters
45
46 TGraph *modelParameterGraph = (TGraph *)gDirectory->Get(
47 Form("photons/layer%d/m%d_m%d_%d_%d/%s", layer, intMaxEta, intMinEta,
48 intMinEta, intMaxEta, parameterName.c_str()));
49 if (modelParameterGraph) {
50 // initialize the model interpolation and save in interpolation map
51 linModelInterpol->InitFromArrayInEkin(modelParameterGraph->GetN(),
52 modelParameterGraph->GetX(),
53 modelParameterGraph->GetY());
55 std::make_pair(parameterName, linModelInterpol));
56 } else {
57 ATH_MSG_DEBUG("[TFCSLateralShapeTuning] Could not find model parameter "
58 "graph for layer="
59 << layer << " minEta=" << intMinEta
60 << " maxEta=" << intMaxEta);
61 return FCSSuccess;
62 }
63 }
64 modelParametersFile->Close();
65
66 return FCSSuccess;
67}
68
71 ATH_MSG_DEBUG("[TFCSLateralShapeTuning] Initializing data tuning model from "
72 "interpolation map.");
74 return FCSSuccess;
75}
76
79 const TFCSTruthState *truth,
80 const TFCSExtrapolationState *) {
81
82 // do not do anything if the parameter interpolation map is empty
83 // this means we are in an pseudorapidity region, where no tuning to data is
84 // available
85 if (m_parameterInterpol.empty())
86 return FCSSuccess;
87
88 // set maximum scaling factor
89 float maxScaling = 500;
90
91 // retrieve particle data
92 const int pdgId = truth->pdgid();
93 const double charge = HepPDT::ParticleID(pdgId).charge();
94
95 // retreive hit information
96 const double centerEta = hit.center_eta();
97 const double centerPhi = hit.center_phi();
98 const double centerZ = hit.center_z();
99 // retrieve truth kinetic energy for interpolation
100 const float Ekin = truth->Ekin();
101 // retrieve calo sample
103
104 ATH_MSG_DEBUG("[TFCSLateralShapeTuning] Initializing with pdgId="
105 << pdgId << ", charge=" << charge << ", Ekin=" << Ekin
106 << ", caloSample=" << layer);
107
108 ATH_MSG_DEBUG("[TFCSLateralShapeTuning] Got hit position: "
109 << " hit.eta=" << hit.eta() << ", hit.phi=" << hit.phi()
110 << ", hit.r=" << hit.r());
111
112 // compute deltaEta and deltaPhi
113 const double deltaEta = hit.eta() - centerEta;
114 const double deltaPhi = hit.phi() - centerPhi;
115
116 if (layer == 2 || layer == 6) {
117
118 double etaScaleFactor = m_parameterInterpol["eta_s"]->evaluate(Ekin);
119 double phiScaleFactor = m_parameterInterpol["phi_s"]->evaluate(Ekin);
120
121 // add a maximum scaling threshold to prevent unreasonable scalings
122 etaScaleFactor =
123 std::abs(etaScaleFactor) < maxScaling ? etaScaleFactor : maxScaling;
124 phiScaleFactor =
125 std::abs(phiScaleFactor) < maxScaling ? phiScaleFactor : maxScaling;
126
127 ATH_MSG_DEBUG("[TFCSLateralShapeTuning] Applying 2D eta_s - eta_phi "
128 "scaling model with eta_s="
129 << etaScaleFactor << " and phi_s=" << phiScaleFactor);
130
131 double deltaEtaCorr = etaScaleFactor * deltaEta;
132 double deltaPhiCorr = phiScaleFactor * deltaPhi;
133
134 hit.setEtaPhiZE(centerEta + deltaEtaCorr, centerPhi + deltaPhiCorr, centerZ,
135 hit.E());
136
137 }
138
139 else if (layer == 1 || layer == 5) {
140
141 double etaScaleFactor = getSeriesScalingFactor(
142 m_parameterInterpol["a0"]->evaluate(Ekin),
143 m_parameterInterpol["a1"]->evaluate(Ekin),
144 m_parameterInterpol["a2"]->evaluate(Ekin),
145 m_parameterInterpol["a3"]->evaluate(Ekin), std::abs(deltaEta));
146
147 // add a maximum scaling threshold to prevent unreasonable scalings
148 etaScaleFactor =
149 std::abs(etaScaleFactor) < maxScaling ? etaScaleFactor : maxScaling;
150
151 ATH_MSG_DEBUG("[TFCSLateralShapeTuning] Applying eta_s series expansion "
152 "model with eta_s="
153 << etaScaleFactor);
154
155 double deltaEtaCorr = etaScaleFactor * deltaEta;
156
157 hit.setEtaPhiZE(centerEta + deltaEtaCorr, centerPhi + deltaPhi, centerZ,
158 hit.E());
159 }
160
161 return FCSSuccess;
162}
163
165 double a0, double a1, double a2, double a3, double distToShowerCenter) {
166
167 double meanDistToShowerCentre = 0.0039;
168 double scaleFactor =
169 1 + a0 + a1 * distToShowerCenter / meanDistToShowerCentre +
170 a2 * std::pow(distToShowerCenter / meanDistToShowerCentre, 2) +
171 a3 * std::pow(distToShowerCenter / meanDistToShowerCentre, 3);
172
173 return scaleFactor;
174}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
void InitFromArrayInEkin(Int_t np, const Double_t Ekin[], const Double_t response[])
void setEtaPhiZE(float eta, float phi, float z, float E)
TFCSLateralShapeParametrizationHitBase(const char *name=nullptr, const char *title=nullptr)
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
simulated one hit position with some energy.
std::map< std::string, TFCSEnergyInterpolationPiecewiseLinear * > interpolationMap
FCSReturnCode initFromModelFile(const std::string &pathToModelParameters, int intMinEta, int intMaxEta)
interpolationMap m_parameterInterpol
TFCSLateralShapeTuning(const char *name=nullptr, const char *title=nullptr)
Constructor.
static double getSeriesScalingFactor(double a0, double a1, double a2, double a3, double distToShowerCenter)
FCSReturnCode initFromMap(const interpolationMap &)
int pdgid() const
double Ekin() const
double a0
Definition globals.cxx:27