BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
DstCnv.cxx
Go to the documentation of this file.
1// File and Version Information:
2// Description:
3// DstCnv is the concrete converter for the Rec branch
4//
5
6#ifndef DstCnv_CXX
7#define DstCnv_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
20#include "DstEvent/DstEvent.h"
25//#include "RootCnvSvc/Util.h"
26#include "McTruth/DecayMode.h"
27
28using namespace DataSvcHelpers;
29
30TDstEvent* DstCnv::m_objWrite = 0;
31
32DstCnv::DstCnv(ISvcLocator* svc)
33: RootEventBaseCnv(classID(), svc)
34{
35 // Here we associate this converter with the path on the TDS.
37 //declareObject(EventModel::Dst::Event, objType(), m_rootTreename, m_rootBranchname);
38}
39
40StatusCode DstCnv::TObjectToDataObject(DataObject*& refpObject) {
41 // fills the TDS object from the persistent one
42 StatusCode sc=StatusCode::SUCCESS;
43
44 MsgStream log(msgSvc(), "DstCnv");
45 log << MSG::DEBUG << "TObjectToDataObject" << endreq;
46 /*
47 SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
48 if (!evt) {
49 log << MSG::ERROR << "Failed to retrieve RecEvent" << endreq;
50 return StatusCode::FAILURE;
51 }
52
53 */
54
55
56 DstEvent * tdsev = new DstEvent();
57 refpObject = tdsev;
58
59
60 return sc;
61}
62
63StatusCode DstCnv::initialize() {
64 MsgStream log(msgSvc(), "DstCnv");
65 log << MSG::DEBUG << "DstCnv::initialize"<< endreq;
66
67 StatusCode status = RootEventBaseCnv::initialize();
68
69 //pass dst converter to the conversion service
70 m_cnvSvc->setDstCnv(this);
71
72 return status;
73
74}
75
76StatusCode DstCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
77 // transforms TDS event to Dst event in root format
78 MsgStream log(msgSvc(), "DstCnv");
79 log << MSG::DEBUG << "DstCnv::DataObjectToTObject" << endreq;
80
81 // test if already done for this event
82 //zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0)) return StatusCode::SUCCESS;
83 if (m_common.m_dstEvt != NULL) return StatusCode::SUCCESS;
84
85/*
86 SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
87
88 if (!evtTds) {
89 log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endreq;
90 return StatusCode::FAILURE;
91 }
92 */
93 DstEvent * devtTds=dynamic_cast<DstEvent *> (obj);
94 if (!devtTds) {
95 log << MSG::ERROR << "Could not downcast to TDS DstEvent" << endreq;
96 return StatusCode::FAILURE;
97 }
98
99 m_objWrite = new TDstEvent(); //zoujh
100 m_common.m_dstEvt = m_objWrite; //zoujh
101
102 // create branch if not yet done
103 if (m_branchNrDst<0) {
104 //zoujh: m_objWrite = new TDstEvent();
105 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TDstEvent",m_objWrite->ClassName(),&m_objWrite,m_branchNrDst);
106 if (sc.isFailure()) {
107 log << MSG::ERROR << "Could not create branch TDstEvent" << endreq;
108 return sc;
109 }
110 }
111
112// Int_t evtId = evtTds->eventNumber();
113// Int_t runId = evtTds->runNumber();
114
115
116 m_objWrite->initialize();
117
118 return StatusCode::SUCCESS;
119}
120#endif
121
122
123
124
125
126
127
128
129
130
IMessageSvc * msgSvc()
#define NULL
virtual StatusCode initialize()
Definition DstCnv.cxx:63
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
Definition DstCnv.cxx:76
DstCnv(ISvcLocator *svc)
Definition DstCnv.cxx:32
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
Definition DstCnv.cxx:40
Definition of a Root address, derived from IOpaqueAddress.
Definition RootAddress.h:21
std::string getTreename() const
Definition RootAddress.h:27
void setDstCnv(DstCnv *dstcnv)
Definition RootCnvSvc.h:162
Base class for all Root Converters.
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 initialize()
static TDstEvent * m_dstEvt
Provide access to the ROOT event pointers.
Definition commonData.h:140