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"
18 return StatusCode::SUCCESS;
24 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
25 MsgStream log(
msgSvc,
"TofRecTDS");
26 log << MSG::INFO <<
"Initialize: TofRecTDS::RegisterNullRecTofTrack()" << endreq;
28 IDataProviderSvc* eventSvc;
29 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
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;
45 delete aRecTofTrackCol;
47 sc = eventSvc->registerObject(
"/Event/Recon/RecTofTrackCol", recTofTrackCol);
48 if( sc != StatusCode::SUCCESS ) {
49 log << MSG::FATAL <<
"Initialize: TofRec could not register Null Rec TOF track collection!" << endreq;
50 delete recTofTrackCol;
51 return StatusCode::FAILURE;
54 return StatusCode::SUCCESS;
58StatusCode
TofRecTDS::RegisterTDS(
int runNumber,
int eventNumber, std::vector<TofTrack*>*& tofTrackVec,
bool forCalibration, std::string calibData ) {
61 if( forCalibration ) {
62 if(
RegisterRecBTofCalHitCol( runNumber, eventNumber, tofTrackVec, calibData ) == StatusCode::FAILURE )
return StatusCode::FAILURE;
63 if(
RegisterRecETofCalHitCol( runNumber, eventNumber, tofTrackVec, calibData ) == StatusCode::FAILURE )
return StatusCode::FAILURE;
65 return StatusCode::SUCCESS;
71 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
72 MsgStream log(
msgSvc,
"TofRecTDS");
74 IDataProviderSvc* eventSvc;
75 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
78 DataObject *aReconEvent ;
79 eventSvc->findObject(
"/Event/Recon",aReconEvent);
80 if(aReconEvent==
NULL) {
81 log << MSG::INFO <<
"TofRecTDS::RegisterReconEvent()" << endreq;
83 StatusCode sc = eventSvc->registerObject(
"/Event/Recon",aReconEvent);
84 if(sc!=StatusCode::SUCCESS) {
85 log << MSG::FATAL <<
"TofRec could not register ReconEvent!" <<endreq;
86 return StatusCode::FAILURE;
89 return StatusCode::SUCCESS;
95 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
96 MsgStream log(
msgSvc,
"TofRecTDS");
97 log << MSG::INFO <<
"TofRecTDS::RegisterRecTofTrack()" << endreq;
99 IDataProviderSvc* eventSvc;
100 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
104 std::vector<TofTrack*>::iterator
iter = tofTrackVec->begin();
105 for( ;
iter < tofTrackVec->end();
iter++ ) {
106 (*iter)->convert2RecTofTrackCol( recTofTrackCol );
111 DataObject *aRecTofTrackCol;
112 eventSvc->findObject(
"/Event/Recon/RecTofTrackCol", aRecTofTrackCol );
113 if( aRecTofTrackCol !=
NULL ) {
115 sc = eventSvc->unregisterObject(
"/Event/Recon/RecTofTrackCol" );
117 delete aRecTofTrackCol;
119 if( sc != StatusCode::SUCCESS ) {
120 log << MSG::FATAL <<
"Could not unregister RecTofTrack collection!" << endreq;
122 RecTofTrackCol::iterator iter_tof = recTofTrackCol->begin();
123 for( ; iter_tof!=recTofTrackCol->end(); iter_tof++ ) {
126 recTofTrackCol->clear();
127 delete recTofTrackCol;
129 std::vector<TofTrack*>::iterator iter_data = tofTrackVec->begin();
130 for( ; iter_data!=tofTrackVec->end(); iter_data++ ) {
133 tofTrackVec->clear();
136 return StatusCode::FAILURE;
140 sc = eventSvc->registerObject(
"/Event/Recon/RecTofTrackCol", recTofTrackCol);
141 if( sc != StatusCode::SUCCESS ) {
142 log << MSG::FATAL <<
"TofRec could not register Rec TOF track collection!" << endreq;
143 RecTofTrackCol::iterator iter_tof = recTofTrackCol->begin();
144 for( ; iter_tof!=recTofTrackCol->end(); iter_tof++ ) {
147 recTofTrackCol->clear();
148 delete recTofTrackCol;
149 return StatusCode::FAILURE;
152 return StatusCode::SUCCESS;
158 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
159 MsgStream log(
msgSvc,
"TofRecTDS");
160 log << MSG::INFO <<
"TofRecTDS::RegisterRecBTofCalHitCol()" << endreq;
162 IDataProviderSvc* eventSvc;
163 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
167 std::vector<TofTrack*>::iterator
iter = tofTrackVec->begin();
168 for( ;
iter < tofTrackVec->end();
iter++ ) {
172 (*iter)->convert2RecBTofCalHitColBarrel( runNumber, eventNumber, recBTofCalHitCol, m_calibData );
175 (*iter)->convert2RecBTofCalHitColETF( runNumber, eventNumber, recBTofCalHitCol, m_calibData );
181 DataObject *aRecBTofCalHitCol;
182 eventSvc->findObject(
"/Event/Recon/RecBTofCalhitCol", aRecBTofCalHitCol );
183 if( aRecBTofCalHitCol !=
NULL ) {
184 scb = eventSvc->unregisterObject(
"/Event/Recon/RecBTofCalHitCol" );
185 if( scb != StatusCode::SUCCESS ) {
186 log << MSG::FATAL <<
"Could not unregister RecBTofCalHit collection!" << endreq;
188 RecBTofCalHitCol::iterator iter_btof = recBTofCalHitCol->begin();
189 for( ; iter_btof!=recBTofCalHitCol->end(); iter_btof++ ) {
192 recBTofCalHitCol->clear();
193 delete recBTofCalHitCol;
195 std::vector<TofTrack*>::iterator iter_data = tofTrackVec->begin();
196 for( ; iter_data!=tofTrackVec->end(); iter_data++ ) {
199 tofTrackVec->clear();
202 return StatusCode::FAILURE;
206 StatusCode sh1 = eventSvc->registerObject(
"/Event/Recon/RecBTofCalHitCol", recBTofCalHitCol);
207 if(sh1!=StatusCode::SUCCESS) {
208 log << MSG::FATAL <<
"TofRec could not register BTOF CalHit collection!!" << endreq;
209 RecBTofCalHitCol::iterator iter_btof = recBTofCalHitCol->begin();
210 for( ; iter_btof!=recBTofCalHitCol->end(); iter_btof++ ) {
213 recBTofCalHitCol->clear();
214 delete recBTofCalHitCol;
215 return StatusCode::FAILURE;
218 return StatusCode::SUCCESS;
224 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
225 MsgStream log(
msgSvc,
"TofRecTDS");
226 log << MSG::INFO <<
"TofRecTDS::RegisterRecETofCalHitCol()" << endreq;
228 IDataProviderSvc* eventSvc;
229 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
233 if( tofTrackVec->size() != 2 )
return StatusCode::SUCCESS;
234 std::vector<TofTrack*>::iterator iter1 = tofTrackVec->begin();
235 std::vector<TofTrack*>::iterator iter2 = iter1+1;
236 if( (*iter1)->tdc1() < 0.0 || (*iter2)->tdc1() < 0.0 )
return StatusCode::SUCCESS;
237 if(
abs( (*iter1)->tdc1() - (*iter2)->tdc1() ) > 2.0 )
return StatusCode::SUCCESS;
243 std::vector<TofTrack*>::iterator
iter = tofTrackVec->begin();
244 for( ;
iter < tofTrackVec->end();
iter++ ) {
247 (*iter)->convert2RecETofCalHitCol( runNumber, eventNumber, recETofCalHitCol, m_calibData );
254 DataObject *aRecETofCalHitCol;
255 eventSvc->findObject(
"/Event/Recon/RecETofCalhitCol", aRecETofCalHitCol );
256 if( aRecETofCalHitCol !=
NULL ) {
257 sce = eventSvc->unregisterObject(
"/Event/Recon/RecETofCalHitCol" );
258 if( sce != StatusCode::SUCCESS ) {
259 log << MSG::FATAL <<
"Could not unregister RecETofCalHit collection!" << endreq;
261 RecETofCalHitCol::iterator iter_etof = recETofCalHitCol->begin();
262 for( ; iter_etof!=recETofCalHitCol->end(); iter_etof++ ) {
265 recETofCalHitCol->clear();
266 delete recETofCalHitCol;
268 std::vector<TofTrack*>::iterator iter_data = tofTrackVec->begin();
269 for( ; iter_data!=tofTrackVec->end(); iter_data++ ) {
272 tofTrackVec->clear();
275 return StatusCode::FAILURE;
279 StatusCode sh2 = eventSvc->registerObject(
"/Event/Recon/RecETofCalHitCol",recETofCalHitCol);
280 if(sh2!=StatusCode::SUCCESS) {
281 log << MSG::FATAL <<
"TofRec could not register ETOF CalHit collection!!" << endreq;
282 RecETofCalHitCol::iterator iter_etof = recETofCalHitCol->begin();
283 for( ; iter_etof!=recETofCalHitCol->end(); iter_etof++ ) {
286 recETofCalHitCol->clear();
287 delete recETofCalHitCol;
288 return StatusCode::FAILURE;
291 return StatusCode::SUCCESS;
ObjectVector< RecBTofCalHit > RecBTofCalHitCol
ObjectVector< RecETofCalHit > RecETofCalHitCol
ObjectVector< RecTofTrack > RecTofTrackCol
StatusCode RegisterRecTofTrackCol(std::vector< TofTrack * > *&tofTrackVec)
StatusCode RegisterTDS(int runNumber, int eventNumber, std::vector< TofTrack * > *&tofTrackVec, bool m_forCalibration, std::string m_calibData)
StatusCode RegisterNullRecTofTrackCol()
StatusCode RegisterRecETofCalHitCol(int runNumber, int eventNumber, std::vector< TofTrack * > *&tofTrackVec, std::string calibData)
StatusCode RegisterRecBTofCalHitCol(int runNumber, int eventNumber, std::vector< TofTrack * > *&tofTrackVec, std::string calibData)
StatusCode InitializeTDS()
StatusCode RegisterReconEvent()