BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtNavigatorCnv.cxx
Go to the documentation of this file.
1// File and Version Information:
2// Description:
3// EvtNavigatorCnv is the concrete converter for the EvtNavigator branch
4//
5
6#ifndef EvtNavigatorCnv_CXX
7#define EvtNavigatorCnv_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/IDataProviderSvc.h"
14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/PropertyMgr.h"
16
17#include "GaudiKernel/IOpaqueAddress.h"
18
19#include "EventModel/EventModel.h"
20#include "EventNavigator/EventNavigator.h"
21#include "RootEventData/TEvtNavigator.h"
22#include "RootCnvSvc/EvtNavigatorCnv.h"
23#include "RootCnvSvc/RootEvtSelector.h"
24#include "RootCnvSvc/RootAddress.h"
25#include "RootCnvSvc/Util.h"
26
27using namespace DataSvcHelpers;
28
29TEvtNavigator* EvtNavigatorCnv::m_evtNavigatorR = 0;
30TEvtNavigator* EvtNavigatorCnv::m_evtNavigatorW = 0;
31
33: RootEventBaseCnv(classID(), svc)
34{
35 // Here we associate this converter with the path on the TDS.
36 MsgStream log(msgSvc(), "EvtNavigatorCnv");
37 m_rootBranchname = "m_mcMdcMcHits:m_mcMdcTracks:m_mcEmcMcHits:m_mcEmcRecShowers";
38 m_adresses.push_back(&m_mcMdcMcHits);
39 m_adresses.push_back(&m_mcMdcTracks);
40 m_adresses.push_back(&m_mcEmcMcHits);
41 m_adresses.push_back(&m_mcEmcRecShowers);
42
43 m_evtNavigatorR = 0;
44 m_evtNavigatorW = 0;
45}
46
47StatusCode EvtNavigatorCnv::TObjectToDataObject(DataObject*& refpObject) {
48 // fills the TDS object from the persistent one
49 StatusCode sc=StatusCode::SUCCESS;
50
51 MsgStream log(msgSvc(), "EvtNavigatorCnv");
52
54 refpObject = evt;
55
56 // fill DataObject
57 evt->setMcMdcMcHitsIdx(m_mcMdcMcHits);
58 evt->setMcMdcTracksIdx(m_mcMdcTracks);
59 evt->setMcEmcMcHitsIdx(m_mcEmcMcHits);
60 evt->setMcEmcRecShowersIdx(m_mcEmcRecShowers);
61
62 delete m_evtNavigatorR;
63 m_evtNavigatorR = 0;
64
65 return sc;
66}
67
69
70 StatusCode status = RootEventBaseCnv::initialize();
72
73 return status;
74
75}
76
77StatusCode EvtNavigatorCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
78 // transforms TDS event to Dst event in root format
79 MsgStream log(msgSvc(), "EvtNavigatorCnv");
80
81 EventNavigator * evtNaviTds=dynamic_cast<EventNavigator *> (obj);
82 if (!evtNaviTds) {
83 log << MSG::ERROR << "Could not downcast to TDS EventNavigator" << endreq;
84 return StatusCode::FAILURE;
85 }
86
87 m_evtNavigatorW = new TEvtNavigator();
88 m_common.m_EvtNavigator = m_evtNavigatorW;
89
90 m_evtNavigatorW->LoadMcMdcTracks(evtNaviTds->getMcMdcTracksIdx());
91 if(evtNaviTds->getMcMdcTracksIdx().empty())
92 m_evtNavigatorW->LoadMcMdcMcHits(evtNaviTds->getMcMdcMcHitsIdx());
93 m_evtNavigatorW->LoadMcEmcRecShowers(evtNaviTds->getMcEmcRecShowersIdx());
94 if(evtNaviTds->getMcEmcRecShowersIdx().empty())
95 m_evtNavigatorW->LoadMcEmcMcHits(evtNaviTds->getMcEmcMcHitsIdx());
96
97 // create branch if not yet done
99 StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"EventNavigator",m_evtNavigatorW->ClassName(),&m_evtNavigatorW,m_branchNrEvtNavigator);
100 if (sc.isFailure()) {
101 delete m_evtNavigatorW;
102 log << MSG::ERROR << "Could not create branch TEvtNavigator in " << rootaddr->getTreename() << endreq;
103 return StatusCode::SUCCESS;
104 //return sc;
105 }
106 }
107
108 return StatusCode::SUCCESS;
109}
110#endif
111
EvtNavigatorCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&refpObject)
do the transformation from ROOT to TDS object
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation from TDS object to ROOT
virtual StatusCode initialize()
Definition of a Root address, derived from IOpaqueAddress.
void setEvtNavigatorCnv(EvtNavigatorCnv *evtnavigatorcnv)
virtual StatusCode initialize()
std::vector< void * > m_adresses
each converter knows the corresponding adresses
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