ATLAS Offline Software
Loading...
Searching...
No Matches
GfexSimMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5
6GfexSimMonitorAlgorithm::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 // we initialise all the containers
39 ATH_CHECK ( m_data_gFexRho.initialize() );
40 ATH_CHECK ( m_data_gFexBlock.initialize() );
41 ATH_CHECK ( m_data_gFexJet.initialize() );
42 ATH_CHECK ( m_data_gScalarEJwoj.initialize() );
43 ATH_CHECK ( m_data_gMETComponentsJwoj.initialize() );
44 ATH_CHECK ( m_data_gMHTComponentsJwoj.initialize() );
45 ATH_CHECK ( m_data_gMSTComponentsJwoj.initialize() );
47 ATH_CHECK ( m_data_gMETComponentsRms.initialize() );
48 ATH_CHECK ( m_data_gScalarENoiseCut.initialize() );
49 ATH_CHECK ( m_data_gScalarERms.initialize() );
50
51
52 ATH_CHECK ( m_simu_gFexRho.initialize() );
53 ATH_CHECK ( m_simu_gFexBlock.initialize() );
54 ATH_CHECK ( m_simu_gFexJet.initialize() );
55 ATH_CHECK ( m_simu_gScalarEJwoj.initialize() );
56 ATH_CHECK ( m_simu_gMETComponentsJwoj.initialize() );
57 ATH_CHECK ( m_simu_gMHTComponentsJwoj.initialize() );
58 ATH_CHECK ( m_simu_gMSTComponentsJwoj.initialize() );
60 ATH_CHECK ( m_simu_gMETComponentsRms.initialize() );
61 ATH_CHECK ( m_simu_gScalarENoiseCut.initialize() );
62 ATH_CHECK ( m_simu_gScalarERms.initialize() );
63
64 ATH_CHECK( m_bcContKey.initialize() );
65
66
67
68 // TOBs may come from trigger bytestream - renounce from scheduler
69
70
71
73}
74
91
95 const EventContext& ctx, bool simReadyFlag) const {
96 SG::ReadHandle<xAOD::gFexJetRoIContainer> tobs1Cont{tobs1Key, ctx};
97 if(!tobs1Cont.isValid()) {
98 return false;
99 }
100 SG::ReadHandle<xAOD::gFexJetRoIContainer> tobs2Cont{tobs2Key, ctx};
101 if(!tobs1Cont.isValid()) {
102 return false;
103 }
104
105
106 auto eventType = Monitored::Scalar<std::string>("EventType","DataTowers"); // always have data towers
107 auto Signature = Monitored::Scalar<std::string>("Signature",label);
108 auto tobMismatched = Monitored::Scalar<double>("tobMismatched",0);
109 auto simReady = Monitored::Scalar<bool>("SimulationReady",simReadyFlag);
110
111 //sorting mismatched data/sim TOB
112 std::set<const xAOD::gFexJetRoI*> mismatchedTOBs;
113 std::set<const xAOD::gFexJetRoI*> DataMismatchedTOBs;
114
115 for (auto tob1 : *tobs1Cont) {
116 bool isMatched = false;
117 //bool isPartMatched = false;
118 auto word1 = tob1->word();
119 auto gfex1 = tob1->gFexType();
120 for (auto tob2 : *tobs2Cont) {
121 if(gfex1 == tob2->gFexType()) {
122 if(word1 == tob2->word()) {
123 isMatched = true;
124 break;
125 } /*else if( (word1&0x7FFFFF7F) == (tob2->word()&0x7FFFFF7F) ) {
126 // matches after ignore saturation bit (31st bit) and status bit (7th bit) (first bit is 0th)
127 isPartMatched=true;
128 }*/
129 }
130 }
131 if(!isMatched) {
132 mismatchedTOBs.insert(tob1); //saving these for TTree
133 DataMismatchedTOBs.insert(tob1); //saving only the mismatched data tob for detail plot
134 }
135 }
136
137 // also check for mismatches in tobs2 collection ... since may have extra tobs in tob2 that aren't in tobs1
138 for (auto tob2 : *tobs2Cont) {
139 bool isMatched = false;
140 auto word = tob2->word();auto gfex = tob2->gFexType();
141 for (auto tob1 : *tobs1Cont) {
142 if(gfex == tob1->gFexType() && word == tob1->word()) {
143 isMatched = true;
144 break;
145 }
146 }
147 if(!isMatched) {
148 mismatchedTOBs.insert(tob2); //saving these for TTree
149 }
150 }
151
152
153
154 auto lbn = Monitored::Scalar<ULong64_t>("LBN",GetEventInfo(ctx)->lumiBlock());
155 if(!mismatchedTOBs.empty()) {
156 // fill the debugging tree with all the words for this signature
157 auto lbnString = Monitored::Scalar<std::string>("LBNString",std::to_string(GetEventInfo(ctx)->lumiBlock()));
158 auto evtNumber = Monitored::Scalar<ULong64_t>("EventNumber",GetEventInfo(ctx)->eventNumber());
159 auto l1id = Monitored::Scalar<unsigned int>("L1ID",GetEventInfo(ctx)->extendedLevel1ID());
160 {
161 std::scoped_lock lock(m_firstEventsMutex);
162 auto itr = m_firstEvents.find(lbn);
163 if(itr==m_firstEvents.end()) {
164 m_firstEvents[lbn] = std::to_string(lbn)+":"+std::to_string(evtNumber);
165 itr = m_firstEvents.find(lbn);
166 }
167 lbnString = itr->second;
168 }
169 std::vector<SortableTob> sortedDataTobs;
170 std::vector<SortableTob> sortedSimTobs;
171
172 // Fill your sorted TOB vectors
173 fillVectors(tobs1Key, ctx, sortedDataTobs);
174 fillVectors(tobs2Key, ctx, sortedSimTobs);
175
176 auto dtobEtas = Monitored::Collection("dataEtas", sortedDataTobs, [](const auto& t) { return t.eta; });
177 auto dtobPhis = Monitored::Collection("dataPhis", sortedDataTobs, [](const auto& t) { return t.phi; });
178 auto dtobEts = Monitored::Collection("dataEts", sortedDataTobs, [](const auto& t) { return t.et; });
179 auto dtobWord0s = Monitored::Collection("dataWord0s", sortedDataTobs, [](const auto& t) { return t.word0; });
180
181 auto stobEtas = Monitored::Collection("simEtas", sortedSimTobs, [](const auto& t) { return t.eta; });
182 auto stobPhis = Monitored::Collection("simPhis", sortedSimTobs, [](const auto& t) { return t.phi; });
183 auto stobEts = Monitored::Collection("simEts", sortedSimTobs, [](const auto& t) { return t.et; });
184 auto stobWord0s = Monitored::Collection("simWord0s", sortedSimTobs, [](const auto& t) { return t.word0; });
185
186 /*if(msgLvl(MSG::DEBUG)) {
187 std::cout << "LBN: " << ULong64_t(lbn) << " EventNumber: " << ULong64_t(evtNumber) << " L1ID: " << GetEventInfo(ctx)->extendedLevel1ID() << " signature: " << label << std::endl;
188 std::cout << " data : " << std::hex;
189 for (const auto w: dword0s) std::cout << w << " ";
190 std::cout << std::endl << " sim : ";
191 for (const auto w: sword0s) std::cout << w << " ";
192 std::cout << std::endl << std::dec;
193 }*/
194 tobMismatched=100;
195 auto simReadyMismatch = Monitored::Scalar<bool>("SimulationReadyMismatch",simReady);
196 auto FillJetTree = Monitored::Scalar<bool>("FillJetTree",true);
197
198 fill("mismatches",FillJetTree,simReadyMismatch,tobMismatched,lbn,lbnString,l1id,evtNumber,dtobEtas,dtobPhis,dtobEts,dtobWord0s,stobEtas,stobPhis,stobEts,stobWord0s,Signature,simReady,eventType);
199 if (label=="gJ" || label=="gLJ") {
200 auto locIdx = Monitored::Scalar<std::string>("locIdx","");
201 for(auto tob : DataMismatchedTOBs) {
202 locIdx = std::to_string(tob->iEta()) + ":" + std::to_string(tob->iPhi());
203 fill("mismatches"+label,lbn,locIdx); //only recording data eta,phi vs LBN
204 }
205 }
206 } else {
207 tobMismatched=0;
208 fill("mismatches",lbn,Signature,tobMismatched,simReady,eventType);
209 }
210
211 return !mismatchedTOBs.empty();
212
213}
214
215
219 const EventContext& ctx, uint32_t tobMask) const {
220 SG::ReadHandle<xAOD::gFexGlobalRoIContainer> tobs1Cont{tobs1Key, ctx};
221 if(!tobs1Cont.isValid()) {
222 return false;
223 }
224 SG::ReadHandle<xAOD::gFexGlobalRoIContainer> tobs2Cont{tobs2Key, ctx};
225 if(!tobs1Cont.isValid()) {
226 return false;
227 }
228
229 auto eventType = Monitored::Scalar<std::string>("EventType","DataTowers"); // always have data towers
230 auto Signature = Monitored::Scalar<std::string>("Signature",label);
231 auto tobMismatched = Monitored::Scalar<double>("tobMismatched",0);
232
233 bool mismatches = (tobs1Cont->size()!=tobs2Cont->size());
234
235 for(const auto tob1 : *tobs1Cont) {
236 bool isMatched = false;
237 uint32_t word1 = tob1->word()&tobMask;
238 auto gfex1 = tob1->globalType();
239 for (auto tob2 : *tobs2Cont) {
240 if(gfex1 == tob2->globalType()) {
241 if(word1 == (tob2->word()&tobMask)) {
242 isMatched = true;
243 break;
244 }
245 }
246 }
247 if(!isMatched) {
248 mismatches = true;
249 }
250 }
251
252 auto lbn = Monitored::Scalar<ULong64_t>("LBN",GetEventInfo(ctx)->lumiBlock());
253 if(mismatches) {
254 // fill the debugging tree with all the words for this signature
255 auto lbnString = Monitored::Scalar<std::string>("LBNString",std::to_string(GetEventInfo(ctx)->lumiBlock()));
256 auto evtNumber = Monitored::Scalar<ULong64_t>("EventNumber",GetEventInfo(ctx)->eventNumber());
257 auto l1id = Monitored::Scalar<unsigned int>("L1ID",GetEventInfo(ctx)->extendedLevel1ID());
258 {
259 std::scoped_lock lock(m_firstEventsMutex);
260 auto itr = m_firstEvents.find(lbn);
261 if(itr==m_firstEvents.end()) {
262 m_firstEvents[lbn] = std::to_string(lbn)+":"+std::to_string(evtNumber);
263 itr = m_firstEvents.find(lbn);
264 }
265 lbnString = itr->second;
266 }
267 auto dtobMet1 = Monitored::Collection("dataTOB1", *tobs1Cont,[](const auto& tob) { return tob->METquantityOne(); });
268 auto dtobMet2 = Monitored::Collection("dataTOB2", *tobs1Cont,[](const auto& tob) { return tob->METquantityTwo(); });
269 auto dtobWord0s = Monitored::Collection("dataWord0s", *tobs1Cont,[](const auto& tob) { return tob->word(); });
270 auto stobMet1 = Monitored::Collection("simTOB1", *tobs2Cont,[](const auto& tob) { return tob->METquantityOne(); });
271 auto stobMet2 = Monitored::Collection("simTOB2", *tobs2Cont,[](const auto& tob) { return tob->METquantityTwo(); });
272 auto stobWord0s = Monitored::Collection("simWord0s", *tobs2Cont,[](const auto& tob) { return tob->word(); });
273
274 /*if(msgLvl(MSG::DEBUG)) {
275 std::cout << "LBN: " << ULong64_t(lbn) << " EventNumber: " << ULong64_t(evtNumber) << " L1ID: " << GetEventInfo(ctx)->extendedLevel1ID() << " signature: " << label << std::endl;
276 std::cout << " data : " << std::hex;
277 for (const auto w: dword0s) std::cout << w << " ";
278 std::cout << std::endl << " sim : ";
279 for (const auto w: sword0s) std::cout << w << " ";
280 std::cout << std::endl << std::dec;
281 }*/
282 tobMismatched=100;
283
284 auto simReadyMismatch = Monitored::Scalar<bool>("SimulationReadyMismatch",false/* global RoI not sim ready yet*/);
285 auto FillGlobalTree = Monitored::Scalar<bool>("FillGlobalTree",true);
286
287 fill("mismatches",FillGlobalTree,simReadyMismatch,lbn,lbnString,evtNumber,l1id,dtobMet1,dtobMet2,dtobWord0s,stobMet1,stobMet2,stobWord0s,Signature,tobMismatched,eventType);
288 } else {
289 tobMismatched=0;
290 fill("mismatches",lbn,Signature,tobMismatched,eventType);
291 }
292
293
294 return !mismatches;
295
296}
297
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_data_gFexBlock
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_simu_gFexBlock
void fillVectors(const SG::ReadHandleKey< T > &key, const EventContext &ctx, std::vector< SortableTob > &sortedTobs) const
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMETComponentsNoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMSTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_data_gFexJet
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gScalarERms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gScalarEJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMETComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMSTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_simu_gFexJet
virtual StatusCode initialize() override
initialize
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
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
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMETComponentsNoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gScalarEJwoj
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gScalarERms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gScalarENoiseCut
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMETComponentsRms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMETComponentsJwoj
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_data_gFexRho
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gScalarENoiseCut
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
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMHTComponentsJwoj
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_simu_gMETComponentsRms
SG::ReadHandleKey< xAOD::gFexGlobalRoIContainer > m_data_gMHTComponentsJwoj
GfexSimMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::gFexJetRoIContainer > m_simu_gFexRho
Declare a monitored scalar variable.
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string label(const std::string &format, int i)
Definition label.h:19
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
void fill(H5::Group &out_file, size_t iterations)