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 if(jetPt > ptCutValue){
126
127 if (std::abs(eta) >= 3.2 ){
128 jetPhi = (phi > 0.0) ? phi + 0.1 : phi - 0.1;
129 float phi_new = (phi > 0.0) ? phi + 0.1 : phi - 0.1;
130 binNumber = getBinNumberJet(eta,phi_new,0,0);
131 fill(m_packageName,jetEta,jetPhi,jetPt);
132 fill(m_packageName,lumiNumber,binNumber);
133 jetPhi = phi;
134 binNumber = getBinNumberJet(eta,phi,0,0);
135 fill(m_packageName,jetEta,jetPhi,jetPt);
136 fill(m_packageName,lumiNumber,binNumber);
137 }
138 else {
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 }}
145 return StatusCode::SUCCESS;
146}
147
148StatusCode GfexMonitorAlgorithm::fillRhoHistograms(const std::string& handleKey, const xAOD::gFexJetRoIContainer* container) const {
149 auto gFexRhoeT = Monitored::Scalar<float>(handleKey, 0.0);
150 for(const xAOD::gFexJetRoI* gFexRhoRoI : *container){
151 gFexRhoeT=gFexRhoRoI->gFexTobEt();
152 fill(m_packageName, gFexRhoeT);
153 }
154 return StatusCode::SUCCESS;
155}
156
157StatusCode GfexMonitorAlgorithm::fillGlobalTobHistograms(const std::string& handleKey, const xAOD::gFexGlobalRoIContainer* container) const {
158 // Find the variable names corresponding to the current key handle
159 std::pair<std::string, std::string> varNames;
160 for (const auto& [key, value] : m_globTobVarMap) {
161 if (handleKey.find(key) != std::string::npos) {
162 varNames = value;
163 break;
164 }
165 }
166 auto varOne = Monitored::Scalar<float>(varNames.first,0.0);
167 auto varTwo = Monitored::Scalar<float>(varNames.second,0.0);
168
169 for (const xAOD::gFexGlobalRoI* globRoI : *container) {
170 varOne = globRoI->METquantityOne();
171 varTwo = globRoI->METquantityTwo();
172 fill(m_packageName, varOne, varTwo);
173 }
174 return StatusCode::SUCCESS;
175}
176
178 if(eta < 0 && eta > -2.5) return FPGAType::FPGAa;
179 if(eta > 0 && eta < 2.5) return FPGAType::FPGAb;
180 if(std::abs(eta) > 2.5 && std::abs(eta)) return FPGAType::FPGAc;
181 return FPGAType::None;
182}
183
184int GfexMonitorAlgorithm::getBinNumberJet (float inputEta, float inputPhi, int xbin, int ybin) const{
185 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};
186 for (int i = 0; i <= 40; i++){
187 if (inputEta >= eta[i] && inputEta < eta[i+1]){
188 xbin = i+1;
189 continue;
190 }
191 }
192 int j=1;
193 for (float phi = -3.2; phi <= 3.2;phi = phi+ 0.2){
194 if (inputPhi >= phi && inputPhi < phi+0.2){
195 ybin = j;
196 break;
197 }
198 j++;
199 }
200 int binN = 32*(xbin-1)+ybin;
201 return binN;
202}
203
204
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)