ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSHistoLateralShapeParametrizationFCal.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CLHEP/Random/RandFlat.h"
6#include "CLHEP/Random/RandPoisson.h"
7
11
12#include "TMath.h"
13
15
16//=============================================
17//======= TFCSHistoLateralShapeParametrizationFCal =========
18//=============================================
19
24
27
29 Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth,
30 const TFCSExtrapolationState * /*extrapol*/) {
31 if (!simulstate.randomEngine()) {
32 return FCSFatal;
33 }
34
35 const int pdgId = truth->pdgid();
36 const double charge =MC::charge(pdgId);
37
38 const int cs = calosample();
39 // const double center_phi=0.5*( extrapol->phi(cs, CaloSubPos::SUBPOS_ENT) +
40 // extrapol->phi(cs, CaloSubPos::SUBPOS_EXT) ); const double center_r=0.5*(
41 // extrapol->r(cs, CaloSubPos::SUBPOS_ENT) + extrapol->r(cs,
42 // CaloSubPos::SUBPOS_EXT) ); const double center_z=0.5*( extrapol->z(cs,
43 // CaloSubPos::SUBPOS_ENT) + extrapol->z(cs, CaloSubPos::SUBPOS_EXT) );
44 const double center_phi = hit.center_phi();
45 const double center_r = hit.center_r();
46 const double center_z = hit.center_z();
47
48 float alpha, r, rnd1, rnd2;
49 rnd1 = CLHEP::RandFlat::shoot(simulstate.randomEngine());
50 rnd2 = CLHEP::RandFlat::shoot(simulstate.randomEngine());
51 if (is_phi_symmetric()) {
52 if (rnd2 >= 0.5) { // Fill negative phi half of shape
53 rnd2 -= 0.5;
54 rnd2 *= 2;
55 m_hist.rnd_to_fct(alpha, r, rnd1, rnd2);
56 alpha = -alpha;
57 } else { // Fill positive phi half of shape
58 rnd2 *= 2;
59 m_hist.rnd_to_fct(alpha, r, rnd1, rnd2);
60 }
61 } else {
62 m_hist.rnd_to_fct(alpha, r, rnd1, rnd2);
63 }
64 if (TMath::IsNaN(alpha) || TMath::IsNaN(r)) {
65 ATH_MSG_ERROR(" Histogram: "
66 << m_hist.get_HistoBordersx().size() - 1 << "*"
67 << m_hist.get_HistoBordersy().size() - 1
68 << " bins, #hits=" << m_nhits << " alpha=" << alpha
69 << " r=" << r << " rnd1=" << rnd1 << " rnd2=" << rnd2);
70 alpha = 0;
71 r = 0.001;
72
73 ATH_MSG_ERROR(" This error could probably be retried");
74 return FCSFatal;
75 }
76
77 const float hit_r = r * cos(alpha) + center_r;
78 float delta_phi = r * sin(alpha) / center_r;
79 // We derive the shower shapes for electrons and positively charged hadrons.
80 // Particle with the opposite charge are expected to have the same shower shape
81 // after the transformation: delta_phi --> -delta_phi
82 if ((charge < 0. && pdgId!=11) || pdgId==-11)
83 delta_phi = -delta_phi;
84 const float hit_phi = delta_phi + center_phi;
85
86 hit.setXYZE(hit_r * cos(hit_phi), hit_r * sin(hit_phi), center_z, hit.E());
87
88 ATH_MSG_DEBUG("HIT: E=" << hit.E() << " cs=" << cs << " x=" << hit.x()
89 << " y=" << hit.y() << " z=" << hit.z() << " r=" << r
90 << " alpha=" << alpha);
91
92 return FCSSuccess;
93}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
ATLAS-specific HepMC functions.
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
TFCSHistoLateralShapeParametrizationFCal(const char *name=nullptr, const char *title=nullptr)
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
simulated one hit position with weight that should be put into simulstate sometime later all hit weig...
TFCS2DFunctionHistogram m_hist
Histogram to be used for the shape simulation.
TFCSHistoLateralShapeParametrization(const char *name=nullptr, const char *title=nullptr)
CLHEP::HepRandomEngine * randomEngine()
int pdgid() const
int r
Definition globals.cxx:22
double charge(const T &p)