ATLAS Offline Software
Loading...
Searching...
No Matches
egGain::GainUncertainty Class Reference

#include <GainUncertainty.h>

Inheritance diagram for egGain::GainUncertainty:
Collaboration diagram for egGain::GainUncertainty:

Public Types

enum class  GainType { MEDIUM , LOW , MEDIUMLOW }

Public Member Functions

 GainUncertainty (const std::string &filename, bool splitGainUnc=false, const std::string &name="GainUncertainty", bool setInterpolation=false)
 ~GainUncertainty ()
double getUncertainty (double etaCalo_input, double et_input, PATCore::ParticleType::Type ptype=PATCore::ParticleType::Electron, bool useUncertainty=false, GainType gainType=GainType::MEDIUMLOW) const
void setLevel (MSG::Level lvl)
 Change the current logging level.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

TH1 * m_alpha_specialGainRun
TH1 * m_gain_impact_Zee
TH1 * m_gain_Impact_elec [s_nEtaBins] {}
TH1 * m_gain_Impact_conv [s_nEtaBins] {}
TH1 * m_gain_Impact_unco [s_nEtaBins] {}
TH1 * m_gain_Impact_elec_medium [s_nEtaBins] {}
TH1 * m_gain_Impact_conv_medium [s_nEtaBins] {}
TH1 * m_gain_Impact_unco_medium [s_nEtaBins] {}
TH1 * m_gain_Impact_elec_low [s_nEtaBins] {}
TH1 * m_gain_Impact_conv_low [s_nEtaBins] {}
TH1 * m_gain_Impact_unco_low [s_nEtaBins] {}
bool m_useInterpolation
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Static Private Attributes

static const int s_nEtaBins = 5

Detailed Description

Definition at line 17 of file GainUncertainty.h.

Member Enumeration Documentation

◆ GainType

Enumerator
MEDIUM 
LOW 
MEDIUMLOW 

Definition at line 23 of file GainUncertainty.h.

23{ MEDIUM, LOW, MEDIUMLOW };

Constructor & Destructor Documentation

◆ GainUncertainty()

egGain::GainUncertainty::GainUncertainty ( const std::string & filename,
bool splitGainUnc = false,
const std::string & name = "GainUncertainty",
bool setInterpolation = false )

Definition at line 17 of file GainUncertainty.cxx.

19 : asg::AsgMessaging(thisname.c_str()) {
20
21 ATH_MSG_INFO("opening file " << filename);
22 std::unique_ptr<TFile> gainFile(TFile::Open(filename.c_str(), "READ"));
23
25 (TH1*)(gainFile->Get("alpha_specialGainRun"))))
26 ATH_MSG_FATAL("cannot open alpha_specialGainRun");
27 m_alpha_specialGainRun->SetDirectory(nullptr);
28 if (not(m_gain_impact_Zee = (TH1*)(gainFile->Get("gain_impact_Zee"))))
29 ATH_MSG_FATAL("cannot open gain_impact_Zee");
30 m_gain_impact_Zee->SetDirectory(nullptr);
31 for (int i = 0; i < s_nEtaBins; i++) {
32 char name[60];
33 sprintf(name, "gain_Impact_elec_%d", i);
34 if (not(m_gain_Impact_elec[i] = (TH1*)(gainFile->Get(name))))
35 ATH_MSG_FATAL("cannot open " << name);
36 m_gain_Impact_elec[i]->SetDirectory(nullptr);
37 sprintf(name, "gain_Impact_conv_%d", i);
38 if (not(m_gain_Impact_conv[i] = (TH1*)(gainFile->Get(name))))
39 ATH_MSG_FATAL("cannot open " << name);
40 m_gain_Impact_conv[i]->SetDirectory(nullptr);
41 sprintf(name, "gain_Impact_unco_%d", i);
42 if (not(m_gain_Impact_unco[i] = (TH1*)(gainFile->Get(name))))
43 ATH_MSG_FATAL("cannot open " << name);
44 m_gain_Impact_unco[i]->SetDirectory(nullptr);
45
46 if (splitGainUnc) {
47 sprintf(name, "gain_Impact_elec_%d_medium", i);
48 if (not(m_gain_Impact_elec_medium[i] = (TH1*)(gainFile->Get(name))))
49 ATH_MSG_FATAL("cannot open " << name);
50 m_gain_Impact_elec_medium[i]->SetDirectory(nullptr);
51
52 sprintf(name, "gain_Impact_conv_%d_medium", i);
53 if (not(m_gain_Impact_conv_medium[i] = (TH1*)(gainFile->Get(name))))
54 ATH_MSG_FATAL("cannot open " << name);
55 m_gain_Impact_conv_medium[i]->SetDirectory(nullptr);
56
57 sprintf(name, "gain_Impact_unco_%d_medium", i);
58 if (not(m_gain_Impact_unco_medium[i] = (TH1*)(gainFile->Get(name))))
59 ATH_MSG_FATAL("cannot open " << name);
60 m_gain_Impact_unco_medium[i]->SetDirectory(nullptr);
61
62 sprintf(name, "gain_Impact_elec_%d_low", i);
63 if (not(m_gain_Impact_elec_low[i] = (TH1*)(gainFile->Get(name))))
64 ATH_MSG_FATAL("cannot open " << name);
65 m_gain_Impact_elec_low[i]->SetDirectory(nullptr);
66
67 sprintf(name, "gain_Impact_conv_%d_low", i);
68 if (not(m_gain_Impact_conv_low[i] = (TH1*)(gainFile->Get(name))))
69 ATH_MSG_FATAL("cannot open " << name);
70 m_gain_Impact_conv_low[i]->SetDirectory(nullptr);
71
72 sprintf(name, "gain_Impact_unco_%d_low", i);
73 if (not(m_gain_Impact_unco_low[i] = (TH1*)(gainFile->Get(name))))
74 ATH_MSG_FATAL("cannot open " << name);
75 m_gain_Impact_unco_low[i]->SetDirectory(nullptr);
76 }
77 }
78
79 m_useInterpolation = setInterpolation;
80}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
static const int s_nEtaBins
TH1 * m_gain_Impact_conv[s_nEtaBins]
TH1 * m_gain_Impact_elec_low[s_nEtaBins]
TH1 * m_gain_Impact_elec_medium[s_nEtaBins]
TH1 * m_gain_Impact_unco_medium[s_nEtaBins]
TH1 * m_gain_Impact_unco[s_nEtaBins]
TH1 * m_gain_Impact_conv_medium[s_nEtaBins]
TH1 * m_gain_Impact_unco_low[s_nEtaBins]
TH1 * m_gain_Impact_conv_low[s_nEtaBins]
TH1 * m_gain_Impact_elec[s_nEtaBins]

◆ ~GainUncertainty()

egGain::GainUncertainty::~GainUncertainty ( )

Definition at line 84 of file GainUncertainty.cxx.

84 {
86 delete m_gain_impact_Zee;
87 for (int i = 0; i < s_nEtaBins; i++) {
88 delete m_gain_Impact_elec[i];
89 delete m_gain_Impact_conv[i];
90 delete m_gain_Impact_unco[i];
91
95
99 }
100}

Member Function Documentation

◆ getUncertainty()

double egGain::GainUncertainty::getUncertainty ( double etaCalo_input,
double et_input,
PATCore::ParticleType::Type ptype = PATCore::ParticleType::Electron,
bool useUncertainty = false,
GainType gainType = GainType::MEDIUMLOW ) const

Definition at line 106 of file GainUncertainty.cxx.

109 {
110 double aeta = std::fabs(etaCalo_input);
111 int ibin = -1;
112 if (aeta < 0.8)
113 ibin = 0;
114 else if (aeta < 1.37)
115 ibin = 1;
116 else if (aeta < 1.52)
117 ibin = 2;
118 else if (aeta < 1.80)
119 ibin = 3;
120 else if (aeta < 2.50)
121 ibin = 4;
122 if (ibin < 0)
123 return 0.;
124 ATH_MSG_VERBOSE("GainUncertainty::getUncertainty " << etaCalo_input << " "
125 << et_input << " " << ptype
126 << " ibin " << ibin);
127
128 // Protection needed as the histograms stops at 1 TeV
129 if (et_input > 999999.)
130 et_input = 999999.;
131
132 // std::cout << " --- in GainUncertainty::getUncertainty " <<
133 // etaCalo_input << " " << et_input << " " << ptype << " ibin " << ibin
134 // << std::endl;
135
136 TH1* hImpact = nullptr;
137 // Medium+Low gain effect
138 if (gainType == GainType::MEDIUMLOW) {
140 hImpact = m_gain_Impact_elec[ibin];
142 hImpact = m_gain_Impact_conv[ibin];
144 hImpact = m_gain_Impact_unco[ibin];
145 else {
147 "Trying to get Gain correction of not allowed particle type");
148 return 0;
149 }
150 }
151
152 // Medium gain effect
153 else if (gainType == GainType::MEDIUM) {
155 hImpact = m_gain_Impact_elec_medium[ibin];
157 hImpact = m_gain_Impact_conv_medium[ibin];
159 hImpact = m_gain_Impact_unco_medium[ibin];
160 else {
162 "Trying to get Gain correction of not allowed particle type");
163 return 0;
164 }
165 }
166 // Low gain effect
167 else if (gainType == GainType::LOW) {
169 hImpact = m_gain_Impact_elec_low[ibin];
171 hImpact = m_gain_Impact_conv_low[ibin];
173 hImpact = m_gain_Impact_unco_low[ibin];
174 else {
176 "Trying to get Gain correction of not allowed particle type");
177 return 0;
178 }
179 }
180
181 double max_et = hImpact->GetXaxis()->GetBinUpEdge(hImpact->GetNbinsX());
182 // Protection needed to match maximum Et in the histogram
183 if (0.001 * et_input > max_et) {
184 et_input = (max_et - 1.) * 1000.;
185 }
186
187 double impact = 0;
188 if (m_useInterpolation) {
189 impact = hImpact->Interpolate(0.001 * et_input);
191 "L2 gain impact without interpolation: "
192 << hImpact->GetBinContent(hImpact->FindFixBin(0.001 * et_input)));
193 ATH_MSG_DEBUG("L2 gain impact with interpolation: "
194 << hImpact->Interpolate(0.001 * et_input));
195 } else {
196 impact = hImpact->GetBinContent(hImpact->FindFixBin(0.001 * et_input));
197 }
198
199 int ieta = m_alpha_specialGainRun->FindFixBin(aeta);
200 if (useL2GainUncertainty)
201 ATH_MSG_INFO("Applying 100% uncertainy on l2 gain corrections");
202
203 double alphaG = m_alpha_specialGainRun->GetBinContent(ieta);
204
205 double impactZee =
206 m_gain_impact_Zee->GetBinContent(m_gain_impact_Zee->FindFixBin(aeta));
207
208 double_t sigmaE = alphaG * impact / impactZee;
209
210 ATH_MSG_VERBOSE("alpha_specialGainRun, gain_impact_Zee, impact, sigmaE = "
211 << alphaG << " " << impactZee << " " << impact << " "
212 << sigmaE);
213
214 return sigmaE;
215}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49 {
50#ifndef XAOD_STANDALONE
51 return ::AthMessaging::msg();
52#else // not XAOD_STANDALONE
53 return m_msg;
54#endif // not XAOD_STANDALONE
55 }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57 {
58#ifndef XAOD_STANDALONE
59 return ::AthMessaging::msg( lvl );
60#else // not XAOD_STANDALONE
61 m_msg << lvl;
62 return m_msg;
63#endif // not XAOD_STANDALONE
64 }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41 {
42#ifndef XAOD_STANDALONE
43 return ::AthMessaging::msgLvl( lvl );
44#else // not XAOD_STANDALONE
45 return m_msg.msgLevel( lvl );
46#endif // not XAOD_STANDALONE
47 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_alpha_specialGainRun

TH1* egGain::GainUncertainty::m_alpha_specialGainRun
private

Definition at line 38 of file GainUncertainty.h.

◆ m_gain_Impact_conv

TH1* egGain::GainUncertainty::m_gain_Impact_conv[s_nEtaBins] {}
private

Definition at line 41 of file GainUncertainty.h.

41{};

◆ m_gain_Impact_conv_low

TH1* egGain::GainUncertainty::m_gain_Impact_conv_low[s_nEtaBins] {}
private

Definition at line 47 of file GainUncertainty.h.

47{};

◆ m_gain_Impact_conv_medium

TH1* egGain::GainUncertainty::m_gain_Impact_conv_medium[s_nEtaBins] {}
private

Definition at line 44 of file GainUncertainty.h.

44{};

◆ m_gain_Impact_elec

TH1* egGain::GainUncertainty::m_gain_Impact_elec[s_nEtaBins] {}
private

Definition at line 40 of file GainUncertainty.h.

40{};

◆ m_gain_Impact_elec_low

TH1* egGain::GainUncertainty::m_gain_Impact_elec_low[s_nEtaBins] {}
private

Definition at line 46 of file GainUncertainty.h.

46{};

◆ m_gain_Impact_elec_medium

TH1* egGain::GainUncertainty::m_gain_Impact_elec_medium[s_nEtaBins] {}
private

Definition at line 43 of file GainUncertainty.h.

43{};

◆ m_gain_Impact_unco

TH1* egGain::GainUncertainty::m_gain_Impact_unco[s_nEtaBins] {}
private

Definition at line 42 of file GainUncertainty.h.

42{};

◆ m_gain_Impact_unco_low

TH1* egGain::GainUncertainty::m_gain_Impact_unco_low[s_nEtaBins] {}
private

Definition at line 48 of file GainUncertainty.h.

48{};

◆ m_gain_Impact_unco_medium

TH1* egGain::GainUncertainty::m_gain_Impact_unco_medium[s_nEtaBins] {}
private

Definition at line 45 of file GainUncertainty.h.

45{};

◆ m_gain_impact_Zee

TH1* egGain::GainUncertainty::m_gain_impact_Zee
private

Definition at line 39 of file GainUncertainty.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_useInterpolation

bool egGain::GainUncertainty::m_useInterpolation
private

Definition at line 50 of file GainUncertainty.h.

◆ s_nEtaBins

const int egGain::GainUncertainty::s_nEtaBins = 5
staticprivate

Definition at line 37 of file GainUncertainty.h.


The documentation for this class was generated from the following files: