152 MsgStream log(
msgSvc(), name());
153 log << MSG::INFO <<
"MrpcRecDBS in execute()!" << endreq;
155 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
157 log << MSG::FATAL <<
"MrpcRecDBS could not find Event Header!" << endreq;
158 return StatusCode::FAILURE;
160 int run = eventHeader->runNumber();
161 int event = eventHeader->eventNumber();
162 if( ( event % 1000 == 0 ) && m_printOutInfo ) {
163 std::cout <<
"run:" << run <<
" event: " <<
event << std::endl;
165 log << MSG::INFO <<
"run= " << run <<
" event= " <<
event << endreq;
171 if( m_acceleratorStatus ==
"Colliding" ) {
173 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
174 if( !estimeCol || ( estimeCol->size() == 0 ) ) {
175 log << MSG::WARNING <<
"MrpcRecDBS Could not find RecEsTimeCol! Run = " << run <<
" Event = " <<
event << endreq;
176 return StatusCode::SUCCESS;
178 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
179 double t0 = (*iter_ESTime)->getTest();
180 int t0Stat = (*iter_ESTime)->getStat();
181 log << MSG::INFO <<
"t0= " << t0 <<
" t0Stat= " << t0Stat << endreq;
187 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
188 if( !mdcKalTrackCol ) {
189 log << MSG::WARNING <<
"No MdcKalTrackCol in TDS! Run = " << run <<
" Event = " <<
event << endreq;
190 return StatusCode::SUCCESS;
196 SmartDataPtr<RecExtTrackCol> extTrackCol(eventSvc(),
"/Event/Recon/RecExtTrackCol");
198 log << MSG::WARNING <<
"No ExtTrackCol in TDS! Run = " << run <<
" Event = " <<
event << endreq;
199 return StatusCode::SUCCESS;
203 if( m_printOutInfo ) { m_printOut->
setExtTrackNum( extTrackCol->size() ); }
210 RecExtTrackCol::iterator iter_track = extTrackCol->begin();
211 for( ; iter_track < extTrackCol->end(); iter_track++ ) {
212 RecMdcKalTrackCol::iterator iter_kal = mdcKalTrackCol->begin();
213 for( ; iter_kal != mdcKalTrackCol->end(); iter_kal++ ) {
214 if( (*iter_kal)->trackId() == (*iter_track)->trackId() )
break;
217 if( iter_kal != mdcKalTrackCol->end() ) {
218 for(
unsigned int i=0; i<5; i++ ) {
219 kal[i] = (*iter_kal)->getStat( 1, i );
223 tof->
setExtTrack( (*iter_track), kal, t0, t0Stat );
225 if( tofTrackVec->size()>0 ) {
226 std::vector<MrpcDBSTrack*>::iterator iterExt = tofTrackVec->begin();
227 for( ; iterExt < tofTrackVec->end(); iterExt++ ) {
228 if( (*iterExt)->isNoHit() )
continue;
233 tofTrackVec->push_back( tof );
244 if( tofDataMap.empty() ) {
245 log << MSG::WARNING <<
"No Tof Data Map in RawDataProviderSvc! Run=" << run <<
" Event=" <<
event << endreq;
249 std::vector<MrpcDBSTrack*>::iterator
iter = tofTrackVec->begin();
250 for( ;
iter < tofTrackVec->end();
iter++ ) {
251 if( (*iter)->isNoHit() )
continue;
252 (*iter)->setTofData( tofDataMap,m_neighborhood );
254 if( (*iter)->isNoHit() )
continue;
255 (*iter)->match(tofTrackVec );
259 iter = tofTrackVec->begin();
261 for( ;
iter < tofTrackVec->end();
iter++ )
263 (*iter)->setCalibration();
270 if(m_store_trans_time==1)
275 m_mrpc_dbs=(*iter)->mrpc_dbs();
276 m_mrpc_extrap=(*iter)->mrpc_extra();
277 m_mrpc_aver=(*iter)->mrpc_aver();
279 m_partID=(*iter)->mrpc_partid();
280 m_stripidentifier=(*iter)->mrpc_stripidentifier();
281 m_time_1=(*iter)->mrpc_time_1();
282 m_time_2=(*iter)->mrpc_time_2();
283 m_trans_time=(*iter)->mrpc_trans_time();
285 m_r_ext=(*iter)->mrpc_r_ext();
286 m_phi_ext=(*iter)->mrpc_phi_ext();
290 SmartDataPtr<Event::TofMcHitCol> mcParticleCol(eventSvc(),
"/Event/MC/TofMcHitCol");
291 double mc_truth_x,mc_truth_y;
292 double mc_truth_trans_time;
293 bool write_root_data=
false;
302 std::cout <<
"Could not retrieve McParticelCol" << std::endl;
307 Event::TofMcHitCol::iterator iter_mc = mcParticleCol->begin();
308 for (; iter_mc != mcParticleCol->end(); iter_mc++)
313 mc_truth_x=(*iter_mc)->getPositionX();
314 mc_truth_y=(*iter_mc)->getPositionY();
315 const Identifier ident = (*iter_mc)->identify();
327 if(m_partID==mc_truth_partid && mc_truth_tofmod==((
int)m_stripidentifier/25) && ((
int)m_stripidentifier%25)==(mc_truth_tofstr))
329 write_root_data=
true;
336 if(mc_truth_trans_time==0) m_transition_time_simulation=-100;
337 else m_transition_time_simulation=mc_truth_trans_time;
339 if(write_root_data) m_tree_mrpc->Fill();
351 SmartDataPtr<RecTofTrackCol> tofTrackCol(eventSvc(),
"/Event/Recon/RecTofTrackCol");
353 log << MSG::FATAL <<
"MrpcRecDBS could not find RecTofTrackCol!" << endreq;
354 return StatusCode::FAILURE;
360 log << MSG::FATAL <<
"In MrpcRecDBS: AcceleratorStatus is NOT correct! m_acceleratorStatus = " << m_acceleratorStatus << endreq;
361 return StatusCode::FAILURE;
364 return StatusCode::SUCCESS;