ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSHistoLateralShapeGausLogWeight.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//======= TFCSHistoLateralShapeGausLogWeight =========
17//=============================================
18
22
24#ifdef USE_GPU
25 delete m_LdFH;
26#endif
27}
28
30 Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState * /*truth*/,
31 const TFCSExtrapolationState * /*extrapol*/) {
32 if (!simulstate.randomEngine()) {
33 return FCSFatal;
34 }
35
36 const double center_eta = hit.center_eta();
37 const double center_phi = hit.center_phi();
38 const double center_r = hit.center_r();
39 const double center_z = hit.center_z();
40
41 const float dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
42 const float eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
43 (1.0 + TMath::Exp(-2 * center_eta)));
44
45 const float delta_eta = hit.eta() - center_eta;
46 const float delta_phi = hit.phi() - center_phi;
47 const float delta_eta_mm = delta_eta * eta_jakobi * dist000;
48 const float delta_phi_mm = delta_phi * center_r;
49 const float delta_r_mm =
50 TMath::Sqrt(delta_eta_mm * delta_eta_mm + delta_phi_mm * delta_phi_mm);
51
52 // TODO: delta_r_mm should perhaps be cached in hit
53
54 Int_t bin = m_hist->FindBin(delta_r_mm);
55 if (bin < 1)
56 bin = 1;
57 if (bin > m_hist->GetNbinsX())
58 bin = m_hist->GetNbinsX();
59 float weight = m_hist->GetBinContent(bin);
60 float RMS = m_hist->GetBinError(bin);
61 if (RMS > 0) {
62 float logweight = CLHEP::RandGaussZiggurat::shoot(simulstate.randomEngine(),
63 -0.5 * RMS * RMS, RMS);
64 weight *= TMath::Exp(logweight);
65 }
66 hit.E() *= weight;
67
68 ATH_MSG_DEBUG("HIT: E=" << hit.E() << " dR_mm=" << delta_r_mm
69 << " weight=" << weight);
70 return FCSSuccess;
71}
72
73#ifdef USE_GPU
74// for FCS-GPU
75// make the histograms with GPU EDM
76void TFCSHistoLateralShapeGausLogWeight::LoadHist() {
77
78 if (m_LdFH) {
79 return;
80 }
81 m_LdFH = new LoadGpuHist();
82 FH1D fh1d;
83
84 fh1d.nbins = m_hist->GetNbinsX();
85 fh1d.h_contents = (float *)malloc(fh1d.nbins * sizeof(float));
86 fh1d.h_errors = (float *)malloc(fh1d.nbins * sizeof(float));
87 fh1d.h_borders = (float *)malloc((fh1d.nbins + 1) * sizeof(float));
88
89 for (int ibin = 0; ibin < fh1d.nbins; ++ibin) {
90 fh1d.h_contents[ibin] = m_hist->GetBinContent(ibin + 1);
91 fh1d.h_errors[ibin] = m_hist->GetBinError(ibin + 1);
92 fh1d.h_borders[ibin] = m_hist->GetXaxis()->GetBinLowEdge(ibin + 1);
93 }
94 fh1d.h_borders[fh1d.nbins] = m_hist->GetXaxis()->GetBinUpEdge(fh1d.nbins);
95
96 m_LdFH->set_hf1d(&fh1d);
97 m_LdFH->LD1D();
98
99 return;
100}
101#endif
#define ATH_MSG_DEBUG(x)
struct FH1D FH1D
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
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
TFCSHistoLateralShapeGausLogWeight(const char *name=nullptr, const char *title=nullptr)
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()
float * h_errors
Definition FH_structs.h:25
int nbins
Definition FH_structs.h:26
float * h_contents
Definition FH_structs.h:24
float * h_borders
Definition FH_structs.h:23