ATLAS Offline Software
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 
20  const char *name, const char *title)
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) {
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 }
FCSReturnCode
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition: TFCSParametrizationBase.h:41
TFCSLateralShapeParametrizationHitBase::Hit::phi
float & phi()
Definition: TFCSLateralShapeParametrizationHitBase.h:87
TFCSHistoLateralShapeWeight
Definition: TFCSHistoLateralShapeWeight.h:13
TFCSHistoLateralShapeWeightHitAndMiss.h
bin
Definition: BinsDiffFromStripMedian.h:43
TFCSExtrapolationState
Definition: TFCSExtrapolationState.h:13
TFCSSimulationState::randomEngine
CLHEP::HepRandomEngine * randomEngine()
Definition: TFCSSimulationState.h:36
TFCSLateralShapeParametrizationHitBase::Hit
Definition: TFCSLateralShapeParametrizationHitBase.h:42
TFCSLateralShapeParametrizationHitBase::Hit::center_phi
float & center_phi()
Definition: TFCSLateralShapeParametrizationHitBase.h:101
covarianceTool.prob
prob
Definition: covarianceTool.py:678
TFCSHistoLateralShapeWeightHitAndMiss::~TFCSHistoLateralShapeWeightHitAndMiss
virtual ~TFCSHistoLateralShapeWeightHitAndMiss()
Definition: TFCSHistoLateralShapeWeightHitAndMiss.cxx:24
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
TFCSLateralShapeParametrizationHitBase::Hit::E
float & E()
Definition: TFCSLateralShapeParametrizationHitBase.h:90
TFCSHistoLateralShapeWeight::m_minWeight
float m_minWeight
Definition: TFCSHistoLateralShapeWeight.h:41
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TFCSHistoLateralShapeWeight::m_maxWeight
float m_maxWeight
Definition: TFCSHistoLateralShapeWeight.h:42
covarianceTool.title
title
Definition: covarianceTool.py:542
TFCSLateralShapeParametrizationHitBase::Hit::center_z
float & center_z()
Definition: TFCSLateralShapeParametrizationHitBase.h:99
FCSFatal
@ FCSFatal
Definition: TFCSParametrizationBase.h:41
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
FCSSuccess
@ FCSSuccess
Definition: TFCSParametrizationBase.h:41
DiTauMassTools::HistInfo::RMS
@ RMS
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
eFEXNTuple.delta_phi
def delta_phi(phi1, phi2)
Definition: eFEXNTuple.py:15
TFCSLateralShapeParametrizationHitBase::Hit::center_eta
float & center_eta()
Definition: TFCSLateralShapeParametrizationHitBase.h:100
TFCSLateralShapeParametrizationHitBase::Hit::center_r
float & center_r()
Definition: TFCSLateralShapeParametrizationHitBase.h:98
TFCSLateralShapeParametrizationHitBase::Hit::eta
float & eta()
Definition: TFCSLateralShapeParametrizationHitBase.h:86
TFCSSimulationState.h
TFCSHistoLateralShapeWeightHitAndMiss::TFCSHistoLateralShapeWeightHitAndMiss
TFCSHistoLateralShapeWeightHitAndMiss(const char *name=nullptr, const char *title=nullptr)
Definition: TFCSHistoLateralShapeWeightHitAndMiss.cxx:19
TFCSTruthState
Definition: TFCSTruthState.h:13
TFCSSimulationState
Definition: TFCSSimulationState.h:32
TFCSHistoLateralShapeWeightHitAndMiss::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: TFCSHistoLateralShapeWeightHitAndMiss.cxx:26