250 {
251
252 MsgStream log(
msgSvc(), name());
253 log << MSG::INFO << "in execute()" << endreq;
254 cout.precision(6);
255
256
257 m_timer_all->
start();
258
259
260 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
261 if (!evTimeCol) {
262 log << MSG::WARNING << "Could not find EvTimeCol" << endreq;
263 return StatusCode::SUCCESS;
264 }else{
265 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
266 if (iter_evt != evTimeCol->end()){
267 m_bunchT0 = (*iter_evt)->getTest()*1.e-9;
268 }
269 }
271
272
273 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
274 if (!eventHeader) {
275 log << MSG::FATAL << "Could not find Event Header" << endreq;
276 return StatusCode::FAILURE;
277 }
278
279 t_eventNum=eventHeader->eventNumber();
280 t_runNum=eventHeader->runNumber();
281 if(m_hist){
282 m_eventNum=eventHeader->eventNumber();
283 m_runNum=eventHeader->runNumber();
284 }
285 if(m_debug>0) cout<<"begin evt "<<eventHeader->eventNumber()<<endl;
286
287
290 vector<RecMdcTrack*> vec_trackPatTds;
291 int nTdsTk = storeTracks(trackList_tds,hitList_tds,vec_trackPatTds);
292
293 if(m_debug>0){
294 RecMdcTrackCol::iterator iteritrk_pattsf = vec_trackPatTds.begin();
295 for(;iteritrk_pattsf!=vec_trackPatTds.end();iteritrk_pattsf++){
296 cout<<"in PATTSF LOST: "<<(*iteritrk_pattsf)->helix(0)<<" "<<(*iteritrk_pattsf)->helix(1)<<" "<<(*iteritrk_pattsf)->helix(2)<<" "<<(*iteritrk_pattsf)->helix(3)<<" "<<(*iteritrk_pattsf)->helix(4)<<" chi2 "<<(*iteritrk_pattsf)->chi2()<<endl;
297 }
298 }
299
300
302 if(m_debugArbHit>0 ) m_par.
lPrint=8;
304
305
306
307
308
309
310 if(m_filter){
312 lowPt_Evt.open(m_evtFile.c_str());
313 vector<int> evtlist;
314 int evtNum;
315 while( lowPt_Evt >> evtNum) {
316 evtlist.push_back(evtNum);
317 }
318 vector<int>::iterator iter_evt = find(evtlist.begin(),evtlist.end(),t_eventNum);
319 if( iter_evt == evtlist.end() ) { setFilterPassed(false); return StatusCode::SUCCESS; }
320 else setFilterPassed(true);
321 }
322
323 if(m_inputType == -1) GetMcInfo();
324
325
326 if(m_debug>0) cout<<"step1 : prepare digi "<<endl;
328
329
330 bool debugTruth = false;
331 if(m_inputType == -1) debugTruth= true;
332 if(m_debug>0) cout<<"step2 : hits-> hough hit list "<<endl;
334
335 if( houghHitList.nHit() < 10 || houghHitList.nHit()>500 ) return StatusCode::SUCCESS;
336 if(m_debug>0) houghHitList.printAll();
337 if(debugTruth) houghHitList.addTruthInfo(g_tkParTruth);
338
339 vector<MdcHit*> mdcHitCol_neg;
340 vector<MdcHit*> mdcHitCol_pos;
341 MdcDigiVec::iterator
iter = mdcDigiVec.begin();
342 for (;
iter != mdcDigiVec.end();
iter++) {
344 if(
HoughHit(digi).driftTime()>1000 ||
HoughHit(digi).driftTime()<=0 )
continue;
347 mdcHitCol_neg.push_back(mdcHit);
348 mdcHitCol_pos.push_back(mdcHit_pos);
349 }
350
351 HoughMap *m_map =
new HoughMap(-1,houghHitList,m_mapHit,m_nBinTheta,m_nBinRho,-1.*m_rhoRange,m_rhoRange,m_peakWidth,m_peakHigh,m_hitPro);
352
353
354 if(m_hist) m_nHit = houghHitList.nHit();
355 if(m_hist) dumpHoughMap(*m_map);
356
357
358 if(m_debug>0) cout<<"step3 : neg track list "<<endl;
359 vector<HoughTrack*> vec_track_neg;
360 vector<HoughTrack*> vec_track2D_neg;
362 if(m_recneg){
364 int trackList_size = trackList_neg.getTrackNum();
365 vector< vector<int> > stat_2d(2,vector<int>(trackList_size,0) );
366 vector< vector<int> > stat_3d(2,vector<int>(trackList_size,0) );
367 int ifit=0;
368 int ifit3D=0;
369 for(int itrack=0;itrack<trackList_size;itrack++){
370 if(m_debug>0) cout<<"begin track: "<<itrack<<endl;
371
372 if(m_debug>0) cout<<" suppose charge -1 "<<endl;
373 HoughTrack &track_neg = trackList_neg.getTrack(itrack);
377 stat_2d[0][itrack] = track_neg.
fit2D(m_bunchT0);
379 if(m_debug>0) cout<<" charge -1 stat2d "<<stat_2d[0][itrack]<<" "<<track_charge_2d<<endl;
380 if( stat_2d[0][itrack] == 0 || track_charge_2d ==0 ) continue;
381
382
383 ifit++;
384
387
388
390 if(m_debug>0) cout<<" nhitstereo -1 "<<nHit3d<<" "<<track_charge_3d<<endl;
391 if( nHit3d <3 || track_charge_3d==0 ) continue;
392
393
394 if( npair==0 ) stat_3d[0][itrack] = track_neg.
fit3D();
396
397
398 if(m_debug>0) cout<<" charge -1 stat3d "<<stat_3d[0][itrack]<<" "<<endl;
399 if( stat_3d[0][itrack]==0 ) continue;
400 vec_track_neg.push_back( &track_neg );
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498 }
499
500 std::sort ( vec_track_neg.begin(),vec_track_neg.end(),
more_pt);
501
502 vector<MdcTrack*> vec_MdcTrack_neg;
503 for( unsigned int i =0;i<vec_track_neg.size();i++){
505 vec_MdcTrack_neg.push_back(mdcTrack);
506 if(m_debug>0) cout<<"trackneg: "<<i<<" pt "<<vec_track_neg[i]->getPt3D()<<endl;
507 if(m_debug>0) vec_track_neg[i]->print();
508 }
509 if(m_debug>0) cout<<"step4 : judge neg track list "<<endl;
510 judgeHit(mdcTrackList_neg,vec_MdcTrack_neg);
511 if(m_debug>0) cout<<"finish - charge "<<endl;
512 }
513
514
515
516 HoughMap *m_map2 =
new HoughMap(1,houghHitList,m_mapHit,m_nBinTheta,m_nBinRho,-1.*m_rhoRange,m_rhoRange,m_peakWidth,m_peakHigh,m_hitPro);
517 if(m_debug>0) cout<<"step5 : pos track list "<<endl;
518 vector<HoughTrack*> vec_track_pos;
520 if(m_recpos){
522 int tracklist_size2 = tracklist_pos.getTrackNum();
523 vector< vector<int> > stat_2d2(2,vector<int>(tracklist_size2,0) );
524 vector< vector<int> > stat_3d2(2,vector<int>(tracklist_size2,0) );
525 int ifit=0;
526 int ifit3D=0;
527 for(int itrack=0;itrack<tracklist_size2;itrack++){
528
529 if(m_debug>0) cout<<" suppose charge +1 "<<endl;
530 HoughTrack &track_pos = tracklist_pos.getTrack(itrack);
534 stat_2d2[0][itrack] = track_pos.
fit2D(m_bunchT0);
536 if(m_debug>0) cout<<" charge +1 stat2d "<<stat_2d2[1][itrack]<<" "<<track_charge_2d<<endl;
537 if( stat_2d2[0][itrack] == 0 || track_charge_2d==0 ) continue;
538
539 ifit++;
540
543
544
546 if(m_debug>0) cout<<" nhitstereo +1 "<<nHit3d<<" "<<track_charge_3d<<endl;
548
549 if( npair==0 ) stat_3d2[0][itrack] = track_pos.
fit3D();
550 else stat_3d2[0][itrack] = track_pos.
fit3D_inner();
551
552
553 if(m_debug>0) cout<<" charge +1 stat3d "<<stat_3d2[1][itrack]<<" "<<endl;
554 if( stat_3d2[0][itrack]==0 ) continue;
555 vec_track_pos.push_back( &track_pos );
556
557 ifit3D++;
558 }
559
560
561 std::sort ( vec_track_pos.begin(),vec_track_pos.end(),
more_pt);
562
563
564 vector<MdcTrack*> vec_MdcTrack_pos;
565 for( unsigned int i =0;i<vec_track_pos.size();i++){
567 vec_MdcTrack_pos.push_back(mdcTrack);
568 if(m_debug>0) cout<<"trackpos : "<<i<<" pt "<<vec_track_pos[i]->getPt3D()<<endl;
569 if(m_debug>0) vec_track_pos[i]->print();
570 }
571 if(m_debug>0) cout<<"step6 : judge pos track list "<<endl;
572 judgeHit(mdcTrackList_pos,vec_MdcTrack_pos);
573 }
574
575
576
577 if(m_combine){
578 compareHough(mdcTrackList_neg);
579 compareHough(mdcTrackList_pos);
580 }
581 if( mdcTrackList_neg.length()!=0 && mdcTrackList_pos.length()!=0 ) judgeChargeTrack(mdcTrackList_neg,mdcTrackList_pos);
582
583 mdcTrackList_neg+=mdcTrackList_pos;
584
585
586 if(m_combineTracking) nTdsTk = comparePatTsf(mdcTrackList_neg,trackList_tds);
587
588
589 if(m_debug>0) cout<<"step8 : store tds "<<endl;
590 if(m_debug>0) cout<<"store tds "<<endl;
591 int tkId = nTdsTk ;
592 for( unsigned int i =0;i<mdcTrackList_neg.length();i++){
593 if(m_debug>0) cout<<"- charge size i : "<<i<<" "<<mdcTrackList_neg.length()<<endl;
594 int tkStat = 4;
595 mdcTrackList_neg[i]->storeTrack(tkId, trackList_tds, hitList_tds, tkStat);
596 tkId++;
597 delete mdcTrackList_neg[i];
598 }
600
602 double t_teventTime = m_timer_all->
elapsed();
603 if(m_hist) m_time = t_teventTime;
604
605 if( m_hist ) ntuple_evt->write();
606
607 delete m_map;
608 delete m_map2;
609 if(m_debug>0) cout<<"after delete map "<<endl;
610 for(int ihit=0;ihit<mdcHitCol_neg.size();ihit++){
611 delete mdcHitCol_neg[ihit];
612 delete mdcHitCol_pos[ihit];
613 }
614
615 if(m_debug>0) cout<<"after delete hit"<<endl;
616
617 if(m_debug>0) cout<<"end event "<<endl;
618
619 return StatusCode::SUCCESS;
620}
std::vector< MdcDigi * > MdcDigiVec
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
bool more_pt(const HoughTrack *tracka, const HoughTrack *trackb)
float elapsed(void) const
static void setBunchTime(double t0)
void setHoughHitList(vector< HoughHit > vec_hit)
int fit2D(double bunchtime)
void setMdcHit(const vector< MdcHit * > *mdchit)
void setCharge(int charge)
void printRecMdcTrackCol() const