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