ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfoCnv_p3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "EventInfo/EventInfo.h"
6#include "EventInfo/EventID.h"
9
14
15static const EventIDCnv_p2 idConv;
18
19
20void EventInfoCnv_p3::persToTrans(const EventInfo_p3* pers, EventInfo* trans, MsgStream &/* log */) const {
21 *trans = EventInfo();
22 std::vector<unsigned int>::const_iterator i= pers->m_AllTheData.begin();
23
24 int vers = (*i); ++i;
25 // std::cout<<"EventInfo vers EventID: "<<(vers&0x003f)<<"\t EventType: "<< ((vers>>6)&0x003f)<<"\tTriggerInfo: "<<((vers>>12)&0x003f) <<"\t Local vars: "<<(vers>>18)<<std::endl;
26
27 bool bugcompat = (vers&(1<<24)) == 0;
28
29 EventID *t = new EventID();
30 idConv.persToTrans(i, t);
31 trans->setEventID (t);
32
33 EventType *et = new EventType();
34 typeConv.persToTrans(i, et, (vers>>6)&0x003f, bugcompat );
35 trans->setEventType (et);
36
37 if ((vers>>12)&0x003f){ // if there is trigger info
38 TriggerInfo *ti = new TriggerInfo();
39 trigInfoCnv.persToTrans(i, ti, bugcompat);
40 trans->setTriggerInfo (ti);
41 }
42 else
43 *trans->m_trigger_info = TriggerInfo();
44
45 if (i != pers->m_AllTheData.end()) {
46 // must reset event flags, in case we're reusing the EventInfo object
47 trans->m_event_flags.clear();
48
49 unsigned int n = pers->m_AllTheData.size() - (i - pers->m_AllTheData.begin());
50 trans->m_event_flags.reserve(n);
51 }
52 while(i!=pers->m_AllTheData.end()){ // there is still some data: m_event_flags
53 trans->m_event_flags.push_back((*i)); ++i;
54 }
55 // std::cout<<"persToTrans of EventInfo \t"<<trans->m_event_flags.size()<<std::endl;
56
57}
58
59void EventInfoCnv_p3::transToPers(const EventInfo* trans, EventInfo_p3* pers, MsgStream &/* log */) const
60{
61
62 // std::cout<<"transToPers of EventInfo ..."<<std::endl;
63 pers->m_AllTheData.reserve(34);
64
65 // For versioning of the different elements, we use 6 bits for
66 // each part:
67 // the first number (LSB) is version of EventIDCnv
68 // the second number is EventType version
69 // the third is TriggerInfo version
70 // the fourth is version of local variables ( now just m_event_flags)
71 // version number == 0 means that part is not saved at all
72 // bit 24 is set if the vector packing bug is fixed.
73
74 int versionToWrite = 2 | (3<<6) | (3<<12) | (1<<18) | (1<<24);
75 pers->m_AllTheData.push_back(versionToWrite);
76 idConv.transToPers(trans->event_ID(), pers->m_AllTheData);
77 typeConv.transToPers(trans->event_type(), pers->m_AllTheData);
78 //
79 if( trans->m_trigger_info ) { // this should always be there !
80 trigInfoCnv.transToPers(trans->trigger_info(), pers->m_AllTheData);
81 }else{
82 pers->m_AllTheData[0]&=0xfffc0fff; // sets TriggerInfo version to 0
83 }
84
85 // Don't write out event flags if they are all == 0
86 if (trans->m_event_flags.size()) {
87 bool copy = false;
88 for (unsigned int i = 0; i < trans->m_event_flags.size(); ++i) {
89 // std::cout << "event flag: \t" << std::hex << trans->m_event_flags[i] << std::dec << std::endl;
90 if (trans->m_event_flags[i]) { copy = true; break; }
91 }
92 if (copy) {
93 std::copy (trans->m_event_flags.begin(), trans->m_event_flags.end(), std::back_inserter (pers->m_AllTheData));
94 // std::cout << "event flags written: \t" << trans->m_event_flags.size() << std::endl;
95 }
96 }
97 // std::cout << "transToPers of EventInfo out size \t" << pers->m_AllTheData.size() << std::endl;
98}
99
100
101
102
103// work around the default constructor of EventInfo allocating memory
104EventInfo* EventInfoCnv_p3::createTransientConst ( const EventInfo_p3* persObj, MsgStream &log) const {
105 std::unique_ptr<EventInfo> trans( new EventInfo() );
106 persToTrans(persObj, trans.get(), log);
107 return(trans.release());
108}
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
static const TriggerInfoCnv_p1 trigInfoCnv
static const EventTypeCnv_p1 typeConv
static const EventIDCnv_p1 idConv
This class provides general information about an event.
This class contains trigger related information.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition EventID.h:35
virtual EventInfo * createTransientConst(const EventInfo_p3 *persObj, MsgStream &log) const override
virtual void persToTrans(const EventInfo_p3 *persObj, EventInfo *transObj, MsgStream &log) const override
virtual void transToPers(const EventInfo *transObj, EventInfo_p3 *persObj, MsgStream &log) const override
std::vector< unsigned int > m_AllTheData
void setEventID(owner< EventID * > pid)
Definition EventInfo.cxx:82
void setEventType(owner< EventType * >)
Definition EventInfo.cxx:90
std::unique_ptr< TriggerInfo > m_trigger_info
void setTriggerInfo(owner< TriggerInfo * > pTrig)
Add TriggerInfo to existing object.
Definition EventInfo.cxx:98
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::vector< unsigned int > m_event_flags
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition EventType.h:92
This class contains trigger related information.
Definition TriggerInfo.h:77
Extra patterns decribing particle interation process.