ATLAS Offline Software
TFCSEnergyInterpolationHistogram.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include "TFile.h"
10 #include "TCanvas.h"
11 #include "TGraph.h"
12 #include "TAxis.h"
13 #include <iostream>
14 #include <vector>
15 
16 #ifdef __FastCaloSimStandAlone__
17 namespace Gaudi {
18 namespace Units {
19 constexpr double megaelectronvolt = 1.;
20 constexpr double kiloelectronvolt = 1.e-3 * megaelectronvolt;
21 constexpr double keV = kiloelectronvolt;
22 } // namespace Units
23 } // namespace Gaudi
24 #else
25 #include "GaudiKernel/SystemOfUnits.h"
26 #endif
27 
28 //=============================================
29 //======= TFCSEnergyInterpolation =========
30 //=============================================
31 
33  const char *name, const char *title)
35 
37  TFCSSimulationState &simulstate, const TFCSTruthState *truth,
38  const TFCSExtrapolationState *) const {
39  float Emean;
40  float Einit;
41  const float Ekin = truth->Ekin();
42  if (OnlyScaleEnergy())
43  Einit = simulstate.E();
44  else
45  Einit = Ekin;
46  if (Einit < m_hist.GetXaxis()->GetBinLowEdge(1)) {
47  Emean = m_hist.GetBinContent(1) * Einit;
48  } else {
49  if (Einit > m_hist.GetXaxis()->GetBinUpEdge(m_hist.GetNbinsX())) {
50  Emean = m_hist.GetBinContent(m_hist.GetNbinsX()) * Einit;
51  } else {
52  Emean = m_hist.GetBinContent(m_hist.GetXaxis()->FindBin(Einit)) * Einit;
53  }
54  }
55 
56  if (OnlyScaleEnergy()) {
57  ATH_MSG_DEBUG("set E=" << Emean << " for true Ekin=" << truth->Ekin()
58  << " and E=" << Einit);
59  } else {
60  ATH_MSG_DEBUG("set E=" << Emean << " for true Ekin=" << truth->Ekin());
61  }
62  simulstate.set_E(Emean);
63 
64  return FCSSuccess;
65 }
66 
67 void TFCSEnergyInterpolationHistogram::Print(Option_t *option) const {
68  TString opt(option);
69  bool shortprint = opt.Index("short") >= 0;
70  bool longprint = msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
71  TString optprint = opt;
72  optprint.ReplaceAll("short", "");
74 
75  if (longprint)
77  optprint << (OnlyScaleEnergy() ? " E()*" : " Ekin()*")
78  << "histNbins=" << m_hist.GetNbinsX() << " "
79  << m_hist.GetXaxis()->GetBinLowEdge(1) << "<=Ekin<="
80  << m_hist.GetXaxis()->GetBinUpEdge(m_hist.GetNbinsX()));
81 }
82 
84  TFCSSimulationState *simulstate, TFCSTruthState *truth,
86  if (!simulstate)
87  simulstate = new TFCSSimulationState();
88  if (!truth)
89  truth = new TFCSTruthState();
90  if (!extrapol)
92 
93  if (!hist) {
94  hist = new TH1F("h1", "h1 title", 16, 0., 512.);
95  hist->SetBinContent(1, 0.687165);
96  hist->SetBinContent(2, 0.756837);
97  hist->SetBinContent(3, 0.836673);
98  hist->SetBinContent(4, 0.896336);
99  hist->SetBinContent(5, 0.889785);
100  hist->SetBinContent(6, 0.901266);
101  hist->SetBinContent(7, 0.888937);
102  hist->SetBinContent(8, 0.919943);
103  hist->SetBinContent(9, 0.941806);
104  hist->SetBinContent(10, 0.934668);
105  hist->SetBinContent(11, 0.939502);
106  hist->SetBinContent(12, 0.940796);
107  hist->SetBinContent(13, 0.945894);
108  hist->SetBinContent(14, 0.955445);
109  hist->SetBinContent(15, 0.955593);
110  hist->SetBinContent(16, 0.943673);
111  }
112 
113  TH1F *hdraw = (TH1F *)hist->Clone();
114  hdraw->SetMarkerColor(46);
115  hdraw->SetMarkerStyle(8);
116 
118  "testTFCSEnergyInterpolationHistogram",
119  "test TFCSEnergyInterpolationHistogram");
120  test.set_pdgid(22);
121  test.set_Ekin_nominal(0.5 *
122  (hdraw->GetXaxis()->GetBinLowEdge(1) +
123  hdraw->GetXaxis()->GetBinUpEdge(hdraw->GetNbinsX())));
124  test.set_Ekin_min(hdraw->GetXaxis()->GetBinLowEdge(1));
125  test.set_Ekin_max(hdraw->GetXaxis()->GetBinUpEdge(hdraw->GetNbinsX()));
126  test.set_eta_nominal(0.225);
127  test.set_eta_min(0.2);
128  test.set_eta_max(0.25);
129  test.InitFromHist(*hist);
130  // test.set_OnlyScaleEnergy();
131  test.Print();
132  test.hist().Dump();
133 
134  truth->set_pdgid(22);
135 
136  TGraph *gr = new TGraph();
137  gr->SetNameTitle("testTFCSEnergyInterpolationHistogramLogX",
138  "test TFCSEnergyInterpolationHistogram");
139  gr->GetXaxis()->SetTitle("Ekin [MeV]");
140  gr->GetYaxis()->SetTitle("<E(reco)>/Ekin(true)");
141 
142  int ip = 0;
143  for (float Ekin = std::max(test.Ekin_min() * 0.25, 0.1);
144  Ekin <= test.Ekin_max() * 4; Ekin *= 1.05) {
145  // Init LorentzVector for truth. For photon Ekin=E
146  truth->SetPxPyPzE(Ekin, 0, 0, Ekin);
147  simulstate->set_E(Ekin);
148  if (test.simulate(*simulstate, truth, extrapol) != FCSSuccess) {
149  return;
150  }
151  gr->SetPoint(ip, Ekin, simulstate->E() / Ekin);
152  ++ip;
153  }
154 
155 // Drawing doesn't make sense inside athena and necessary libraries not linked
156 // by default
157 #if defined(__FastCaloSimStandAlone__)
158  TCanvas *c = new TCanvas(hdraw->GetName(), hdraw->GetTitle());
159  hdraw->Draw("HIST");
160  gr->Draw("same,APL");
161  c->SetLogx();
162 #endif
163 }
FCSReturnCode
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition: TFCSParametrizationBase.h:41
TFCSEnergyInterpolationHistogram.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
make_coralServer_rep.opt
opt
Definition: make_coralServer_rep.py:19
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
plotmaker.hist
hist
Definition: plotmaker.py:148
gr
#define gr
TFCSEnergyInterpolationHistogram::simulate
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Initialize simulstate with the mean reconstructed energy in the calorimater expeted from the true kin...
Definition: TFCSEnergyInterpolationHistogram.cxx:36
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
TFCSExtrapolationState
Definition: TFCSExtrapolationState.h:13
RunActsMaterialValidation.extrapol
extrapol
Definition: RunActsMaterialValidation.py:91
TFCSEnergyInterpolationHistogram::hist
const TH1F & hist() const
Definition: TFCSEnergyInterpolationHistogram.h:37
python.SystemOfUnits.keV
int keV
Definition: SystemOfUnits.py:156
TFCSEnergyInterpolationHistogram
Definition: TFCSEnergyInterpolationHistogram.h:11
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TFCSTruthState::Ekin
double Ekin() const
Definition: TFCSTruthState.h:26
covarianceTool.title
title
Definition: covarianceTool.py:542
python.SystemOfUnits.megaelectronvolt
int megaelectronvolt
Definition: SystemOfUnits.py:144
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
TFCSParametrizationBase::Print
void Print(Option_t *option="") const
Print object information.
Definition: TFCSParametrizationBase.cxx:52
FCSSuccess
@ FCSSuccess
Definition: TFCSParametrizationBase.h:41
python.SystemOfUnits.kiloelectronvolt
int kiloelectronvolt
Definition: SystemOfUnits.py:146
TFCSEnergyInterpolationHistogram::Print
void Print(Option_t *option="") const override
Definition: TFCSEnergyInterpolationHistogram.cxx:67
Athena::Units
Definition: Units.h:45
TFCSEnergyInterpolationHistogram::unit_test
static void unit_test(TFCSSimulationState *simulstate=nullptr, TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr, TH1F *hist=nullptr)
Definition: TFCSEnergyInterpolationHistogram.cxx:83
TFCSParametrization
Definition: TFCSParametrization.h:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TFCSSimulationState::set_E
void set_E(int sample, double Esample)
Definition: TFCSSimulationState.h:48
TFCSEnergyInterpolationHistogram::OnlyScaleEnergy
bool OnlyScaleEnergy() const
Definition: TFCSEnergyInterpolationHistogram.h:22
TFCSEnergyInterpolationHistogram::TFCSEnergyInterpolationHistogram
TFCSEnergyInterpolationHistogram(const char *name=nullptr, const char *title=nullptr)
Definition: TFCSEnergyInterpolationHistogram.cxx:32
TFCSTruthState.h
TFCSExtrapolationState.h
DEBUG
#define DEBUG
Definition: page_access.h:11
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
TFCSSimulationState::E
double E() const
Definition: TFCSSimulationState.h:42
TFCSSimulationState.h
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
TFCSTruthState
Definition: TFCSTruthState.h:13
python.compressB64.c
def c
Definition: compressB64.py:93
TFCSSimulationState
Definition: TFCSSimulationState.h:32
TFCSEnergyInterpolationHistogram::m_hist
TH1F m_hist
Definition: TFCSEnergyInterpolationHistogram.h:52
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
TFCSTruthState::set_pdgid
void set_pdgid(int val)
Definition: TFCSTruthState.h:18