BOSS 8.0.0
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/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 "EventModel/EventHeader.h"
20#include "EventModel/EventModel.h"
21#include "ReconEvent/ReconEvent.h"
22#include "RootCnvSvc/Rec/RecTrackCnv.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
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 ) : RootEventBaseCnv( classID(), svc ) {
38
39 // Here we associate this converter with the path on the TDS.
41 // declareObject(EventModel::Recon::Event, objType(), m_rootTreename, m_rootBranchname);
42 // //Dst-->Recon liangyt -->Rec m_objWrite=0;
43}
44
46 MsgStream log( msgSvc(), "RecTrackCnv" );
47 log << MSG::DEBUG << "RecTrackCnv::initialize" << endmsg;
48
49 StatusCode status = RootEventBaseCnv::initialize();
50
51 // pass dst converter to the conversion service
52 m_cnvSvc->setRecTrackCnv( this );
53
54 return status;
55}
56
57StatusCode RecTrackCnv::TObjectToDataObject( DataObject*& refpObject ) {
58 // fills the TDS object from the persistent one
59 StatusCode sc = StatusCode::SUCCESS;
60
61 MsgStream log( msgSvc(), "RecTrackCnv" );
62 log << MSG::DEBUG << "TObjectToDataObject" << endmsg;
63 /*
64 SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
65 if (!evt) {
66 log << MSG::ERROR << "Failed to retrieve RecEvent" << endmsg;
67 return StatusCode::FAILURE;
68 }
69
70 */
71
72 ReconEvent* tdsev = new ReconEvent();
73 refpObject = tdsev;
74 // sc =m_eds ->registerObject(EventModel::EventHeader, evt);
75
76 return sc;
77}
78
79StatusCode RecTrackCnv::DataObjectToTObject( DataObject* obj, RootAddress* rootaddr ) {
80 // transforms TDS event to Dst event in root format
81 MsgStream log( msgSvc(), "RecTrackCnv" );
82 log << MSG::DEBUG << "RecTrackCnv::DataObjectToTObject" << endmsg;
83
84 // test if already done for this event
85 // zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0))
86 // return StatusCode::SUCCESS;
87
88 if ( m_common.m_rectrackEvt != NULL ) return StatusCode::SUCCESS;
89 /*
90 SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
91
92 if (!evtTds) {
93 log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endmsg;
94 return StatusCode::FAILURE;
95 }
96 */
97 ReconEvent* devtTds = dynamic_cast<ReconEvent*>( obj );
98 if ( !devtTds )
99 {
100 log << MSG::ERROR << "Could not downcast to TDS Event" << endmsg;
101 return StatusCode::FAILURE;
102 }
103
104 m_objWrite = new TRecTrackEvent(); // zoujh
105 m_common.m_rectrackEvt = m_objWrite; // zoujh
106
107 // create branch if not yet done
108 if ( m_branchNrRecon < 0 )
109 { ///////////liangyt
110 // zoujh: m_objWrite = new TDstEvent();
111 StatusCode sc =
112 m_rootInterface->createBranch( rootaddr->getTreename(), "TRecEvent",
113 m_objWrite->ClassName(), &m_objWrite, m_branchNrRecon );
114
115 if ( sc.isFailure() )
116 {
117 cout << "Could not create branch TRecEvent" << endl;
118 log << MSG::ERROR << "Could not create branch TRecEvent" << endmsg;
119 return sc;
120 }
121 }
122
123 // Int_t evtId = evtTds->eventNumber();
124 // Int_t runId = evtTds->runNumber();
125
126 m_objWrite->initialize();
127
128 return StatusCode::SUCCESS;
129}
130#endif
IMessageSvc * msgSvc()
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
RecTrackCnv(ISvcLocator *svc)
virtual StatusCode initialize()
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
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)