ATLAS Offline Software
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 
87  const TFCSParametrizationBase &ref) const {
89  return true;
91  return false;
93  return false;
95  return false;
96  return true;
97 }
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 }
TFCSParametrization::compare
bool compare(const TFCSParametrizationBase &ref) const
Definition: TFCSParametrization.cxx:78
TFCSParametrizationBase::compare
bool compare(const TFCSParametrizationBase &ref) const
Do not persistify!
Definition: TFCSParametrizationBase.cxx:42
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TFCSLateralShapeParametrizationHitNumberFromE
Definition: TFCSLateralShapeParametrizationHitNumberFromE.h:13
TFCSLateralShapeParametrizationHitNumberFromE.h
TFCSLateralShapeParametrizationHitNumberFromE::operator==
virtual bool operator==(const TFCSParametrizationBase &ref) const override
The == operator compares the content of instances.
Definition: TFCSLateralShapeParametrizationHitNumberFromE.cxx:86
TFCSLateralShapeParametrization::Print
void Print(Option_t *option="") const override
Definition: TFCSLateralShapeParametrization.cxx:53
TFCSLateralShapeParametrizationHitNumberFromE::m_stochastic
double m_stochastic
Definition: TFCSLateralShapeParametrizationHitNumberFromE.h:61
TFCSLateralShapeParametrizationHitNumberFromE::m_constant
double m_constant
Definition: TFCSLateralShapeParametrizationHitNumberFromE.h:63
TFCSExtrapolationState
Definition: TFCSExtrapolationState.h:13
TFCSSimulationState::randomEngine
CLHEP::HepRandomEngine * randomEngine()
Definition: TFCSSimulationState.h:36
RunActsMaterialValidation.extrapol
extrapol
Definition: RunActsMaterialValidation.py:90
TFCSLateralShapeParametrizationHitNumberFromE::get_sigma2_fluctuation
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.
Definition: TFCSLateralShapeParametrizationHitNumberFromE.cxx:39
TFCSLateralShapeParametrizationHitNumberFromE::compare
bool compare(const TFCSParametrizationBase &ref) const
Definition: TFCSLateralShapeParametrizationHitNumberFromE.cxx:99
TFCSLateralShapeParametrizationHitBase
Definition: TFCSLateralShapeParametrizationHitBase.h:13
TFCSLateralShapeParametrizationHitNumberFromE::m_stochastic_hadron
double m_stochastic_hadron
Definition: TFCSLateralShapeParametrizationHitNumberFromE.h:62
TFCSParametrizationBase
Definition: TFCSParametrizationBase.h:46
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
covarianceTool.title
title
Definition: covarianceTool.py:542
dumpNswErrorDb.constant
def constant
Definition: dumpNswErrorDb.py:22
TFCSParametrizationBase::set_match_all_pdgid
virtual void set_match_all_pdgid()
Definition: TFCSParametrizationBase.h:83
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
pmontree.opt
opt
Definition: pmontree.py:16
TFCSLateralShapeParametrizationHitNumberFromE::get_number_of_hits
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...
Definition: TFCSLateralShapeParametrizationHitNumberFromE.cxx:71
TFCSLateralShapeParametrization::compare
bool compare(const TFCSParametrizationBase &ref) const
Definition: TFCSLateralShapeParametrization.cxx:32
TFCSLateralShapeParametrization::calosample
int calosample() const
Definition: TFCSLateralShapeParametrization.h:34
ref
const boost::regex ref(r_ef)
DEBUG
#define DEBUG
Definition: page_access.h:11
TFCSSimulationState::E
double E() const
Definition: TFCSSimulationState.h:42
TFCSSimulationState.h
TFCSLateralShapeParametrizationHitNumberFromE::Print
void Print(Option_t *option="") const override
Definition: TFCSLateralShapeParametrizationHitNumberFromE.cxx:123
TFCSTruthState
Definition: TFCSTruthState.h:13
TFCSSimulationState
Definition: TFCSSimulationState.h:32
TFCSLateralShapeParametrizationHitNumberFromE::TFCSLateralShapeParametrizationHitNumberFromE
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....
Definition: TFCSLateralShapeParametrizationHitNumberFromE.cxx:18
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