ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSHistoLateralShapeWeightHitAndMiss.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
10
11#include "TH1.h"
12#include "TVector2.h"
13#include "TMath.h"
14
15//=============================================
16//======= TFCSHistoLateralShapeWeightHitAndMiss =========
17//=============================================
18
22
25
27 Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState * /*truth*/,
28 const TFCSExtrapolationState * /*extrapol*/) {
29 if (!simulstate.randomEngine()) {
30 return FCSFatal;
31 }
32
33 const double center_eta = hit.center_eta();
34 const double center_phi = hit.center_phi();
35 const double center_r = hit.center_r();
36 const double center_z = hit.center_z();
37
38 const float dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
39 const float eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
40 (1.0 + TMath::Exp(-2 * center_eta)));
41
42 const float delta_eta = hit.eta() - center_eta;
43 const float delta_phi = hit.phi() - center_phi;
44 const float delta_eta_mm = delta_eta * eta_jakobi * dist000;
45 const float delta_phi_mm = delta_phi * center_r;
46 const float delta_r_mm =
47 TMath::Sqrt(delta_eta_mm * delta_eta_mm + delta_phi_mm * delta_phi_mm);
48
49 // TODO: delta_r_mm should perhaps be cached in hit
50
51 Int_t bin = m_hist->FindBin(delta_r_mm);
52 if (bin < 1)
53 bin = 1;
54 if (bin > m_hist->GetNbinsX())
55 bin = m_hist->GetNbinsX();
56 float meanweight = m_hist->GetBinContent(bin);
57 float weight = meanweight;
58 float RMS = m_hist->GetBinError(bin);
59 if (RMS > 0) {
60 weight = CLHEP::RandGaussZiggurat::shoot(simulstate.randomEngine(),
61 meanweight, RMS);
62 }
63
64 /* -------------------------------------------------------------------
65 * Weight is used to scale hit energy.
66 *
67 * if (meanweight > m_minWeight and meanweight < m_maxWeight)
68 * Hit is accecpted with probability of m_minWeight/meanweight.
69 * If not accepted, weight is set to zero (this is
70 * equivalent to not accept the hit).
71 *
72 * if (meanweight<=m_minWeight)
73 * Give lower energy to hit with probability 1.
74 * TFCSLateralShapeParametrizationHitChain needs to be able
75 * to generate more hits in this case
76 *
77 * if (meanweight >= m_maxWeight)
78 * meanweight is above upper threshold. It is set to m_maxWeight.
79 * -------------------------------------------------------------------
80 */
81 if (meanweight >= m_maxWeight) {
82 weight = m_maxWeight;
83 } else if (meanweight > m_minWeight) {
84 float prob = m_minWeight / meanweight;
85 float rnd = CLHEP::RandFlat::shoot(simulstate.randomEngine());
86 if (rnd >= prob)
87 weight = 0.;
88 }
89
90 hit.E() *= weight;
91 ATH_MSG_DEBUG("HIT: E=" << hit.E() << " dR_mm=" << delta_r_mm
92 << " meanweight=" << meanweight
93 << " weight=" << weight);
94
95 return FCSSuccess;
96}
#define ATH_MSG_DEBUG(x)
static TRandom * rnd
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
TFCSHistoLateralShapeWeightHitAndMiss(const char *name=nullptr, const char *title=nullptr)
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.
TFCSHistoLateralShapeWeight(const char *name=nullptr, const char *title=nullptr)
TH1 * m_hist
Histogram to be used for the shape simulation The histogram x-axis should be in dR^2=deta^2+dphi^2.
CLHEP::HepRandomEngine * randomEngine()