BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtRecEventCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2
3#include "EventModel/EventModel.h"
4#include "EvtRecEvent/EvtRecObject.h"
5#include "EvtRecEvent/EvtRecEvent.h"
6#include "RootCnvSvc/RootAddress.h"
7#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
8#include "RootCnvSvc/EvtRec/EvtRecEventCnv.h"
9
11 : RootEventBaseCnv(classID(), svc)
12{
13 m_rootBranchname = "m_evtRecEvent";
14 m_adresses.push_back(&m_evtRecEvent);
15 m_evtRecEvent = 0;
16}
17
18StatusCode EvtRecEventCnv::TObjectToDataObject(DataObject*& refpObject) {
19 MsgStream log(msgSvc(), "EvtRecEventCnv");
20 log << MSG::DEBUG << "EvtRecEventCnv::TObjectToDataObject" << endreq;
21
22 // create the TDS location for the EvtRecEvent
23 EvtRecEvent* evtRecEvent = new EvtRecEvent;
24 refpObject = evtRecEvent;
25
26 if ( ! m_evtRecEvent ) return StatusCode::SUCCESS;
27 // convert
28 evtRecEvent->setTotalTracks ( m_evtRecEvent->totalTracks() );
29 evtRecEvent->setTotalCharged( m_evtRecEvent->totalCharged() );
30 evtRecEvent->setTotalNeutral( m_evtRecEvent->totalNeutral() );
31 evtRecEvent->setNumberOfVee ( m_evtRecEvent->numberOfVee() );
32 evtRecEvent->setNumberOfPi0 ( m_evtRecEvent->numberOfPi0() );
33
34 delete m_evtRecEvent;
35 m_evtRecEvent = 0;
36
37 return StatusCode::SUCCESS;
38}
39
40StatusCode EvtRecEventCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
41
42 MsgStream log(msgSvc(), "EvtRecEventCnv");
43 log << MSG::DEBUG << "EvtRecEventCnv::DataObjectToTObject" << endreq;
44
45 EvtRecEvent* evtRecEvent = dynamic_cast<EvtRecEvent*> (obj);
46 if ( ! evtRecEvent ) {
47 log << MSG::ERROR << "Could not downcast to EvtRecEvent" << endreq;
48 return StatusCode::FAILURE;
49 }
50
51 DataObject* evt = NULL;
52 StatusCode sc = m_eds->findObject(EventModel::EvtRec::Event, evt);
53 if ( sc.isFailure() ) {
54 log << MSG::ERROR << "Could not get EvtRecObject in TDS" << endreq;
55 return StatusCode::FAILURE;
56 }
57
58 EvtRecObject* devtTds = dynamic_cast<EvtRecObject*> (evt);
59 if ( ! devtTds ) {
60 log << MSG::ERROR << "EvtRecEventCnv: Could not downcast to TDS EvtRecObject" << endreq;
61 }
62
63 IOpaqueAddress* addr;
64 m_cnvSvc->getEvtRecCnv()->createRep(evt, addr);
66
67 TEvtRecEvent* m_evtRecEvent = const_cast<TEvtRecEvent*>( recEvt->getEvtRecEvent() );
68
69 m_evtRecEvent->setTotalTracks ( evtRecEvent->totalTracks() );
70 m_evtRecEvent->setTotalCharged( evtRecEvent->totalCharged() );
71 m_evtRecEvent->setTotalNeutral( evtRecEvent->totalNeutral() );
72 m_evtRecEvent->setNumberOfVee ( evtRecEvent->numberOfVee() );
73 m_evtRecEvent->setNumberOfPi0 ( evtRecEvent->numberOfPi0() );
74
75 return StatusCode::SUCCESS;
76}
EvtRecEventCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
Definition of a Root address, derived from IOpaqueAddress.
IDataProviderSvc * m_eds
pointer to eventdataservice
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.