ATLAS Offline Software
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 
5 #include "GfexMonitorAlgorithm.h"
6 #include "CaloDetDescr/CaloDetDescrElement.h"
8 #include "Identifier/Identifier.h"
12 #include <istream>
13 
14 GfexMonitorAlgorithm::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 
42 StatusCode 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){
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){
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 
101 StatusCode 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 
148 StatusCode 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 
157 StatusCode 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 
184 int 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 
GfexMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: GfexMonitorAlgorithm.cxx:42
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
xAOD::gFexJetRoI_v1::eta
float eta() const
retrieves the Eta index from the 32-bit word
Definition: gFexJetRoI_v1.cxx:167
GfexMonitorAlgorithm::FPGAType::FPGAb
@ FPGAb
GfexMonitorAlgorithm::GfexMonitorAlgorithm
GfexMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GfexMonitorAlgorithm.cxx:14
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::gFexGlobalRoI_v1
Class describing properties of a LVL1 gFEX global Trigger Object (TOB) in the xAOD format.
Definition: gFexGlobalRoI_v1.h:25
GfexMonitorAlgorithm::m_gFexJetTobKeyList
SG::ReadHandleKeyArray< xAOD::gFexJetRoIContainer > m_gFexJetTobKeyList
Definition: GfexMonitorAlgorithm.h:29
athena.value
value
Definition: athena.py:124
xAOD::gFexJetRoI_v1::gFexTobEt
int16_t gFexTobEt() const
TOB ET (decoded from TOB, stored for convenience)
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloCell_ID.h
GfexMonitorAlgorithm::m_gFexRhoTobKeyList
SG::ReadHandleKeyArray< xAOD::gFexJetRoIContainer > m_gFexRhoTobKeyList
Definition: GfexMonitorAlgorithm.h:30
GfexMonitorAlgorithm::m_gFexGlobalTobKeyList
SG::ReadHandleKeyArray< xAOD::gFexGlobalRoIContainer > m_gFexGlobalTobKeyList
Definition: GfexMonitorAlgorithm.h:31
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
xAOD::gFexJetRoI_v1::phi
float phi() const
High value of phi corresponding to phi index (using gFex convention, phi in [0, 2pi]).
Definition: gFexJetRoI_v1.cxx:300
GfexMonitorAlgorithm.h
GfexMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: GfexMonitorAlgorithm.cxx:19
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::gFexJetRoI_v1
Class describing properties of a LVL1 gFEX jet Trigger Object (TOB) in the xAOD format.
Definition: gFexJetRoI_v1.h:25
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
GfexMonitorAlgorithm::m_ptCutValuesgLJ
FloatArrayProperty m_ptCutValuesgLJ
Definition: GfexMonitorAlgorithm.h:26
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
GfexMonitorAlgorithm::fillRhoHistograms
StatusCode fillRhoHistograms(const std::string &handleKey, const xAOD::gFexJetRoIContainer *container) const
Definition: GfexMonitorAlgorithm.cxx:148
GfexMonitorAlgorithm::m_globTobVarMap
std::map< std::string, std::pair< std::string, std::string > > m_globTobVarMap
Definition: GfexMonitorAlgorithm.h:24
GfexMonitorAlgorithm::fillGlobalTobHistograms
StatusCode fillGlobalTobHistograms(const std::string &handleKey, const xAOD::gFexGlobalRoIContainer *container) const
Definition: GfexMonitorAlgorithm.cxx:157
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
GfexMonitorAlgorithm::FPGAType::None
@ None
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
HWIdentifier.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::gFexJetRoI
gFexJetRoI_v1 gFexJetRoI
Define the latest version of the gFexJetRoI class.
Definition: gFexJetRoI.h:16
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
GfexMonitorAlgorithm::FPGAType
FPGAType
Definition: GfexMonitorAlgorithm.h:23
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
GfexMonitorAlgorithm::getBinNumberJet
int getBinNumberJet(float, float, int, int) const
Definition: GfexMonitorAlgorithm.cxx:184
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
GfexMonitorAlgorithm::m_ptCutValuesgJ
FloatArrayProperty m_ptCutValuesgJ
Definition: GfexMonitorAlgorithm.h:27
GfexMonitorAlgorithm::FPGAType::FPGAa
@ FPGAa
GfexMonitorAlgorithm::m_packageName
StringProperty m_packageName
Definition: GfexMonitorAlgorithm.h:25
GfexMonitorAlgorithm::getFPGAType
FPGAType getFPGAType(const float &eta) const
Definition: GfexMonitorAlgorithm.cxx:177
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
GfexMonitorAlgorithm::fillJetHistograms
StatusCode fillJetHistograms(const std::string &handleKey, const xAOD::gFexJetRoIContainer *container, const float &ptCutValue, const auto &lbn) const
Definition: GfexMonitorAlgorithm.cxx:101
CaloGain.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
GfexMonitorAlgorithm::FPGAType::FPGAc
@ FPGAc