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

#include <HITowerWeightTool.h>

Inheritance diagram for HITowerWeightTool:
Collaboration diagram for HITowerWeightTool:

Public Member Functions

 HITowerWeightTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~HITowerWeightTool ()=default
 
virtual StatusCode initialize () override
 
virtual float getEtaPhiResponse (float eta, float phi, int runIndex) const override
 
virtual float getEtaPhiOffset (float eta, float phi, int runIndex) const override
 
virtual float getWeight (float eta, float phi, int sampling) const override
 
virtual float getWeightEta (float eta, float phi, int sampling) const override
 
virtual float getWeightPhi (float eta, float phi, int sampling) const override
 
virtual float getWeightMag (float eta, float phi, int sampling) const override
 
virtual int getRunIndex (const EventContext &ctx) const override
 

Private Attributes

Gaudi::Property< bool > m_applycorrection {this, "ApplyCorrection", true , "If false, unit weigts are applied"}
 
Gaudi::Property< std::vector< int > > m_defaultRunNumbers {this, "DefaultRunNumbers", {226000,287931,338037,367384,440101} , "List of run numbers that will be used if the event run number is not found in the InputFile"}
 
Gaudi::Property< std::string > m_inputFile {this, "InputFile", "cluster.geo.HIJING_2018.root","File containing cluster geometric moments."}
 
Gaudi::Property< std::string > m_configDir {this, "ConfigDir", "HIJetCorrection/","Directory containing configuration file."}
 
TH3Fm_h3W
 
TH3Fm_h3Eta
 
TH3Fm_h3Phi
 
TH3Fm_h3Mag
 
TH3Fm_h3EtaPhiResponse
 
TH3Fm_h3EtaPhiOffset
 
std::map< unsigned int, int > m_runMap
 

Detailed Description

Definition at line 22 of file HITowerWeightTool.h.

Constructor & Destructor Documentation

◆ HITowerWeightTool()

HITowerWeightTool::HITowerWeightTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 8 of file HITowerWeightTool.cxx.

8  :
9  base_class(type, name, parent),
10  m_h3W(nullptr),
11  m_h3Eta(nullptr),
12  m_h3Phi(nullptr),
13  m_h3Mag(nullptr),
14  m_h3EtaPhiResponse(nullptr),
15  m_h3EtaPhiOffset(nullptr)
16 {
17 }

◆ ~HITowerWeightTool()

virtual HITowerWeightTool::~HITowerWeightTool ( )
virtualdefault

Member Function Documentation

◆ getEtaPhiOffset()

float HITowerWeightTool::getEtaPhiOffset ( float  eta,
float  phi,
int  runIndex 
) const
overridevirtual

Definition at line 48 of file HITowerWeightTool.cxx.

49 {
50  if(runIndex<=0) return 0;
51 
52  int eb=std::as_const(m_h3EtaPhiOffset)->GetXaxis()->FindFixBin(eta);
53  int pb=std::as_const(m_h3EtaPhiOffset)->GetYaxis()->FindFixBin(phi);
54  return m_h3EtaPhiOffset->GetBinContent(eb,pb,runIndex)*std::cosh(eta);
55 }

◆ getEtaPhiResponse()

float HITowerWeightTool::getEtaPhiResponse ( float  eta,
float  phi,
int  runIndex 
) const
overridevirtual

Definition at line 38 of file HITowerWeightTool.cxx.

39 {
40  if(runIndex<=0) return 1;
41 
42  int eb=std::as_const(m_h3EtaPhiResponse)->GetXaxis()->FindFixBin(eta);
43  int pb=std::as_const(m_h3EtaPhiResponse)->GetYaxis()->FindFixBin(phi);
44  return m_h3EtaPhiResponse->GetBinContent(eb,pb,runIndex);
45 }

◆ getRunIndex()

int HITowerWeightTool::getRunIndex ( const EventContext &  ctx) const
overridevirtual

Definition at line 58 of file HITowerWeightTool.cxx.

59 {
60  if (!m_applycorrection){
61  ATH_MSG_DEBUG("Using unit weights and doing no eta-phi correction.");
62  return 0;
63  }
64 
65  unsigned int run_number=ctx.eventID().run_number();
66 
67  auto itr=m_runMap.find(run_number);
68  if(itr==m_runMap.end())
69  {
70  //trying generic run numbers <=> no run dependence
72  {
73  auto itrg=m_runMap.find(run_number);
74  if(itrg!=m_runMap.end())
75  {
76  ATH_MSG_DEBUG("Using run " << run_number << " generic calibration for eta-phi correction.");
77  return itrg->second;
78  }
79  }
80 
81  if(m_defaultRunNumbers.empty())
82  {
83  ATH_MSG_WARNING("No calibration for " << run_number << " is avaliable and no generic run numbers were set. Doing no eta-phi correction.");
84  }
85  else
86  {
87  std::string str_defaultRunNumbers="";
89  {
90  str_defaultRunNumbers+=std::to_string(run_number)+", ";
91  }
92  str_defaultRunNumbers.resize(str_defaultRunNumbers.length()-2);
93 
94  ATH_MSG_WARNING("No calibration for " << run_number << " is avaliable; no generic calibration for runs "<<str_defaultRunNumbers<<". Doing no eta-phi correction.");
95  }
96 
97  return 0;
98  }
99  else
100  {
101  return itr->second;
102  }
103 }

◆ getWeight()

float HITowerWeightTool::getWeight ( float  eta,
float  phi,
int  sampling 
) const
overridevirtual

Definition at line 20 of file HITowerWeightTool.cxx.

21 {
22  return m_h3W->GetBinContent(m_h3W->FindFixBin(eta,phi,sample));
23 }

◆ getWeightEta()

float HITowerWeightTool::getWeightEta ( float  eta,
float  phi,
int  sampling 
) const
overridevirtual

Definition at line 24 of file HITowerWeightTool.cxx.

25 {
26  return m_h3Eta->GetBinContent(m_h3Eta->FindFixBin(eta,phi,sample));
27 }

◆ getWeightMag()

float HITowerWeightTool::getWeightMag ( float  eta,
float  phi,
int  sampling 
) const
overridevirtual

Definition at line 32 of file HITowerWeightTool.cxx.

33 {
34  return m_h3Mag->GetBinContent(m_h3Mag->FindFixBin(eta,phi,sample));
35 }

◆ getWeightPhi()

float HITowerWeightTool::getWeightPhi ( float  eta,
float  phi,
int  sampling 
) const
overridevirtual

Definition at line 28 of file HITowerWeightTool.cxx.

29 {
30  return m_h3Phi->GetBinContent(m_h3Phi->FindFixBin(eta,phi,sample));
31 }

◆ initialize()

StatusCode HITowerWeightTool::initialize ( )
overridevirtual

Definition at line 106 of file HITowerWeightTool.cxx.

107 {
108  std::string local_path = static_cast<std::string>(m_configDir)+m_inputFile;
109  std::string full_path=PathResolverFindCalibFile(local_path);
110  ATH_MSG_INFO("Reading input file "<< m_inputFile << " from " << full_path);
111  TFile* f=TFile::Open(full_path.c_str());
112  if(f==nullptr)
113  {
114  ATH_MSG_FATAL("Cannot read config file " << full_path );
115  return StatusCode::FAILURE;
116  }
117 
118  m_h3W=(TH3F*)f->GetObjectChecked("h3_w","TH3F");
119  if(m_h3W==nullptr)
120  {
121  ATH_MSG_FATAL("Cannot find TH3F m_h3W in config file " << full_path );
122  return StatusCode::FAILURE;
123  }
124 
125  m_h3Eta=(TH3F*)f->GetObjectChecked("h3_eta","TH3F");
126  if(m_h3Eta==nullptr)
127  {
128  ATH_MSG_FATAL("Cannot find TH3F m_h3Eta in config file " << full_path );
129  return StatusCode::FAILURE;
130  }
131 
132  m_h3Phi=(TH3F*)f->GetObjectChecked("h3_phi","TH3F");
133  if(m_h3Phi==nullptr)
134  {
135  ATH_MSG_FATAL("Cannot find TH3F m_h3Phi in config file " << full_path );
136  return StatusCode::FAILURE;
137  }
138 
139  m_h3Mag=(TH3F*)f->GetObjectChecked("h3_R","TH3F");
140  if(m_h3Mag==nullptr)
141  {
142  ATH_MSG_FATAL("Cannot find TH3F m_h3Mag in config file " << full_path );
143  return StatusCode::FAILURE;
144  }
145 
146  m_h3W->SetDirectory(0);
147  m_h3Eta->SetDirectory(0);
148  m_h3Phi->SetDirectory(0);
149  m_h3Mag->SetDirectory(0);
150 
151  m_h3EtaPhiResponse=(TH3F*)f->GetObjectChecked("h3_eta_phi_response","TH3F");
152  if(m_h3EtaPhiResponse==nullptr)
153  {
154  ATH_MSG_FATAL("Cannot find TH3F h3_eta_phi_response in config file " << full_path );
155  return StatusCode::FAILURE;
156  }
157  m_h3EtaPhiResponse->SetDirectory(0);
158  m_h3EtaPhiOffset=(TH3F*)f->GetObjectChecked("h3_eta_phi_offset","TH3F");
159  if(m_h3EtaPhiOffset==nullptr)
160  {
161  ATH_MSG_FATAL("Cannot find TH3F h3_eta_phi_offset in config file " << full_path );
162  return StatusCode::FAILURE;
163  }
164  m_h3EtaPhiOffset->SetDirectory(0);
165 
166  TH1I* h1_run_index=(TH1I*)f->GetObjectChecked("h1_run_index","TH1I");
167  if(h1_run_index==nullptr)
168  {
169  ATH_MSG_FATAL("Cannot find TH3F h1_run_index in config file " << full_path );
170  return StatusCode::FAILURE;
171  }
172  for(int xbin=1; xbin<=h1_run_index->GetNbinsX(); xbin++) {
173  m_runMap.emplace_hint(m_runMap.end(),std::make_pair(h1_run_index->GetBinContent(xbin),xbin));
174  }
175  f->Close();
176  return StatusCode::SUCCESS;
177 }

Member Data Documentation

◆ m_applycorrection

Gaudi::Property<bool> HITowerWeightTool::m_applycorrection {this, "ApplyCorrection", true , "If false, unit weigts are applied"}
private

Definition at line 38 of file HITowerWeightTool.h.

◆ m_configDir

Gaudi::Property<std::string> HITowerWeightTool::m_configDir {this, "ConfigDir", "HIJetCorrection/","Directory containing configuration file."}
private

Definition at line 42 of file HITowerWeightTool.h.

◆ m_defaultRunNumbers

Gaudi::Property<std::vector<int> > HITowerWeightTool::m_defaultRunNumbers {this, "DefaultRunNumbers", {226000,287931,338037,367384,440101} , "List of run numbers that will be used if the event run number is not found in the InputFile"}
private

Definition at line 40 of file HITowerWeightTool.h.

◆ m_h3Eta

TH3F* HITowerWeightTool::m_h3Eta
private

Definition at line 45 of file HITowerWeightTool.h.

◆ m_h3EtaPhiOffset

TH3F* HITowerWeightTool::m_h3EtaPhiOffset
private

Definition at line 49 of file HITowerWeightTool.h.

◆ m_h3EtaPhiResponse

TH3F* HITowerWeightTool::m_h3EtaPhiResponse
private

Definition at line 48 of file HITowerWeightTool.h.

◆ m_h3Mag

TH3F* HITowerWeightTool::m_h3Mag
private

Definition at line 47 of file HITowerWeightTool.h.

◆ m_h3Phi

TH3F* HITowerWeightTool::m_h3Phi
private

Definition at line 46 of file HITowerWeightTool.h.

◆ m_h3W

TH3F* HITowerWeightTool::m_h3W
private

Definition at line 44 of file HITowerWeightTool.h.

◆ m_inputFile

Gaudi::Property<std::string> HITowerWeightTool::m_inputFile {this, "InputFile", "cluster.geo.HIJING_2018.root","File containing cluster geometric moments."}
private

Definition at line 41 of file HITowerWeightTool.h.

◆ m_runMap

std::map<unsigned int, int> HITowerWeightTool::m_runMap
private

Definition at line 50 of file HITowerWeightTool.h.


The documentation for this class was generated from the following files:
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
HITowerWeightTool::m_h3Phi
TH3F * m_h3Phi
Definition: HITowerWeightTool.h:46
plotting.plot_kinematics.run_number
run_number
Definition: plot_kinematics.py:29
HITowerWeightTool::m_h3EtaPhiOffset
TH3F * m_h3EtaPhiOffset
Definition: HITowerWeightTool.h:49
HITowerWeightTool::m_inputFile
Gaudi::Property< std::string > m_inputFile
Definition: HITowerWeightTool.h:41
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
keylayer_zslicemap.pb
pb
Definition: keylayer_zslicemap.py:188
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HITowerWeightTool::m_h3EtaPhiResponse
TH3F * m_h3EtaPhiResponse
Definition: HITowerWeightTool.h:48
TH1I
Definition: rootspy.cxx:332
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
HITowerWeightTool::m_h3W
TH3F * m_h3W
Definition: HITowerWeightTool.h:44
HITowerWeightTool::m_defaultRunNumbers
Gaudi::Property< std::vector< int > > m_defaultRunNumbers
Definition: HITowerWeightTool.h:40
HITowerWeightTool::m_applycorrection
Gaudi::Property< bool > m_applycorrection
Definition: HITowerWeightTool.h:38
HITowerWeightTool::m_runMap
std::map< unsigned int, int > m_runMap
Definition: HITowerWeightTool.h:50
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TH3F::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:500
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TH3F
Definition: rootspy.cxx:495
HITowerWeightTool::m_h3Eta
TH3F * m_h3Eta
Definition: HITowerWeightTool.h:45
HITowerWeightTool::m_configDir
Gaudi::Property< std::string > m_configDir
Definition: HITowerWeightTool.h:42
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TH1I::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:337
HITowerWeightTool::m_h3Mag
TH3F * m_h3Mag
Definition: HITowerWeightTool.h:47