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,ctx));
58  ATH_CHECK(fillEMHistograms(m_packageName+'_'+key.key()+"_HiPtCut", emDataContPtr, m_hiPtCut,ctx));
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,ctx));
83  ATH_CHECK(fillTauHistograms(m_packageName+'_'+key.key()+"_HiPtCut", tauDataContPtr, m_hiPtCut,ctx));
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 EventContext& ctx) const {
98 
99  ATH_MSG_DEBUG("EfexMonitorAlgorithm::fillEMHistograms");
100 
101  // monitored variables for histograms
102  auto lbn = Monitored::Scalar<int>("LBN",GetEventInfo(ctx)->lumiBlock());
103  auto binNumber = Monitored::Scalar<int>("binNumber",0);
104  auto nEmTOBs_passcut = Monitored::Scalar<int>("nEMTOBs",0.0); // Number of ToBs passing the cut
105  auto TOBeT = Monitored::Scalar<float>("TOBTransverseEnergy",0.0);
106  auto TOBeta = Monitored::Scalar<float>("TOBEta",0.0);
107  auto TOBphi = Monitored::Scalar<float>("TOBPhi",0.0);
108  auto TOBshelfNumber = Monitored::Scalar<float>("TOBshelfNumber",0.0);
109  auto TOBeFEXNumberSh0 = Monitored::Scalar<float>("TOBeFEXNumberSh0",0.0);
110  auto TOBeFEXNumberSh1 = Monitored::Scalar<float>("TOBeFEXNumberSh1",0.0);
111  auto TOBfpga = Monitored::Scalar<float>("TOBfpga",0.0);
112  auto TOBReta = Monitored::Scalar<float>("TOBReta",0.0);
113  auto TOBRhad = Monitored::Scalar<float>("TOBRhad",0.0);
114  auto TOBWstot = Monitored::Scalar<float>("TOBWstot",0.0);
115  auto TOBReta_threshold = Monitored::Scalar<float>("TOBReta_threshold",0.0);
116  auto TOBRhad_threshold = Monitored::Scalar<float>("TOBRhad_threshold",0.0);
117  auto TOBWstot_threshold = Monitored::Scalar<float>("TOBWstot_threshold",0.0);
118 
119  for(const xAOD::eFexEMRoI* efexEmRoI : *emcont){
120  if (efexEmRoI->et() >= cut_et){
121  nEmTOBs_passcut += 1;
122  TOBeT = efexEmRoI->et();
123  fill(groupName, TOBeT);
124  TOBeta = efexEmRoI->eta();
125  TOBphi = efexEmRoI->phi();
126  fill(groupName, TOBeta, TOBphi);
127  TOBshelfNumber=efexEmRoI->shelfNumber();
128  fill(groupName, TOBshelfNumber);
129  // Only fill the relevant shelf variable
130  if (TOBshelfNumber == 0) {
131  TOBeFEXNumberSh0 = int(efexEmRoI->eFexNumber());
132  fill(groupName, TOBeFEXNumberSh0);
133  } else {
134  TOBeFEXNumberSh1 = int(efexEmRoI->eFexNumber());
135  fill(groupName, TOBeFEXNumberSh1);
136  }
137  TOBfpga = efexEmRoI->fpga();
138  fill(groupName, TOBfpga);
139  TOBReta = efexEmRoI->Reta();
140  fill(groupName, TOBReta);
141  TOBRhad = efexEmRoI->Rhad();
142  fill(groupName, TOBRhad);
143  TOBWstot = efexEmRoI->Wstot();
144  fill(groupName, TOBWstot);
145  TOBReta_threshold = efexEmRoI->RetaThresholds();
146  fill(groupName, TOBReta_threshold);
147  TOBRhad_threshold = efexEmRoI->RhadThresholds();
148  fill(groupName, TOBRhad_threshold);
149  TOBWstot_threshold = efexEmRoI->WstotThresholds();
150  fill(groupName, TOBWstot_threshold);
151  int iPhi = efexEmRoI->iPhi();
152  if (iPhi>31) iPhi -= 64;
153  binNumber = (iPhi+32)*50 + 25 + efexEmRoI->iEta();
154  fill(groupName,binNumber,lbn);
155  }
156  }
157  fill(groupName, nEmTOBs_passcut);
158 
159  return StatusCode::SUCCESS;
160 }
161 
162 StatusCode EfexMonitorAlgorithm::fillTauHistograms(const std::string& groupName, const xAOD::eFexTauRoIContainer *taucont, const float &cut_et,const EventContext& ctx) const {
163 
164  ATH_MSG_DEBUG("EfexMonitorAlgorithm::fillTauHistograms");
165 
166  // monitored variables for histograms
167  auto lbn = Monitored::Scalar<int>("LBN",GetEventInfo(ctx)->lumiBlock());
168  auto binNumber = Monitored::Scalar<int>("binNumber",0);
169  auto nTauTOBs_passcut = Monitored::Scalar<int>("nTauTOBs",0.0); // Number of ToBs passing the cut
170  auto tauTOBeT = Monitored::Scalar<float>("tauTOBTransverseEnergy",0.0);
171  auto tauTOBeta = Monitored::Scalar<float>("tauTOBEta",0.0);
172  auto tauTOBphi = Monitored::Scalar<float>("tauTOBPhi",0.0);
173  auto tauTOBshelfNumber = Monitored::Scalar<float>("tauTOBshelfNumber",0.0);
174  auto tauTOBeFEXNumberSh0 = Monitored::Scalar<float>("tauTOBeFEXNumberSh0",0.0);
175  auto tauTOBeFEXNumberSh1 = Monitored::Scalar<float>("tauTOBeFEXNumberSh1",0.0);
176  auto tauTOBfpga = Monitored::Scalar<float>("tauTOBfpga",0.0);
177  auto tauTOBRcore = Monitored::Scalar<float>("tauTOBRcore",0.0);
178  auto tauTOBRhad = Monitored::Scalar<float>("tauTOBRhad",0.0);
179  auto tauTOBRcore_threshold = Monitored::Scalar<float>("tauTOBRcore_threshold",0.0);
180  auto tauTOBRhad_threshold = Monitored::Scalar<float>("tauTOBRhad_threshold",0.0);
181  auto tauTOBthree_threshold = Monitored::Scalar<float>("tauTOBthree_threshold",0.0);
182 
183  for(const xAOD::eFexTauRoI* efexTauRoI : *taucont){
184  if (efexTauRoI->et() >= cut_et){
185  nTauTOBs_passcut += 1;
186  tauTOBeT = efexTauRoI->et();
187  fill(groupName, tauTOBeT);
188  tauTOBeta = efexTauRoI->eta();
189  tauTOBphi = efexTauRoI->phi();
190  fill(groupName, tauTOBeta, tauTOBphi);
191  tauTOBshelfNumber=efexTauRoI->shelfNumber();
192  fill(groupName, tauTOBshelfNumber);
193  // Only fill the relevant shelf variable
194  if (tauTOBshelfNumber == 0) {
195  tauTOBeFEXNumberSh0 = int(efexTauRoI->eFexNumber());
196  fill(groupName, tauTOBeFEXNumberSh0);
197  } else {
198  tauTOBeFEXNumberSh1 = int(efexTauRoI->eFexNumber());
199  fill(groupName, tauTOBeFEXNumberSh1);
200  }
201  tauTOBfpga = efexTauRoI->fpga();
202  fill(groupName, tauTOBfpga);
203  tauTOBRcore = efexTauRoI->rCore();
204  fill(groupName, tauTOBRcore);
205  tauTOBRhad = efexTauRoI->rHad();
206  fill(groupName, tauTOBRhad);
207  tauTOBRcore_threshold=efexTauRoI->rCoreThresholds();
208  fill(groupName, tauTOBRcore_threshold);
209  tauTOBRhad_threshold=efexTauRoI->rHadThresholds();
210  fill(groupName, tauTOBRhad_threshold);
211  tauTOBthree_threshold=efexTauRoI->tauThreeThresholds();
212  fill(groupName, tauTOBthree_threshold);
213  int iPhi = efexTauRoI->iPhi();
214  if (iPhi>31) iPhi -= 64;
215  binNumber = (iPhi+32)*50 + 26 + efexTauRoI->iEta();
216  fill(groupName,binNumber,lbn);
217  }
218  }
219  fill(groupName, nTauTOBs_passcut);
220 
221  return StatusCode::SUCCESS;
222 }
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
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.
EfexMonitorAlgorithm::fillEMHistograms
StatusCode fillEMHistograms(const std::string &groupName, const xAOD::eFexEMRoIContainer *emcont, const float &cut_et, const EventContext &ctx) const
Definition: EfexMonitorAlgorithm.cxx:97
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?
EfexMonitorAlgorithm::fillTauHistograms
StatusCode fillTauHistograms(const std::string &groupName, const xAOD::eFexTauRoIContainer *taucont, const float &cut_et, const EventContext &ctx) const
Definition: EfexMonitorAlgorithm.cxx:162
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
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