ATLAS Offline Software
Loading...
Searching...
No Matches
EnergyLossUpdator.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// EnergyLossUpdator.cxx, (c) ATLAS Detector software
8
9// Trk include
13// Gaudi
14#include "GaudiKernel/MsgStream.h"
15#include "GaudiKernel/SystemOfUnits.h"
16
17
18#include <cmath>
19
20
21// constructor
23 const std::string& n,
24 const IInterface* p)
25 : AthAlgTool(t, n, p)
26{
27 declareInterface<Trk::IEnergyLossUpdator>(this);
28}
29
30// public interface method
31double
33 double p,
34 ParticleHypothesis particle) const
35{
36 if (particle == Trk::undefined || particle == Trk::nonInteracting) {
37 return 0.;
38 }
39
40 // preparation of kinetic constants
41 double m = Trk::ParticleMasses::mass[particle];
42 double E = std::sqrt(p * p + m * m);
43 double beta = p / E;
44 double gamma = E / m;
45
46 // add ionization and radiation
47 double dEdX =
48 Trk::MaterialInteraction::dEdXBetheBloch(mat, beta, gamma, particle) +
50
51 // add e+e- pair production and photonuclear effect for muons at energies
52 // above 8 GeV
53 if ((particle == Trk::muon) && (E > 8000.)) {
54 if (E < 1.e6) {
55 dEdX += -0.5345 / mat.x0() + 6.803e-5 * E / mat.x0() +
56 2.278e-11 * E * E / mat.x0() -
57 9.899e-18 * E * E * E / mat.x0(); // E below 1 TeV
58 } else {
59 dEdX += -2.986 / mat.x0() + 9.253e-5 * E / mat.x0(); // E above 1 TeV
60 }
61 }
62 return dEdX;
63}
64
65// public interface method
68 double p,
69 double pathcorrection,
70 PropDirection dir,
71 ParticleHypothesis particle,
72 bool useMPV) const
73{
74 if (particle == Trk::undefined) {
76 "undefined ParticleHypothesis, energy loss calculation cancelled");
77 return {};
78 }
79
80 if (useMPV) {
81 return ionizationEnergyLoss(mat, p, pathcorrection, dir, particle);
82 }
83
84 double deltaE = 0.;
85 // preparation
86 double sign = (dir == Trk::oppositeMomentum) ? -1. : 1.;
87
88 double pathLength = pathcorrection * mat.thicknessInX0() * mat.x0();
89
90 double sigIoni = 0.;
91 double sigRad = 0.;
92 double kazL = 0.;
94 p, (mat.material()), particle, sigIoni, kazL);
96 p, (mat.material()), particle, sigRad);
97
98 meanIoni = sign * pathLength * meanIoni;
99 meanRad = sign * pathLength * meanRad;
100 sigIoni = pathLength * sigIoni;
101 sigRad = pathLength * sigRad;
102 kazL = pathLength * kazL;
103
104 //
105 // include pathlength dependence of Landau ionization
106 //
107 sigIoni = sigIoni - kazL * std::log(pathLength);
108
109 deltaE = meanIoni + meanRad;
110
111 double sigmaDeltaE = std::sqrt(sigIoni * sigIoni + sigRad * sigRad);
112 ATH_MSG_DEBUG(" Energy loss updator deltaE "
113 << deltaE << " meanIoni " << meanIoni << " meanRad " << meanRad
114 << " sigIoni " << sigIoni << " sigRad " << sigRad << " sign "
115 << sign << " pathLength " << pathLength);
116 return (!m_detailedEloss ? Trk::EnergyLoss(deltaE, sigmaDeltaE)
117 : Trk::EnergyLoss(deltaE, sigmaDeltaE, sigmaDeltaE,
118 sigmaDeltaE, meanIoni, sigIoni,
119 meanRad, sigRad, pathLength));
120}
121
122// public interface method
123
126 double caloEnergy,
127 double caloEnergyError,
128 double pCaloEntry,
129 double momentumError,
130 int& elossFlag) const
131{
132 //
133 // Input: the detailed EnergyLoss object in the Calorimeter that contains the
134 // different Eloss terms and their uncertainties; caloEnergy and error; and
135 // the muon momentumError (all in MeV)
136 //
137 // For use in the MuonSystem
138 // Input: caloEnergy = 0. caloEnergyError = 0. and pCaloEntry = pMuonEntry
139 // momentum at MuonEntry
140 //
141 // Output: an updated Energy loss values deltaE()
142 // that can be used in the track fit and corresponds to the Most
143 // Probable EnergyLoss value taking into account the ionization,
144 // radiation and smearing due to the errors including the
145 // momentumError (in MeV)
146 //
147 // elossFlag = false if Calorimeter Energy is NOT stored (and later
148 // fitted) on the Eloss object
149 // = true Calorimeter Energy is stored and will be fitted
150 //
151 // deltaE is used in the final fit
152 //
153
154 elossFlag = 0;
155
156 int isign = 1;
157 if (eLoss.deltaE() < 0) {
158 isign = -1;
159 }
160
161 double deltaE = eLoss.deltaE();
162 double sigmaDeltaE = eLoss.sigmaDeltaE();
163 // Detailed Eloss
164 double deltaE_ioni = eLoss.meanIoni();
165 double sigmaDeltaE_ioni = 0.45 * eLoss.sigmaIoni(); // sigma Landau
166 double deltaE_rad = eLoss.meanRad();
167 double sigmaDeltaE_rad =
168 eLoss.sigmaRad(); // rms and mean of steep exponential
169 double depth = eLoss.length();
170
171 // Eloss radiative protection
172
173 if (eLoss.meanRad() > 100000.) {
174 deltaE_rad = 100000.;
175 sigmaDeltaE_rad = eLoss.sigmaRad() * 100000. / eLoss.meanRad();
176 }
177
178 double sigmaPlusDeltaE = eLoss.sigmaPlusDeltaE();
179 double sigmaMinusDeltaE = eLoss.sigmaMinusDeltaE();
180
181 double MOP = deltaE_ioni - isign * 3.59524 * sigmaDeltaE_ioni;
182
183 //
184 // MOP shift due to ionization and radiation
185 //
186 double MOPshift =
187 isign * 50 * 10000. / pCaloEntry +
188 isign * 0.75 * std::sqrt(sigmaDeltaE_ioni * sigmaDeltaE_rad);
189 double MOPshiftNoRad = isign * 50 * 10000. / pCaloEntry;
190 //
191 // define sigmas for Landau convoluted with exponential
192 //
193 double fracErad = sigmaDeltaE_rad +
194 std::abs(deltaE_rad) * pCaloEntry / (800000. + pCaloEntry);
195 double sigmaL = sigmaDeltaE_ioni + 0.8 * fracErad / 3.59524;
196 // double sigmaLNoRad = sigmaDeltaE_ioni;
197 double sigmaMinus = 1.02 * sigmaDeltaE_ioni + 0.08 * sigmaDeltaE_rad;
198 double sigmaPlus = 4.65 * sigmaDeltaE_ioni + 1.16 * sigmaDeltaE_rad;
199 // double sigmaMinusNoRad = 1.02 * sigmaDeltaE_ioni;
200 // double sigmaPlusNoRad = 4.65 * sigmaDeltaE_ioni;
201 double xc = momentumError / (sigmaL > 0. ? sigmaL : 1.);
202 double correction =
203 (0.3849 * xc * xc + 7.76672e-03 * xc * xc * xc) /
204 (1 + 2.8631 * xc + 0.3849 * xc * xc + 7.76672e-03 * xc * xc * xc);
205
206 //
207 // Case where the measured Calorimeter energy is not available (e.g. low pT or
208 // not isolated)
209 //
210
211 if (caloEnergyError <= 0) {
212 //
213 // Shift of MOP due to momentum resolution
214 //
215 double MOPreso = isign * 3.59524 * sigmaL * correction;
216
217 deltaE = MOP + MOPshift + MOPreso;
218 sigmaMinusDeltaE = sigmaMinus;
219 sigmaPlusDeltaE = sigmaPlus;
220 sigmaDeltaE = std::sqrt(0.5 * sigmaMinusDeltaE * sigmaMinusDeltaE +
221 0.5 * sigmaPlusDeltaE * sigmaPlusDeltaE);
222 //
223 if (m_optimalRadiation && std::abs(deltaE) < caloEnergy &&
224 pCaloEntry > 100000) {
225 //
226 // Calorimeter measurement can be used as veto to say there was no
227 // significant radiation
228 //
229 // In that case the Eloss is taken as the ionization Eloss
230 // Use MOP after correction for landau tail (MOPshiftNoRad) and momentum
231 // resolution smearing (MOPreso)
232 //
233 sigmaL = sigmaDeltaE_ioni + 0.3 * fracErad / 3.59524;
234 xc = momentumError / (sigmaL > 0. ? sigmaL : 1.);
235 correction =
236 (0.3849 * xc * xc + 7.76672e-03 * xc * xc * xc) /
237 (1 + 2.8631 * xc + 0.3849 * xc * xc + 7.76672e-03 * xc * xc * xc);
238
239 MOPreso = isign * 3.59524 * sigmaL * correction;
240 deltaE = MOP + MOPshift + MOPreso;
241 sigmaMinusDeltaE = sigmaMinus;
242 sigmaPlusDeltaE = sigmaPlus;
243 sigmaDeltaE = std::sqrt(0.5 * sigmaMinusDeltaE * sigmaMinusDeltaE +
244 0.5 * sigmaPlusDeltaE * sigmaPlusDeltaE);
245 }
246 } else {
247 double sigmaPlusTot =
248 std::sqrt(sigmaPlus * sigmaPlus + caloEnergyError * caloEnergyError);
249 if (m_optimalRadiation) {
250 sigmaPlusTot =
251 std::sqrt(4.65 * sigmaDeltaE_ioni * 4.65 * sigmaDeltaE_ioni +
252 caloEnergyError * caloEnergyError);
253 }
254 double MOPtot = std::abs(MOP + MOPshift);
255 if (m_optimalRadiation) {
256 MOPtot = std::abs(MOP + MOPshiftNoRad);
257 }
258
259 if (caloEnergy > MOPtot + 2 * sigmaPlusTot) {
260 //
261 // Use measured Calorimeter energy
262 //
263 //
264 // take into account the tail in the Measured Eloss
265 //
266 double MOPreso = isign * 3.59524 * sigmaL * correction;
267 deltaE = isign * caloEnergy + MOPreso;
268 sigmaMinusDeltaE = caloEnergyError + 0.08 * sigmaDeltaE_rad;
269 sigmaPlusDeltaE = caloEnergyError + 1.16 * sigmaDeltaE_rad;
270 sigmaDeltaE = std::sqrt(0.5 * sigmaMinusDeltaE * sigmaMinusDeltaE +
271 0.5 * sigmaPlusDeltaE * sigmaPlusDeltaE);
272 elossFlag = 1;
273 } else {
274 // Use MOP after corrections
275
276 //
277 // Shift of MOP due to momentum resolution smearing
278 //
279 sigmaL = sigmaDeltaE_ioni + 0.3 * fracErad / 3.59524;
280 xc = momentumError / (sigmaL > 0. ? sigmaL : 1);
281 correction =
282 (0.3849 * xc * xc + 7.76672e-03 * xc * xc * xc) /
283 (1 + 2.8631 * xc + 0.3849 * xc * xc + 7.76672e-03 * xc * xc * xc);
284 double MOPreso = isign * 3.59524 * sigmaL * correction;
285 //
286 // Use MOP after correction for landau tail (MOPshiftNoRad) and radiation
287 // (MOPshift) and momentum resolution smearing (MOPreso)
288 //
289 deltaE = MOP + MOPshift + MOPreso;
290 sigmaMinusDeltaE = sigmaMinus;
291 sigmaPlusDeltaE = sigmaPlus;
292 sigmaDeltaE = std::sqrt(0.5 * sigmaMinusDeltaE * sigmaMinusDeltaE +
293 0.5 * sigmaPlusDeltaE * sigmaPlusDeltaE);
294 }
295 }
296
297 return {deltaE,
298 sigmaDeltaE,
299 sigmaMinusDeltaE,
300 sigmaPlusDeltaE,
301 deltaE_ioni,
302 sigmaDeltaE_ioni,
303 deltaE_rad,
304 sigmaDeltaE_rad,
305 depth};
306}
307
308// public interface method
309void
311 double eta,
312 double phi,
313 double& X0Scale,
314 double& ElossScale) const
315{
316 //
317 // for Calorimeter icalo = 1
318 // Muon System icalo = 0
319 // convention eta, phi is at Calorimeter Exit (or Muon Entry)
320 // eta and phi are from the position (not direction)
321 //
322 // input X0 and ElossScale = 1
323 // output updated X0Scale and ElossScale
324 //
325
326 double X0CaloGirder[4] = {
327 -1.02877e-01, -2.74322e-02, 8.12989e-02, 9.73551e-01
328 };
329
330 // R2012 to R2015 determined on ATLAS-R2-2015-03-01-00 to be used in rel 21
331 constexpr double X0CaloScale[60] = {
332 1.01685, 1.02092, 1.01875, 1.01812, 1.01791, 1.01345, 1.01354,
333 1.02145, 1.01645, 1.01585, 1.0172, 1.02262, 1.01464, 0.990931,
334 0.971953, 0.99845, 1.01433, 0.982143, 0.974015, 0.978742, 0.960029,
335 0.966766, 0.980199, 0.989586, 0.997144, 1.00169, 0.994166, 0.966332,
336 0.93671, 0.935656, 0.921994, 0.901489, 0.897799, 0.89638, 0.905629,
337 0.903374, 0.925922, 0.941203, 0.956273, 0.968618, 0.976883, 0.988349,
338 0.99855, 1.00212, 1.01456, 1.01541, 1.02532, 1.03238, 1.03688,
339 1.03783, 1.02078, 1.01529, 1.0156, 1.02212, 1.02226, 1.02406,
340 1.02188, 1.00661, 1.00661, 1.00661
341 };
342
343 // R2012 to R2015 determined on ATLAS-R2-2015-03-01-00 to be used in rel 21
344 constexpr double ElossCaloScale[30] = {
345 1.06921, 1.06828, 1.06734, 1.06092, 1.06638, 1.06335, 1.07421, 1.05885,
346 1.07351, 1.07435, 1.06902, 1.07704, 1.08782, 1.09844, 1.115, 1.07609,
347 1.08233, 1.08764, 1.08209, 1.08255, 1.08008, 1.07573, 1.077, 1.07271,
348 1.07343, 1.07769, 1.07794, 1.08377, 1.08377, 1.08377
349 };
350
351 //
352 constexpr double X0MuonScale[60] = {
353 -0.0320612, -0.0320612, -0.0320612, -0.0320612, -0.0693796, -0.0389677,
354 -0.0860891, -0.124606, -0.0882329, -0.100014, -0.0790912, -0.0745538,
355 -0.099088, -0.0933711, -0.0618782, -0.0619762, -0.0658361, -0.109704,
356 -0.129547, -0.143364, -0.0774768, -0.0739859, -0.0417835, -0.022119,
357 0.00308797, 0.0197657, -0.0137871, -0.036848, -0.0643794, -0.0514949,
358 -0.0317105, 0.016539, 0.0308435, -0.00056883, -0.00756813, -0.00760612,
359 -0.0234571, -0.0980915, -0.101175, -0.102354, -0.0920337, -0.100337,
360 -0.0887628, 0.0660931, 0.228999, 0.260675, 0.266301, 0.267907,
361 0.281668, 0.194433, 0.132954, 0.20707, 0.220466, 0.20936,
362 0.191441, 0.191441, 0.191441, 0.191441, 0.191441, 0.191441
363 };
364
365 int i60 = std::abs(eta) * 20.;
366
367 if (i60 < 0) {
368 i60 = 0;
369 }
370 if (i60 > 59) {
371 i60 = 59;
372 }
373
374 if (icalo == 1) {
375 //
376 // Girder parametrization
377 //
378 double x =
379 phi + 3.1416 - 3.1416 / 32. * int((3.1416 + phi) / (3.1416 / 32.));
380 double scale = 0.;
381 if (x > M_PI / 64.) {
382 x = M_PI / 32. - x;
383 }
384
385 if (x < 0.005) {
386 scale =
387 X0CaloGirder[0] * (1 - x / 0.005) + X0CaloGirder[1] + X0CaloGirder[3];
388 } else if (x < 0.017) {
389 scale = X0CaloGirder[1] + X0CaloGirder[3];
390 } else if (x < 0.028) {
391 scale = X0CaloGirder[2] + X0CaloGirder[3];
392 } else {
393 scale = X0CaloGirder[3];
394 }
395
396 if (std::abs(eta) > 1.3) {
397 scale = 1.;
398 }
399 //
400 // eta dependence of X0
401 //
402 scale *= X0CaloScale[i60];
403 X0Scale = scale;
404 //
405 // eta dependence of Eloss
406 //
407 int i30 = std::abs(eta) * 10.;
408 if (i30 < 0) {
409 i30 = 0;
410 }
411 if (i30 > 29) {
412 i30 = 29;
413 }
414
415 double nfactor = 0.987363 / 1.05471;
416
417 ElossScale = nfactor * ElossCaloScale[i30] * scale;
418 } else {
419 //
420 // Muon system
421 //
422 // eta dependence of X0
423 //
424 double scale = 1. + X0MuonScale[i60];
425 //
426 // Muon scale is now 1 with MuonTrackingGeometry and TrkDetDescrGeoModelCnv
427 // fixes
428 //
429 scale = 1.0;
430 X0Scale = scale;
431 ElossScale = 0.93 * scale;
432 }
433}
434
437 double p,
438 double pathcorrection,
439 PropDirection dir,
440 ParticleHypothesis particle) const
441{
442 // preparation
443 double sign = (dir == Trk::oppositeMomentum) ? -1. : 1.;
444 double pathLength = pathcorrection * mat.thicknessInX0() * mat.x0();
445
446 double sigIoni = 0.;
447 double kazL = 0.;
448
449 double meanIoni =
451 p, (mat.material()), particle, sigIoni, kazL, pathLength);
452
453 return (!m_detailedEloss
454 ? Trk::EnergyLoss(meanIoni, sigIoni)
455 : Trk::EnergyLoss(meanIoni,
456 sigIoni,
457 sigIoni,
458 sigIoni,
459 meanIoni,
460 sigIoni,
461 0.,
462 0.,
463 pathLength));
464}
#define M_PI
Scalar eta() const
pseudorapidity method
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
int sign(int a)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual EnergyLoss updateEnergyLoss(EnergyLoss &eLoss, double caloEnergy, double caloEnergyError, double pCaloEntry, double momentumError, int &elossFlag) const override final
Method to recalculate Eloss values for the fit setting an elossFlag using as an input the detailed El...
virtual double dEdX(const MaterialProperties &mat, double p, ParticleHypothesis particle=pion) const override final
dEdX calculation when providing MaterialProperties, a momentum, a pathlength, and a ParicleHypothesis...
BooleanProperty m_optimalRadiation
virtual EnergyLoss energyLoss(const MaterialProperties &mat, double p, double pathcorrection, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, bool useMPV=false) const override final
deltaE calculation using dEdX and integrating along pathlength, assuming constant dEdX during for the...
virtual void getX0ElossScales(int icalo, double eta, double phi, double &X0Scale, double &ElossScale) const override final
Routine to calculate X0 and Eloss scale factors for the Calorimeter and Muon System.
Trk::EnergyLoss ionizationEnergyLoss(const MaterialProperties &mat, double p, double pathcorrection, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion) const
EnergyLossUpdator(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
BooleanProperty m_detailedEloss
This class describes energy loss material effects in the ATLAS tracking EDM.
Definition EnergyLoss.h:34
double meanRad() const
double length() const
double sigmaPlusDeltaE() const
returns the positive side
double sigmaMinusDeltaE() const
returns the negative side
double sigmaIoni() const
double meanIoni() const
double sigmaDeltaE() const
returns the symmatric error
double sigmaRad() const
double deltaE() const
returns the
Material with information about thickness of material.
std::string depth
tag string for intendation
Definition fastadd.cxx:46
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
PropDirection
PropDirection, enum for direction of the propagation.
@ oppositeMomentum
@ x
Definition ParamDefs.h:55
@ phi
Definition ParamDefs.h:75
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
static double dEdXBetheHeitler(const Trk::MaterialProperties &mat, double initialE, Trk::ParticleHypothesis particle)
static double dEdl_ionization(double p, const Material &mat, ParticleHypothesis particle, double &sigma, double &kazL)
dE/dl ionization energy loss per path unit
static double dEdl_radiation(double p, const Material &mat, ParticleHypothesis particle, double &sigma)
dE/dl radiation energy loss per path unit
static double dE_MPV_ionization(double p, const Trk::Material &mat, Trk::ParticleHypothesis particle, double &sigma, double &kazL, double path)
Most Propable dE ionization energly loss.
static double dEdXBetheBloch(const Trk::MaterialProperties &mat, double beta, double gamma, Trk::ParticleHypothesis particle)
dE/dl ionization energy loss per path unit