BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrigCnv.cxx
Go to the documentation of this file.
1// File and Version Information:
2// Description:
3// TrigCnv is the concrete converter for the Trig branch
4//
5
6#ifndef TrigCnv_CXX
7#define TrigCnv_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 "RootCnvSvc/RootAddress.h"
18#include "RootCnvSvc/RootEvtSelector.h"
19#include "RootCnvSvc/Trig/TrigCnv.h"
20#include "TrigEvent/TrigEvent.h"
21// #include "RootCnvSvc/Util.h"
22
23using namespace DataSvcHelpers;
24TTrigEvent* TrigCnv::m_objWrite = 0;
25
26TrigCnv::TrigCnv( ISvcLocator* svc ) : RootEventBaseCnv( classID(), svc ) {
27 // Here we associate this converter with the path on the TDS.
28 // o m_rootBranchname ="m_fromMc";
29 // declareObject(EventModel::Digi::Event, objType(), m_rootTreename, m_rootBranchname);
30 // o m_adresses.push_back(&m_fromMc);
31
32 // m_objWrite=0;
33}
34
35StatusCode TrigCnv::initialize() {
36 MsgStream log( msgSvc(), "TrigCnv" );
37 log << MSG::DEBUG << "TrigCnv::initialize" << endmsg;
38
39 StatusCode status = RootEventBaseCnv::initialize();
40
41 // pass dst converter to the conversion service
42 m_cnvSvc->setTrigCnv( this );
43
44 return status;
45}
46
47StatusCode TrigCnv::TObjectToDataObject( DataObject*& refpObject ) {
48 // fills the TDS object from the root object
49 StatusCode sc = StatusCode::SUCCESS;
50
51 MsgStream log( msgSvc(), "TrigCnv" );
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 TrigEvent* tdsev = new TrigEvent();
61 refpObject = tdsev;
62
63 m_fromMc = false; // There is no "TTrigEvent" branch in MC-dst-files
64 tdsev->initialize( m_fromMc );
65
66 return sc;
67}
68
69StatusCode TrigCnv::DataObjectToTObject( DataObject* obj, RootAddress* rootaddr ) {
70 // transforms TDS event to digi event in root format
71 MsgStream log( msgSvc(), "TrigCnv" );
72 log << MSG::DEBUG << "TrigCnv::DataObjectToTObject" << endmsg;
73
74 // test if already done for this event
75 // zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0))
76 // return StatusCode::SUCCESS;
77 if ( m_common.m_trigEvt != NULL ) return StatusCode::SUCCESS;
78
79 /*
80 SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
81
82 if (!evtTds) {
83 log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endmsg;
84 return StatusCode::FAILURE;
85 }
86 */
87 TrigEvent* devtTds = dynamic_cast<TrigEvent*>( obj );
88 if ( !devtTds )
89 {
90 log << MSG::ERROR << "Could not downcast to TDS RecEvent" << endmsg;
91 return StatusCode::FAILURE;
92 }
93 m_objWrite = new TTrigEvent(); // zoujh
94 m_common.m_trigEvt = m_objWrite; // zoujh
95
96 // create branch if not yet done
97 if ( m_branchNr < 0 )
98 {
99 // zoujh: m_objWrite = new TTrigEvent();
100 StatusCode sc =
101 m_rootInterface->createBranch( rootaddr->getTreename(), "TTrigEvent",
102 m_objWrite->ClassName(), &m_objWrite, m_branchNr );
103 if ( sc.isFailure() )
104 {
105 log << MSG::ERROR << "Could not create branch TTrigEvent" << endmsg;
106 return sc;
107 }
108 }
109
110 // Int_t evtId = evtTds->eventNumber();
111 // Int_t runId = evtTds->runNumber();
112
113 // o Bool_t fromMc = devtTds->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 << "******************************" << std::endl;
120#endif
121
122 // o m_objWrite->initialize(fromMc);
123 m_objWrite->initialize();
124
125 return StatusCode::SUCCESS;
126}
127#endif
IMessageSvc * msgSvc()
Definition of a Root address, derived from IOpaqueAddress.
virtual StatusCode initialize()
int m_branchNr
the branchNr of this converter for writing
RootInterface * m_rootInterface
pointer to the RootInterface
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)
TrigCnv(ISvcLocator *svc)
Definition TrigCnv.cxx:26
virtual StatusCode initialize()
Definition TrigCnv.cxx:35
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
Definition TrigCnv.cxx:69
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
Definition TrigCnv.cxx:47