ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloSimEvent
src
TFCSBinnedShowerBase.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ISF_FastCaloSimEvent/TFCSBinnedShowerBase.h
"
6
7
#include "
TruthUtils/HepMCHelpers.h
"
8
#include "
ISF_FastCaloSimEvent/TFCSExtrapolationState.h
"
9
#include "
ISF_FastCaloSimEvent/TFCSSimulationState.h
"
10
#include "
ISF_FastCaloSimEvent/TFCSTruthState.h
"
11
12
#include "TMath.h"
13
14
#include <cmath>
15
#include <cstdlib>
16
#include <limits>
17
18
//=============================================
19
//======= TFCSBinnedShowerBase =========
20
//=============================================
21
22
TFCSBinnedShowerBase::TFCSBinnedShowerBase
(
const
char
*name,
const
char
*title)
23
:
TFCSLateralShapeParametrizationHitBase
(name, title) {
24
reset_OnlyScaleEnergy
();
25
}
26
27
TFCSBinnedShowerBase::~TFCSBinnedShowerBase
() {}
28
29
FCSReturnCode
TFCSBinnedShowerBase::simulate
(
30
TFCSSimulationState
&simulstate,
const
TFCSTruthState
*truth,
31
const
TFCSExtrapolationState
*extrapol)
const
{
32
33
// select a random event from the library
34
float
eta_center, phi_center;
35
long
unsigned
int
reference_layer_index =
CaloCell_ID_FCS::CaloSample_FCS::EMB2
;
36
eta_center =
37
extrapol->
eta
(reference_layer_index,
TFCSExtrapolationState::SUBPOS_MID
);
38
if
(eta_center > 1.4) {
// Endcap becomes more relevant
39
reference_layer_index =
CaloCell_ID_FCS::CaloSample_FCS::EME2
;
40
}
41
// TODO: What about the endcap?
42
eta_center =
43
extrapol->
eta
(reference_layer_index,
TFCSExtrapolationState::SUBPOS_MID
);
44
phi_center =
45
extrapol->
phi
(reference_layer_index,
TFCSExtrapolationState::SUBPOS_MID
);
46
47
// Fill the total energy and layer energies into simulstate
48
float
Einit;
49
const
float
Ekin = truth->
Ekin
();
50
51
if
(
OnlyScaleEnergy
())
52
Einit = simulstate.
E
();
53
else
54
Einit = Ekin;
55
56
// Reset the total energy
57
simulstate.
set_E
(0);
58
59
get_event
(simulstate, eta_center, phi_center, Einit, reference_layer_index);
60
61
for
(
long
unsigned
int
layer_index = 0;
62
layer_index <
CaloCell_ID_FCS::MaxSample
; ++layer_index) {
63
64
float
layer_energy =
get_layer_energy
(simulstate, layer_index);
65
66
// Reset and set the layer energy
67
simulstate.
set_E
(layer_index, 0);
68
simulstate.
add_E
(layer_index, layer_energy);
69
}
70
71
if
(simulstate.
E
() > std::numeric_limits<double>::epsilon()) {
72
for
(
int
ilayer = 0; ilayer <
CaloCell_ID_FCS::MaxSample
; ++ilayer) {
73
simulstate.
set_Efrac
(ilayer, simulstate.
E
(ilayer) / simulstate.
E
());
74
}
75
}
76
return
FCSSuccess
;
77
}
78
79
FCSReturnCode
TFCSBinnedShowerBase::simulate_hit
(
80
Hit
&
hit
,
TFCSSimulationState
&simulstate,
const
TFCSTruthState
*truth,
81
const
TFCSExtrapolationState
*
/*extrapol*/
) {
82
83
const
int
pdgId = truth->
pdgid
();
84
const
float
charge
=
MC::charge
(pdgId);
85
long
unsigned
int
layer_index =
calosample
();
86
87
const
double
center_eta =
hit
.center_eta();
88
const
double
center_phi =
hit
.center_phi();
89
const
double
center_r =
hit
.center_r();
90
const
double
center_z =
hit
.center_z();
91
92
ATH_MSG_VERBOSE
(
" Layer "
<< layer_index <<
" Extrap eta "
<< center_eta
93
<<
" phi "
<< center_phi <<
" R "
<< center_r);
94
95
//next MR: change to std::abs, std::sqrt functions
96
const
float
dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
97
const
float
eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
98
(1.0 + TMath::Exp(-2 * center_eta)));
99
100
long
unsigned
int
hit_index =
hit
.idx();
101
102
// Get necessary the hit information
103
float
r
, alpha, E;
104
std::tie(
r
, alpha, E) =
105
get_hit_position_and_energy
(simulstate, layer_index, hit_index);
106
107
hit
.reset();
108
hit
.E() = E;
109
110
if
(layer_index <=
CaloCell_ID_FCS::CaloSample_FCS::FCAL0
) {
111
float
delta_eta_mm =
r
* std::cos(alpha);
112
float
delta_phi_mm =
r
* std::sin(alpha);
113
114
// Particles with negative eta are expected to have the same shape
115
// as those with positive eta after transformation: delta_eta -->
116
// -delta_eta
117
if
(center_eta < 0.) {
118
delta_eta_mm = -delta_eta_mm;
119
}
120
121
// We derive the shower shapes for electrons and positively charged
122
// hadrons. Particle with the opposite charge are expected to have the
123
// same shower shape after the transformation: delta_phi -->
124
// -delta_phi
125
if
((
charge
< 0. && pdgId != 11) || pdgId == -11)
126
delta_phi_mm = -delta_phi_mm;
127
128
const
float
delta_eta = delta_eta_mm / eta_jakobi / dist000;
129
const
float
delta_phi = delta_phi_mm / center_r;
130
131
hit
.eta() = center_eta + delta_eta;
132
hit
.phi() = TVector2::Phi_mpi_pi(center_phi + delta_phi);
133
134
ATH_MSG_VERBOSE
(
" Hit eta "
<<
hit
.eta() <<
" phi "
<<
hit
.phi()
135
<<
" layer "
<< layer_index);
136
137
}
else
{
// FCAL is in (x,y,z)
138
const
float
hit_r =
r
* std::cos(alpha) + center_r;
139
float
delta_phi =
r
* std::sin(alpha) / center_r;
140
// We derive the shower shapes for electrons and positively charged
141
// hadrons. Particle with the opposite charge are expected to have the
142
// same shower shape after the transformation: delta_phi -->
143
// -delta_phi
144
if
((
charge
< 0. && pdgId != 11) || pdgId == -11)
145
delta_phi = -delta_phi;
146
const
float
hit_phi = TVector2::Phi_mpi_pi(center_phi + delta_phi);
147
hit
.x() = hit_r * std::cos(hit_phi);
148
hit
.y() = hit_r * std::sin(hit_phi);
149
hit
.z() = center_z;
150
ATH_MSG_VERBOSE
(
" Hit x "
<<
hit
.x() <<
" y "
<<
hit
.y() <<
" layer "
151
<< layer_index);
152
}
153
154
return
FCSSuccess
;
155
}
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
HepMCHelpers.h
ATLAS-specific HepMC functions.
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
TFCSBinnedShowerBase.h
TFCSExtrapolationState.h
FCSReturnCode
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition
TFCSParametrizationBase.h:41
FCSSuccess
@ FCSSuccess
Definition
TFCSParametrizationBase.h:41
TFCSSimulationState.h
TFCSTruthState.h
TFCSBinnedShowerBase::reset_OnlyScaleEnergy
void reset_OnlyScaleEnergy()
Definition
TFCSBinnedShowerBase.h:34
TFCSBinnedShowerBase::TFCSBinnedShowerBase
TFCSBinnedShowerBase(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSBinnedShowerBase.cxx:22
TFCSBinnedShowerBase::get_layer_energy
virtual float get_layer_energy(TFCSSimulationState &simulstate, long unsigned int layer_index) const =0
TFCSBinnedShowerBase::simulate_hit
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
simulated one hit position with some energy.
Definition
TFCSBinnedShowerBase.cxx:79
TFCSBinnedShowerBase::get_hit_position_and_energy
virtual std::tuple< float, float, float > get_hit_position_and_energy(TFCSSimulationState &simulstate, long unsigned int layer_index, long unsigned int hit_index) const =0
TFCSBinnedShowerBase::OnlyScaleEnergy
bool OnlyScaleEnergy() const
Definition
TFCSBinnedShowerBase.h:30
TFCSBinnedShowerBase::get_event
virtual void get_event(TFCSSimulationState &simulstate, float eta_center, float phi_center, float e_init, long unsigned int reference_layer_index) const =0
do not persistify
TFCSBinnedShowerBase::~TFCSBinnedShowerBase
virtual ~TFCSBinnedShowerBase()
Definition
TFCSBinnedShowerBase.cxx:27
TFCSBinnedShowerBase::simulate
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
Definition
TFCSBinnedShowerBase.cxx:29
TFCSExtrapolationState
Definition
TFCSExtrapolationState.h:13
TFCSExtrapolationState::phi
double phi(int layer, int subpos) const
Definition
TFCSExtrapolationState.h:55
TFCSExtrapolationState::SUBPOS_MID
@ SUBPOS_MID
Definition
TFCSExtrapolationState.h:20
TFCSExtrapolationState::eta
double eta(int layer, int subpos) const
Definition
TFCSExtrapolationState.h:54
TFCSLateralShapeParametrizationHitBase::Hit
Definition
TFCSLateralShapeParametrizationHitBase.h:42
TFCSLateralShapeParametrizationHitBase::TFCSLateralShapeParametrizationHitBase
TFCSLateralShapeParametrizationHitBase(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSLateralShapeParametrizationHitBase.cxx:15
TFCSLateralShapeParametrization::calosample
int calosample() const
Definition
TFCSLateralShapeParametrization.h:34
TFCSSimulationState
Definition
TFCSSimulationState.h:32
TFCSSimulationState::set_E
void set_E(int sample, double Esample)
Definition
TFCSSimulationState.h:48
TFCSSimulationState::add_E
void add_E(int sample, double Esample)
Definition
TFCSSimulationState.h:53
TFCSSimulationState::set_Efrac
void set_Efrac(int sample, double Efracsample)
Definition
TFCSSimulationState.h:49
TFCSSimulationState::E
double E() const
Definition
TFCSSimulationState.h:42
TFCSTruthState
Definition
TFCSTruthState.h:13
TFCSTruthState::pdgid
int pdgid() const
Definition
TFCSTruthState.h:25
TFCSTruthState::Ekin
double Ekin() const
Definition
TFCSTruthState.h:26
r
int r
Definition
globals.cxx:22
CaloCell_ID_FCS::EMB2
@ EMB2
Definition
FastCaloSim_CaloCell_ID.h:21
CaloCell_ID_FCS::MaxSample
@ MaxSample
Definition
FastCaloSim_CaloCell_ID.h:47
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition
FastCaloSim_CaloCell_ID.h:40
CaloCell_ID_FCS::EME2
@ EME2
Definition
FastCaloSim_CaloCell_ID.h:25
MC::charge
double charge(const T &p)
Definition
HepMCHelpers.h:1004
Generated on
for ATLAS Offline Software by
1.17.0