ATLAS Offline Software
EfexMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "EfexMonitorAlgorithm.h"
6 
7 
8 EfexMonitorAlgorithm::EfexMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
9  : AthMonitorAlgorithm(name,pSvcLocator)
10 {
11 }
12 
14 
15  ATH_MSG_DEBUG("EfexMonitorAlgorith::initialize");
16  ATH_MSG_DEBUG("Package Name "<< m_packageName);
17  ATH_MSG_DEBUG("Low Pt Cut "<< m_lowPtCut);
18  ATH_MSG_DEBUG("High Pt Cut "<< m_hiPtCut);
19 
20  ATH_MSG_INFO("m_eFexEMTobKeyList "<< m_eFexEMTobKeyList);
21  ATH_MSG_INFO("m_eFexTauTobKeyList "<< m_eFexTauTobKeyList);
22 
23  // we initialise all the containers that we need
24  ATH_CHECK( m_eFexEMTobKeyList.initialize() );
25  ATH_CHECK( m_eFexTauTobKeyList.initialize() );
26 
27  // TOBs may come from trigger bytestream - renounce from scheduler
30 
32 
33  return StatusCode::SUCCESS;
34 }
35 
36 StatusCode EfexMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
37 
38  ATH_MSG_DEBUG("EfexMonitorAlgorithm::fillHistograms");
39 
40  auto locIdx = Monitored::Scalar<std::string>("locIdx","");
41  auto tobEt = Monitored::Scalar<float>("tobEt",0);
42  auto lbn = Monitored::Scalar<int>("LBN",GetEventInfo(ctx)->lumiBlock());
43 
44  // Loop over EM read handle keys in key array
46  SG::ReadHandle<xAOD::eFexEMRoIContainer> eFexContainer (key, ctx);
47  // Check that this container is present
48  if ( !eFexContainer.isValid() ) {
49  ATH_MSG_WARNING("No eFex EM container found in storegate "<< key.key());
50  }
51  else {
52  auto nEmTOBs_total = Monitored::Scalar<int>(key.key() +"_nTOBs_nocut",0.0);
53  nEmTOBs_total = eFexContainer->size();
54  fill(m_packageName, nEmTOBs_total,lbn);
55  // Fill EM histograms for the low/high cuts
56  const xAOD::eFexEMRoIContainer* emDataContPtr = eFexContainer.cptr();
57  ATH_CHECK(fillEMHistograms(m_packageName+'_'+key.key()+"_LowPtCut", emDataContPtr, m_lowPtCut));
58  ATH_CHECK(fillEMHistograms(m_packageName+'_'+key.key()+"_HiPtCut", emDataContPtr, m_hiPtCut));
59  if(key.key().find("Sim") == std::string::npos) {
60  for (const xAOD::eFexEMRoI *roi: *emDataContPtr) {
61  locIdx = std::to_string(roi->iPhi() / 8) + ":" + std::to_string(roi->iEta());
62  tobEt = roi->et();
63  fill(m_packageName + "_" + key.key(), tobEt, lbn, locIdx);
64  }
65  }
66  }
67  } // Finished EM loop
68 
69  // Loop over Tau read handle keys in key array
71  SG::ReadHandle<xAOD::eFexTauRoIContainer> eFexTauContainer(key, ctx);
72  // Check that this container is present
73  if ( !eFexTauContainer.isValid() ) {
74  ATH_MSG_WARNING("No eFex Tau container found in storegate "<< key.key());
75  }
76  else {
77  auto nTauTOBs_total = Monitored::Scalar<int>(key.key()+"_nTOBs_nocut",0.0);
78  nTauTOBs_total = eFexTauContainer->size();
79  fill(m_packageName, nTauTOBs_total,lbn);
80  // Fill Tau histograms for the low/high cuts
81  const xAOD::eFexTauRoIContainer* tauDataContPtr = eFexTauContainer.cptr();
82  ATH_CHECK(fillTauHistograms(m_packageName+'_'+key.key()+"_LowPtCut", tauDataContPtr, m_lowPtCut));
83  ATH_CHECK(fillTauHistograms(m_packageName+'_'+key.key()+"_HiPtCut", tauDataContPtr, m_hiPtCut));
84  if(key.key().find("Sim") == std::string::npos) {
85  for (const xAOD::eFexTauRoI *roi: *tauDataContPtr) {
86  locIdx = std::to_string(roi->iPhi() / 8) + ":" + std::to_string(roi->iEta());
87  tobEt = roi->et();
88  fill(m_packageName + "_" + key.key(), tobEt, lbn, locIdx);
89  }
90  }
91  }
92  } // Finished Tau loop
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 StatusCode EfexMonitorAlgorithm::fillEMHistograms(const std::string& groupName, const xAOD::eFexEMRoIContainer *emcont, const float &cut_et) const {
98 
99  ATH_MSG_DEBUG("EfexMonitorAlgorithm::fillEMHistograms");
100 
101  // monitored variables for histograms
102  auto nEmTOBs_passcut = Monitored::Scalar<int>("nEMTOBs",0.0); // Number of ToBs passing the cut
103  auto TOBeT = Monitored::Scalar<float>("TOBTransverseEnergy",0.0);
104  auto TOBeta = Monitored::Scalar<float>("TOBEta",0.0);
105  auto TOBphi = Monitored::Scalar<float>("TOBPhi",0.0);
106  auto TOBshelfNumber = Monitored::Scalar<float>("TOBshelfNumber",0.0);
107  auto TOBeFEXNumberSh0 = Monitored::Scalar<float>("TOBeFEXNumberSh0",0.0);
108  auto TOBeFEXNumberSh1 = Monitored::Scalar<float>("TOBeFEXNumberSh1",0.0);
109  auto TOBfpga = Monitored::Scalar<float>("TOBfpga",0.0);
110  auto TOBReta = Monitored::Scalar<float>("TOBReta",0.0);
111  auto TOBRhad = Monitored::Scalar<float>("TOBRhad",0.0);
112  auto TOBWstot = Monitored::Scalar<float>("TOBWstot",0.0);
113  auto TOBReta_threshold = Monitored::Scalar<float>("TOBReta_threshold",0.0);
114  auto TOBRhad_threshold = Monitored::Scalar<float>("TOBRhad_threshold",0.0);
115  auto TOBWstot_threshold = Monitored::Scalar<float>("TOBWstot_threshold",0.0);
116 
117  for(const xAOD::eFexEMRoI* efexEmRoI : *emcont){
118  if (efexEmRoI->et() >= cut_et){
119  nEmTOBs_passcut += 1;
120  TOBeT = efexEmRoI->et();
121  fill(groupName, TOBeT);
122  TOBeta = efexEmRoI->eta();
123  TOBphi = efexEmRoI->phi();
124  fill(groupName, TOBeta, TOBphi);
125  TOBshelfNumber=efexEmRoI->shelfNumber();
126  fill(groupName, TOBshelfNumber);
127  // Only fill the relevant shelf variable
128  if (TOBshelfNumber == 0) {
129  TOBeFEXNumberSh0 = int(efexEmRoI->eFexNumber());
130  fill(groupName, TOBeFEXNumberSh0);
131  } else {
132  TOBeFEXNumberSh1 = int(efexEmRoI->eFexNumber());
133  fill(groupName, TOBeFEXNumberSh1);
134  }
135  TOBfpga = efexEmRoI->fpga();
136  fill(groupName, TOBfpga);
137  TOBReta = efexEmRoI->Reta();
138  fill(groupName, TOBReta);
139  TOBRhad = efexEmRoI->Rhad();
140  fill(groupName, TOBRhad);
141  TOBWstot = efexEmRoI->Wstot();
142  fill(groupName, TOBWstot);
143  TOBReta_threshold = efexEmRoI->RetaThresholds();
144  fill(groupName, TOBReta_threshold);
145  TOBRhad_threshold = efexEmRoI->RhadThresholds();
146  fill(groupName, TOBRhad_threshold);
147  TOBWstot_threshold = efexEmRoI->WstotThresholds();
148  fill(groupName, TOBWstot_threshold);
149  }
150  }
151  fill(groupName, nEmTOBs_passcut);
152 
153  return StatusCode::SUCCESS;
154 }
155 
156 StatusCode EfexMonitorAlgorithm::fillTauHistograms(const std::string& groupName, const xAOD::eFexTauRoIContainer *taucont, const float &cut_et) const {
157 
158  ATH_MSG_DEBUG("EfexMonitorAlgorithm::fillTauHistograms");
159 
160  // monitored variables for histograms
161  auto nTauTOBs_passcut = Monitored::Scalar<int>("nTauTOBs",0.0); // Number of ToBs passing the cut
162  auto tauTOBeT = Monitored::Scalar<float>("tauTOBTransverseEnergy",0.0);
163  auto tauTOBeta = Monitored::Scalar<float>("tauTOBEta",0.0);
164  auto tauTOBphi = Monitored::Scalar<float>("tauTOBPhi",0.0);
165  auto tauTOBshelfNumber = Monitored::Scalar<float>("tauTOBshelfNumber",0.0);
166  auto tauTOBeFEXNumberSh0 = Monitored::Scalar<float>("tauTOBeFEXNumberSh0",0.0);
167  auto tauTOBeFEXNumberSh1 = Monitored::Scalar<float>("tauTOBeFEXNumberSh1",0.0);
168  auto tauTOBfpga = Monitored::Scalar<float>("tauTOBfpga",0.0);
169  auto tauTOBRcore = Monitored::Scalar<float>("tauTOBRcore",0.0);
170  auto tauTOBRhad = Monitored::Scalar<float>("tauTOBRhad",0.0);
171  auto tauTOBRcore_threshold = Monitored::Scalar<float>("tauTOBRcore_threshold",0.0);
172  auto tauTOBRhad_threshold = Monitored::Scalar<float>("tauTOBRhad_threshold",0.0);
173  auto tauTOBthree_threshold = Monitored::Scalar<float>("tauTOBthree_threshold",0.0);
174 
175  for(const xAOD::eFexTauRoI* efexTauRoI : *taucont){
176  if (efexTauRoI->et() >= cut_et){
177  nTauTOBs_passcut += 1;
178  tauTOBeT = efexTauRoI->et();
179  fill(groupName, tauTOBeT);
180  tauTOBeta = efexTauRoI->eta();
181  tauTOBphi = efexTauRoI->phi();
182  fill(groupName, tauTOBeta, tauTOBphi);
183  tauTOBshelfNumber=efexTauRoI->shelfNumber();
184  fill(groupName, tauTOBshelfNumber);
185  // Only fill the relevant shelf variable
186  if (tauTOBshelfNumber == 0) {
187  tauTOBeFEXNumberSh0 = int(efexTauRoI->eFexNumber());
188  fill(groupName, tauTOBeFEXNumberSh0);
189  } else {
190  tauTOBeFEXNumberSh1 = int(efexTauRoI->eFexNumber());
191  fill(groupName, tauTOBeFEXNumberSh1);
192  }
193  tauTOBfpga = efexTauRoI->fpga();
194  fill(groupName, tauTOBfpga);
195  tauTOBRcore = efexTauRoI->rCore();
196  fill(groupName, tauTOBRcore);
197  tauTOBRhad = efexTauRoI->rHad();
198  fill(groupName, tauTOBRhad);
199  tauTOBRcore_threshold=efexTauRoI->rCoreThresholds();
200  fill(groupName, tauTOBRcore_threshold);
201  tauTOBRhad_threshold=efexTauRoI->rHadThresholds();
202  fill(groupName, tauTOBRhad_threshold);
203  tauTOBthree_threshold=efexTauRoI->tauThreeThresholds();
204  fill(groupName, tauTOBthree_threshold);
205  }
206  }
207  fill(groupName, nTauTOBs_passcut);
208 
209  return StatusCode::SUCCESS;
210 }
EfexMonitorAlgorithm::fillTauHistograms
StatusCode fillTauHistograms(const std::string &groupName, const xAOD::eFexTauRoIContainer *taucont, const float &cut_et) const
Definition: EfexMonitorAlgorithm.cxx:156
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
RunTileMonitoring.groupName
groupName
Definition: RunTileMonitoring.py:158
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray
void renounceArray(SG::VarHandleKeyArray &handlesArray)
remove all handles from I/O resolution
Definition: AthCommonDataStore.h:364
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
xAOD::eFexEMRoI_v1
Class describing a LVL1 eFEX EM region of interest.
Definition: eFexEMRoI_v1.h:33
EfexMonitorAlgorithm::m_eFexTauTobKeyList
SG::ReadHandleKeyArray< xAOD::eFexTauRoIContainer > m_eFexTauTobKeyList
Definition: EfexMonitorAlgorithm.h:29
EfexMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: EfexMonitorAlgorithm.cxx:36
EfexMonitorAlgorithm::fillEMHistograms
StatusCode fillEMHistograms(const std::string &groupName, const xAOD::eFexEMRoIContainer *emcont, const float &cut_et) const
Definition: EfexMonitorAlgorithm.cxx:97
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
EfexMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: EfexMonitorAlgorithm.cxx:13
EfexMonitorAlgorithm::m_packageName
StringProperty m_packageName
Definition: EfexMonitorAlgorithm.h:24
xAOD::eFexTauRoI_v1
Class describing a LVL1 eFEX tau region of interest.
Definition: eFexTauRoI_v1.h:29
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
EfexMonitorAlgorithm::m_hiPtCut
Gaudi::Property< float > m_hiPtCut
Definition: EfexMonitorAlgorithm.h:26
EfexMonitorAlgorithm.h
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.
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:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
EfexMonitorAlgorithm::EfexMonitorAlgorithm
EfexMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: EfexMonitorAlgorithm.cxx:8
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
EfexMonitorAlgorithm::m_lowPtCut
Gaudi::Property< float > m_lowPtCut
Definition: EfexMonitorAlgorithm.h:25
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
EfexMonitorAlgorithm::m_eFexEMTobKeyList
SG::ReadHandleKeyArray< xAOD::eFexEMRoIContainer > m_eFexEMTobKeyList
Definition: EfexMonitorAlgorithm.h:28
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37