ATLAS Offline Software
GfexSimMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 GfexSimMonitorAlgorithm::GfexSimMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : AthMonitorAlgorithm(name,pSvcLocator) {}
7 
9 
10  ATH_MSG_DEBUG("Initializing GfexSimMonitorAlgorithm algorithm with name: "<< name());
11 
12  ATH_MSG_DEBUG("m_data_key_gFexRho" << m_data_gFexRho);
13  ATH_MSG_DEBUG("m_data_gFexBlock" << m_data_gFexBlock );
14  ATH_MSG_DEBUG("m_data_gFexJet" << m_data_gFexJet );
15  ATH_MSG_DEBUG("m_data_gScalarEJwoj" << m_data_gScalarEJwoj );
16  ATH_MSG_DEBUG("m_data_gMETComponentsJwoj" << m_data_gMETComponentsJwoj );
17  ATH_MSG_DEBUG("m_data_gMHTComponentsJwoj" << m_data_gMHTComponentsJwoj );
18  ATH_MSG_DEBUG("m_data_gMSTComponentsJwoj" << m_data_gMSTComponentsJwoj );
19  ATH_MSG_DEBUG("m_data_gMETComponentsNoiseCut" << m_data_gMETComponentsNoiseCut );
20  ATH_MSG_DEBUG("m_data_gMETComponentsRms" << m_data_gMETComponentsRms );
21  ATH_MSG_DEBUG("m_data_gScalarENoiseCut" << m_data_gScalarENoiseCut );
22  ATH_MSG_DEBUG("m_data_gScalarERms" << m_data_gScalarERms );
23 
24 
25  ATH_MSG_DEBUG("m_simu_key_gFexRho" << m_simu_gFexRho);
26  ATH_MSG_DEBUG("m_simu_gFexBlock" << m_simu_gFexBlock );
27  ATH_MSG_DEBUG("m_simu_gFexJet" << m_simu_gFexJet );
28  ATH_MSG_DEBUG("m_simu_gScalarEJwoj" << m_simu_gScalarEJwoj );
29  ATH_MSG_DEBUG("m_simu_gMETComponentsJwoj" << m_simu_gMETComponentsJwoj );
30  ATH_MSG_DEBUG("m_simu_gMHTComponentsJwoj" << m_simu_gMHTComponentsJwoj );
31  ATH_MSG_DEBUG("m_simu_gMSTComponentsJwoj" << m_simu_gMSTComponentsJwoj );
32  ATH_MSG_DEBUG("m_simu_gMETComponentsNoiseCut" << m_simu_gMETComponentsNoiseCut );
33  ATH_MSG_DEBUG("m_simu_gMETComponentsRms" << m_simu_gMETComponentsRms );
34  ATH_MSG_DEBUG("m_simu_gScalarENoiseCut" << m_simu_gScalarENoiseCut );
35  ATH_MSG_DEBUG("m_simu_gScalarERms" << m_simu_gScalarERms );
36 
37 
38 /* ATH_MSG_DEBUG("m_data_key_gGlob " << m_data_key_gGlob );
39  ATH_MSG_DEBUG("m_data_key_gJ " << m_data_key_gJ );
40 
41  ATH_MSG_DEBUG("m_simu_key_gGlob " << m_simu_key_gGlob );
42  ATH_MSG_DEBUG("m_simu_key_gJ " << m_simu_key_gJ );
43 */
44 
45 
46  // we initialise all the containers
47  ATH_CHECK ( m_data_gFexRho.initialize() );
48  ATH_CHECK ( m_data_gFexBlock.initialize() );
49  ATH_CHECK ( m_data_gFexJet.initialize() );
50  ATH_CHECK ( m_data_gScalarEJwoj.initialize() );
51  ATH_CHECK ( m_data_gMETComponentsJwoj.initialize() );
52  ATH_CHECK ( m_data_gMHTComponentsJwoj.initialize() );
53  ATH_CHECK ( m_data_gMSTComponentsJwoj.initialize() );
55  ATH_CHECK ( m_data_gMETComponentsRms.initialize() );
56  ATH_CHECK ( m_data_gScalarENoiseCut.initialize() );
57  ATH_CHECK ( m_data_gScalarERms.initialize() );
58 
59 
60  ATH_CHECK ( m_simu_gFexRho.initialize() );
61  ATH_CHECK ( m_simu_gFexBlock.initialize() );
62  ATH_CHECK ( m_simu_gFexJet.initialize() );
63  ATH_CHECK ( m_simu_gScalarEJwoj.initialize() );
64  ATH_CHECK ( m_simu_gMETComponentsJwoj.initialize() );
65  ATH_CHECK ( m_simu_gMHTComponentsJwoj.initialize() );
66  ATH_CHECK ( m_simu_gMSTComponentsJwoj.initialize() );
68  ATH_CHECK ( m_simu_gMETComponentsRms.initialize() );
69  ATH_CHECK ( m_simu_gScalarENoiseCut.initialize() );
70  ATH_CHECK ( m_simu_gScalarERms.initialize() );
71 
72  ATH_CHECK( m_bcContKey.initialize() );
73 
74 
75 
76  // TOBs may come from trigger bytestream - renounce from scheduler
77 
78 
90 
91 
93 }
94 
95 StatusCode GfexSimMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
96 
100  compareGlobalRoI("gTEJWOJ",m_data_gScalarEJwoj,m_simu_gScalarEJwoj,ctx,0xff000fff); // wont compare MET value in scalarE tob
107  compareGlobalRoI("gTERHO",m_data_gScalarERms,m_simu_gScalarERms,ctx,0xff000fff);
108 
109  return StatusCode::SUCCESS;
110 }
111 
115  const EventContext& ctx, bool simReadyFlag) const {
116  SG::ReadHandle<xAOD::gFexJetRoIContainer> tobs1Cont{tobs1Key, ctx};
117  if(!tobs1Cont.isValid()) {
118  return false;
119  }
120  SG::ReadHandle<xAOD::gFexJetRoIContainer> tobs2Cont{tobs2Key, ctx};
121  if(!tobs1Cont.isValid()) {
122  return false;
123  }
124 
125  bool mismatches = (tobs1Cont->size()!=tobs2Cont->size());
126  //bool mismatchesExlStatusAndSat = mismatches;
127 
128  auto eventType = Monitored::Scalar<std::string>("EventType","DataTowers"); // always have data towers
129  auto Signature = Monitored::Scalar<std::string>("Signature",label);
130  auto tobMismatched = Monitored::Scalar<double>("tobMismatched",0);
131  auto simReady = Monitored::Scalar<bool>("SimulationReady",simReadyFlag);
132 
133  for(const auto tob1 : *tobs1Cont) {
134  bool isMatched = false;
135  //bool isPartMatched = false;
136  auto word1 = tob1->word();
137  auto gfex1 = tob1->gFexType();
138  for (auto tob2 : *tobs2Cont) {
139  if(gfex1 == tob2->gFexType()) {
140  if(word1 == tob2->word()) {
141  isMatched = true;
142  break;
143  } /*else if( (word1&0x7FFFFF7F) == (tob2->word()&0x7FFFFF7F) ) {
144  // matches after ignore saturation bit (31st bit) and status bit (7th bit) (first bit is 0th)
145  isPartMatched=true;
146  }*/
147  }
148  }
149  if(!isMatched) {
150  mismatches = true;
151  }
152  tobMismatched = (isMatched) ? 0 : 100;
153  fill("mismatches",eventType,Signature,tobMismatched);
154  }
155 
156 
157 
158  if(mismatches) {
159  // fill the debugging tree with all the words for this signature
160  auto lbnString = Monitored::Scalar<std::string>("LBNString",std::to_string(GetEventInfo(ctx)->lumiBlock()));
162  auto evtNumber = Monitored::Scalar<ULong64_t>("EventNumber",GetEventInfo(ctx)->eventNumber());
163  {
164  std::scoped_lock lock(m_firstEventsMutex);
165  auto itr = m_firstEvents.find(lbn);
166  if(itr==m_firstEvents.end()) {
167  m_firstEvents[lbn] = std::to_string(lbn)+":"+std::to_string(evtNumber);
168  itr = m_firstEvents.find(lbn);
169  }
170  lbnString = itr->second;
171  }
172  std::vector<float> detas{};std::vector<float> setas{};
173  std::vector<float> dphis{};std::vector<float> sphis{};
174  std::vector<unsigned int> dword0s{};std::vector<unsigned int> sword0s{};
175  auto dtobEtas = Monitored::Collection("dataEtas", detas);
176  auto dtobPhis = Monitored::Collection("dataPhis", dphis);
177  auto dtobWord0s = Monitored::Collection("dataWord0s", dword0s);
178  auto stobEtas = Monitored::Collection("simEtas", setas);
179  auto stobPhis = Monitored::Collection("simPhis", sphis);
180  auto stobWord0s = Monitored::Collection("simWord0s", sword0s);
181  fillVectors(tobs1Key,ctx,detas,dphis,dword0s);
182  fillVectors(tobs2Key,ctx,setas,sphis,sword0s);
183  if(msgLvl(MSG::DEBUG)) {
184  std::cout << "LBN: " << ULong64_t(lbn) << " EventNumber: " << ULong64_t(evtNumber) << " L1ID: " << GetEventInfo(ctx)->extendedLevel1ID() << " signature: " << label << std::endl;
185  std::cout << " data : " << std::hex;
186  for (const auto w: dword0s) std::cout << w << " ";
187  std::cout << std::endl << " sim : ";
188  for (const auto w: sword0s) std::cout << w << " ";
189  std::cout << std::endl << std::dec;
190  }
191  fill("mismatches",lbn,lbnString,evtNumber,dtobEtas,dtobPhis,dtobWord0s,stobEtas,stobPhis,stobWord0s,Signature,simReady);
192  }
193 
194  return !mismatches;
195 
196 }
197 
198 
202  const EventContext& ctx, uint32_t tobMask) const {
203  SG::ReadHandle<xAOD::gFexGlobalRoIContainer> tobs1Cont{tobs1Key, ctx};
204  if(!tobs1Cont.isValid()) {
205  return false;
206  }
207  SG::ReadHandle<xAOD::gFexGlobalRoIContainer> tobs2Cont{tobs2Key, ctx};
208  if(!tobs1Cont.isValid()) {
209  return false;
210  }
211 
212  auto eventType = Monitored::Scalar<std::string>("EventType","DataTowers"); // always have data towers
213  auto Signature = Monitored::Scalar<std::string>("Signature",label);
214  auto tobMismatched = Monitored::Scalar<double>("tobMismatched",0);
215 
216 
217  bool mismatches = (tobs1Cont->size()!=tobs2Cont->size());
218 
219  for(const auto tob1 : *tobs1Cont) {
220  bool isMatched = false;
221  uint32_t word1 = tob1->word()&tobMask;
222  auto gfex1 = tob1->globalType();
223  for (auto tob2 : *tobs2Cont) {
224  if(gfex1 == tob2->globalType()) {
225  if(word1 == (tob2->word()&tobMask)) {
226  isMatched = true;
227  break;
228  }
229  }
230 
231  }
232  if(!isMatched) {
233  mismatches = true;
234  }
235  tobMismatched = (isMatched) ? 0 : 100; //100*(!isMatched && !isPartMatched); - commented out. Is from when was treating part-matches as matches
236  fill("mismatches",eventType,Signature,tobMismatched);
237  }
238 
239  if(mismatches) {
240  // fill the debugging tree with all the words for this signature
241  auto lbnString = Monitored::Scalar<std::string>("LBNString",std::to_string(GetEventInfo(ctx)->lumiBlock()));
243  auto evtNumber = Monitored::Scalar<ULong64_t>("EventNumber",GetEventInfo(ctx)->eventNumber());
244  {
245  std::scoped_lock lock(m_firstEventsMutex);
246  auto itr = m_firstEvents.find(lbn);
247  if(itr==m_firstEvents.end()) {
248  m_firstEvents[lbn] = std::to_string(lbn)+":"+std::to_string(evtNumber);
249  itr = m_firstEvents.find(lbn);
250  }
251  lbnString = itr->second;
252  }
253  std::vector<float> detas{};std::vector<float> setas{}; // will be empty, b.c. meaningless for global TOBs
254  std::vector<float> dphis{};std::vector<float> sphis{};
255  std::vector<unsigned int> dword0s{};std::vector<unsigned int> sword0s{};
256  for(const auto tob1 : *tobs1Cont) {
257  dword0s.push_back(tob1->word());
258  }
259  for(const auto tob2 : *tobs2Cont) {
260  sword0s.push_back(tob2->word());
261  }
262  auto dtobEtas = Monitored::Collection("dataEtas", detas);
263  auto dtobPhis = Monitored::Collection("dataPhis", dphis);
264  auto dtobWord0s = Monitored::Collection("dataWord0s", dword0s);
265  auto stobEtas = Monitored::Collection("simEtas", setas);
266  auto stobPhis = Monitored::Collection("simPhis", sphis);
267  auto stobWord0s = Monitored::Collection("simWord0s", sword0s);
268  if(msgLvl(MSG::DEBUG)) {
269  std::cout << "LBN: " << ULong64_t(lbn) << " EventNumber: " << ULong64_t(evtNumber) << " L1ID: " << GetEventInfo(ctx)->extendedLevel1ID() << " signature: " << label << std::endl;
270  std::cout << " data : " << std::hex;
271  for (const auto w: dword0s) std::cout << w << " ";
272  std::cout << std::endl << " sim : ";
273  for (const auto w: sword0s) std::cout << w << " ";
274  std::cout << std::endl << std::dec;
275  }
276  fill("mismatches",lbn,lbnString,evtNumber,dtobEtas,dtobPhis,dtobWord0s,stobEtas,stobPhis,stobWord0s,Signature);
277  }
278 
279 
280  return !mismatches;
281 
282 }
GfexSimMonitorAlgorithm::m_simu_gFexBlock
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_simu_gFexBlock
Definition: GfexSimMonitorAlgorithm.h:62
xAOD::word1
word1
Definition: eFexEMRoI_v1.cxx:82
GfexSimMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: GfexSimMonitorAlgorithm.cxx:95
GfexSimMonitorAlgorithm::m_simu_gMHTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMHTComponentsJwoj
Definition: GfexSimMonitorAlgorithm.h:67
GfexSimMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: GfexSimMonitorAlgorithm.cxx:8
GfexSimMonitorAlgorithm::m_simu_gScalarERms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gScalarERms
Definition: GfexSimMonitorAlgorithm.h:72
GfexSimMonitorAlgorithm::m_data_gFexBlock
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_data_gFexBlock
Definition: GfexSimMonitorAlgorithm.h:39
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
GfexSimMonitorAlgorithm::m_simu_gMETComponentsRms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMETComponentsRms
Definition: GfexSimMonitorAlgorithm.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition: AthCommonDataStore.h:380
GfexSimMonitorAlgorithm::m_data_gScalarERms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gScalarERms
Definition: GfexSimMonitorAlgorithm.h:49
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:48
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
GfexSimMonitorAlgorithm::m_simu_gFexRho
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_simu_gFexRho
Definition: GfexSimMonitorAlgorithm.h:61
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
GfexSimMonitorAlgorithm::fillVectors
void fillVectors(const SG::ReadHandleKey< T > &key, const EventContext &ctx, std::vector< float > &etas, std::vector< float > &phis, std::vector< unsigned int > &word0s) const
Definition: GfexSimMonitorAlgorithm.h:80
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
GfexSimMonitorAlgorithm::m_simu_gScalarENoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gScalarENoiseCut
Definition: GfexSimMonitorAlgorithm.h:71
GfexSimMonitorAlgorithm::m_bcContKey
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Definition: GfexSimMonitorAlgorithm.h:53
GfexSimMonitorAlgorithm::compareGlobalRoI
bool compareGlobalRoI(const std::string &label, const SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > &tobs1Key, const SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > &tobs2Key, const EventContext &ctx, uint32_t tobMask=0xffffffff) const
Definition: GfexSimMonitorAlgorithm.cxx:199
GfexSimMonitorAlgorithm::m_simu_gMSTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMSTComponentsJwoj
Definition: GfexSimMonitorAlgorithm.h:68
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
GfexSimMonitorAlgorithm::m_data_gMETComponentsRms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMETComponentsRms
Definition: GfexSimMonitorAlgorithm.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
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
GfexSimMonitorAlgorithm::m_data_gFexJet
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_data_gFexJet
Definition: GfexSimMonitorAlgorithm.h:40
GfexSimMonitorAlgorithm::GfexSimMonitorAlgorithm
GfexSimMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GfexSimMonitorAlgorithm.cxx:6
GfexSimMonitorAlgorithm::m_data_gFexRho
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_data_gFexRho
Definition: GfexSimMonitorAlgorithm.h:38
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
GfexSimMonitorAlgorithm.h
GfexSimMonitorAlgorithm::compareJetRoI
bool compareJetRoI(const std::string &label, const SG::ReadHandleKey< xAOD::gFexJetRoIContainer > &tobs1Key, const SG::ReadHandleKey< xAOD::gFexJetRoIContainer > &tobs2Key, const EventContext &ctx, bool simReady=false) const
Definition: GfexSimMonitorAlgorithm.cxx:112
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
GfexSimMonitorAlgorithm::m_data_gScalarENoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gScalarENoiseCut
Definition: GfexSimMonitorAlgorithm.h:48
GfexSimMonitorAlgorithm::m_data_gScalarEJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gScalarEJwoj
Definition: GfexSimMonitorAlgorithm.h:42
GfexSimMonitorAlgorithm::m_simu_gMETComponentsNoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMETComponentsNoiseCut
Definition: GfexSimMonitorAlgorithm.h:69
GfexSimMonitorAlgorithm::m_simu_gMETComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMETComponentsJwoj
Definition: GfexSimMonitorAlgorithm.h:66
DEBUG
#define DEBUG
Definition: page_access.h:11
GfexSimMonitorAlgorithm::m_data_gMSTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMSTComponentsJwoj
Definition: GfexSimMonitorAlgorithm.h:45
GfexSimMonitorAlgorithm::m_data_gMETComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMETComponentsJwoj
Definition: GfexSimMonitorAlgorithm.h:43
GfexSimMonitorAlgorithm::m_simu_gScalarEJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gScalarEJwoj
Definition: GfexSimMonitorAlgorithm.h:65
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
GfexSimMonitorAlgorithm::m_simu_gFexJet
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_simu_gFexJet
Definition: GfexSimMonitorAlgorithm.h:63
GfexSimMonitorAlgorithm::m_data_gMETComponentsNoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMETComponentsNoiseCut
Definition: GfexSimMonitorAlgorithm.h:46
GfexSimMonitorAlgorithm::m_data_gMHTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMHTComponentsJwoj
Definition: GfexSimMonitorAlgorithm.h:44
GfexSimMonitorAlgorithm::m_firstEventsMutex
std::mutex m_firstEventsMutex
Definition: GfexSimMonitorAlgorithm.h:33
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28