ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSLateralShapeParametrizationHitNumberFromE.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CLHEP/Random/RandPoisson.h"
6
9
10#include "TMath.h"
11#include <TClass.h>
12
13//=============================================
14//======= TFCSHistoLateralShapeParametrization =========
15//=============================================
16
19 const char *title,
20 double stochastic,
21 double constant)
23 m_stochastic(stochastic), m_stochastic_hadron(0.0), m_constant(constant) {
25}
26
29 const char *title,
30 double stochastic,
31 double stochastic_hadron,
32 double constant)
34 m_stochastic(stochastic), m_stochastic_hadron(stochastic_hadron),
35 m_constant(constant) {
37}
38
40 TFCSSimulationState &simulstate, const TFCSTruthState * /*truth*/,
41 const TFCSExtrapolationState * /*extrapol*/) const {
42 int cs = calosample();
43 float energy = simulstate.E(cs);
44
45 if (energy < 0) {
46 return 1;
47 }
48
49 if (TMath::IsNaN(energy)) {
50 ATH_MSG_DEBUG("Energy is NaN");
51 return 1;
52 }
53
54 double sqrtE = sqrt(energy / 1000.0);
55 double sigma_stochastic = m_stochastic / sqrtE;
56 double sigma_stochastic_hadron = m_stochastic_hadron / sqrtE;
57
58 // Attention: linear sum of "hadron" stochastic term and constant term as
59 // emulation of fluctuations in EM component
60 double sigma_hadron = m_constant + sigma_stochastic_hadron;
61
62 // Usual quadratic sum of "hardon" component and normal stochastic term
63 double sigma2 =
64 sigma_stochastic * sigma_stochastic + sigma_hadron * sigma_hadron;
65
66 ATH_MSG_DEBUG("sigma^2 fluctuation=" << sigma2);
67
68 return sigma2;
69}
70
72 TFCSSimulationState &simulstate, const TFCSTruthState *truth,
73 const TFCSExtrapolationState *extrapol) const {
74 if (!simulstate.randomEngine()) {
75 return -1;
76 }
77
78 float sigma2 = get_sigma2_fluctuation(simulstate, truth, extrapol);
79 int hits = CLHEP::RandPoisson::shoot(simulstate.randomEngine(), 1.0 / sigma2);
80
81 ATH_MSG_DEBUG("#hits=" << hits);
82
83 return hits;
84}
85
98
100 const TFCSParametrizationBase &ref) const {
101 if (IsA() != ref.IsA()) {
102 ATH_MSG_DEBUG("compare(): different class types "
103 << IsA()->GetName() << " != " << ref.IsA()->GetName());
104 return false;
105 }
108 if (m_stochastic != ref_typed.m_stochastic ||
110 m_constant != ref_typed.m_constant) {
111 ATH_MSG_DEBUG("operator==(): different fluctuation model sigma^2=["
112 << m_stochastic << "/sqrt(E/GeV)]^2 + [" << m_constant
113 << " + " << m_stochastic_hadron
114 << "/sqrt(E/GeV)]^2 != sigma^2=[" << ref_typed.m_stochastic
115 << "/sqrt(E/GeV)]^2 + [" << ref_typed.m_constant << " + "
116 << ref_typed.m_stochastic_hadron << "/sqrt(E/GeV)]^2");
117 return false;
118 }
119
120 return true;
121}
122
124 Option_t *option) const {
125 TString opt(option);
126 bool shortprint = opt.Index("short") >= 0;
127 bool longprint = msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
128 TString optprint = opt;
129 optprint.ReplaceAll("short", "");
131
132 if (longprint)
133 ATH_MSG_INFO(optprint << " sigma^2=[" << m_stochastic
134 << "/sqrt(E/GeV)]^2 + [" << m_constant << " + "
135 << m_stochastic_hadron << "/sqrt(E/GeV)]^2");
136}
const boost::regex ref(r_ef)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
Definition MLogging.h:222
TFCSLateralShapeParametrizationHitBase(const char *name=nullptr, const char *title=nullptr)
virtual bool operator==(const TFCSParametrizationBase &ref) const override
The == operator compares the content of instances.
int get_number_of_hits(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Call get_number_of_hits() only once per shower simulation, as it could be calculated with random numb...
double get_sigma2_fluctuation(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Give the effective size sigma^2 of the fluctuations from the stochastic and constant term.
TFCSLateralShapeParametrizationHitNumberFromE(const char *name=nullptr, const char *title=nullptr, double stochastic=0.1, double constant=0)
LAr: 10.1%/sqrt(E) stochastic=0.101; constant=0.002; HadEC: 21.4%/sqrt(E) stochastic=0....
void Print(Option_t *option="") const override
bool compare(const TFCSParametrizationBase &ref) const
bool compare(const TFCSParametrizationBase &ref) const
Do not persistify!
bool compare(const TFCSParametrizationBase &ref) const
CLHEP::HepRandomEngine * randomEngine()
#define IsA
Declare the TObject style functions.