ATLAS Offline Software
Loading...
Searching...
No Matches
GfexMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4
6#include "CaloDetDescr/CaloDetDescrElement.h"
8#include "Identifier/Identifier.h"
12#include <istream>
13
14GfexMonitorAlgorithm::GfexMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
15 : AthMonitorAlgorithm(name,pSvcLocator)
16{
17}
18
20 ATH_MSG_DEBUG("GfexMonitorAlgorithm::initialize");
21 ATH_MSG_DEBUG("Package Name "<< m_packageName);
22
23 ATH_CHECK( m_gFexJetTobKeyList.initialize() ) ;
24 ATH_CHECK( m_gFexRhoTobKeyList.initialize() ) ;
25 ATH_CHECK( m_gFexGlobalTobKeyList.initialize() ) ;
26
27
28 // Fill variable name map for global TOBs
29 m_globTobVarMap.insert({"gScalarEJwoj", {"gFexMet", "gFexSumEt"}});
30 m_globTobVarMap.insert({"gMETComponentsJwoj", {"METx", "METy"}});
31 m_globTobVarMap.insert({"gMHTComponentsJwoj", {"MHTx", "MHTy"}});
32 m_globTobVarMap.insert({"gMSTComponentsJwoj", {"MSTx", "MSTy"}});
33 // NC and Rho commented out for future
34 // m_globTobVarMap.insert({"gMETComponentsNoiseCut", {"METx_NoiseCut", "METy_NoiseCut"}});
35 // m_globTobVarMap.insert({"gMETComponentsRms", {"METx_Rms", "METy_Rms"}});
36 // m_globTobVarMap.insert({"gScalarENoiseCut", {"gFexMet_NoiseCut", "gFexSumEt_NoiseCut"}});
37 // m_globTobVarMap.insert({"gScalarERms", {"gFexMet_Rms", "gFexSumEt_Rms"}});
38
40}
41
42StatusCode GfexMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
43 ATH_MSG_DEBUG("GfexMonitorAlgorithm::fillHistograms");
44
45 // Small-R and large-R jets container loop
46 for (const auto& key : m_gFexJetTobKeyList){
47 SG::ReadHandle<xAOD::gFexJetRoIContainer> jetContainer (key, ctx);
48 auto lumi = GetEventInfo(ctx)->lumiBlock();
49
50 // Check that this container is present
51 if ( !jetContainer.isValid() ) {
52 ATH_MSG_WARNING("No gFex jet container found in storegate: "<< key.key());
53 }
54
55 else {
56 if (key.key() == "L1_gFexLRJetRoI"){
57 const xAOD::gFexJetRoIContainer* jetContainerPtr = jetContainer.cptr();
58 // Loop over all required pt cut values - LRJets
59 for(auto ptCut : m_ptCutValuesgLJ){
60 ATH_CHECK(fillJetHistograms(key.key(), jetContainerPtr, ptCut, lumi));
61 }
62 }
63 if (key.key() == "L1_gFexSRJetRoI"){
64 const xAOD::gFexJetRoIContainer* jetContainerPtr = jetContainer.cptr();
65 // Loop over all required pt cut values - SRJets
66 for(auto ptCut : m_ptCutValuesgJ){
67 ATH_CHECK(fillJetHistograms(key.key(), jetContainerPtr, ptCut, lumi));
68 }
69 }
70 }
71 } // end jet loop
72
73 // Rho container loop
74 for (const auto& key : m_gFexRhoTobKeyList){
75 SG::ReadHandle<xAOD::gFexJetRoIContainer> rhoContainer (key, ctx);
76 // Check that this container is present
77 if ( !rhoContainer.isValid() ) {
78 ATH_MSG_WARNING("No gFex rho container found in storegate: "<< key.key());
79 }
80 else {
81 const xAOD::gFexJetRoIContainer* rhoContainerPtr = rhoContainer.cptr();
82 ATH_CHECK(fillRhoHistograms(key.key(), rhoContainerPtr));
83 }
84 } // end rho container loop
85
86 // Global TOB container loop
87 for (const auto& key : m_gFexGlobalTobKeyList){
88 SG::ReadHandle<xAOD::gFexGlobalRoIContainer> globalTobContainer (key, ctx);
89 // Check that this container is present
90 if ( !globalTobContainer.isValid() ) {
91 ATH_MSG_WARNING("No gFex global TOB container found in storegate: "<< key.key());
92 }
93 else {
94 const xAOD::gFexGlobalRoIContainer* globalTobContainerPtr = globalTobContainer.cptr();
95 ATH_CHECK(fillGlobalTobHistograms(key.key(), globalTobContainerPtr));
96 }
97 } // end global TOBs container loop
98 return StatusCode::SUCCESS;
99}
100
101StatusCode GfexMonitorAlgorithm::fillJetHistograms(const std::string& handleKey, const xAOD::gFexJetRoIContainer* container, const float& ptCutValue ,const auto& lbn) const {
102
103 // Define name extension based on pT cut value
104 std::string histNameExt = ptCutValue != -1. ? (std::string("_CutPt") + std::to_string(int(ptCutValue))) : "";
105 auto gtype = Monitored::Scalar<int>(handleKey + "gFexType", 0.0);
106 auto jetEta = Monitored::Scalar<float>(handleKey + "Eta" + histNameExt, 0.0);
107 auto jetPhi = Monitored::Scalar<float>(handleKey + "Phi" + histNameExt, 0.0);
108 auto jetPt = Monitored::Scalar<float>(handleKey + "Pt" + histNameExt, 0.0);
109 auto binNumber = Monitored::Scalar<int>(handleKey+"binNumber"+histNameExt,0);
110 auto lumiNumber = Monitored::Scalar<int>(handleKey+"LBN"+histNameExt, lbn );
111
112
113
114
115 for(const xAOD::gFexJetRoI* gFexJetRoI : *container){
116
117 float eta = gFexJetRoI->eta();
118 float phi = gFexJetRoI->phi();
119 jetPt = gFexJetRoI->gFexTobEt();
120
121 if (eta < -3.17 && eta > -3.25){ eta = -3.225;}
122 if (eta < 3.3 && eta > 3.17){ eta = 3.275;}
123 jetEta = eta;
124
125 /*
126 FPGAc -> In the FPGAc region (abs(eta) > 3.2), the size of the gTowers in phi is twice the size of the gTowers in FPGAa and FPGAb.
127 Using one fill() method for all eta bins results in a checker pattern in the forward region. To ensure that the histogram
128 reflects the difference in the size of gTowers in the forward region, the fill() method is used twice for abs(eta) > 3.2
129 */
130
131 if(jetPt > ptCutValue){
132
133 if (std::abs(eta) >= 3.2 ){
134 jetPhi = (phi > 0.0) ? phi + 0.1 : phi - 0.1;
135 float phi_new = (phi > 0.0) ? phi + 0.1 : phi - 0.1;
136 binNumber = getBinNumberJet(eta,phi_new,0,0);
137 fill(m_packageName,jetEta,jetPhi,jetPt);
138 fill(m_packageName,lumiNumber,binNumber);
139 jetPhi = phi;
140 binNumber = getBinNumberJet(eta,phi,0,0);
141 fill(m_packageName,jetEta,jetPhi,jetPt);
142 fill(m_packageName,lumiNumber,binNumber);
143 }
144 else {
145 jetPhi = phi;
146 binNumber = getBinNumberJet(eta,phi,0,0);
147 fill(m_packageName,jetEta,jetPhi,jetPt);
148 fill(m_packageName,lumiNumber,binNumber);
149 }
150 }}
151 return StatusCode::SUCCESS;
152}
153
154StatusCode GfexMonitorAlgorithm::fillRhoHistograms(const std::string& handleKey, const xAOD::gFexJetRoIContainer* container) const {
155 auto gFexRhoeT = Monitored::Scalar<float>(handleKey, 0.0);
156 for(const xAOD::gFexJetRoI* gFexRhoRoI : *container){
157 gFexRhoeT=gFexRhoRoI->gFexTobEt();
158 fill(m_packageName, gFexRhoeT);
159 }
160 return StatusCode::SUCCESS;
161}
162
163StatusCode GfexMonitorAlgorithm::fillGlobalTobHistograms(const std::string& handleKey, const xAOD::gFexGlobalRoIContainer* container) const {
164 // Find the variable names corresponding to the current key handle
165 std::pair<std::string, std::string> varNames;
166 for (const auto& [key, value] : m_globTobVarMap) {
167 if (handleKey.find(key) != std::string::npos) {
168 varNames = value;
169 break;
170 }
171 }
172 auto varOne = Monitored::Scalar<float>(varNames.first,0.0);
173 auto varTwo = Monitored::Scalar<float>(varNames.second,0.0);
174
175 for (const xAOD::gFexGlobalRoI* globRoI : *container) {
176 varOne = globRoI->METquantityOne();
177 varTwo = globRoI->METquantityTwo();
178 fill(m_packageName, varOne, varTwo);
179 }
180 return StatusCode::SUCCESS;
181}
182
184 if(eta < 0 && eta > -2.5) return FPGAType::FPGAa;
185 if(eta > 0 && eta < 2.5) return FPGAType::FPGAb;
186 if(std::abs(eta) > 2.5 && std::abs(eta)) return FPGAType::FPGAc;
187 return FPGAType::None;
188}
189
190int GfexMonitorAlgorithm::getBinNumberJet (float inputEta, float inputPhi, int xbin, int ybin) const{
191 const std::vector<float> eta = {-4.9, -4.1,-3.5,-3.25,-3.2,-3.1,-2.9,-2.7,-2.5,-2.2,-2.0,-1.8,-1.6,-1.4,-1.2,-1.0,-0.8,-0.6,-0.4,-0.2,0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.5,2.7,2.9,3.1,3.25,3.3,3.5,4.1,4.9};
192 for (int i = 0; i <= 40; i++){
193 if (inputEta >= eta[i] && inputEta < eta[i+1]){
194 xbin = i+1;
195 continue;
196 }
197 }
198 int j=1;
199 for (float phi = -3.2; phi <= 3.2;phi = phi+ 0.2){
200 if (inputPhi >= phi && inputPhi < phi+0.2){
201 ybin = j;
202 break;
203 }
204 j++;
205 }
206 int binN = 32*(xbin-1)+ybin;
207 return binN;
208}
209
210
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKeyArray< xAOD::gFexJetRoIContainer > m_gFexRhoTobKeyList
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
std::map< std::string, std::pair< std::string, std::string > > m_globTobVarMap
FloatArrayProperty m_ptCutValuesgLJ
FloatArrayProperty m_ptCutValuesgJ
int getBinNumberJet(float, float, int, int) const
FPGAType getFPGAType(const float &eta) const
SG::ReadHandleKeyArray< xAOD::gFexGlobalRoIContainer > m_gFexGlobalTobKeyList
StatusCode fillRhoHistograms(const std::string &handleKey, const xAOD::gFexJetRoIContainer *container) const
StatusCode fillGlobalTobHistograms(const std::string &handleKey, const xAOD::gFexGlobalRoIContainer *container) const
SG::ReadHandleKeyArray< xAOD::gFexJetRoIContainer > m_gFexJetTobKeyList
GfexMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode fillJetHistograms(const std::string &handleKey, const xAOD::gFexJetRoIContainer *container, const float &ptCutValue, const auto &lbn) const
virtual StatusCode initialize() override
initialize
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
float phi() const
High value of phi corresponding to phi index (using gFex convention, phi in [0, 2pi]).
int16_t gFexTobEt() const
TOB ET (decoded from TOB, stored for convenience)
float eta() const
retrieves the Eta index from the 32-bit word
gFexGlobalRoIContainer_v1 gFexGlobalRoIContainer
gFexJetRoI_v1 gFexJetRoI
Define the latest version of the gFexJetRoI class.
Definition gFexJetRoI.h:16
gFexGlobalRoI_v1 gFexGlobalRoI
Define the latest version of the eFexEMRoI class.
gFexJetRoIContainer_v1 gFexJetRoIContainer
void fill(H5::Group &out_file, size_t iterations)