BOSS 7.0.3
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
19#include "EventModel/EventHeader.h"
20#include "EventModel/EventModel.h"
21#include "RootEventData/TEvtHeader.h"
22#include "RootCnvSvc/EvtHeaderCnv.h"
23#include "RootCnvSvc/RootEvtSelector.h"
24#include "RootCnvSvc/RootAddress.h"
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";
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}
47
48StatusCode EvtHeaderCnv::TObjectToDataObject(DataObject*& refpObject) {
49 // fills the TDS object from the persistent one
50 StatusCode sc=StatusCode::SUCCESS;
51
52 MsgStream log(msgSvc(), "EvtHeaderCnv");
53 log << MSG::DEBUG << "TObjectToDataObject" << endreq;
54
55
56
58 evt->setEventNumber(m_eventId);
59 evt->setRunNumber(m_runId);
60 evt->setTime(m_time);
61 evt->setEventTag(m_eventTag);
62 evt->setFlag1( m_flag1 );
63 evt->setFlag2( m_flag2 );
64
65 refpObject = evt;
66
67 log << MSG::DEBUG << "TObjectToDataObject eventid = "<<m_eventId<<" "<<m_runId
68 << " "<<std::hex<<"0x"<<m_eventTag<<std::dec<<endreq;
69 // cout << MSG::DEBUG << "TObjectToDataObject eventid = "<<m_eventId<<" "<<m_runId
70 // << " "<<std::hex<<"0x"<<m_eventTag<<std::dec<<endl;
71
72 //char dummy;
73 //cin>>dummy;
74
75 return sc;
76}
77
79 MsgStream log(msgSvc(), "EvtHeaderCnv");
80 log << MSG::DEBUG << "EvtHeaderCnv::initialize"<< endreq;
81
82 StatusCode status = RootEventBaseCnv::initialize();
83
84 //pass dst converter to the conversion service
86
87 return status;
88
89}
90
91StatusCode EvtHeaderCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
92 // transforms TDS event to Dst event in root format
93 MsgStream log(msgSvc(), "EvtHeaderCnv");
94 log << MSG::DEBUG << "EvtHeaderCnv::DataObjectToTObject" << endreq;
95
96
97 Event::EventHeader * devtTds=dynamic_cast<Event::EventHeader *> (obj);
98 if (!devtTds) {
99 log << MSG::ERROR << "Could not downcast to TDS EventHeader" << endreq;
100 return StatusCode::FAILURE;
101 }
102
103 Int_t evtId = devtTds->eventNumber();
104 Int_t runId = devtTds->runNumber();
105 UInt_t time = devtTds->time();
106 UInt_t evtTag=devtTds->eventTag();
107 UInt_t flag1 = devtTds->flag1();
108 UInt_t flag2 = devtTds->flag2();
109
110 if(evtId == -1){
111 //wrong evh
112 return StatusCode::SUCCESS;
113 }
114
115
116 m_objWrite = new TEvtHeader(); //zoujh
117 m_common.m_EvtHeader = m_objWrite; //zoujh
118
119 log << MSG::DEBUG << "EvtHeaderCnv::DataObjectToTObject tree name: " <<rootaddr->getTreename()<<endreq;
120 // create branch if not yet done
121 if (m_branchNrEvtHeader<0) {
122 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TEvtHeader",m_objWrite->ClassName(),&m_objWrite,m_branchNrEvtHeader);
123 //StatusCode sc = m_rootInterface->createBranch("Event","TEvtHeader",m_objWrite->ClassName(),&m_objWrite,m_branchNrEvtHeader);
124 if (sc.isFailure()) {
125 delete m_objWrite;
126 log << MSG::ERROR << "Could not create branch TEvtHeader" << endreq;
127 return StatusCode::SUCCESS;
128 //return sc;
129 }
130 }
131
132 m_eventId = evtId;
133 m_runId = runId;
134 m_time = time;
135 m_eventTag= evtTag;
136 m_flag1 = flag1;
137 m_flag2 = flag2;
138 log << MSG::DEBUG << "EvtHeaderCnv::DataObjectToTObject eventid = "<<evtId<<" "<<runId <<" "<<std::hex<<evtTag<<std::dec<< endreq;
139
140 m_objWrite->initialize(evtId, runId, evtTag);
141 m_objWrite->setTime(time);
142 m_objWrite->setFlag1( flag1 );
143 m_objWrite->setFlag2( flag2 );
144
145 return StatusCode::SUCCESS;
146}
147#endif
148
Double_t time
void setEventTag(unsigned int value)
Update EventTag.
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.
virtual StatusCode initialize()
std::vector< void * > m_adresses
each converter knows the corresponding adresses
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 initialize(Int_t Id, Int_t runId, UInt_t evenTag)
Definition: TEvtHeader.cxx:23