ATLAS Offline Software
corr_HV_EMECPS.cxx
Go to the documentation of this file.
2 #include <iostream>
3 #include <cstdlib>
4 #include <cstdio>
5 #include <cmath>
6 #include <string>
7 #include <utility>
8 
9 #include <TH2D.h>
10 #include <TFile.h>
11 #include <TSystem.h>
12 
14 
15 
17  std::string filename = PathResolverFindCalibFile("egammaLayerRecalibTool/v2/emecps_hv_corr_2015-2016_207X.root");
18 
19  m_file = TFile::Open(filename.c_str());
20  if (not m_file or m_file->IsZombie()) {
21  std::cerr << "FATAL: cannot open " << filename << std::endl;
22  }
23  else {
24  m_HV[0]=(TH2D*) (m_file->Get("hc"));
25  if (!m_HV[0]) {
26  std::cerr << " cannot read histogram hc " << std::endl;
27  }
28  m_HV[1]=(TH2D*) (m_file->Get("ha"));
29  if (!m_HV[1]) {
30  std::cerr << " cannot read histogram hc " << std::endl;
31  }
32  }
33 }
34 //===============================================================================
36 {
37  m_file->Close();
38 }
39 
40 //===============================================================================
41 float corr_HV_EMECPS::getCorr(int run, float eta,float phi) const
42 {
43  float newCorr=1.;
44  if (eta>-1.5 && eta<1.5) return newCorr;
45  if (eta<-1.85 || eta > 1.85) return newCorr;
46 
47  int iside=0;
48  if (eta>0.) iside=1;
49 
50  if (!m_HV[iside]) {
51  std::cerr << " cannot find histogram to apply correction " << std::endl;
52  } else {
53  int ibin = std::as_const(*m_HV[iside]).GetXaxis()->FindFixBin(((Double_t)(run+0.1)));
54  if (ibin<1 || ibin>7) return newCorr;
55  if (phi>3.14159) phi=phi-6.283185;
56  int jbin = std::as_const(*m_HV[iside]).GetYaxis()->FindFixBin(phi);
57  if (jbin<1 || jbin>2048) return newCorr;
58  newCorr = m_HV[iside]->GetBinContent(ibin,jbin);
59  }
60  //std::cout << " in corr_HV_EMECPS run,eta,phi,corr " << run << " " << eta << " " << phi << " " << newCorr << std::endl;
61  return newCorr;
62 
63 }
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
corr_HV_EMECPS::m_file
TFile * m_file
Definition: corr_HV_EMECPS.h:29
corr_HV_EMECPS::m_HV
TH2D * m_HV[2]
Definition: corr_HV_EMECPS.h:28
run
Definition: run.py:1
corr_HV_EMECPS::corr_HV_EMECPS
corr_HV_EMECPS()
constructor (initialization done there reading a root file for the HV maps per period
Definition: corr_HV_EMECPS.cxx:16
PathResolver.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
corr_HV_EMECPS::~corr_HV_EMECPS
~corr_HV_EMECPS()
Definition: corr_HV_EMECPS.cxx:35
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
corr_HV_EMECPS.h
corr_HV_EMECPS::getCorr
float getCorr(int run, float eta, float phi) const
get correction factor to apply to raw EMECPS energy : corrected raw EMECPS energy = correction factor...
Definition: corr_HV_EMECPS.cxx:41