BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtHeaderCnv.cxx
Go to the documentation of this file.
1// File and Version Information:
2// Description:
3// EvtHeaderCnv is the concrete converter for the Rec branch
4//
5
6#ifndef EvtHeaderCnv_CXX
7#define EvtHeaderCnv_CXX
8
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/DataObject.h"
11#include "GaudiKernel/SmartDataPtr.h"
12#include "GaudiKernel/RegistryEntry.h"
13#include "GaudiKernel/IDataProviderSvc.h"
14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/PropertyMgr.h"
16
17#include "GaudiKernel/IOpaqueAddress.h"
18
25//#include "RootCnvSvc/Util.h"
26
27using namespace DataSvcHelpers;
28
29TEvtHeader* EvtHeaderCnv::m_objWrite = 0;
30
32: RootEventBaseCnv(classID(), svc)
33{
34 // Here we associate this converter with the path on the TDS.
35 MsgStream log(msgSvc(), "EvtHeaderCnv");
36 log << MSG::DEBUG << " constructor of EvtHeaderCnv "<<endreq;
37 //m_rootTreename ="Event";
38 m_rootBranchname ="m_runId:m_eventId:m_time:m_eventTag:m_flag1:m_flag2:m_etsT1:m_etsT2";
39 //declareObject(EventModel::Dst::Event, objType(), m_rootTreename, m_rootBranchname);
40 m_adresses.push_back(&m_runId);
41 m_adresses.push_back(&m_eventId);
42 m_adresses.push_back(&m_time);
43 m_adresses.push_back(&m_eventTag);
44 m_adresses.push_back(&m_flag1);
45 m_adresses.push_back(&m_flag2);
46 m_adresses.push_back(&m_etsT1);
47 m_adresses.push_back(&m_etsT2);
48}
49
50StatusCode EvtHeaderCnv::TObjectToDataObject(DataObject*& refpObject) {
51 // fills the TDS object from the persistent one
52 StatusCode sc=StatusCode::SUCCESS;
53
54 MsgStream log(msgSvc(), "EvtHeaderCnv");
55 log << MSG::DEBUG << "TObjectToDataObject" << endreq;
56
57
58
60 evt->setEventNumber(m_eventId);
61 evt->setRunNumber(m_runId);
62 evt->setTime(m_time);
63 evt->setEventTag(m_eventTag);
64 evt->setFlag1( m_flag1 );
65 evt->setFlag2( m_flag2 );
66 evt->setEtsT1( m_etsT1);
67 evt->setEtsT2( m_etsT2);
68
69 refpObject = evt;
70
71 log << MSG::DEBUG << "TObjectToDataObject eventid = "<<m_eventId<<" "<<m_runId
72 << " "<<std::hex<<"0x"<<m_eventTag<<std::dec<<endreq;
73 // cout << MSG::DEBUG << "TObjectToDataObject eventid = "<<m_eventId<<" "<<m_runId
74 // << " "<<std::hex<<"0x"<<m_eventTag<<std::dec<<endl;
75
76 //char dummy;
77 //cin>>dummy;
78
79 return sc;
80}
81
83 MsgStream log(msgSvc(), "EvtHeaderCnv");
84 log << MSG::DEBUG << "EvtHeaderCnv::initialize"<< endreq;
85
86 StatusCode status = RootEventBaseCnv::initialize();
87
88 //pass dst converter to the conversion service
90
91 return status;
92
93}
94
95StatusCode EvtHeaderCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
96 // transforms TDS event to Dst event in root format
97 MsgStream log(msgSvc(), "EvtHeaderCnv");
98 log << MSG::DEBUG << "EvtHeaderCnv::DataObjectToTObject" << endreq;
99
100
101 Event::EventHeader * devtTds=dynamic_cast<Event::EventHeader *> (obj);
102 if (!devtTds) {
103 log << MSG::ERROR << "Could not downcast to TDS EventHeader" << endreq;
104 return StatusCode::FAILURE;
105 }
106
107 Int_t evtId = devtTds->eventNumber();
108 Int_t runId = devtTds->runNumber();
109 UInt_t time = devtTds->time();
110 UInt_t evtTag=devtTds->eventTag();
111 UInt_t flag1 = devtTds->flag1();
112 UInt_t flag2 = devtTds->flag2();
113 ULong_t etsT1 = devtTds->etsT1();
114 ULong_t etsT2 = devtTds->etsT2();
115
116 if(evtId == -1){
117 //wrong evh
118 return StatusCode::SUCCESS;
119 }
120
121
122 m_objWrite = new TEvtHeader(); //zoujh
123 m_common.m_EvtHeader = m_objWrite; //zoujh
124
125 log << MSG::DEBUG << "EvtHeaderCnv::DataObjectToTObject tree name: " <<rootaddr->getTreename()<<endreq;
126 // create branch if not yet done
127 if (m_branchNrEvtHeader<0) {
128 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TEvtHeader",m_objWrite->ClassName(),&m_objWrite,m_branchNrEvtHeader);
129 //StatusCode sc = m_rootInterface->createBranch("Event","TEvtHeader",m_objWrite->ClassName(),&m_objWrite,m_branchNrEvtHeader);
130 if (sc.isFailure()) {
131 delete m_objWrite;
132 log << MSG::ERROR << "Could not create branch TEvtHeader" << endreq;
133 return StatusCode::SUCCESS;
134 //return sc;
135 }
136 }
137
138 m_eventId = evtId;
139 m_runId = runId;
140 m_time = time;
141 m_eventTag= evtTag;
142 m_flag1 = flag1;
143 m_flag2 = flag2;
144 m_etsT1 = etsT1;
145 m_etsT2 = etsT2;
146 log << MSG::DEBUG << "EvtHeaderCnv::DataObjectToTObject eventid = "<<evtId<<" "<<runId <<" "<<std::hex<<evtTag<<std::dec<< endreq;
147
148 m_objWrite->initialize(evtId, runId, evtTag);
149 m_objWrite->setTime(time);
150 m_objWrite->setFlag1( flag1 );
151 m_objWrite->setFlag2( flag2 );
152 m_objWrite->setEtsT1( etsT1 );
153 m_objWrite->setEtsT2( etsT2 );
154
155 return StatusCode::SUCCESS;
156}
157#endif
158
Double_t time
IMessageSvc * msgSvc()
int eventNumber() const
Retrieve event number.
Definition EventHeader.h:37
void setRunNumber(int value)
Update run number.
Definition EventHeader.h:44
void setTime(int value)
Definition EventHeader.h:48
void setFlag1(unsigned int value)
Update flags.
Definition EventHeader.h:59
int runNumber() const
Retrieve run number.
Definition EventHeader.h:42
unsigned long etsT2()
Definition EventHeader.h:65
unsigned int flag2()
Definition EventHeader.h:57
unsigned int flag1()
Retrieve flags.
Definition EventHeader.h:56
void setEventNumber(int value)
Update event number.
Definition EventHeader.h:39
unsigned int eventTag()
Retrieve EventTag.
Definition EventHeader.h:51
void setFlag2(unsigned int value)
Definition EventHeader.h:60
unsigned int time() const
Definition EventHeader.h:46
void setEtsT2(unsigned long value)
Definition EventHeader.h:71
void setEtsT1(unsigned long value)
Update ETS.
Definition EventHeader.h:69
unsigned long etsT1()
Retrieve ETS.
Definition EventHeader.h:63
void setEventTag(unsigned int value)
Update EventTag.
Definition EventHeader.h:53
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
virtual StatusCode initialize()
EvtHeaderCnv(ISvcLocator *svc)
Definition of a Root address, derived from IOpaqueAddress.
Definition RootAddress.h:21
std::string getTreename() const
Definition RootAddress.h:27
void setEvtHeaderCnv(EvtHeaderCnv *evtheadercnv)
Definition RootCnvSvc.h:168
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
virtual StatusCode initialize()
RootInterface * m_rootInterface
pointer to the RootInterface
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createBranch(const std::string &tree, const std::string &branch, const char *classname, void *addr, int &branchnr)
create a branch in this tree
void setFlag2(int value)
Definition TEvtHeader.h:35
void initialize(Int_t Id, Int_t runId, UInt_t evenTag)
void setEtsT1(unsigned long value)
Definition TEvtHeader.h:40
void setTime(int value)
Definition TEvtHeader.h:30
void setEtsT2(unsigned long value)
Definition TEvtHeader.h:41
void setFlag1(int value)
Definition TEvtHeader.h:34
static TEvtHeader * m_EvtHeader
Definition commonData.h:113