BOSS 7.0.5
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/MsgStream.h"
10#include "GaudiKernel/DataObject.h"
11#include "GaudiKernel/SmartDataPtr.h"
12#include "GaudiKernel/RegistryEntry.h"
13#include "GaudiKernel/IOpaqueAddress.h"
14
15#include "EventModel/EventHeader.h"
16#include "RawEvent/DigiEvent.h"
17#include "EventModel/EventModel.h"
18#include "RootCnvSvc/Digi/DigiCnv.h"
19#include "RootCnvSvc/RootEvtSelector.h"
20#include "RootCnvSvc/RootAddress.h"
21#include "RootCnvSvc/Util.h"
22
23using namespace DataSvcHelpers;
24TDigiEvent* DigiCnv::m_objWrite = 0;
25
26DigiCnv::DigiCnv(ISvcLocator* svc)
27: RootEventBaseCnv(classID(), svc)
28{
29 // Here we associate this converter with the path on the TDS.
30 m_rootBranchname ="m_fromMc";
31 //declareObject(EventModel::Digi::Event, objType(), m_rootTreename, m_rootBranchname);
32 m_adresses.push_back(&m_fromMc);
33
34 //m_objWrite=0;
35
36}
37
38StatusCode DigiCnv::initialize() {
39 MsgStream log(msgSvc(), "DigiCnv");
40 log << MSG::DEBUG << "DigiCnv::initialize"<< endreq;
41
42 StatusCode status = RootEventBaseCnv::initialize();
43
44 //pass dst converter to the conversion service
45 m_cnvSvc->setDigiCnv(this);
46
47 return status;
48
49}
50
51StatusCode DigiCnv::TObjectToDataObject(DataObject*& refpObject) {
52 // fills the TDS object from the persistent one
53 StatusCode sc=StatusCode::SUCCESS;
54
55 MsgStream log(msgSvc(), "DigiCnv");
56 log << MSG::DEBUG << "TObjectToDataObject" << endreq;
57/*
58 SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
59 if (!evt) {
60 log << MSG::ERROR << "Failed to retrieve RecEvent" << endreq;
61 return StatusCode::FAILURE;
62 }
63*/
64 DigiEvent * tdsev = new DigiEvent();
65 refpObject = tdsev;
66
67 tdsev->initialize(m_fromMc);
68
69 return sc;
70}
71
72StatusCode DigiCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
73 // transforms TDS event to digi event in root format
74 MsgStream log(msgSvc(), "DigiCnv");
75 log << MSG::DEBUG << "DigiCnv::DataObjectToTObject" << endreq;
76
77 // test if already done for this event
78 //zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0)) return StatusCode::SUCCESS;
79 if (m_common.m_recEvt != 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" << endreq;
86 return StatusCode::FAILURE;
87 }
88 */
89 DigiEvent * devtTds=dynamic_cast<DigiEvent *> (obj);
90 if (!devtTds) {
91 log << MSG::ERROR << "Could not downcast to TDS RecEvent" << endreq;
92 return StatusCode::FAILURE;
93 }
94
95 m_objWrite = new TDigiEvent(); //zoujh
96 m_common.m_recEvt = m_objWrite; //zoujh
97
98 // create branch if not yet done
99 if (m_branchNr<0) {
100 //zoujh: m_objWrite = new TDigiEvent();
101 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TDigiEvent",m_objWrite->ClassName(),&m_objWrite,m_branchNr);
102 if (sc.isFailure()) {
103 log << MSG::ERROR << "Could not create branch TDigiEvent" << endreq;
104 return sc;
105 }
106 }
107
108 //Int_t evtId = evtTds->eventNumber();
109 //Int_t runId = evtTds->runNumber();
110
111 Bool_t fromMc = devtTds->fromMc();
112
113 // const bool m_fromMc = fromMc;
114
115#ifdef DEBUG
116 std::cout<<"******************************"<<std::endl;
117 std::cout<<" eveId: "<<evtId<<std::endl;
118 std::cout<<" runId: "<<runId<<std::endl;
119 std::cout<<" fromMc: "<<fromMc<<std::endl;
120 std::cout<<"******************************"<<std::endl;
121#endif
122 m_objWrite->initialize(fromMc);
123
124 return StatusCode::SUCCESS;
125}
126#endif
127
128
129
130
131
132
133
134
135
136
virtual StatusCode initialize()
Definition: DigiCnv.cxx:38
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
Definition: DigiCnv.cxx:51
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
Definition: DigiCnv.cxx:72
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)
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(Bool_t fromMc=true)
Definition: TDigiEvent.cxx:78
static TDigiEvent * m_recEvt
Provide access to the ROOT event pointers.