ATLAS Offline Software
L1DynamicPedestalProviderRoot.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
5 // L1DynamicPedestalProviderRoot.cxx
7 
9 
11 
12 #include "TFile.h"
13 #include "TProfile.h"
14 #include "TString.h"
15 
16 namespace LVL1
17 {
18 
19 //================ Constructor ================================================
21  const std::string& n,
22  const IInterface* p)
23  :
24  AthAlgTool(t, n, p)
25 {
26  declareInterface<IL1DynamicPedestalProvider>(this);
27 
28  declareProperty( "FirRefFile", m_firRefFileName );
29 }
30 
31 //================ Destructor =================================================
33 {
34 }
35 
36 //================ Initialisation =============================================
38 {
39  // read the values of the BCID correction from the root-file
40  // code copied from L1TriggerTowerTool.cxx@599780
41  std::string fullFileName = PathResolver::find_file(m_firRefFileName, "DATAPATH");
42  if(fullFileName.empty()) {
43  // path could not be resolved
44  ATH_MSG_FATAL("Could not resolve input file " << m_firRefFileName);
45  return StatusCode::FAILURE;
46  }
47 
48  TFile firRefFile(fullFileName.c_str(), "READ");
49  if (firRefFile.IsZombie()) {
50  ATH_MSG_FATAL("Could not open file " << fullFileName);
51  return StatusCode::FAILURE;
52  }
53  for (int iBin = 0; iBin < s_nElement; ++iBin) {
54  TString histoNameEm = "p1_bcidFir_em_"+(TString)std::to_string(iBin);
55  TString histoNameHad = "p1_bcidFir_had_"+(TString)std::to_string(iBin);
56  TProfile* h_em = (TProfile*)firRefFile.Get(histoNameEm);
57  TProfile* h_had = (TProfile*)firRefFile.Get(histoNameHad);
58  for (int iBcid = 0; iBcid < s_nBcid; ++iBcid) {
59  //m_firRefEm[iBin][iBcid] = floor(h_em->GetBinContent(iBcid+1)+0.5);
60  //m_firRefHad[iBin][iBcid] = floor(h_had->GetBinContent(iBcid+1)+0.5);
61  // IRH
62  m_firRefEm[s_nElement-iBin-1][iBcid] = floor(h_em->GetBinContent(iBcid+1)+0.5);
63  m_firRefHad[s_nElement-iBin-1][iBcid] = floor(h_had->GetBinContent(iBcid+1)+0.5);
64  }
65  }
66  firRefFile.Close();
67 
68  return StatusCode::SUCCESS;
69 }
70 
71 //================ Correction =================================================
72 // Return the dynamic pedestal.
73 // The correction is currently not available as a function of mu.
74 // In case no correction is available or applicable this function
75 // returns the uncorrected pedestal.
76 int L1DynamicPedestalProviderRoot::dynamicPedestal(int iEta, int layer, int pedestal, int iBCID, float /* mu */) const
77 {
78  if(iEta < 0 || iEta >= s_nElement) {
79  ATH_MSG_ERROR("Inputs out of range: iEta = " << iEta);
80  return pedestal;
81  }
82 
83  if(iBCID < 0 || iBCID >= s_nBcid) {
84  return pedestal;
85  }
86 
87  if (layer == 0) { // Em
88  if (m_firRefEm[iEta][iBCID] > 0) return m_firRefEm[iEta][iBCID];
89  } else if (layer == 1) { // Had
90  if (m_firRefHad[iEta][iBCID] > 0) return m_firRefHad[iEta][iBCID];
91  } else {
92  ATH_MSG_ERROR("Wrong layer index. Give 0 for Em, 1 for Had.");
93  }
94  return pedestal;
95 }
96 
97 } // end of namespace
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
LVL1::L1DynamicPedestalProviderRoot::m_firRefHad
int m_firRefHad[s_nElement][s_nBcid]
Definition: L1DynamicPedestalProviderRoot.h:54
LVL1::L1DynamicPedestalProviderRoot::s_nBcid
static const int s_nBcid
Definition: L1DynamicPedestalProviderRoot.h:52
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
LVL1::L1DynamicPedestalProviderRoot::m_firRefEm
int m_firRefEm[s_nElement][s_nBcid]
Definition: L1DynamicPedestalProviderRoot.h:53
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LVL1::L1DynamicPedestalProviderRoot::s_nElement
static const int s_nElement
Definition: L1DynamicPedestalProviderRoot.h:51
LVL1::L1DynamicPedestalProviderRoot::m_firRefFileName
std::string m_firRefFileName
Definition: L1DynamicPedestalProviderRoot.h:49
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
L1DynamicPedestalProviderRoot.h
-*- C++ -*-
LVL1::L1DynamicPedestalProviderRoot::L1DynamicPedestalProviderRoot
L1DynamicPedestalProviderRoot(const std::string &, const std::string &, const IInterface *)
constructor
Definition: L1DynamicPedestalProviderRoot.cxx:20
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LVL1::L1DynamicPedestalProviderRoot::~L1DynamicPedestalProviderRoot
virtual ~L1DynamicPedestalProviderRoot()
default destructor
Definition: L1DynamicPedestalProviderRoot.cxx:32
PathResolver.h
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
LVL1::L1DynamicPedestalProviderRoot::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: L1DynamicPedestalProviderRoot.cxx:37
LVL1::L1DynamicPedestalProviderRoot::dynamicPedestal
virtual int dynamicPedestal(int iEta, int layer, int pedestal, int iBCID, float mu) const override
retrieve the bcidCorrection value
Definition: L1DynamicPedestalProviderRoot.cxx:76
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:74