BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
RecTrackCnv.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 RecTrackCnv_CXX
7#define RecTrackCnv_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#include "McTruth/DecayMode.h"
27
28using namespace DataSvcHelpers;
29
30// Instantiation of a static factory class used by clients to create
31// instances of this service
32//static CnvFactory<RecTrackCnv> s_factory;
33//const ICnvFactory& RecTrackCnvFactory = s_factory;
34
35TRecTrackEvent* RecTrackCnv::m_objWrite = 0;
36
37RecTrackCnv::RecTrackCnv(ISvcLocator* svc)
38: RootEventBaseCnv(classID(), svc)
39{
40
41 // Here we associate this converter with the path on the TDS.
43 //declareObject(EventModel::Recon::Event, objType(), m_rootTreename, m_rootBranchname); //Dst-->Recon liangyt -->Rec
44 //m_objWrite=0;
45}
46
48 MsgStream log(msgSvc(), "RecTrackCnv");
49 log << MSG::DEBUG << "RecTrackCnv::initialize"<< endreq;
50
51 StatusCode status = RootEventBaseCnv::initialize();
52
53 //pass dst converter to the conversion service
55
56 return status;
57
58}
59
60StatusCode RecTrackCnv::TObjectToDataObject(DataObject*& refpObject) {
61 // fills the TDS object from the persistent one
62 StatusCode sc=StatusCode::SUCCESS;
63
64 MsgStream log(msgSvc(), "RecTrackCnv");
65 log << MSG::DEBUG << "TObjectToDataObject" << endreq;
66 /*
67 SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
68 if (!evt) {
69 log << MSG::ERROR << "Failed to retrieve RecEvent" << endreq;
70 return StatusCode::FAILURE;
71 }
72
73 */
74
75 ReconEvent * tdsev = new ReconEvent();
76 refpObject = tdsev;
77 //sc =m_eds ->registerObject(EventModel::EventHeader, evt);
78
79
80 return sc;
81}
82
83StatusCode RecTrackCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
84 // transforms TDS event to Dst event in root format
85 MsgStream log(msgSvc(), "RecTrackCnv");
86 log << MSG::DEBUG << "RecTrackCnv::DataObjectToTObject" << endreq;
87
88 // test if already done for this event
89 //zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0)) return StatusCode::SUCCESS;
90
91 if (m_common.m_rectrackEvt != NULL) return StatusCode::SUCCESS;
92/*
93 SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
94
95 if (!evtTds) {
96 log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endreq;
97 return StatusCode::FAILURE;
98 }
99*/
100 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (obj);
101 if (!devtTds) {
102 log << MSG::ERROR << "Could not downcast to TDS Event" << endreq;
103 return StatusCode::FAILURE;
104 }
105
106 m_objWrite = new TRecTrackEvent(); //zoujh
107 m_common.m_rectrackEvt = m_objWrite; //zoujh
108
109 // create branch if not yet done
110 if (m_branchNrRecon<0) { ///////////liangyt
111 //zoujh: m_objWrite = new TDstEvent();
112 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TRecEvent",m_objWrite->ClassName(),&m_objWrite,m_branchNrRecon);
113
114
115 if (sc.isFailure()) {
116 cout<<"Could not create branch TRecEvent"<<endl;
117 log << MSG::ERROR << "Could not create branch TRecEvent" << endreq;
118 return sc;
119 }
120 }
121
122 //Int_t evtId = evtTds->eventNumber();
123 //Int_t runId = evtTds->runNumber();
124
125
126 m_objWrite->initialize();
127
128 return StatusCode::SUCCESS;
129}
130#endif
131
132
133
134
135
136
137
138
139
140
IMessageSvc * msgSvc()
#define NULL
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
Definition: RecTrackCnv.cxx:60
RecTrackCnv(ISvcLocator *svc)
Definition: RecTrackCnv.cxx:37
virtual StatusCode initialize()
Definition: RecTrackCnv.cxx:47
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
Definition: RecTrackCnv.cxx:83
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
std::string getTreename() const
Definition: RootAddress.h:27
void setRecTrackCnv(RecTrackCnv *rectrackcnv)
Definition: RootCnvSvc.h:167
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
static TRecTrackEvent * m_rectrackEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:200