CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
MrpcDBSRecTDS.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/ISvcLocator.h"
3#include "GaudiKernel/IDataProviderSvc.h"
4#include "GaudiKernel/Bootstrap.h"
5#include "GaudiKernel/IMessageSvc.h"
6#include "GaudiKernel/StatusCode.h"
7#include "GaudiKernel/SmartDataPtr.h"
10//#include "TofRecEvent/RecBTofCalHit.h"
11//#include "TofRecEvent/RecETofCalHit.h"
14
16 if( RegisterReconEvent() == StatusCode::FAILURE ) return StatusCode::FAILURE;
17 if( RegisterNullRecTofTrackCol() == StatusCode::FAILURE ) return StatusCode::FAILURE;
18 return StatusCode::SUCCESS;
19}
20
21
23 IMessageSvc* msgSvc;
24 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
25 MsgStream log(msgSvc, "MrpcRecDBSTDS");
26 log << MSG::INFO << "Initialize: MrpcRecDBSTDS::RegisterNullRecTofTrack()" << endreq;
27
28 IDataProviderSvc* eventSvc;
29 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
30
31 RecTofTrackCol* recTofTrackCol = new RecTofTrackCol;
32
33// Check whether the RecTofTrackCol has been registered.
34 StatusCode sc;
35 DataObject *aRecTofTrackCol;
36 eventSvc->findObject( "/Event/Recon/RecTofTrackCol", aRecTofTrackCol );
37 if( aRecTofTrackCol != NULL ) {
38 sc = eventSvc->unregisterObject( "/Event/Recon/RecTofTrackCol" );
39 if( sc != StatusCode::SUCCESS ) {
40 log << MSG::FATAL << "Initialize: Could not unregister RecTofTrack collection!" << endreq;
41 delete recTofTrackCol;
42 return StatusCode::FAILURE;
43 }
44 }
45 delete aRecTofTrackCol;
46
47 sc = eventSvc->registerObject("/Event/Recon/RecTofTrackCol", recTofTrackCol);
48 if( sc != StatusCode::SUCCESS ) {
49 log << MSG::FATAL << "Initialize: MrpcRecDBS could not register Null Rec TOF track collection!" << endreq;
50 delete recTofTrackCol;
51 return StatusCode::FAILURE;
52 }
53
54 return StatusCode::SUCCESS;
55}
56
57
58StatusCode MrpcDBSRecTDS::RegisterTDS(std::vector<MrpcDBSTrack*>*& tofTrackVec ) {
59 // if( RegisterReconEvent() == StatusCode::FAILURE ) return StatusCode::FAILURE;
60 if( RegisterRecTofTrackCol( tofTrackVec ) == StatusCode::FAILURE ) return StatusCode::FAILURE;
61
62 return StatusCode::SUCCESS;
63}
64
65
67 IMessageSvc* msgSvc;
68 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
69 MsgStream log(msgSvc, "MrpcRecDBSTDS");
70
71 IDataProviderSvc* eventSvc;
72 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
73
74// Register Reconstructed Track To TDS
75 DataObject *aReconEvent ;
76 eventSvc->findObject("/Event/Recon",aReconEvent);
77 if(aReconEvent==NULL) {
78 log << MSG::INFO << "MrpcRecDBSTDS::RegisterReconEvent()" << endreq;
79 aReconEvent = new ReconEvent();
80 StatusCode sc = eventSvc->registerObject("/Event/Recon",aReconEvent);
81 if(sc!=StatusCode::SUCCESS) {
82 log << MSG::FATAL << "MrpcRecDBS could not register ReconEvent!" <<endreq;
83 return StatusCode::FAILURE;
84 }
85 }
86 return StatusCode::SUCCESS;
87}
88
89
90StatusCode MrpcDBSRecTDS::RegisterRecTofTrackCol( std::vector<MrpcDBSTrack*>*& tofTrackVec ) {
91 IMessageSvc* msgSvc;
92 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
93 MsgStream log(msgSvc, "MrpcRecDBSTDS");
94 log << MSG::INFO << "MrpcRecDBSTDS::RegisterRecTofTrack()" << endreq;
95
96 IDataProviderSvc* eventSvc;
97 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
98
99 RecTofTrackCol* recTofTrackCol = new RecTofTrackCol;
100
101 std::vector<MrpcDBSTrack*>::iterator iter = tofTrackVec->begin();
102 for( ; iter < tofTrackVec->end(); iter++ ) {
103 (*iter)->convert2RecTofTrackCol( recTofTrackCol );
104 }
105
106// Check whether the RecTofTrackCol has been registered.
107 StatusCode sc;
108 DataObject *aRecTofTrackCol;
109 eventSvc->findObject( "/Event/Recon/RecTofTrackCol", aRecTofTrackCol );
110 if( aRecTofTrackCol != NULL ) {
111
112 sc = eventSvc->unregisterObject( "/Event/Recon/RecTofTrackCol" );
113
114 delete aRecTofTrackCol;
115
116 if( sc != StatusCode::SUCCESS ) {
117 log << MSG::FATAL << "Could not unregister RecTofTrack collection!" << endreq;
118
119 RecTofTrackCol::iterator iter_tof = recTofTrackCol->begin();
120 for( ; iter_tof!=recTofTrackCol->end(); iter_tof++ ) {
121 delete (*iter_tof);
122 }
123 recTofTrackCol->clear();
124 delete recTofTrackCol;
125
126 std::vector<MrpcDBSTrack*>::iterator iter_data = tofTrackVec->begin();
127 for( ; iter_data!=tofTrackVec->end(); iter_data++ ) {
128 delete (*iter_data);
129 }
130 tofTrackVec->clear();
131 delete tofTrackVec;
132
133 return StatusCode::FAILURE;
134 }
135 }
136
137 sc = eventSvc->registerObject("/Event/Recon/RecTofTrackCol", recTofTrackCol);
138 if( sc != StatusCode::SUCCESS ) {
139 log << MSG::FATAL << "MrpcRecDBS could not register Rec TOF track collection!" << endreq;
140 RecTofTrackCol::iterator iter_tof = recTofTrackCol->begin();
141 for( ; iter_tof!=recTofTrackCol->end(); iter_tof++ ) {
142 delete (*iter_tof);
143 }
144 recTofTrackCol->clear();
145 delete recTofTrackCol;
146 return StatusCode::FAILURE;
147 }
148
149 return StatusCode::SUCCESS;
150}
151
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
ObjectVector< RecTofTrack > RecTofTrackCol
Definition RecTofTrack.h:33
IMessageSvc * msgSvc()
StatusCode RegisterNullRecTofTrackCol()
StatusCode RegisterRecTofTrackCol(std::vector< MrpcDBSTrack * > *&tofTrackVec)
StatusCode RegisterReconEvent()
StatusCode InitializeTDS()
StatusCode RegisterTDS(std::vector< MrpcDBSTrack * > *&tofTrackVec)