ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
egGain::GainUncertainty Class Reference

#include <GainUncertainty.h>

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

Public Types

enum  GainType { GainType::MEDIUM, GainType::LOW, GainType::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. More...
 

Private Member Functions

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

Private Attributes

TH1m_alpha_specialGainRun
 
TH1m_gain_impact_Zee
 
TH1m_gain_Impact_elec [s_nEtaBins] {}
 
TH1m_gain_Impact_conv [s_nEtaBins] {}
 
TH1m_gain_Impact_unco [s_nEtaBins] {}
 
TH1m_gain_Impact_elec_medium [s_nEtaBins] {}
 
TH1m_gain_Impact_conv_medium [s_nEtaBins] {}
 
TH1m_gain_Impact_unco_medium [s_nEtaBins] {}
 
TH1m_gain_Impact_elec_low [s_nEtaBins] {}
 
TH1m_gain_Impact_conv_low [s_nEtaBins] {}
 
TH1m_gain_Impact_unco_low [s_nEtaBins] {}
 
bool m_useInterpolation
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

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 
24  if (not(m_alpha_specialGainRun =
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 }

◆ ~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 
96  delete m_gain_Impact_elec_low[i];
97  delete m_gain_Impact_conv_low[i];
98  delete m_gain_Impact_unco_low[i];
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) {
139  if (ptype == PATCore::ParticleType::Electron)
140  hImpact = m_gain_Impact_elec[ibin];
141  else if (ptype == PATCore::ParticleType::ConvertedPhoton)
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) {
154  if (ptype == PATCore::ParticleType::Electron)
155  hImpact = m_gain_Impact_elec_medium[ibin];
156  else if (ptype == PATCore::ParticleType::ConvertedPhoton)
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) {
168  if (ptype == PATCore::ParticleType::Electron)
169  hImpact = m_gain_Impact_elec_low[ibin];
170  else if (ptype == PATCore::ParticleType::ConvertedPhoton)
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 =
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 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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
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
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.

◆ m_gain_Impact_conv_low

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

Definition at line 47 of file GainUncertainty.h.

◆ m_gain_Impact_conv_medium

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

Definition at line 44 of file GainUncertainty.h.

◆ m_gain_Impact_elec

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

Definition at line 40 of file GainUncertainty.h.

◆ m_gain_Impact_elec_low

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

Definition at line 46 of file GainUncertainty.h.

◆ m_gain_Impact_elec_medium

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

Definition at line 43 of file GainUncertainty.h.

◆ m_gain_Impact_unco

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

Definition at line 42 of file GainUncertainty.h.

◆ m_gain_Impact_unco_low

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

Definition at line 48 of file GainUncertainty.h.

◆ m_gain_Impact_unco_medium

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

Definition at line 45 of file GainUncertainty.h.

◆ 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.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
PATCore::ParticleType::UnconvertedPhoton
@ UnconvertedPhoton
Definition: PATCoreEnums.h:38
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
egGain::GainUncertainty::s_nEtaBins
static const int s_nEtaBins
Definition: GainUncertainty.h:37
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
egGain::GainUncertainty::m_gain_Impact_conv
TH1 * m_gain_Impact_conv[s_nEtaBins]
Definition: GainUncertainty.h:41
egGain::GainUncertainty::m_useInterpolation
bool m_useInterpolation
Definition: GainUncertainty.h:50
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
egGain::GainUncertainty::GainType::MEDIUM
@ MEDIUM
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
egGain::GainUncertainty::m_gain_Impact_unco_medium
TH1 * m_gain_Impact_unco_medium[s_nEtaBins]
Definition: GainUncertainty.h:45
egGain::GainUncertainty::GainType::MEDIUMLOW
@ MEDIUMLOW
egGain::GainUncertainty::m_gain_impact_Zee
TH1 * m_gain_impact_Zee
Definition: GainUncertainty.h:39
PATCore::ParticleType::ConvertedPhoton
@ ConvertedPhoton
Definition: PATCoreEnums.h:39
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:92
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
egGain::GainUncertainty::m_gain_Impact_unco
TH1 * m_gain_Impact_unco[s_nEtaBins]
Definition: GainUncertainty.h:42
egGain::GainUncertainty::m_alpha_specialGainRun
TH1 * m_alpha_specialGainRun
Definition: GainUncertainty.h:38
egGain::GainUncertainty::m_gain_Impact_elec_low
TH1 * m_gain_Impact_elec_low[s_nEtaBins]
Definition: GainUncertainty.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
egGain::GainUncertainty::GainType::LOW
@ LOW
TH1::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:298
EMAmbiguityType::MEDIUM
@ MEDIUM
Definition: EMAmbiguityToolDefs.h:18
egGain::GainUncertainty::m_gain_Impact_elec
TH1 * m_gain_Impact_elec[s_nEtaBins]
Definition: GainUncertainty.h:40
egGain::GainUncertainty::m_gain_Impact_elec_medium
TH1 * m_gain_Impact_elec_medium[s_nEtaBins]
Definition: GainUncertainty.h:43
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TH1
Definition: rootspy.cxx:268
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
PATCore::ParticleType::Electron
@ Electron
Definition: PATCoreEnums.h:40
egGain::GainUncertainty::m_gain_Impact_conv_low
TH1 * m_gain_Impact_conv_low[s_nEtaBins]
Definition: GainUncertainty.h:47
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
egGain::GainUncertainty::m_gain_Impact_conv_medium
TH1 * m_gain_Impact_conv_medium[s_nEtaBins]
Definition: GainUncertainty.h:44
egGain::GainUncertainty::m_gain_Impact_unco_low
TH1 * m_gain_Impact_unco_low[s_nEtaBins]
Definition: GainUncertainty.h:48