ATLAS Offline Software
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
LArTemperatureCorrectionTool Class Reference

Correction on the energy for temperature fluctuations authors: Ruggero Turra 2015. More...

#include <LArTemperatureCorrectionTool.h>

Inheritance diagram for LArTemperatureCorrectionTool:
Collaboration diagram for LArTemperatureCorrectionTool:

Classes

struct  AllValues
 

Public Member Functions

 LArTemperatureCorrectionTool (const std::string &filename)
 
AllValues get_corrections (int run)
 correction should be applied on MC as a multiplication: E = E * correction More...
 
double get_correction_barrel (int run)
 
double get_correction_endcapA (int run)
 
double get_correction_endcapC (int run)
 
int get_cache_size () const
 
int get_first_run () const
 
int get_last_run () const
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Public Attributes

AllValues base_temperature {}
 
AllValues sensitivity_temperature {}
 

Private Member Functions

AllValues search_temperature (int run)
 
AllValues search_correction (int run)
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

std::unique_ptr< TFile > m_file
 
TTree * m_tree
 
std::map< int, AllValuesm_cache
 
int m_first_run
 
int m_last_run
 
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...
 

Detailed Description

Correction on the energy for temperature fluctuations authors: Ruggero Turra 2015.

Compute the relative correction to the energy due to temperature fluctuations for barrel / endcap A / C, where endcap = EMEC + HEC. This is not a CP tool, and it should not be used alone. The correction K is run-dependent and should be applied as E -> E (1 + K) on the raw energy (for example on the layer energies). The correction is relative to a reference temperature, different for every partition.

If a run is in the future (with respect to the runs known by the tool) the correction is based on the temperature of the last run. Similarly if it is in the past (but it should not happen).

Temperature values are from oracle, and averaged for every run.

Definition at line 33 of file LArTemperatureCorrectionTool.h.

Constructor & Destructor Documentation

◆ LArTemperatureCorrectionTool()

LArTemperatureCorrectionTool::LArTemperatureCorrectionTool ( const std::string &  filename)

Definition at line 19 of file LArTemperatureCorrectionTool.cxx.

21  : asg::AsgMessaging("LArTemperatureCorrectionTool"),
22  m_file(TFile::Open(filename.c_str())) {
23  if (!m_file or m_file->IsZombie()) {
24  throw std::runtime_error("LArTemperatureCorrectionTool: Cannot open file");
25  }
26 
27  m_tree = dynamic_cast<TTree*>(m_file->Get("temperature"));
28  if (!m_tree) {
29  throw std::runtime_error("LArTemperatureCorrectionTool: Cannot find tree");
30  }
31 
32  Int_t t_run = 0;
33  m_tree->SetBranchAddress("run", &t_run);
34  m_tree->GetEntry(0);
35  m_first_run = t_run;
36  m_tree->GetEntry(m_tree->GetEntries() - 1);
37  m_last_run = t_run;
38 
40  get_value_parameter<double>(*m_file, "base_temperature_barrel");
42  get_value_parameter<double>(*m_file, "base_temperature_endcapA");
44  get_value_parameter<double>(*m_file, "base_temperature_endcapC");
45 
47  get_value_parameter<double>(*m_file, "sensitivity_temperature_barrel");
49  get_value_parameter<double>(*m_file, "sensitivity_temperature_endcapA");
51  get_value_parameter<double>(*m_file, "sensitivity_temperature_endcapC");
52 
53  ATH_MSG_INFO("LArTemperatureCorrectionTool initialized for runs "
54  << m_first_run << ".." << m_last_run);
55  ATH_MSG_INFO("base temperatures (barrel/endcapA/endcapC) = "
57  << "/" << base_temperature.endcapC);
58  ATH_MSG_INFO("sensitivity relE/K (barrel/endcapA/endcapC) = "
62 }

Member Function Documentation

◆ get_cache_size()

int LArTemperatureCorrectionTool::get_cache_size ( ) const
inline

Definition at line 51 of file LArTemperatureCorrectionTool.h.

51 { return m_cache.size(); }

◆ get_correction_barrel()

double LArTemperatureCorrectionTool::get_correction_barrel ( int  run)
inline

Definition at line 44 of file LArTemperatureCorrectionTool.h.

44 { return get_corrections(run).barrel; }

◆ get_correction_endcapA()

double LArTemperatureCorrectionTool::get_correction_endcapA ( int  run)
inline

Definition at line 45 of file LArTemperatureCorrectionTool.h.

45  {
46  return get_corrections(run).endcapA;
47  }

◆ get_correction_endcapC()

double LArTemperatureCorrectionTool::get_correction_endcapC ( int  run)
inline

Definition at line 48 of file LArTemperatureCorrectionTool.h.

48  {
49  return get_corrections(run).endcapC;
50  }

◆ get_corrections()

LArTemperatureCorrectionTool::AllValues LArTemperatureCorrectionTool::get_corrections ( int  run)

correction should be applied on MC as a multiplication: E = E * correction

Definition at line 119 of file LArTemperatureCorrectionTool.cxx.

119  {
120  const auto it = m_cache.find(run);
121  if (it != m_cache.end()) {
122  return it->second;
123  } else {
124  AllValues corrections{};
125  if (run < m_first_run) {
127  "run " << run << " is before the first run - using the first run");
128  corrections = search_correction(m_first_run);
129  } else if (run > m_last_run) {
130  ATH_MSG_WARNING("run " << run
131  << " is after the last run - using the last run");
132  corrections = search_correction(m_last_run);
133  } else {
134  corrections = search_correction(run);
135  }
136  m_cache[run] = corrections;
137  return corrections;
138  }
139 }

◆ get_first_run()

int LArTemperatureCorrectionTool::get_first_run ( ) const
inline

Definition at line 52 of file LArTemperatureCorrectionTool.h.

52 { return m_first_run; }

◆ get_last_run()

int LArTemperatureCorrectionTool::get_last_run ( ) const
inline

Definition at line 53 of file LArTemperatureCorrectionTool.h.

53 { return m_last_run; }

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

◆ search_correction()

LArTemperatureCorrectionTool::AllValues LArTemperatureCorrectionTool::search_correction ( int  run)
private

Definition at line 65 of file LArTemperatureCorrectionTool.cxx.

65  {
66  AllValues temp = search_temperature(run);
67  temp.barrel = 1. - (temp.barrel - base_temperature.barrel) *
69  temp.endcapA = 1. - (temp.endcapA - base_temperature.endcapA) *
71  temp.endcapC = 1. - (temp.endcapC - base_temperature.endcapC) *
73  return temp;
74 }

◆ search_temperature()

LArTemperatureCorrectionTool::AllValues LArTemperatureCorrectionTool::search_temperature ( int  run)
private

Definition at line 77 of file LArTemperatureCorrectionTool.cxx.

77  {
78  Float_t t_barrel = base_temperature.barrel;
79  Float_t t_endcapA = base_temperature.endcapA;
80  Float_t t_endcapC = base_temperature.endcapC;
81  Int_t t_run = 0;
82  m_tree->SetBranchAddress("run", &t_run);
83  m_tree->SetBranchAddress("average_temperature_barrel", &t_barrel);
84  m_tree->SetBranchAddress("average_temperature_endcapA", &t_endcapA);
85  m_tree->SetBranchAddress("average_temperature_endcapC", &t_endcapC);
86 
87  // use bisection, tree is ordered by run number
88  int low = 0;
89  int high = m_tree->GetEntries() - 1;
90  int mid = 0;
91  while (low <= high) {
92 
93  if (high - low < 50) { // prefer sequential scan
94  for (int i = low; i <= high; ++i) {
95  m_tree->GetEntry(i);
96  if (run == t_run) {
97  return AllValues{t_barrel, t_endcapA, t_endcapC};
98  }
99  }
100  break;
101  }
102 
103  mid = low + (high - low) / 2; // scared of overflow?
104  m_tree->GetEntry(mid);
105  if (run == t_run) {
106  return AllValues{t_barrel, t_endcapA, t_endcapC};
107  } else if (run < t_run) {
108  high = mid - 1;
109  } else {
110  low = mid + 1;
111  }
112  }
113 
114  ATH_MSG_WARNING("run " << run << " not found - no temperature correction");
115  return base_temperature;
116 }

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

◆ base_temperature

AllValues LArTemperatureCorrectionTool::base_temperature {}

Definition at line 54 of file LArTemperatureCorrectionTool.h.

◆ m_cache

std::map<int, AllValues> LArTemperatureCorrectionTool::m_cache
private

Definition at line 62 of file LArTemperatureCorrectionTool.h.

◆ m_file

std::unique_ptr<TFile> LArTemperatureCorrectionTool::m_file
private

Definition at line 58 of file LArTemperatureCorrectionTool.h.

◆ m_first_run

int LArTemperatureCorrectionTool::m_first_run
private

Definition at line 63 of file LArTemperatureCorrectionTool.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_last_run

int LArTemperatureCorrectionTool::m_last_run
private

Definition at line 63 of file LArTemperatureCorrectionTool.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_tree

TTree* LArTemperatureCorrectionTool::m_tree
private

Definition at line 59 of file LArTemperatureCorrectionTool.h.

◆ sensitivity_temperature

AllValues LArTemperatureCorrectionTool::sensitivity_temperature {}

Definition at line 55 of file LArTemperatureCorrectionTool.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
LArTemperatureCorrectionTool::base_temperature
AllValues base_temperature
Definition: LArTemperatureCorrectionTool.h:54
LArTemperatureCorrectionTool::AllValues::barrel
double barrel
Definition: LArTemperatureCorrectionTool.h:36
LArTemperatureCorrectionTool::m_first_run
int m_first_run
Definition: LArTemperatureCorrectionTool.h:63
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArTemperatureCorrectionTool::search_temperature
AllValues search_temperature(int run)
Definition: LArTemperatureCorrectionTool.cxx:77
LArTemperatureCorrectionTool::m_file
std::unique_ptr< TFile > m_file
Definition: LArTemperatureCorrectionTool.h:58
skel.it
it
Definition: skel.GENtoEVGEN.py:423
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
LArTemperatureCorrectionTool::m_tree
TTree * m_tree
Definition: LArTemperatureCorrectionTool.h:59
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
LArTemperatureCorrectionTool::AllValues::endcapC
double endcapC
Definition: LArTemperatureCorrectionTool.h:38
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArTemperatureCorrectionTool::search_correction
AllValues search_correction(int run)
Definition: LArTemperatureCorrectionTool.cxx:65
run
Definition: run.py:1
LArTemperatureCorrectionTool::m_last_run
int m_last_run
Definition: LArTemperatureCorrectionTool.h:63
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
LArTemperatureCorrectionTool::sensitivity_temperature
AllValues sensitivity_temperature
Definition: LArTemperatureCorrectionTool.h:55
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
LArTemperatureCorrectionTool::AllValues::endcapA
double endcapA
Definition: LArTemperatureCorrectionTool.h:37
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
LArTemperatureCorrectionTool::get_corrections
AllValues get_corrections(int run)
correction should be applied on MC as a multiplication: E = E * correction
Definition: LArTemperatureCorrectionTool.cxx:119
LArTemperatureCorrectionTool::m_cache
std::map< int, AllValues > m_cache
Definition: LArTemperatureCorrectionTool.h:62