ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloSimEvent
src
TFCSHistoLateralShapeGausLogWeightHitAndMiss.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/TFCSHistoLateralShapeGausLogWeightHitAndMiss.h
"
9
#include "
ISF_FastCaloSimEvent/TFCSSimulationState.h
"
10
11
#include "TH1.h"
12
#include "TVector2.h"
13
#include "TMath.h"
14
15
//=============================================
16
//======= TFCSHistoLateralShapeGausLogWeightHitAndMiss =========
17
//=============================================
18
19
TFCSHistoLateralShapeGausLogWeightHitAndMiss::
20
TFCSHistoLateralShapeGausLogWeightHitAndMiss
(
const
char
*name,
21
const
char
*title)
22
:
TFCSHistoLateralShapeWeight
(name, title) {}
23
24
TFCSHistoLateralShapeGausLogWeightHitAndMiss::
25
~TFCSHistoLateralShapeGausLogWeightHitAndMiss
() {}
26
27
FCSReturnCode
TFCSHistoLateralShapeGausLogWeightHitAndMiss::simulate_hit
(
28
Hit
&
hit
,
TFCSSimulationState
&simulstate,
const
TFCSTruthState
*
/*truth*/
,
29
const
TFCSExtrapolationState
*
/*extrapol*/
) {
30
if
(!simulstate.
randomEngine
()) {
31
return
FCSFatal
;
32
}
33
34
const
double
center_eta =
hit
.center_eta();
35
const
double
center_phi =
hit
.center_phi();
36
const
double
center_r =
hit
.center_r();
37
const
double
center_z =
hit
.center_z();
38
39
const
float
dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
40
const
float
eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
41
(1.0 + TMath::Exp(-2 * center_eta)));
42
43
const
float
delta_eta =
hit
.eta() - center_eta;
44
const
float
delta_phi =
hit
.phi() - center_phi;
45
const
float
delta_eta_mm = delta_eta * eta_jakobi * dist000;
46
const
float
delta_phi_mm = delta_phi * center_r;
47
const
float
delta_r_mm =
48
TMath::Sqrt(delta_eta_mm * delta_eta_mm + delta_phi_mm * delta_phi_mm);
49
50
// TODO: delta_r_mm should perhaps be cached in hit
51
52
Int_t
bin
=
m_hist
->FindBin(delta_r_mm);
53
if
(
bin
< 1)
54
bin
= 1;
55
if
(
bin
>
m_hist
->GetNbinsX())
56
bin
=
m_hist
->GetNbinsX();
57
float
meanweight =
m_hist
->GetBinContent(
bin
);
58
float
weight = meanweight;
59
float
RMS =
m_hist
->GetBinError(
bin
);
60
if
(RMS > 0) {
61
float
logweight = CLHEP::RandGaussZiggurat::shoot(simulstate.
randomEngine
(),
62
-0.5 * RMS * RMS, RMS);
63
weight *= TMath::Exp(logweight);
64
}
65
if
(meanweight <= 1) {
66
// if meanweight<=1, give lower energy to hit.
67
// TFCSLateralShapeParametrizationHitChain needs to be able to generate more
68
// hits in this case
69
hit
.E() *= weight;
70
}
else
{
71
// if meanweight>1, accept only 1/meanweight events, but give them a higher
72
// energy increased by weight. This leads to larger fluctuations, while
73
// keeping the shape unchanged.
74
float
prob = 1.0 / meanweight;
75
float
rnd
= CLHEP::RandFlat::shoot(simulstate.
randomEngine
());
76
if
(
rnd
< prob)
77
hit
.E() *= weight;
78
else
79
hit
.E() = 0;
80
}
81
82
ATH_MSG_DEBUG
(
"HIT: E="
<<
hit
.E() <<
" dR_mm="
<< delta_r_mm
83
<<
" meanweight="
<< meanweight
84
<<
" weight="
<< weight);
85
return
FCSSuccess
;
86
}
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
rnd
static TRandom * rnd
Definition
LArWheelSliceSolidTests.cxx:68
TFCSHistoLateralShapeGausLogWeightHitAndMiss.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
TFCSHistoLateralShapeGausLogWeightHitAndMiss::TFCSHistoLateralShapeGausLogWeightHitAndMiss
TFCSHistoLateralShapeGausLogWeightHitAndMiss(const char *name=nullptr, const char *title=nullptr)
Definition
TFCSHistoLateralShapeGausLogWeightHitAndMiss.cxx:20
TFCSHistoLateralShapeGausLogWeightHitAndMiss::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
TFCSHistoLateralShapeGausLogWeightHitAndMiss.cxx:27
TFCSHistoLateralShapeGausLogWeightHitAndMiss::~TFCSHistoLateralShapeGausLogWeightHitAndMiss
virtual ~TFCSHistoLateralShapeGausLogWeightHitAndMiss()
Definition
TFCSHistoLateralShapeGausLogWeightHitAndMiss.cxx:25
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
Generated on
for ATLAS Offline Software by
1.17.0