ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaPoolTestDataReader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
16
17// INCLUDE HEADER FILES:
18
29#include "EventInfo/EventInfo.h"
31#include "EventInfo/EventID.h"
32#include "EventInfo/EventType.h"
34
35#include <algorithm>
36#include <sstream>
37
39 ISvcLocator* pSvcLocator):
40 AthAlgorithm(name, pSvcLocator)
41{}
42
45
47{
48 return StatusCode::SUCCESS;
49}
50
52{
53
54 ATH_MSG_DEBUG("Executing AthenaPoolTestDataReader" );
55
56
57 // Retrieve collections
58
59 // A's only
60
61 std::string test1;
62 std::string test2;
63 bool error = false;
64
66 ATH_CHECK( evtStore()->retrieve(col, "AthenaPoolTestCollection_1") );
67
68
69 ATH_MSG_DEBUG("Collection of A's" );
70 int i = 0;
71 for (const IAthenaPoolTestData* elt : *col) {
72 ATH_MSG_DEBUG( "Read: " << elt->printWhoYouAre() );
73 AthenaPoolTestA data(i+1, i+2);
74 ATH_MSG_DEBUG( "Should be: " << data.printWhoYouAre() );
75 test1 = elt->printWhoYouAre();
76 test2 = data.printWhoYouAre();
77 if (test1 != test2) {
78 ATH_MSG_ERROR( "Incorrect data: in/out " << test1 << " " << test2 );
79 error = true;
80 }
81 ++i;
82 }
83
84
85 // B's only
86
87 ATH_CHECK( evtStore()->retrieve(col, "AthenaPoolTestCollection_2") );
88
89 ATH_MSG_DEBUG("Collection of B's" );
90 i = 0;
91 for (const IAthenaPoolTestData* elt : *col) {
92 ATH_MSG_DEBUG( "Read: " << elt->printWhoYouAre() );
93 AthenaPoolTestB data(i+11, i+12);
94 ATH_MSG_DEBUG( "Should be: " << data.printWhoYouAre() );
95 test1 = elt->printWhoYouAre();
96 test2 = data.printWhoYouAre();
97 if (test1 != test2) {
98 ATH_MSG_ERROR( "Incorrect data: in/out " << test1 << " " << test2 );
99 error = true;
100 }
101 ++i;
102 }
103
104
105 // A's and B's
106
107 ATH_CHECK( evtStore()->retrieve(col, "AthenaPoolTestCollection_3") );
108
109 ATH_MSG_DEBUG("Collection of A's and B's" );
110 i = 0;
111 for (const IAthenaPoolTestData* elt : *col) {
112 ATH_MSG_DEBUG( "Read: " << elt->printWhoYouAre() );
113 if (i < 3) {
114 AthenaPoolTestA data(i+21, i+22);
115 ATH_MSG_DEBUG( "Should be: " << data.printWhoYouAre() );
116 test1 = elt->printWhoYouAre();
117 test2 = data.printWhoYouAre();
118 if (test1 != test2) {
119 ATH_MSG_ERROR( "Incorrect data: in/out " << test1 << " " << test2 );
120 error = true;
121 }
122 }
123 else {
124 AthenaPoolTestB data(i+21, i+22);
125 ATH_MSG_DEBUG( "Should be: " << data.printWhoYouAre() );
126 test1 = elt->printWhoYouAre();
127 test2 = data.printWhoYouAre();
128 if (test1 != test2) {
129 ATH_MSG_ERROR( "Incorrect data: in/out " << test1 << " " << test2 );
130 error = true;
131 }
132 }
133 ++i;
134 }
135
136
137 // C's only
138
139 ATH_CHECK( evtStore()->retrieve(col, "AthenaPoolTestCollection_4") );
140
141 ATH_MSG_DEBUG("Collection of C's" );
142 i = 0;
143 for (const IAthenaPoolTestData* elt : *col) {
144 ATH_MSG_DEBUG( "Read: " << elt->printWhoYouAre() );
145 AthenaPoolTestC data(0, 0, i+3, i+4);
146 ATH_MSG_DEBUG( "Should be: " << data.printWhoYouAre() );
147 test1 = elt->printWhoYouAre();
148 test2 = data.printWhoYouAre();
149 if (test1 != test2) {
150 ATH_MSG_ERROR( "Incorrect data: in/out " << test1 << " " << test2 );
151 error = true;
152 }
153 ++i;
154 }
155
156
157 // D's only
158
159 ATH_CHECK( evtStore()->retrieve(col, "AthenaPoolTestCollection_5") );
160
161 ATH_MSG_DEBUG("Collection of D's" );
162 i = 0;
163 for (const IAthenaPoolTestData* elt : *col) {
164 ATH_MSG_DEBUG( "Read: " << elt->printWhoYouAre() );
165 AthenaPoolTestD data(0, 0, i+13, i+14, i+15, i+16);
166 ATH_MSG_DEBUG( "Should be: " << data.printWhoYouAre() );
167 test1 = elt->printWhoYouAre();
168 test2 = data.printWhoYouAre();
169 if (test1 != test2) {
170 ATH_MSG_ERROR( "Incorrect data: in/out " << test1 << " " << test2 );
171 error = true;
172 }
173 ++i;
174 }
175
176
177 // Test for CLHEP matrix
178
179 // Now create a write 10 Hit objects
180 //bool readMatrix = false;
181 bool readMatrix = true;
182 if (readMatrix) {
183 const AthenaPoolTestMatrix* matrix = nullptr;
184 for ( int i = 0; i < 3; ++i ) {
185 std::stringstream stream;
186 stream << "AthenaPoolTestMatrix_" << i;
187 std::string key(stream.str());
188 ATH_CHECK( evtStore()->retrieve(matrix, key) );
189 ATH_MSG_DEBUG("Retrieved matrix " << i + 1 << " " << key );
190
191 const HepGeom::Point3D<double>& point = matrix->point();
192 const HepGeom::Point3D<double>& point1 = matrix->point1();
193 ATH_MSG_DEBUG(" Points (by value,by ptr) x,y,z : "
194 << point.x() << " "
195 << point.y() << " "
196 << point.z() << " "
197 << ", x,y,z "
198 << point1.x() << " "
199 << point1.y() << " "
200 << point1.z() << " ");
201 const CLHEP::HepMatrix& smallMatrix = matrix->smallMatrix();
202 ATH_MSG_DEBUG(" Small matrix : ( " << smallMatrix.num_row() << ", " << smallMatrix.num_col() << " ) " );
203 stream.clear();
204 stream << " values: ";
205 for (int i = 0; i < smallMatrix.num_row(); ++i) {
206 for (int j = 0; j < smallMatrix.num_col(); ++ j) {
207 stream << smallMatrix[i][j] << ", ";
208 }
209 }
210 ATH_MSG_VERBOSE(stream.str());
211
212 const CLHEP::HepMatrix& bigMatrix = matrix->bigMatrix();
213 ATH_MSG_DEBUG(" Big matrix : ( " << bigMatrix.num_row() << ", " << bigMatrix.num_col() << " ) " );
214 stream.clear();
215 stream << " values: ";
216 for (int i = 0; i < bigMatrix.num_row(); ++i) {
217 for (int j = 0; j < bigMatrix.num_col(); ++ j) {
218 stream << bigMatrix[i][j] << ", ";
219 }
220 }
221 ATH_MSG_VERBOSE(stream.str());
222 ATH_MSG_DEBUG(" Other matrices : " );
223 for ( int ii = 0; ii < matrix->numberOfMatrices(); ++ii ) {
224 const CLHEP::HepMatrix& matrx = matrix->matrix( ii );
225 ATH_MSG_DEBUG(" ( " << matrx.num_row() << ", " << matrx.num_col() << " ) " );
226 stream.clear();
227 stream << " values: ";
228 for (int i = 0; i < matrx.num_row(); ++i) {
229 for (int j = 0; j < matrx.num_col(); ++ j) {
230 stream << matrx[i][j] << ", ";
231 }
232 }
233 ATH_MSG_VERBOSE(stream.str());
234 }
235
236 // print out matrix maps
237 AthenaPoolTestMatrix::matrixMaps_t mats = matrix->matrixMaps();
238
239 ATH_MSG_DEBUG(" Matrix maps : " << mats.size() );
240 std::map<unsigned int, CLHEP::HepMatrix>& mp0 = mats[0];
241 std::map<unsigned int, CLHEP::HepMatrix>& mp1 = mats[1];
242 std::map<unsigned int, CLHEP::HepMatrix>::const_iterator itmp = mp0.begin();
243 ATH_MSG_DEBUG(" Key, row, column " << (*itmp).first << " "
244 << (*itmp).second.num_row() << ", " << (*itmp).second.num_col() );
245 ++itmp;
246 ATH_MSG_DEBUG(" Key, row, column " << (*itmp).first << " "
247 << (*itmp).second.num_row() << ", " << (*itmp).second.num_col() );
248 itmp = mp1.begin();
249 ATH_MSG_DEBUG(" Key, row, column " << (*itmp).first << " "
250 << (*itmp).second.num_row() << ", " << (*itmp).second.num_col() );
251 ++itmp;
252 ATH_MSG_DEBUG(" Key, row, column " << (*itmp).first << " "
253 << (*itmp).second.num_row() << ", " << (*itmp).second.num_col() );
254
255 // Print out the transform:
256 ATH_MSG_DEBUG(" Matrix transform: " );
257 const HepGeom::Transform3D& trans = matrix->trans();
258 ATH_MSG_DEBUG(" Matrix transform: " );
259 ATH_MSG_DEBUG(" xx " << trans(0,0) );
260 ATH_MSG_DEBUG(" xy " << trans(0,1) );
261 ATH_MSG_DEBUG(" xz " << trans(0,2) );
262 ATH_MSG_DEBUG(" yx " << trans(1,0) );
263 ATH_MSG_DEBUG(" yy " << trans(1,1) );
264 ATH_MSG_DEBUG(" yz " << trans(1,2) );
265 ATH_MSG_DEBUG(" zx " << trans(2,0) );
266 ATH_MSG_DEBUG(" zy " << trans(2,1) );
267 ATH_MSG_DEBUG(" zz " << trans(2,2) );
268 ATH_MSG_DEBUG(" dx " << trans(3,0) );
269 ATH_MSG_DEBUG(" dy " << trans(3,1) );
270 ATH_MSG_DEBUG(" dz " << trans(3,2) );
271
272 }
273 }
274
275
276
277 // Read in nested collections
278
279 bool readMap = true;
280 const AthenaPoolTestMap* tmapPtr;
281 if (evtStore()->retrieve(tmapPtr, "AthenaPoolMap").isFailure()) {
282 ATH_MSG_ERROR("Unable to retrieve AthenaPoolMap object ");
283 readMap = false;
284 }
285 else {
286 ATH_MSG_DEBUG("Retrieved AthenaPoolMap" );
287 }
288
289 if (readMap) {
290
291 const AthenaPoolTestMap& tmap = *tmapPtr;
292
293 typedef AthenaPoolTestMapData::Deposit deposit_t;
294 typedef std::vector<deposit_t> deposit_vec;
295
296 deposit_vec deposits;
297
298 //deposit_t deposit;
299
300 // Printout data
301 AthenaPoolTestMap::const_iterator itm = tmap.begin();
302 AthenaPoolTestMap::const_iterator endm = tmap.end();
303 for (; itm != endm; ++itm) {
304
305 std::stringstream stream;
306 stream << "AthenaPoolTestMap: key " << (*itm).first
307 << " word " << (*itm).second.word()
308 << " Deposits: (barCode, evtIndx, wgt) ";
309
310 deposits.clear();
311 (*itm).second.deposits(deposits);
312 for (unsigned int i = 0; i < deposits.size(); ++i) {
313 AthenaPoolTestMapDataLink& link = deposits[i].first;
314 stream << link.barcode() << " "
315 << link.eventIndex() << " "
316 << deposits[i].second << " ";
317 }
318 ATH_MSG_DEBUG(stream.str());
319 }
320 }
321
322
323 // Read back dummy classes
324
325 const dummy_A* dummyA;
326 if (evtStore()->retrieve(dummyA, "Dummy_A").isFailure() ) {
327 ATH_MSG_ERROR("Could not retrieve Dummy_A");
328 }
329 else {
330 ATH_MSG_DEBUG("Read back dummy_A class " );
331 }
332 const std::vector<dummy_B>& b = dummyA->dummy();
333 ATH_MSG_DEBUG("Dummy A: size B " << b.size() );
334 for (unsigned int i = 0; i < b.size(); ++i) {
335 const std::vector<dummy_C>& c = b[i].dummy();
336 ATH_MSG_DEBUG("Dummy B: size C " << c.size() );
337 for (unsigned int j = 0; j < c.size(); ++j) {
338 ATH_MSG_DEBUG("i,c: " << j << " " << c[j].value() );
339 }
340 }
341
342 // dummy_E, D
343
344 const dummy_E* dummyE;
345 ATH_CHECK( evtStore()->retrieve(dummyE, "Dummy_E") );
346 const std::vector<const dummy_D*>& d = dummyE->dummy();
347 ATH_MSG_DEBUG("Dummy E: size D " << d.size() );
348 for (unsigned int i = 0; i < d.size(); ++i) {
349 ATH_MSG_DEBUG("Dummy D: value " << d[i]->value() );
350 }
351
352
353 // Read PileupEventInfo
354
355 // Normal EventInfo
356 const EventInfo * evt = nullptr;
357 ATH_CHECK( evtStore()->retrieve( evt, "McEventInfo" ) );
358 ATH_MSG_DEBUG( "Normal EventInfo" );
359 ATH_MSG_DEBUG( "Event ID: ["
360 << evt->event_ID()->event_number() << ":"
361 << evt->event_ID()->time_stamp() << "] " );
362 ATH_MSG_DEBUG( *(evt->event_ID()) );
363 {
364 std::stringstream stream;
365 stream << "Event type: user type "
366 << evt->event_type()->user_type();
367 for (unsigned int i = 0; i < evt->event_type()->n_mc_event_weights (); ++i)
368 stream<< " weight " << i << ": " << evt->event_type()->mc_event_weight(i);
369 ATH_MSG_DEBUG(stream.str());
370 }
371
372 // Check interactions per crossing
373 ATH_MSG_DEBUG( "Actual interatctions per crossing: "
374 << evt->actualInteractionsPerCrossing() << " and ave: "
375 << evt->averageInteractionsPerCrossing() );
376
377 // We only loop up to Lumi and not nDets since Lumi is set separately
378 for (unsigned int i = 0; i < EventInfo::Lumi; ++i) {
379 ATH_MSG_DEBUG( "Subdet: " << i << " flags "
380 << MSG::hex << evt->eventFlags(EventInfo::EventFlagSubDet(i)) << MSG::dec );
381 EventInfo::EventFlagErrorState error = evt->errorState(EventInfo::EventFlagSubDet(i));
382 if (error == EventInfo::NotSet)
383 ATH_MSG_DEBUG( "Subdet: " << i << " error state: NotSet " );
384 else if (error == EventInfo::Warning)
385 ATH_MSG_DEBUG( "Subdet: " << i << " error state: Warning " );
386 else if (error == EventInfo::Error)
387 ATH_MSG_DEBUG( "Subdet: " << i << " error state: Error " );
388 }
389
390
391 // PileupEventInfo as itself
392 const PileUpEventInfo* pevt = nullptr;
393 ATH_CHECK( evtStore()->retrieve( pevt, "OverlayEvent" ) );
394 ATH_MSG_DEBUG( "PileUpEventInfo" );
395 ATH_MSG_DEBUG( "Event ID: ["
396 << pevt->event_ID()->run_number() << ","
397 << pevt->event_ID()->event_number() << ":"
398 << pevt->event_ID()->time_stamp() << "] " );
399 ATH_MSG_DEBUG( *(pevt->event_ID()) );
400 ATH_MSG_DEBUG( "Event type: user type "
401 << pevt->event_type()->user_type() );
402
403 {
404 std::stringstream stream;
405 stream << "Trigger info: status " << pevt->trigger_info()->statusElement()
406 << " extLvl1ID " << pevt->trigger_info()->extendedLevel1ID()
407 << " lvl1Type " << pevt->trigger_info()->level1TriggerType()
408 << " lvl1Info ";
409 for (unsigned int i = 0; i < pevt->trigger_info()->level1TriggerInfo().size(); ++i) {
410 stream << pevt->trigger_info()->level1TriggerInfo()[i] << " ";
411 }
412 stream << "lvl2Info ";
413 for (unsigned int i = 0; i < pevt->trigger_info()->level2TriggerInfo().size(); ++i) {
414 stream << pevt->trigger_info()->level2TriggerInfo()[i] << " ";
415 }
416 stream << "EventFilterInfo ";
417 for (unsigned int i = 0; i < pevt->trigger_info()->eventFilterInfo().size(); ++i) {
418 stream << pevt->trigger_info()->eventFilterInfo()[i] << " ";
419 }
420 stream << "EventFilterInfo ";
421 for (unsigned int i = 0; i < pevt->trigger_info()->streamTags().size(); ++i) {
422 stream << " i " << i << " name " << pevt->trigger_info()->streamTags()[i].name();
423 stream << " type " << pevt->trigger_info()->streamTags()[i].type();
424 stream << " ObeyLumi " << pevt->trigger_info()->streamTags()[i].obeysLumiblock();
425 }
426 ATH_MSG_DEBUG(stream.str());
427 }
428
429 // Get normal event info as a sub-event info
430 ATH_MSG_DEBUG( "SubEventInfos" );
431 PileUpEventInfo::SubEvent::const_iterator it = pevt->beginSubEvt();
432 PileUpEventInfo::SubEvent::const_iterator end = pevt->endSubEvt();
433 if (it == end) {
434 ATH_MSG_DEBUG( "None found" );
435 }
436 for (; it != end; ++it) {
437 const EventInfo* sevt = (*it).pSubEvt;
438 ATH_MSG_DEBUG( "Time, index "
439 << (*it).time() << " " << (*it).index() );
440 if (sevt) {
441 ATH_MSG_DEBUG( "Event ID: ["
442 << sevt->event_ID()->run_number() << ","
443 << sevt->event_ID()->event_number() << ":"
444 << sevt->event_ID()->time_stamp() << "] " );
445 ATH_MSG_DEBUG( "Event type: user type "
446 << sevt->event_type()->user_type() );
447 ATH_MSG_DEBUG( "Pileup time, index type "
448 << it->time() << " " << it->index() );
449 }
450 else {
451 ATH_MSG_DEBUG( "Subevent is null ptr " );
452 }
453 }
454
455 if (error) return (StatusCode::FAILURE);
456
457 return StatusCode::SUCCESS;
458}
459
461{
462 return StatusCode::SUCCESS;
463}
464
465
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Class definition for AthenaPoolTestA.
Class definition for AthenaPoolTestB.
Class definition for AthenaPoolTestC.
Class definition for AthenaPoolTestD.
Class definition for AthenaPoolTestMatrix.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
This class provides general information about an event.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Class definition for IAthenaPoolTestCollection.
This class provides information about an overlaid event.
This class contains trigger related information.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Simple class with two int's for testing pool i/o from Athena.
Simple class with int,int,float,double for testing pool i/o from Athena.
Simple class with four int's divided among protected/private for testing pool i/o from Athena.
Simple class with HepGeom::Point3D<double> for testing pool i/o from Athena.
~AthenaPoolTestDataReader()
Algorithm destructor.
virtual StatusCode execute()
Algorithm execute once per event.
virtual StatusCode finalize()
Algorithm finalize at end of job.
virtual StatusCode initialize()
Algorithm initialize at begin of job.
AthenaPoolTestDataReader(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor.
std::pair< AthenaPoolTestMapDataLink, float > Deposit
Simple class with various CLHEP classes for testing pool i/o from Athena.
std::vector< std::map< unsigned int, CLHEP::HepMatrix > > matrixMaps_t
EventID * event_ID()
the unique identification of the event.
TriggerInfo * trigger_info()
trigger information (ptr may be NULL)
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
std::string user_type(void) const
Access to user type.
Definition EventType.cxx:94
Interface class for AthenaPoolTest i/o tests with DataVector.
Interface class for AthenaPoolTest i/o tests.
This class provides information about an overlaid event.
SubEvent::iterator endSubEvt()
SubEvent::iterator beginSubEvt()
number_type level1TriggerType() const
get level1 trigger type
const std::vector< number_type > & eventFilterInfo() const
get event filter trigger info
number_type extendedLevel1ID() const
get extended level1 ID
number_type statusElement() const
get status element
const std::vector< number_type > & level1TriggerInfo() const
get level1 trigger info
const std::vector< StreamTag > & streamTags() const
get stream tags
const std::vector< number_type > & level2TriggerInfo() const
get level2 trigger info
test nested vectors - problem seen in root3/4 transition
Definition dummy_A.h:51
const std::vector< dummy_B > & dummy() const
Definition dummy_A.h:55
Test derived class that contains a list of parent classes.
Definition dummy_E.h:42
const std::vector< const dummy_D * > & dummy() const
Definition dummy_E.h:47