ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloSimEvent
src
TFCSHistoLateralShapeGausLogWeight.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "CLHEP/Random/RandFlat.h"
6
#include "CLHEP/Random/RandGaussZiggurat.h"
7
8
#include "
ISF_FastCaloSimEvent/TFCSHistoLateralShapeGausLogWeight.h
"
9
#include "
ISF_FastCaloSimEvent/TFCSSimulationState.h
"
10
11
#include "TH1.h"
12
#include "TVector2.h"
13
#include "TMath.h"
14
15
//=============================================
16
//======= TFCSHistoLateralShapeGausLogWeight =========
17
//=============================================
18
19
TFCSHistoLateralShapeGausLogWeight::TFCSHistoLateralShapeGausLogWeight
(
20
const
char
*name,
const
char
*title)
21
:
TFCSHistoLateralShapeWeight
(name, title) {}
22
23
TFCSHistoLateralShapeGausLogWeight::~TFCSHistoLateralShapeGausLogWeight
() {
24
#ifdef USE_GPU
25
delete
m_LdFH;
26
#endif
27
}
28
29
FCSReturnCode
TFCSHistoLateralShapeGausLogWeight::simulate_hit
(
30
Hit
&
hit
,
TFCSSimulationState
&simulstate,
const
TFCSTruthState
*
/*truth*/
,
31
const
TFCSExtrapolationState
*
/*extrapol*/
) {
32
if
(!simulstate.
randomEngine
()) {
33
return
FCSFatal
;
34
}
35
36
const
double
center_eta =
hit
.center_eta();
37
const
double
center_phi =
hit
.center_phi();
38
const
double
center_r =
hit
.center_r();
39
const
double
center_z =
hit
.center_z();
40
41
const
float
dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
42
const
float
eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
43
(1.0 + TMath::Exp(-2 * center_eta)));
44
45
const
float
delta_eta =
hit
.eta() - center_eta;
46
const
float
delta_phi =
hit
.phi() - center_phi;
47
const
float
delta_eta_mm = delta_eta * eta_jakobi * dist000;
48
const
float
delta_phi_mm = delta_phi * center_r;
49
const
float
delta_r_mm =
50
TMath::Sqrt(delta_eta_mm * delta_eta_mm + delta_phi_mm * delta_phi_mm);
51
52
// TODO: delta_r_mm should perhaps be cached in hit
53
54
Int_t
bin
=
m_hist
->FindBin(delta_r_mm);
55
if
(
bin
< 1)
56
bin
= 1;
57
if
(
bin
>
m_hist
->GetNbinsX())
58
bin
=
m_hist
->GetNbinsX();
59
float
weight =
m_hist
->GetBinContent(
bin
);
60
float
RMS =
m_hist
->GetBinError(
bin
);
61
if
(RMS > 0) {
62
float
logweight = CLHEP::RandGaussZiggurat::shoot(simulstate.
randomEngine
(),
63
-0.5 * RMS * RMS, RMS);
64
weight *= TMath::Exp(logweight);
65
}
66
hit
.E() *= weight;
67
68
ATH_MSG_DEBUG
(
"HIT: E="
<<
hit
.E() <<
" dR_mm="
<< delta_r_mm
69
<<
" weight="
<< weight);
70
return
FCSSuccess
;
71
}
72
73
#ifdef USE_GPU
74
// for FCS-GPU
75
// make the histograms with GPU EDM
76
void
TFCSHistoLateralShapeGausLogWeight::LoadHist() {
77
78
if
(m_LdFH) {
79
return
;
80
}
81
m_LdFH =
new
LoadGpuHist();
82
FH1D
fh1d;
83
84
fh1d.
nbins
=
m_hist
->GetNbinsX();
85
fh1d.
h_contents
= (
float
*)
malloc
(fh1d.
nbins
*
sizeof
(
float
));
86
fh1d.
h_errors
= (
float
*)
malloc
(fh1d.
nbins
*
sizeof
(
float
));
87
fh1d.
h_borders
= (
float
*)
malloc
((fh1d.
nbins
+ 1) *
sizeof
(
float
));
88
89
for
(
int
ibin = 0; ibin < fh1d.
nbins
; ++ibin) {
90
fh1d.
h_contents
[ibin] =
m_hist
->GetBinContent(ibin + 1);
91
fh1d.
h_errors
[ibin] =
m_hist
->GetBinError(ibin + 1);
92
fh1d.
h_borders
[ibin] =
m_hist
->GetXaxis()->GetBinLowEdge(ibin + 1);
93
}
94
fh1d.
h_borders
[fh1d.
nbins
] =
m_hist
->GetXaxis()->GetBinUpEdge(fh1d.
nbins
);
95
96
m_LdFH->set_hf1d(&fh1d);
97
m_LdFH->LD1D();
98
99
return
;
100
}
101
#endif
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
FH1D
struct FH1D FH1D
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
TFCSHistoLateralShapeGausLogWeight.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
TFCSHistoLateralShapeGausLogWeight::~TFCSHistoLateralShapeGausLogWeight
virtual ~TFCSHistoLateralShapeGausLogWeight()
Definition
TFCSHistoLateralShapeGausLogWeight.cxx:23
TFCSHistoLateralShapeGausLogWeight::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
TFCSHistoLateralShapeGausLogWeight.cxx:29
TFCSHistoLateralShapeGausLogWeight::TFCSHistoLateralShapeGausLogWeight
TFCSHistoLateralShapeGausLogWeight(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSHistoLateralShapeGausLogWeight.cxx:19
TFCSHistoLateralShapeWeight::TFCSHistoLateralShapeWeight
TFCSHistoLateralShapeWeight(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSHistoLateralShapeWeight.cxx:21
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
TFCSLateralShapeParametrizationHitBase::Hit
Definition
TFCSLateralShapeParametrizationHitBase.h:42
TFCSSimulationState
Definition
TFCSSimulationState.h:32
TFCSSimulationState::randomEngine
CLHEP::HepRandomEngine * randomEngine()
Definition
TFCSSimulationState.h:36
TFCSTruthState
Definition
TFCSTruthState.h:13
bin
Definition
BinsDiffFromStripMedian.h:43
TrigInDetValidation_Base.malloc
malloc
Definition
TrigInDetValidation_Base.py:127
FH1D::h_errors
float * h_errors
Definition
FH_structs.h:25
FH1D::nbins
int nbins
Definition
FH_structs.h:26
FH1D::h_contents
float * h_contents
Definition
FH_structs.h:24
FH1D::h_borders
float * h_borders
Definition
FH_structs.h:23
Generated on
for ATLAS Offline Software by
1.17.0