217 {
218 setFilterPassed(false);
219
220 MsgStream log(
msgSvc(), name());
221 log << MSG::INFO << "in execute()" << endreq;
222
223
224 if(m_hist>0){
225 for (int ii=0;ii<43;ii++){
226 for (int jj=0;jj<288;jj++){
234 mcDrift[ii][jj] = -99.;
235 mcX[ii][jj] = -99.;
236 mcY[ii][jj] = -99.;
237 mcZ[ii][jj] = -99.;
238 mcLR[ii][jj] = -99.;
239 hitPoisoned[ii][jj]=-99;
240 }
241 }
242 }
243
244
246#ifdef MDCPATREC_TIMETEST
247 m_timer[1]->start();
248 ti_nHit=0;
249#endif
250
251 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),"/Event/EventHeader");
252 if (!evtHead) {
253 log << MSG::FATAL<< "Could not retrieve event header" << endreq;
254 return( StatusCode::FAILURE);
255 }
256 t_eventNo = evtHead->eventNumber();
257 if(m_debug!=0)std::cout<<t_iExexute<<" run "<<evtHead->runNumber()<<" evt "<<t_eventNo<<std::endl;
258 t_iExexute++;
259
260 if (m_selEvtNo.size() >0){
261 std::vector<int>::iterator it = m_selEvtNo.begin();
262 for (; it!=m_selEvtNo.end(); it++){
263 if((*it)== t_eventNo) setFilterPassed(true);
264 }
265 }
266
267 double t0 = 0.;
268 t_t0 = -1.;
269 t_t0Stat = -1;
270 bool iterateT0 = false;
271 const int nBunch = 3;
272 double iBunch = 0 ;
273 double BeamDeltaTime = 24. / nBunch;
274 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
275 if (!evTimeCol || evTimeCol->size()==0) {
276 log << MSG::WARNING <<" run "<<evtHead->runNumber() <<" evt "<<t_eventNo<< " Could not find RecEsTimeCol" << endreq;
277 if(m_fieldCosmic){
278 return StatusCode::SUCCESS;
279 }
280 }
281 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
282
283 if (iter_evt != evTimeCol->end()){
284 t_t0Stat = (*iter_evt)->getStat();
285 t_t0 = (*iter_evt)->getTest();
286
287 if (m_doLineFit){
288
289 if (
abs(t_t0)<0.00001 || (t_t0 < 0) || (t_t0 > 9999.0) ){
290 log << MSG::WARNING << "Skip with t0 = "<<t_t0 << endreq;
291 return StatusCode::SUCCESS;
292 }
293 }
294 t0 = t_t0*1.e-9;
295 if(m_debug>0) std::cout<<name()<<" t0 "<<t0<<" "<<std::endl;
296 }
297
298
299restart:
300 if ( !m_recForEsTime && m_tryBunch) {
301 if ( t_t0Stat < 10 ) return StatusCode::SUCCESS;
302 }
303 if ( m_tryBunch ){
304 if ( iBunch > (nBunch - 1) ) return StatusCode::SUCCESS;
305 if ( t_t0Stat < 0 ){ iterateT0 = true; }
306 if ( iterateT0 ){
307
308 if ( (t_t0Stat > -1) && (fabs( iBunch * BeamDeltaTime - t_t0) < 2.) ){
309 ++iBunch;
310 goto restart;
311 }else{ t0 = iBunch * BeamDeltaTime *1.e-9;}
312 ++iBunch;
313 }
314 }
315
316 SmartDataPtr<MdcHitMap> hitMap(eventSvc(),"/Event/Hit/MdcHitMap");
317 if (!hitMap) {
318 log << MSG::FATAL << "Could not retrieve MDC hit map" << endreq;
319 return( StatusCode::FAILURE);
320 }
321
322 SmartDataPtr<MdcHitCol> hitCol(eventSvc(),"/Event/Hit/MdcHitCol");
323 if (!hitCol) {
324 log << MSG::FATAL << "Could not retrieve MDC hit list" << endreq;
325 return( StatusCode::FAILURE);
326 }
327 StatusCode sc;
328
329
330 DataObject *aReconEvent;
331 eventSvc()->findObject("/Event/Recon",aReconEvent);
332 if(aReconEvent==NULL) {
334 StatusCode sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
335 if(sc!=StatusCode::SUCCESS) {
336 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
337 return( StatusCode::FAILURE);
338 }
339 }
340
341 DataObject *aTrackCol;
342 DataObject *aRecHitCol;
343
344 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
345 if(!m_combineTracking){
346 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
347 if(aTrackCol != NULL) {
348 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
349 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
350 }
351 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
352 if(aRecHitCol != NULL) {
353 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
354 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
355 }
356 }
357
359 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
360 if (aTrackCol) {
362 }else{
365 if(!sc.isSuccess()) {
366 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
367 return StatusCode::FAILURE;
368 }
369 }
371 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
372 if (aRecHitCol) {
374 }else{
377 if(!sc.isSuccess()) {
378 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
379 return StatusCode::FAILURE;
380 }
381 }
382
383 if(m_debug>0) std::cout<<name()<<" t0 "<<t0<<" "<<std::endl;
384 m_hitData->loadevent(hitCol, hitMap, t0);
385 t_nDigi = hitCol->size();
386
388 m_hitData->poisonHits(_gm,m_debug);
389 }
390
392 for(int i=0;i<m_hitData->nhits();i++){
393 const MdcHit* thisHit = m_hitData->hit(i);
396 if(m_hitData->segUsage().get(thisHit)->deadHit()){
397 hitPoisoned[l][
w] = 1;
398 }else{
399 hitPoisoned[l][
w] = 0;
400 }
401 }
402 }
403
404#ifdef MDCPATREC_TIMETEST
405 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
406 if(!mcParticleCol){
407 log << MSG::INFO << "Could not retrieve McParticelCol" << endreq;
408 }
409 m_mcTkNum = mcParticleCol->size();
410#endif
411
412
414
415
416
417 int nSegs = 0;
419
420 nSegs = m_segFinder->createSegs(_gm, *m_segs, m_hitData->segUsage(),
421 m_hitData->hitMap(), t0);
422 }
423 log << MSG::INFO << " Found " << nSegs << " segments" << endreq;
424 if (m_debug>1){
425 std::cout<<"------------------------------------------------"<<std::endl;
426 std::cout<<"==event "<<t_eventNo<< " Found " << nSegs << " segments" << std::endl;
427 m_segs->plot();
428 }
429
432 }
433
434
435
436
437 int nTracks = 0;
438 int nDeleted = 0;
440 if (nSegs > 2) {
441 nTracks = m_tracks->createFromSegs(m_segs.get(), m_hitData->hitMap(),
442 _gm, context, t0);
443 }
444
445 if(m_arbitrateHits) nDeleted = m_tracks->arbitrateHits();
446 int nKeep = nTracks - nDeleted;
447
448 if (m_debug>0 && (nTracks - nDeleted)>0){
449 std::cout<< "MdcTrkRecon: evt "<< setw(5)<<t_eventNo
450 <<" nDigi "<<setw(4)<<t_nDigi<< " t0 "<<setw(5)<<t_t0
451 << " keep "<< nKeep <<" track(s)";
452 if (nDeleted!=0){ std::cout <<",deleted " <<nDeleted; }
453 std::cout<< std::endl;
454 }else{
455 if (m_debug>0){
456 std::cout<< "MdcTrkRecon: evt "<< setw(5)<<t_eventNo
457 <<" nDigi "<<setw(4)<<t_nDigi<< " t0 "<<setw(5)<<t_t0
458 <<" found 0 track "<< endl;
459 }
460 }
461
462 if (m_flags.
lHist) t_nRecTk = nKeep;
463
464#ifdef MDCPATREC_RESLAYER
465 m_tracks->setResLayer(m_resLayer);
466#endif
468
469 m_tracks->store(trackList, hitList);
470
471 if(m_debug>1){
472 std::cout<<name()<<" print track list "<<std::endl;
474 }
475
476
477#ifdef MDCPATREC_TIMETEST
478 RecMdcTrackCol::iterator
iter = trackList->begin();
479 for (;
iter != trackList->end();
iter++) {
481 ti_nHit += tk->getNhits();
482 }
483#endif
484
485 }
486
487 m_segs->destroySegs();
488
489
490
491
493#ifdef MDCPATREC_TIMETEST
494 m_timer[1]->stop();
495
496
497 m_eventTime = m_timer[1]->elapsed();
498 m_t5recTkNum = m_tracks->length();
499 m_t5EvtNo = t_eventNo;
500 m_t5nHit = ti_nHit;
501 m_t5nDigi = t_nDigi;
502 sc = m_tupleTime->write();
503#endif
504
505 if ( m_tryBunch ){
506 if ( nTracks <1 ){ iterateT0 = true;
507 goto restart;
508 }
509 }
511
512 return StatusCode::SUCCESS;
513}
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
double haveDigiDrift[43][288]
int haveDigiAmbig[43][288]
double haveDigiPhi[43][288]
double haveDigiTheta[43][288]
double haveDigiPt[43][288]
unsigned layernumber() const
unsigned wirenumber() const
void printRecMdcTrackCol() const
bool poisoningHits() const
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol