ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSEnergyInterpolationLinear.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "TCanvas.h"
10#include "TGraph.h"
11#include "TAxis.h"
12#include <iostream>
13
14//=============================================
15//======= TFCSEnergyInterpolationLinear =========
16//=============================================
17
19 const char *title)
20 : TFCSParametrization(name, title), m_slope(1), m_offset(0) {}
21
24 const TFCSTruthState *truth,
25 const TFCSExtrapolationState *) const {
26 const float Emean = m_slope * truth->Ekin() + m_offset;
27
28 ATH_MSG_DEBUG("set E=" << Emean << " for true Ekin=" << truth->Ekin());
29 simulstate.set_E(Emean);
30
31 return FCSSuccess;
32}
33
34void TFCSEnergyInterpolationLinear::Print(Option_t *option) const {
35 TString opt(option);
36 bool shortprint = opt.Index("short") >= 0;
37 bool longprint = msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
38 TString optprint = opt;
39 optprint.ReplaceAll("short", "");
41
42 if (longprint)
43 ATH_MSG_INFO(optprint << " Emean=" << m_slope << "*Ekin(true) + "
44 << m_offset);
45}
46
48 TFCSSimulationState *simulstate, TFCSTruthState *truth,
49 const TFCSExtrapolationState *extrapol) {
50 if (!simulstate)
51 simulstate = new TFCSSimulationState();
52 if (!truth)
53 truth = new TFCSTruthState();
54 if (!extrapol)
55 extrapol = new TFCSExtrapolationState();
56
57 TFCSEnergyInterpolationLinear test("testTFCSEnergyInterpolation",
58 "test linear TFCSEnergyInterpolation");
59 test.set_pdgid(22);
60 test.set_Ekin_nominal(1000);
61 test.set_Ekin_min(1000);
62 test.set_Ekin_max(100000);
63 test.set_eta_nominal(0.225);
64 test.set_eta_min(0.2);
65 test.set_eta_max(0.25);
66 test.set_slope(0.95);
67 test.set_offset(-50);
68 test.Print();
69
70 truth->set_pdgid(22);
71
72 TGraph *gr = new TGraph();
73 gr->SetNameTitle("testTFCSEnergyInterpolation",
74 "test linear TFCSEnergyInterpolation");
75 gr->GetXaxis()->SetTitle("Ekin [MeV]");
76 gr->GetYaxis()->SetTitle("<E(reco)>/Ekin(true)");
77
78 int ip = 0;
79 for (float Ekin = 1000; Ekin <= 100000; Ekin *= 1.1) {
80 // Init LorentzVector for truth. For photon Ekin=E
81 truth->SetPxPyPzE(Ekin, 0, 0, Ekin);
82 if (test.simulate(*simulstate, truth, extrapol) != FCSSuccess) {
83 return;
84 }
85 gr->SetPoint(ip, Ekin, simulstate->E() / Ekin);
86 ++ip;
87 }
88
89// Drawing doesn't make sense inside athena and necessary libraries not linked
90// by default
91#if defined(__FastCaloSimStandAlone__)
92 TCanvas *c = new TCanvas("testTFCSEnergyInterpolation",
93 "test linear TFCSEnergyInterpolation");
94 gr->Draw("APL");
95 c->SetLogx();
96#endif
97}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define gr
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
Definition MLogging.h:222
TFCSEnergyInterpolationLinear(const char *name=nullptr, const char *title=nullptr)
static void unit_test(TFCSSimulationState *simulstate=nullptr, TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
void Print(Option_t *option="") const override
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
void Print(Option_t *option="") const
Print object information.
TFCSParametrization(const char *name=nullptr, const char *title=nullptr)
void set_E(int sample, double Esample)
void set_pdgid(int val)
double Ekin() const