BOSS 8.0.0
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/DataObject.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/ISvcLocator.h"
12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/PropertyMgr.h"
14#include "GaudiKernel/RegistryEntry.h"
15#include "GaudiKernel/SmartDataPtr.h"
16
17#include "GaudiKernel/IOpaqueAddress.h"
18
19#include "DstEvent/DstEvent.h"
20#include "EventModel/EventHeader.h"
21#include "EventModel/EventModel.h"
22#include "RootCnvSvc/Dst/DstCnv.h"
23#include "RootCnvSvc/RootAddress.h"
24#include "RootCnvSvc/RootEvtSelector.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 ) : RootEventBaseCnv( classID(), svc ) {
33 // Here we associate this converter with the path on the TDS.
35 // declareObject(EventModel::Dst::Event, objType(), m_rootTreename, m_rootBranchname);
36}
37
38StatusCode DstCnv::TObjectToDataObject( DataObject*& refpObject ) {
39 // fills the TDS object from the persistent one
40 StatusCode sc = StatusCode::SUCCESS;
41
42 MsgStream log( msgSvc(), "DstCnv" );
43 log << MSG::DEBUG << "TObjectToDataObject" << endmsg;
44 /*
45 SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
46 if (!evt) {
47 log << MSG::ERROR << "Failed to retrieve RecEvent" << endmsg;
48 return StatusCode::FAILURE;
49 }
50
51 */
52
53 DstEvent* tdsev = new DstEvent();
54 refpObject = tdsev;
55
56 return sc;
57}
58
59StatusCode DstCnv::initialize() {
60 MsgStream log( msgSvc(), "DstCnv" );
61 log << MSG::DEBUG << "DstCnv::initialize" << endmsg;
62
63 StatusCode status = RootEventBaseCnv::initialize();
64
65 // pass dst converter to the conversion service
66 m_cnvSvc->setDstCnv( this );
67
68 return status;
69}
70
71StatusCode DstCnv::DataObjectToTObject( DataObject* obj, RootAddress* rootaddr ) {
72 // transforms TDS event to Dst event in root format
73 MsgStream log( msgSvc(), "DstCnv" );
74 log << MSG::DEBUG << "DstCnv::DataObjectToTObject" << endmsg;
75
76 // test if already done for this event
77 // zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0))
78 // return StatusCode::SUCCESS;
79 if ( m_common.m_dstEvt != NULL ) return StatusCode::SUCCESS;
80
81 /*
82 SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
83
84 if (!evtTds) {
85 log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endmsg;
86 return StatusCode::FAILURE;
87 }
88 */
89 DstEvent* devtTds = dynamic_cast<DstEvent*>( obj );
90 if ( !devtTds )
91 {
92 log << MSG::ERROR << "Could not downcast to TDS DstEvent" << endmsg;
93 return StatusCode::FAILURE;
94 }
95
96 m_objWrite = new TDstEvent(); // zoujh
97 m_common.m_dstEvt = m_objWrite; // zoujh
98
99 // create branch if not yet done
100 if ( m_branchNrDst < 0 )
101 {
102 // zoujh: m_objWrite = new TDstEvent();
103 StatusCode sc =
104 m_rootInterface->createBranch( rootaddr->getTreename(), "TDstEvent",
105 m_objWrite->ClassName(), &m_objWrite, m_branchNrDst );
106 if ( sc.isFailure() )
107 {
108 log << MSG::ERROR << "Could not create branch TDstEvent" << endmsg;
109 return sc;
110 }
111 }
112
113 // Int_t evtId = evtTds->eventNumber();
114 // Int_t runId = evtTds->runNumber();
115
116 m_objWrite->initialize();
117
118 return StatusCode::SUCCESS;
119}
120#endif
IMessageSvc * msgSvc()
virtual StatusCode initialize()
Definition DstCnv.cxx:59
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
Definition DstCnv.cxx:71
DstCnv(ISvcLocator *svc)
Definition DstCnv.cxx:32
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
Definition DstCnv.cxx:38
Definition of a Root address, derived from IOpaqueAddress.
virtual StatusCode initialize()
RootInterface * m_rootInterface
pointer to the RootInterface
std::string m_rootBranchname
root branchname (may be concatenated of severals)
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)