5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/AlgFactory.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/SmartDataLocator.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/PropertyMgr.h"
49 Algorithm(name, pSvcLocator)
51 declareProperty(
"AcceleratorStatus", m_acceleratorStatus );
52 declareProperty(
"MagneticField", m_magneticField );
53 declareProperty(
"FirstIteration", m_firstIteration );
54 declareProperty(
"PrintOutInfo", m_printOutInfo );
55 declareProperty(
"neighborhood", m_neighborhood=6 );
62 MsgStream log(
msgSvc(), name());
63 log << MSG::INFO <<
"MrpcRec in initialize()" << endreq;
66 StatusCode scg = service(
"TofGeomSvc",
tofGeomSvc);
67 if (scg== StatusCode::SUCCESS) {
68 log << MSG::INFO <<
"MrpcRec Get Geometry Service Sucessfully!" << endreq;
70 log << MSG::ERROR <<
"MrpcRec Get Geometry Service Failed !" << endreq;
71 return StatusCode::FAILURE;
75 StatusCode scc = service(
"TofCaliSvc",
tofCaliSvc);
76 if (scc == StatusCode::SUCCESS) {
77 log << MSG::INFO <<
"MrpcRec Get Calibration Service Sucessfully!" << endreq;
79 log << MSG::ERROR <<
"MrpcRec Get Calibration Service Failed !" << endreq;
80 return StatusCode::FAILURE;
84 StatusCode scd = service(
"RawDataProviderSvc",
tofDigiSvc);
85 if (scd == StatusCode::SUCCESS) {
86 log << MSG::INFO <<
"MrpcRec Get Tof Raw Data Service Sucessfully!" << endreq;
88 log << MSG::ERROR <<
"MrpcRec Get Tof Raw Data Service Failed !" << endreq;
89 return StatusCode::FAILURE;
93 if( m_printOutInfo ) { m_printOut =
new MrpcCount; }
95 return StatusCode::SUCCESS;
99 MsgStream log(
msgSvc(), name());
100 log << MSG::INFO <<
"MrpcRec begin_run!"<< endreq;
101 return StatusCode::SUCCESS;
108 MsgStream log(
msgSvc(), name());
109 log << MSG::INFO <<
"MrpcRec in execute()!" << endreq;
111 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
113 log << MSG::FATAL <<
"MrpcRec could not find Event Header!" << endreq;
114 return StatusCode::FAILURE;
116 int run = eventHeader->runNumber();
117 int event = eventHeader->eventNumber();
118 if( ( event % 1000 == 0 ) && m_printOutInfo ) {
119 std::cout <<
"run:" << run <<
" event: " <<
event << std::endl;
121 log << MSG::INFO <<
"run= " << run <<
" event= " <<
event << endreq;
127 if( m_acceleratorStatus ==
"Colliding" ) {
129 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
130 if( !estimeCol || ( estimeCol->size() == 0 ) ) {
131 log << MSG::WARNING <<
"MrpcRec Could not find RecEsTimeCol! Run = " << run <<
" Event = " <<
event << endreq;
132 return StatusCode::SUCCESS;
134 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
135 double t0 = (*iter_ESTime)->getTest();
136 int t0Stat = (*iter_ESTime)->getStat();
137 log << MSG::INFO <<
"t0= " << t0 <<
" t0Stat= " << t0Stat << endreq;
142 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
143 if( !mdcKalTrackCol ) {
144 log << MSG::WARNING <<
"No MdcKalTrackCol in TDS! Run = " << run <<
" Event = " <<
event << endreq;
145 return StatusCode::SUCCESS;
151 SmartDataPtr<RecExtTrackCol> extTrackCol(eventSvc(),
"/Event/Recon/RecExtTrackCol");
153 log << MSG::WARNING <<
"No ExtTrackCol in TDS! Run = " << run <<
" Event = " <<
event << endreq;
154 return StatusCode::SUCCESS;
157 if( m_printOutInfo ) { m_printOut->
setExtTrackNum( extTrackCol->size() ); }
163 RecExtTrackCol::iterator iter_track = extTrackCol->begin();
164 for( ; iter_track < extTrackCol->end(); iter_track++ ) {
165 RecMdcKalTrackCol::iterator iter_kal = mdcKalTrackCol->begin();
166 for( ; iter_kal != mdcKalTrackCol->end(); iter_kal++ ) {
167 if( (*iter_kal)->trackId() == (*iter_track)->trackId() )
break;
170 if( iter_kal != mdcKalTrackCol->end() ) {
171 for(
unsigned int i=0; i<5; i++ ) {
172 kal[i] = (*iter_kal)->getStat( 1, i );
176 tof->
setExtTrack( (*iter_track), kal, t0, t0Stat );
178 if( tofTrackVec->size()>0 ) {
179 std::vector<MrpcTrack*>::iterator iterExt = tofTrackVec->begin();
180 for( ; iterExt < tofTrackVec->end(); iterExt++ ) {
181 if( (*iterExt)->isNoHit() )
continue;
186 tofTrackVec->push_back( tof );
189 if( m_printOutInfo ) {
195 if( tofDataMap.empty() ) {
196 log << MSG::WARNING <<
"No Tof Data Map in RawDataProviderSvc! Run=" << run <<
" Event=" <<
event << endreq;
200 std::vector<MrpcTrack*>::iterator
iter = tofTrackVec->begin();
201 for( ;
iter < tofTrackVec->end();
iter++ ) {
202 if( (*iter)->isNoHit() )
continue;
203 (*iter)->setTofData( tofDataMap,m_neighborhood );
205 if( (*iter)->isNoHit() )
continue;
206 (*iter)->match(tofTrackVec );
210 iter = tofTrackVec->begin();
211 for( ;
iter < tofTrackVec->end();
iter++ )
213 (*iter)->setCalibration();
216 tds.
RegisterTDS( eventHeader->runNumber(), eventHeader->eventNumber(), tofTrackVec );
221 SmartDataPtr<RecTofTrackCol> tofTrackCol(eventSvc(),
"/Event/Recon/RecTofTrackCol");
223 log << MSG::FATAL <<
"MrpcRec could not find RecTofTrackCol!" << endreq;
224 return StatusCode::FAILURE;
229 log << MSG::FATAL <<
"In MrpcRec: AcceleratorStatus is NOT correct! m_acceleratorStatus = " << m_acceleratorStatus << endreq;
230 return StatusCode::FAILURE;
233 return StatusCode::SUCCESS;
240 if( m_printOutInfo ) {
244 return StatusCode::SUCCESS;
252 std::vector<MrpcTrack*>::iterator
iter = tofTrackVec->begin();
253 for( ;
iter < tofTrackVec->end();
iter++ ) {
256 tofTrackVec->clear();
IRawDataProviderSvc * tofDigiSvc
std::vector< MrpcTrack * > TofTrackVec
std::multimap< unsigned int, TofData * > TofDataMap
virtual TofDataMap & tofDataMapTof(double estime=0)=0
void setExtTrackNum(unsigned int ntrk)
void setTrack3(MrpcTrack *&tof)
void setTrack2(MrpcTrack *&tof)
void setTrack1Col(std::vector< MrpcTrack * > *&tofTrackVec)
StatusCode RegisterNullRecTofTrackCol()
StatusCode RegisterTDS(int runNumber, int eventNumber, std::vector< MrpcTrack * > *&tofTrackVec)
MrpcRec(const std::string &name, ISvcLocator *pSvcLocator)
void clearTofTrackVec(std::vector< MrpcTrack * > *&tofTrackVec)
void getMultiHit(MrpcTrack *&)
void setExtTrack(RecExtTrack *extTrack, int kal[5], double t0, int t0Stat)