ATLAS Offline Software
Loading...
Searching...
No Matches
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
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.
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.

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.

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

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
39 base_temperature.barrel =
40 get_value_parameter<double>(*m_file, "base_temperature_barrel");
41 base_temperature.endcapA =
42 get_value_parameter<double>(*m_file, "base_temperature_endcapA");
43 base_temperature.endcapC =
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) = "
56 << base_temperature.barrel << "/" << base_temperature.endcapA
57 << "/" << base_temperature.endcapC);
58 ATH_MSG_INFO("sensitivity relE/K (barrel/endcapA/endcapC) = "
59 << sensitivity_temperature.barrel << "/"
60 << sensitivity_temperature.endcapA << "/"
61 << sensitivity_temperature.endcapC);
62}
#define ATH_MSG_INFO(x)
T get_value_parameter(TFile &f, const std::string &name)

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; }
AllValues get_corrections(int run)
correction should be applied on MC as a multiplication: E = E * correction

◆ get_correction_endcapA()

double LArTemperatureCorrectionTool::get_correction_endcapA ( int run)
inline

◆ get_correction_endcapC()

double LArTemperatureCorrectionTool::get_correction_endcapC ( int run)
inline

◆ 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}
#define ATH_MSG_WARNING(x)

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

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

54{};

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

135{ nullptr };

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

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

55{};

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