ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloSimEvent
src
TFCSHistoLateralShapeParametrizationFCal.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "CLHEP/Random/RandFlat.h"
6
#include "CLHEP/Random/RandPoisson.h"
7
8
#include "
ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrizationFCal.h
"
9
#include "
ISF_FastCaloSimEvent/TFCSSimulationState.h
"
10
#include "
ISF_FastCaloSimEvent/TFCSExtrapolationState.h
"
11
12
#include "TMath.h"
13
14
#include "
TruthUtils/HepMCHelpers.h
"
15
16
//=============================================
17
//======= TFCSHistoLateralShapeParametrizationFCal =========
18
//=============================================
19
20
TFCSHistoLateralShapeParametrizationFCal::
21
TFCSHistoLateralShapeParametrizationFCal
(
const
char
*name,
22
const
char
*title)
23
:
TFCSHistoLateralShapeParametrization
(name, title) {}
24
25
TFCSHistoLateralShapeParametrizationFCal::
26
~TFCSHistoLateralShapeParametrizationFCal
() {}
27
28
FCSReturnCode
TFCSHistoLateralShapeParametrizationFCal::simulate_hit
(
29
Hit
&
hit
,
TFCSSimulationState
&simulstate,
const
TFCSTruthState
*truth,
30
const
TFCSExtrapolationState
*
/*extrapol*/
) {
31
if
(!simulstate.
randomEngine
()) {
32
return
FCSFatal
;
33
}
34
35
const
int
pdgId = truth->
pdgid
();
36
const
double
charge
=
MC::charge
(pdgId);
37
38
const
int
cs =
calosample
();
39
// const double center_phi=0.5*( extrapol->phi(cs, CaloSubPos::SUBPOS_ENT) +
40
// extrapol->phi(cs, CaloSubPos::SUBPOS_EXT) ); const double center_r=0.5*(
41
// extrapol->r(cs, CaloSubPos::SUBPOS_ENT) + extrapol->r(cs,
42
// CaloSubPos::SUBPOS_EXT) ); const double center_z=0.5*( extrapol->z(cs,
43
// CaloSubPos::SUBPOS_ENT) + extrapol->z(cs, CaloSubPos::SUBPOS_EXT) );
44
const
double
center_phi =
hit
.center_phi();
45
const
double
center_r =
hit
.center_r();
46
const
double
center_z =
hit
.center_z();
47
48
float
alpha,
r
, rnd1, rnd2;
49
rnd1 = CLHEP::RandFlat::shoot(simulstate.
randomEngine
());
50
rnd2 = CLHEP::RandFlat::shoot(simulstate.
randomEngine
());
51
if
(
is_phi_symmetric
()) {
52
if
(rnd2 >= 0.5) {
// Fill negative phi half of shape
53
rnd2 -= 0.5;
54
rnd2 *= 2;
55
m_hist
.rnd_to_fct(alpha,
r
, rnd1, rnd2);
56
alpha = -alpha;
57
}
else
{
// Fill positive phi half of shape
58
rnd2 *= 2;
59
m_hist
.rnd_to_fct(alpha,
r
, rnd1, rnd2);
60
}
61
}
else
{
62
m_hist
.rnd_to_fct(alpha,
r
, rnd1, rnd2);
63
}
64
if
(TMath::IsNaN(alpha) || TMath::IsNaN(
r
)) {
65
ATH_MSG_ERROR
(
" Histogram: "
66
<<
m_hist
.get_HistoBordersx().size() - 1 <<
"*"
67
<<
m_hist
.get_HistoBordersy().size() - 1
68
<<
" bins, #hits="
<<
m_nhits
<<
" alpha="
<< alpha
69
<<
" r="
<<
r
<<
" rnd1="
<< rnd1 <<
" rnd2="
<< rnd2);
70
alpha = 0;
71
r
= 0.001;
72
73
ATH_MSG_ERROR
(
" This error could probably be retried"
);
74
return
FCSFatal
;
75
}
76
77
const
float
hit_r =
r
* cos(alpha) + center_r;
78
float
delta_phi =
r
* sin(alpha) / center_r;
79
// We derive the shower shapes for electrons and positively charged hadrons.
80
// Particle with the opposite charge are expected to have the same shower shape
81
// after the transformation: delta_phi --> -delta_phi
82
if
((
charge
< 0. && pdgId!=11) || pdgId==-11)
83
delta_phi = -delta_phi;
84
const
float
hit_phi = delta_phi + center_phi;
85
86
hit
.setXYZE(hit_r * cos(hit_phi), hit_r * sin(hit_phi), center_z,
hit
.E());
87
88
ATH_MSG_DEBUG
(
"HIT: E="
<<
hit
.E() <<
" cs="
<< cs <<
" x="
<<
hit
.x()
89
<<
" y="
<<
hit
.y() <<
" z="
<<
hit
.z() <<
" r="
<<
r
90
<<
" alpha="
<< alpha);
91
92
return
FCSSuccess
;
93
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
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
TFCSExtrapolationState.h
TFCSHistoLateralShapeParametrizationFCal.h
FCSReturnCode
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition
TFCSParametrizationBase.h:41
FCSFatal
@ FCSFatal
Definition
TFCSParametrizationBase.h:41
FCSSuccess
@ FCSSuccess
Definition
TFCSParametrizationBase.h:41
TFCSSimulationState.h
TFCSExtrapolationState
Definition
TFCSExtrapolationState.h:13
TFCSHistoLateralShapeParametrizationFCal::~TFCSHistoLateralShapeParametrizationFCal
~TFCSHistoLateralShapeParametrizationFCal()
Definition
TFCSHistoLateralShapeParametrizationFCal.cxx:26
TFCSHistoLateralShapeParametrizationFCal::TFCSHistoLateralShapeParametrizationFCal
TFCSHistoLateralShapeParametrizationFCal(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSHistoLateralShapeParametrizationFCal.cxx:21
TFCSHistoLateralShapeParametrizationFCal::simulate_hit
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
simulated one hit position with weight that should be put into simulstate sometime later all hit weig...
Definition
TFCSHistoLateralShapeParametrizationFCal.cxx:28
TFCSHistoLateralShapeParametrization::is_phi_symmetric
bool is_phi_symmetric() const
Definition
TFCSHistoLateralShapeParametrization.h:36
TFCSHistoLateralShapeParametrization::m_nhits
float m_nhits
Definition
TFCSHistoLateralShapeParametrization.h:97
TFCSHistoLateralShapeParametrization::m_hist
TFCS2DFunctionHistogram m_hist
Histogram to be used for the shape simulation.
Definition
TFCSHistoLateralShapeParametrization.h:96
TFCSHistoLateralShapeParametrization::TFCSHistoLateralShapeParametrization
TFCSHistoLateralShapeParametrization(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSHistoLateralShapeParametrization.cxx:25
TFCSLateralShapeParametrizationHitBase::Hit
Definition
TFCSLateralShapeParametrizationHitBase.h:42
TFCSLateralShapeParametrization::calosample
int calosample() const
Definition
TFCSLateralShapeParametrization.h:34
TFCSSimulationState
Definition
TFCSSimulationState.h:32
TFCSSimulationState::randomEngine
CLHEP::HepRandomEngine * randomEngine()
Definition
TFCSSimulationState.h:36
TFCSTruthState
Definition
TFCSTruthState.h:13
TFCSTruthState::pdgid
int pdgid() const
Definition
TFCSTruthState.h:25
r
int r
Definition
globals.cxx:22
MC::charge
double charge(const T &p)
Definition
HepMCHelpers.h:1004
Generated on
for ATLAS Offline Software by
1.17.0