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  // TOBs may come from trigger bytestream - renounce from scheduler
31 
32  // Fill variable name map for global TOBs
33  m_globTobVarMap.insert({"gScalarEJwoj", {"gFexMet", "gFexSumEt"}});
34  m_globTobVarMap.insert({"gMETComponentsJwoj", {"METx", "METy"}});
35  m_globTobVarMap.insert({"gMHTComponentsJwoj", {"MHTx", "MHTy"}});
36  m_globTobVarMap.insert({"gMSTComponentsJwoj", {"MSTx", "MSTy"}});
37  m_globTobVarMap.insert({"gMETComponentsNoiseCut", {"METx_NoiseCut", "METy_NoiseCut"}});
38  m_globTobVarMap.insert({"gMETComponentsRms", {"METx_Rms", "METy_Rms"}});
39  m_globTobVarMap.insert({"gScalarENoiseCut", {"gFexMet_NoiseCut", "gFexSumEt_NoiseCut"}});
40  m_globTobVarMap.insert({"gScalarERms", {"gFexMet_Rms", "gFexSumEt_Rms"}});
41 
43 }
44 
45 StatusCode GfexMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
46  ATH_MSG_DEBUG("GfexMonitorAlgorithm::fillHistograms");
47 
48  // Small-R and large-R jets container loop
49  for (const auto& key : m_gFexJetTobKeyList){
51  // Check that this container is present
52  if ( !jetContainer.isValid() ) {
53  ATH_MSG_WARNING("No gFex jet container found in storegate: "<< key.key());
54  }
55  else {
56  const xAOD::gFexJetRoIContainer* jetContainerPtr = jetContainer.cptr();
57  // Loop over all required pt cut values
58  for(auto ptCut : m_ptCutValues){
59  ATH_CHECK(fillJetHistograms(key.key(), jetContainerPtr, ptCut));
60  }
61  }
62  } // end jet loop
63 
64  // Rho container loop
65  for (const auto& key : m_gFexRhoTobKeyList){
67  // Check that this container is present
68  if ( !rhoContainer.isValid() ) {
69  ATH_MSG_WARNING("No gFex rho container found in storegate: "<< key.key());
70  }
71  else {
72  const xAOD::gFexJetRoIContainer* rhoContainerPtr = rhoContainer.cptr();
73  ATH_CHECK(fillRhoHistograms(key.key(), rhoContainerPtr));
74  }
75  } // end rho container loop
76 
77  // Global TOB container loop
78  for (const auto& key : m_gFexGlobalTobKeyList){
79  SG::ReadHandle<xAOD::gFexGlobalRoIContainer> globalTobContainer (key, ctx);
80  // Check that this container is present
81  if ( !globalTobContainer.isValid() ) {
82  ATH_MSG_WARNING("No gFex global TOB container found in storegate: "<< key.key());
83  }
84  else {
85  const xAOD::gFexGlobalRoIContainer* globalTobContainerPtr = globalTobContainer.cptr();
86  ATH_CHECK(fillGlobalTobHistograms(key.key(), globalTobContainerPtr));
87  }
88  } // end global TOBs container loop
89  return StatusCode::SUCCESS;
90 }
91 
92 StatusCode GfexMonitorAlgorithm::fillJetHistograms(const std::string& handleKey, const xAOD::gFexJetRoIContainer* container, const float& ptCutValue) const {
93 
94  // Define name extension based on pT cut value
95  std::string histNameExt = ptCutValue != -1. ? (std::string("_CutPt") + std::to_string(int(ptCutValue))) : "";
96 
97  auto gtype = Monitored::Scalar<int>(handleKey + "gFexType", 0.0);
98  auto jetEta = Monitored::Scalar<float>(handleKey + "Eta" + histNameExt, 0.0);
99  auto jetPhi = Monitored::Scalar<float>(handleKey + "Phi" + histNameExt, 0.0);
100  auto jetPt = Monitored::Scalar<float>(handleKey + "Pt" + histNameExt, 0.0);
101 
102  auto jetEtaFPGAa = Monitored::Scalar<float>(handleKey + "EtaFPGAa" + histNameExt, 0.0);
103  auto jetEtaFPGAb = Monitored::Scalar<float>(handleKey + "EtaFPGAb" + histNameExt, 0.0);
104  auto jetEtaFPGAc = Monitored::Scalar<float>(handleKey + "EtaFPGAc" + histNameExt, 0.0);
105 
106  auto jetPhiFPGAa = Monitored::Scalar<float>(handleKey + "PhiFPGAa" + histNameExt, 0.0);
107  auto jetPhiFPGAb = Monitored::Scalar<float>(handleKey + "PhiFPGAb" + histNameExt, 0.0);
108  auto jetPhiFPGAc = Monitored::Scalar<float>(handleKey + "PhiFPGAc" + histNameExt, 0.0);
109 
110  auto jetPtFPGAa = Monitored::Scalar<float>(handleKey + "PtFPGAa" + histNameExt, 0.0);
111  auto jetPtFPGAb = Monitored::Scalar<float>(handleKey + "PtFPGAb" + histNameExt, 0.0);
112  auto jetPtFPGAc = Monitored::Scalar<float>(handleKey + "PtFPGAc" + histNameExt, 0.0);
113 
114  for(const xAOD::gFexJetRoI* gFexJetRoI : *container){
115  jetEta = gFexJetRoI->eta();
116  jetPhi = gFexJetRoI->phi();
117  jetPt = gFexJetRoI->gFexTobEt();
118  gtype = gFexJetRoI->gFexType();
119 
120  if(jetPt > ptCutValue){
121  fill(m_packageName, jetEta, jetPhi, jetPt, gtype);
122  // Check for different pFPGAs
123  FPGAType pFPGA(getFPGAType(jetEta));
124  if (pFPGA == FPGAType::FPGAa){
125  jetEtaFPGAa = gFexJetRoI->eta();
126  jetPhiFPGAa = gFexJetRoI->phi();
127  jetPtFPGAa = gFexJetRoI->gFexTobEt();
128  fill(m_packageName, jetEtaFPGAa, jetPhiFPGAa, jetPtFPGAa);
129  }
130  if (pFPGA == FPGAType::FPGAb){
131  jetEtaFPGAb = gFexJetRoI->eta();
132  jetPhiFPGAb = gFexJetRoI->phi();
133  jetPtFPGAb = gFexJetRoI->gFexTobEt();
134  fill(m_packageName, jetEtaFPGAb, jetPhiFPGAb, jetPtFPGAb);
135  }
136  if (pFPGA == FPGAType::FPGAc){
137  jetEtaFPGAc = gFexJetRoI->eta();
138  jetPhiFPGAc = gFexJetRoI->phi();
139  jetPtFPGAc = gFexJetRoI->gFexTobEt();
140  fill(m_packageName, jetEtaFPGAc, jetPhiFPGAc, jetPtFPGAc);
141  }
142  }
143  }
144  return StatusCode::SUCCESS;
145 }
146 
147 StatusCode GfexMonitorAlgorithm::fillRhoHistograms(const std::string& handleKey, const xAOD::gFexJetRoIContainer* container) const {
148  auto gFexRhoeT = Monitored::Scalar<float>(handleKey, 0.0);
149  for(const xAOD::gFexJetRoI* gFexRhoRoI : *container){
150  gFexRhoeT=gFexRhoRoI->gFexTobEt();
151  fill(m_packageName, gFexRhoeT);
152  }
153  return StatusCode::SUCCESS;
154 }
155 
156 StatusCode GfexMonitorAlgorithm::fillGlobalTobHistograms(const std::string& handleKey, const xAOD::gFexGlobalRoIContainer* container) const {
157  // Find the variable names corresponding to the current key handle
158  std::pair<std::string, std::string> varNames;
159  for (const auto& [key, value] : m_globTobVarMap) {
160  if (handleKey.find(key) != std::string::npos) {
161  varNames = value;
162  break;
163  }
164  }
165  auto varOne = Monitored::Scalar<float>(varNames.first,0.0);
166  auto varTwo = Monitored::Scalar<float>(varNames.second,0.0);
167 
168  for (const xAOD::gFexGlobalRoI* globRoI : *container) {
169  varOne = globRoI->METquantityOne();
170  varTwo = globRoI->METquantityTwo();
171  fill(m_packageName, varOne, varTwo);
172  }
173  return StatusCode::SUCCESS;
174 }
175 
177  if(eta < 0 && eta > -2.5) return FPGAType::FPGAa;
178  if(eta > 0 && eta < 2.5) return FPGAType::FPGAb;
179  if(std::abs(eta) > 2.5 && std::abs(eta)) return FPGAType::FPGAc;
180  return FPGAType::None;
181 }
GfexMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: GfexMonitorAlgorithm.cxx:45
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:163
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:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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:28
athena.value
value
Definition: athena.py:122
xAOD::gFexJetRoI_v1::gFexTobEt
int16_t gFexTobEt() const
TOB ET (decoded from TOB, stored for convenience)
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray
void renounceArray(SG::VarHandleKeyArray &handlesArray)
remove all handles from I/O resolution
Definition: AthCommonDataStore.h:364
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloCell_ID.h
GfexMonitorAlgorithm::m_gFexRhoTobKeyList
SG::ReadHandleKeyArray< xAOD::gFexJetRoIContainer > m_gFexRhoTobKeyList
Definition: GfexMonitorAlgorithm.h:29
GfexMonitorAlgorithm::m_gFexGlobalTobKeyList
SG::ReadHandleKeyArray< xAOD::gFexGlobalRoIContainer > m_gFexGlobalTobKeyList
Definition: GfexMonitorAlgorithm.h:30
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:220
GfexMonitorAlgorithm.h
GfexMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: GfexMonitorAlgorithm.cxx:19
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
xAOD::gFexJetRoI_v1::gFexType
int gFexType() const
retrieves the Saturated info from the 32-bit word
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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:147
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:156
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
GfexMonitorAlgorithm::FPGAType::None
@ None
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
JetAnalysisAlgorithmsTest_EMTopo_eljob.jetContainer
string jetContainer
Definition: JetAnalysisAlgorithmsTest_EMTopo_eljob.py:36
GfexMonitorAlgorithm::m_ptCutValues
FloatArrayProperty m_ptCutValues
Definition: GfexMonitorAlgorithm.h:26
HWIdentifier.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
GfexMonitorAlgorithm::fillJetHistograms
StatusCode fillJetHistograms(const std::string &handleKey, const xAOD::gFexJetRoIContainer *container, const float &ptCutValue) const
Definition: GfexMonitorAlgorithm.cxx:92
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
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:176
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
CaloGain.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
GfexMonitorAlgorithm::FPGAType::FPGAc
@ FPGAc