BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DigiCnv.cxx
Go to the documentation of this file.
1// File and Version Information:
2// Description:
3// DigiCnv is the concrete converter for the Rec branch
4//
5
6#ifndef DigiCnv_CXX
7#define DigiCnv_CXX
8
9#include "GaudiKernel/DataObject.h"
10#include "GaudiKernel/IOpaqueAddress.h"
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/RegistryEntry.h"
13#include "GaudiKernel/SmartDataPtr.h"
14
15#include "EventModel/EventHeader.h"
16#include "EventModel/EventModel.h"
17#include "RawEvent/DigiEvent.h"
18#include "RootCnvSvc/Digi/DigiCnv.h"
19#include "RootCnvSvc/RootAddress.h"
20#include "RootCnvSvc/RootEvtSelector.h"
21// #include "RootCnvSvc/Util.h"
22
23using namespace DataSvcHelpers;
24TDigiEvent* DigiCnv::m_objWrite = 0;
25
26DigiCnv::DigiCnv( ISvcLocator* svc ) : RootEventBaseCnv( classID(), svc ) {
27 // Here we associate this converter with the path on the TDS.
28 m_rootBranchname = "m_fromMc";
29 // declareObject(EventModel::Digi::Event, objType(), m_rootTreename, m_rootBranchname);
30 m_adresses.push_back( &m_fromMc );
31
32 // m_objWrite=0;
33}
34
35StatusCode DigiCnv::initialize() {
36 MsgStream log( msgSvc(), "DigiCnv" );
37 log << MSG::DEBUG << "DigiCnv::initialize" << endmsg;
38
39 StatusCode status = RootEventBaseCnv::initialize();
40
41 // pass dst converter to the conversion service
42 m_cnvSvc->setDigiCnv( this );
43
44 return status;
45}
46
47StatusCode DigiCnv::TObjectToDataObject( DataObject*& refpObject ) {
48 // fills the TDS object from the persistent one
49 StatusCode sc = StatusCode::SUCCESS;
50
51 MsgStream log( msgSvc(), "DigiCnv" );
52 log << MSG::DEBUG << "TObjectToDataObject" << endmsg;
53 /*
54 SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
55 if (!evt) {
56 log << MSG::ERROR << "Failed to retrieve RecEvent" << endmsg;
57 return StatusCode::FAILURE;
58 }
59 */
60 DigiEvent* tdsev = new DigiEvent();
61 refpObject = tdsev;
62
63 tdsev->initialize( m_fromMc );
64
65 return sc;
66}
67
68StatusCode DigiCnv::DataObjectToTObject( DataObject* obj, RootAddress* rootaddr ) {
69 // transforms TDS event to digi event in root format
70 MsgStream log( msgSvc(), "DigiCnv" );
71 log << MSG::DEBUG << "DigiCnv::DataObjectToTObject" << endmsg;
72
73 // test if already done for this event
74 // zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0))
75 // return StatusCode::SUCCESS;
76 if ( m_common.m_recEvt != NULL ) return StatusCode::SUCCESS;
77
78 /*
79 SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
80
81 if (!evtTds) {
82 log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endmsg;
83 return StatusCode::FAILURE;
84 }
85 */
86 DigiEvent* devtTds = dynamic_cast<DigiEvent*>( obj );
87 if ( !devtTds )
88 {
89 log << MSG::ERROR << "Could not downcast to TDS RecEvent" << endmsg;
90 return StatusCode::FAILURE;
91 }
92
93 m_objWrite = new TDigiEvent(); // zoujh
94 m_common.m_recEvt = m_objWrite; // zoujh
95
96 // create branch if not yet done
97 if ( m_branchNr < 0 )
98 {
99 // zoujh: m_objWrite = new TDigiEvent();
100 StatusCode sc =
101 m_rootInterface->createBranch( rootaddr->getTreename(), "TDigiEvent",
102 m_objWrite->ClassName(), &m_objWrite, m_branchNr );
103 if ( sc.isFailure() )
104 {
105 log << MSG::ERROR << "Could not create branch TDigiEvent" << endmsg;
106 return sc;
107 }
108 }
109
110 // Int_t evtId = evtTds->eventNumber();
111 // Int_t runId = evtTds->runNumber();
112
113 Bool_t fromMc = devtTds->fromMc();
114
115 // const bool m_fromMc = fromMc;
116
117#ifdef DEBUG
118 std::cout << "******************************" << std::endl;
119 std::cout << " eveId: " << evtId << std::endl;
120 std::cout << " runId: " << runId << std::endl;
121 std::cout << " fromMc: " << fromMc << std::endl;
122 std::cout << "******************************" << std::endl;
123#endif
124 m_objWrite->initialize( fromMc );
125
126 return StatusCode::SUCCESS;
127}
128#endif
IMessageSvc * msgSvc()
virtual StatusCode initialize()
Definition DigiCnv.cxx:35
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
Definition DigiCnv.cxx:47
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
Definition DigiCnv.cxx:68
DigiCnv(ISvcLocator *svc)
Definition DigiCnv.cxx:26
bool fromMc() const
Retrieve flag of origin.
Definition of a Root address, derived from IOpaqueAddress.
virtual StatusCode initialize()
std::vector< void * > m_adresses
each converter knows the corresponding adresses
int m_branchNr
the branchNr of this converter for writing
RootInterface * m_rootInterface
pointer to the RootInterface
std::string m_rootBranchname
root branchname (may be concatenated of severals)
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)