ATLAS Offline Software
Loading...
Searching...
No Matches
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
16namespace 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 =================================================
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.
76int 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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
L1DynamicPedestalProviderRoot(const std::string &, const std::string &, const IInterface *)
constructor
virtual int dynamicPedestal(int iEta, int layer, int pedestal, int iBCID, float mu) const override
retrieve the bcidCorrection value
virtual ~L1DynamicPedestalProviderRoot()
default destructor
virtual StatusCode initialize() override
standard Athena-Algorithm method
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...