CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
RootCnvSvc-04-01-15/src/EvtRec/EvtRecCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2
3#include "EventModel/EventModel.h"
4#include "EvtRecEvent/EvtRecObject.h"
5#include "RootEventData/TEvtRecObject.h"
6
7#include "RootCnvSvc/RootAddress.h"
8#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
9
10TEvtRecObject* EvtRecCnv::m_objWrite = 0;
11
12EvtRecCnv::EvtRecCnv(ISvcLocator* svc)
13 : RootEventBaseCnv(classID(), svc)
14{
15 m_rootBranchname = "";
16}
17
18StatusCode EvtRecCnv::initialize() {
19 StatusCode status = RootEventBaseCnv::initialize();
20
22
23 return status;
24}
25
26StatusCode EvtRecCnv::TObjectToDataObject(DataObject*& refpObject) {
27 MsgStream log(msgSvc(), "EvtRecCnv");
28 log << MSG::DEBUG << "EvtRecCnv::TObjectToDataObject" << endreq;
29
30 // create the TDS location for the EvtRecObject
31 EvtRecObject* evtRecObject = new EvtRecObject;
32 refpObject = evtRecObject;
33
34 return StatusCode::SUCCESS;
35}
36
37StatusCode EvtRecCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
38
39 MsgStream log(msgSvc(), "EvtRecCnv");
40 log << MSG::DEBUG << "EvtRecCnv::DataObjectToTObject" << endreq;
41
42 if ( m_common.m_evtRecObject != NULL ) return StatusCode::SUCCESS;
43
44 EvtRecObject* evtRecObject = dynamic_cast<EvtRecObject*> (obj);
45 if ( ! evtRecObject ) {
46 log << MSG::ERROR << "Could not downcast to EvtRecObject" << endreq;
47 return StatusCode::FAILURE;
48 }
49
50 m_objWrite = new TEvtRecObject();
51 m_common.m_evtRecObject = m_objWrite;
52
53 // create branch if not yet done
54 if ( m_branchNrEvtRec < 0 ) {
55 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TEvtRecObject",m_objWrite->ClassName(),&m_objWrite,m_branchNrEvtRec);
56
57 if ( sc.isFailure() ) {
58 cout<<"Could not create branch TEvtRecObject"<<endl;
59 log << MSG::ERROR << "Could not create branch TEvtRecObject" << endreq;
60 return sc;
61 }
62 }
63
64 m_objWrite->initialize();
65
66 return StatusCode::SUCCESS;
67}
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition of a Root address, derived from IOpaqueAddress.
RootInterface * m_rootInterface
pointer to the RootInterface
virtual StatusCode createBranch(const std::string &tree, const std::string &branch, const char *classname, void *addr, int &branchnr)
create a branch in this tree