BOSS 7.0.7
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
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
IMessageSvc * msgSvc()
IndexMap & getMcMdcMcHitsIdx()
void setMcEmcRecShowersIdx(IndexMap &map)
void setMcMdcMcHitsIdx(IndexMap &map)
IndexMap & getMcEmcMcHitsIdx()
void setMcEmcMcHitsIdx(IndexMap &map)
IndexMap & getMcEmcRecShowersIdx()
IndexMap & getMcMdcTracksIdx()
void setMcMdcTracksIdx(IndexMap &map)
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.
Definition: RootAddress.h:21
std::string getTreename() const
Definition: RootAddress.h:27
void setEvtNavigatorCnv(EvtNavigatorCnv *evtnavigatorcnv)
Definition: RootCnvSvc.h:169
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
virtual StatusCode initialize()
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 LoadMcEmcMcHits(std::multimap< int, int > &map)
Definition: TEvtNavigator.h:26
void LoadMcMdcMcHits(std::multimap< int, int > &map)
Definition: TEvtNavigator.h:24
void LoadMcEmcRecShowers(std::multimap< int, int > &map)
Definition: TEvtNavigator.h:27
void LoadMcMdcTracks(std::multimap< int, int > &map)
Definition: TEvtNavigator.h:25
static TEvtNavigator * m_EvtNavigator
Definition: commonData.h:115