ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloSimEvent
src
TFCSHistoLateralShapeWeight.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <utility>
6
7
#include "CLHEP/Random/RandFlat.h"
8
#include "CLHEP/Random/RandGaussZiggurat.h"
9
10
#include "
ISF_FastCaloSimEvent/TFCSHistoLateralShapeWeight.h
"
11
#include "
ISF_FastCaloSimEvent/TFCSSimulationState.h
"
12
13
#include "TH1.h"
14
#include "TVector2.h"
15
#include "TMath.h"
16
17
//=============================================
18
//======= TFCSHistoLateralShapeWeight =========
19
//=============================================
20
21
TFCSHistoLateralShapeWeight::TFCSHistoLateralShapeWeight
(
const
char
*name,
22
const
char
*title)
23
:
TFCSLateralShapeParametrizationHitBase
(name, title) {}
24
25
TFCSHistoLateralShapeWeight::~TFCSHistoLateralShapeWeight
() {
26
if
(
m_hist
)
27
delete
m_hist
;
28
}
29
30
float
TFCSHistoLateralShapeWeight::getMinWeight
()
const
{
return
m_minWeight
; }
31
32
float
TFCSHistoLateralShapeWeight::getMaxWeight
()
const
{
return
m_maxWeight
; }
33
34
FCSReturnCode
TFCSHistoLateralShapeWeight::simulate_hit
(
35
Hit
&
hit
,
TFCSSimulationState
&simulstate,
const
TFCSTruthState
*
/*truth*/
,
36
const
TFCSExtrapolationState
*
/*extrapol*/
) {
37
if
(!simulstate.
randomEngine
()) {
38
return
FCSFatal
;
39
}
40
41
const
double
center_eta =
hit
.center_eta();
42
const
double
center_phi =
hit
.center_phi();
43
const
double
center_r =
hit
.center_r();
44
const
double
center_z =
hit
.center_z();
45
46
const
float
dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
47
const
float
eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
48
(1.0 + TMath::Exp(-2 * center_eta)));
49
50
const
float
delta_eta =
hit
.eta() - center_eta;
51
const
float
delta_phi =
hit
.phi() - center_phi;
52
const
float
delta_eta_mm = delta_eta * eta_jakobi * dist000;
53
const
float
delta_phi_mm = delta_phi * center_r;
54
const
float
delta_r_mm =
55
TMath::Sqrt(delta_eta_mm * delta_eta_mm + delta_phi_mm * delta_phi_mm);
56
57
// TODO: delta_r_mm should perhaps be cached in hit
58
59
Int_t
bin
=
m_hist
->FindBin(delta_r_mm);
60
if
(
bin
< 1)
61
bin
= 1;
62
if
(
bin
>
m_hist
->GetNbinsX())
63
bin
=
m_hist
->GetNbinsX();
64
float
weight =
m_hist
->GetBinContent(
bin
);
65
float
RMS =
m_hist
->GetBinError(
bin
);
66
if
(RMS > 0) {
67
weight =
68
CLHEP::RandGaussZiggurat::shoot(simulstate.
randomEngine
(), weight, RMS);
69
}
70
hit
.E() *= weight;
71
72
ATH_MSG_DEBUG
(
"HIT: E="
<<
hit
.E() <<
" dR_mm="
<< delta_r_mm
73
<<
" weight="
<< weight);
74
return
FCSSuccess
;
75
}
76
77
bool
TFCSHistoLateralShapeWeight::Initialize
(TH1 *hist) {
78
if
(!hist)
79
return
false
;
80
if
(
m_hist
)
81
delete
m_hist
;
82
m_hist
= (TH1 *)hist->Clone(TString(
"TFCSHistoLateralShapeWeight_"
) +
83
hist->GetName());
84
m_hist
->SetDirectory(
nullptr
);
85
86
return
true
;
87
}
88
89
void
TFCSHistoLateralShapeWeight::Print
(Option_t *option)
const
{
90
TString opt(option);
91
bool
shortprint = opt.Index(
"short"
) >= 0;
92
bool
longprint =
msgLvl
(MSG::DEBUG) || (
msgLvl
(MSG::INFO) && !shortprint);
93
TString optprint = opt;
94
optprint.ReplaceAll(
"short"
,
""
);
95
TFCSLateralShapeParametrizationHitBase::Print
(option);
96
97
if
(longprint) {
98
if
(
m_hist
)
99
ATH_MSG_INFO
(optprint
100
<<
" Histogram: "
<<
m_hist
->GetNbinsX() <<
" bins ["
101
<< std::as_const(
m_hist
)->GetXaxis()->GetXmin() <<
","
102
<< std::as_const(
m_hist
)->GetXaxis()->GetXmax() <<
"]"
103
<<
" min weight: "
<<
m_minWeight
104
<<
" max weight: "
<<
m_maxWeight
);
105
else
106
ATH_MSG_INFO
(optprint <<
" no Histogram"
);
107
}
108
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
TFCSHistoLateralShapeWeight.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
ISF_FCS::MLogging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
Definition
MLogging.h:222
TFCSExtrapolationState
Definition
TFCSExtrapolationState.h:13
TFCSHistoLateralShapeWeight::~TFCSHistoLateralShapeWeight
virtual ~TFCSHistoLateralShapeWeight()
Definition
TFCSHistoLateralShapeWeight.cxx:25
TFCSHistoLateralShapeWeight::simulate_hit
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
weight the energy of one hit in order to generate fluctuations
Definition
TFCSHistoLateralShapeWeight.cxx:34
TFCSHistoLateralShapeWeight::m_maxWeight
float m_maxWeight
Definition
TFCSHistoLateralShapeWeight.h:42
TFCSHistoLateralShapeWeight::Print
virtual void Print(Option_t *option="") const override
Definition
TFCSHistoLateralShapeWeight.cxx:89
TFCSHistoLateralShapeWeight::Initialize
bool Initialize(TH1 *hist)
Init from histogram.
Definition
TFCSHistoLateralShapeWeight.cxx:77
TFCSHistoLateralShapeWeight::TFCSHistoLateralShapeWeight
TFCSHistoLateralShapeWeight(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSHistoLateralShapeWeight.cxx:21
TFCSHistoLateralShapeWeight::getMinWeight
virtual float getMinWeight() const override
Get minimum and maximum value of weight for hit energy reweighting.
Definition
TFCSHistoLateralShapeWeight.cxx:30
TFCSHistoLateralShapeWeight::m_minWeight
float m_minWeight
Definition
TFCSHistoLateralShapeWeight.h:41
TFCSHistoLateralShapeWeight::m_hist
TH1 * m_hist
Histogram to be used for the shape simulation The histogram x-axis should be in dR^2=deta^2+dphi^2.
Definition
TFCSHistoLateralShapeWeight.h:40
TFCSHistoLateralShapeWeight::getMaxWeight
virtual float getMaxWeight() const override
Definition
TFCSHistoLateralShapeWeight.cxx:32
TFCSLateralShapeParametrizationHitBase::Hit
Definition
TFCSLateralShapeParametrizationHitBase.h:42
TFCSLateralShapeParametrizationHitBase::TFCSLateralShapeParametrizationHitBase
TFCSLateralShapeParametrizationHitBase(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSLateralShapeParametrizationHitBase.cxx:15
TFCSLateralShapeParametrization::Print
void Print(Option_t *option="") const override
Definition
TFCSLateralShapeParametrization.cxx:53
TFCSSimulationState
Definition
TFCSSimulationState.h:32
TFCSSimulationState::randomEngine
CLHEP::HepRandomEngine * randomEngine()
Definition
TFCSSimulationState.h:36
TFCSTruthState
Definition
TFCSTruthState.h:13
bin
Definition
BinsDiffFromStripMedian.h:43
Generated on
for ATLAS Offline Software by
1.17.0