248 {
249
250 MsgStream log(
msgSvc(), name());
251 log << MSG::INFO << "in execute()" << endreq;
252 cout.precision(6);
253
254
255 m_timer_all->
start();
256
257
258 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
259 if (!evTimeCol) {
260 log << MSG::WARNING << "Could not find EvTimeCol" << endreq;
261 return StatusCode::SUCCESS;
262 }else{
263 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
264 if (iter_evt != evTimeCol->end()){
265 m_bunchT0 = (*iter_evt)->getTest()*1.e-9;
266 }
267 }
269
270
271 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
272 if (!eventHeader) {
273 log << MSG::FATAL << "Could not find Event Header" << endreq;
274 return StatusCode::FAILURE;
275 }
276
277 t_eventNum=eventHeader->eventNumber();
278 t_runNum=eventHeader->runNumber();
279 if(m_hist){
280 m_eventNum=eventHeader->eventNumber();
281 m_runNum=eventHeader->runNumber();
282 }
283 if(m_debug>0) cout<<"begin evt "<<eventHeader->eventNumber()<<endl;
284
285
288 vector<RecMdcTrack*> vec_trackPatTds;
289 int nTdsTk = storeTracks(trackList_tds,hitList_tds,vec_trackPatTds);
290
291 if(m_debug>0){
292 RecMdcTrackCol::iterator iteritrk_pattsf = vec_trackPatTds.begin();
293 for(;iteritrk_pattsf!=vec_trackPatTds.end();iteritrk_pattsf++){
294 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;
295 }
296 }
297
298
300 if(m_debugArbHit>0 ) m_par.
lPrint=8;
302
303
304
305
306
307
308 if(m_filter){
310 lowPt_Evt.open(m_evtFile.c_str());
311 vector<int> evtlist;
312 int evtNum;
313 while( lowPt_Evt >> evtNum) {
314 evtlist.push_back(evtNum);
315 }
316 vector<int>::iterator iter_evt = find(evtlist.begin(),evtlist.end(),t_eventNum);
317 if( iter_evt == evtlist.end() ) { setFilterPassed(false); return StatusCode::SUCCESS; }
318 else setFilterPassed(true);
319 }
320
321 if(m_inputType == -1) GetMcInfo();
322
323
324 if(m_debug>0) cout<<"step1 : prepare digi "<<endl;
326
327
328 bool debugTruth = false;
329 if(m_inputType == -1) debugTruth= true;
330 if(m_debug>0) cout<<"step2 : hits-> hough hit list "<<endl;
332
333 if( houghHitList.nHit() < 10 || houghHitList.nHit()>500 ) return StatusCode::SUCCESS;
334 if(m_debug>0) houghHitList.printAll();
335 if(debugTruth) houghHitList.addTruthInfo(g_tkParTruth);
336
337 vector<MdcHit*> mdcHitCol_neg;
338 vector<MdcHit*> mdcHitCol_pos;
339 MdcDigiVec::iterator
iter = mdcDigiVec.begin();
340 for (;
iter != mdcDigiVec.end();
iter++) {
342 if(
HoughHit(digi).driftTime()>1000 ||
HoughHit(digi).driftTime()<=0 )
continue;
345 mdcHitCol_neg.push_back(mdcHit);
346 mdcHitCol_pos.push_back(mdcHit_pos);
347 }
348
349 HoughMap *m_map =
new HoughMap(-1,houghHitList,m_mapHit,m_nBinTheta,m_nBinRho,-1.*m_rhoRange,m_rhoRange,m_peakWidth,m_peakHigh,m_hitPro);
350
351
352 if(m_hist) m_nHit = houghHitList.nHit();
353 if(m_hist) dumpHoughMap(*m_map);
354
355
356 if(m_debug>0) cout<<"step3 : neg track list "<<endl;
357 vector<HoughTrack*> vec_track_neg;
358 vector<HoughTrack*> vec_track2D_neg;
360 if(m_recneg){
362 int trackList_size = trackList_neg.getTrackNum();
363 vector< vector<int> > stat_2d(2,vector<int>(trackList_size,0) );
364 vector< vector<int> > stat_3d(2,vector<int>(trackList_size,0) );
365 int ifit=0;
366 int ifit3D=0;
367 for(int itrack=0;itrack<trackList_size;itrack++){
368 if(m_debug>0) cout<<"begin track: "<<itrack<<endl;
369
370 if(m_debug>0) cout<<" suppose charge -1 "<<endl;
371 HoughTrack &track_neg = trackList_neg.getTrack(itrack);
375 stat_2d[0][itrack] = track_neg.
fit2D(m_bunchT0);
377 if(m_debug>0) cout<<" charge -1 stat2d "<<stat_2d[0][itrack]<<" "<<track_charge_2d<<endl;
378 if( stat_2d[0][itrack] == 0 || track_charge_2d ==0 ) continue;
379
380
381 ifit++;
382
385
386
388 if(m_debug>0) cout<<" nhitstereo -1 "<<nHit3d<<" "<<track_charge_3d<<endl;
389 if( nHit3d <3 || track_charge_3d==0 ) continue;
390
391
392 if( npair==0 ) stat_3d[0][itrack] = track_neg.
fit3D();
394
395
396 if(m_debug>0) cout<<" charge -1 stat3d "<<stat_3d[0][itrack]<<" "<<endl;
397 if( stat_3d[0][itrack]==0 ) continue;
398 vec_track_neg.push_back( &track_neg );
399
400
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 std::sort ( vec_track_neg.begin(),vec_track_neg.end(),
more_pt);
499
500 vector<MdcTrack*> vec_MdcTrack_neg;
501 for( unsigned int i =0;i<vec_track_neg.size();i++){
503 vec_MdcTrack_neg.push_back(mdcTrack);
504 if(m_debug>0) cout<<"trackneg: "<<i<<" pt "<<vec_track_neg[i]->getPt3D()<<endl;
505 if(m_debug>0) vec_track_neg[i]->print();
506 }
507 if(m_debug>0) cout<<"step4 : judge neg track list "<<endl;
508 judgeHit(mdcTrackList_neg,vec_MdcTrack_neg);
509 if(m_debug>0) cout<<"finish - charge "<<endl;
510 }
511
512
513
514 HoughMap *m_map2 =
new HoughMap(1,houghHitList,m_mapHit,m_nBinTheta,m_nBinRho,-1.*m_rhoRange,m_rhoRange,m_peakWidth,m_peakHigh,m_hitPro);
515 if(m_debug>0) cout<<"step5 : pos track list "<<endl;
516 vector<HoughTrack*> vec_track_pos;
518 if(m_recpos){
520 int tracklist_size2 = tracklist_pos.getTrackNum();
521 vector< vector<int> > stat_2d2(2,vector<int>(tracklist_size2,0) );
522 vector< vector<int> > stat_3d2(2,vector<int>(tracklist_size2,0) );
523 int ifit=0;
524 int ifit3D=0;
525 for(int itrack=0;itrack<tracklist_size2;itrack++){
526
527 if(m_debug>0) cout<<" suppose charge +1 "<<endl;
528 HoughTrack &track_pos = tracklist_pos.getTrack(itrack);
532 stat_2d2[0][itrack] = track_pos.
fit2D(m_bunchT0);
534 if(m_debug>0) cout<<" charge +1 stat2d "<<stat_2d2[1][itrack]<<" "<<track_charge_2d<<endl;
535 if( stat_2d2[0][itrack] == 0 || track_charge_2d==0 ) continue;
536
537 ifit++;
538
541
542
544 if(m_debug>0) cout<<" nhitstereo +1 "<<nHit3d<<" "<<track_charge_3d<<endl;
546
547 if( npair==0 ) stat_3d2[0][itrack] = track_pos.
fit3D();
548 else stat_3d2[0][itrack] = track_pos.
fit3D_inner();
549
550
551 if(m_debug>0) cout<<" charge +1 stat3d "<<stat_3d2[1][itrack]<<" "<<endl;
552 if( stat_3d2[0][itrack]==0 ) continue;
553 vec_track_pos.push_back( &track_pos );
554
555 ifit3D++;
556 }
557
558
559 std::sort ( vec_track_pos.begin(),vec_track_pos.end(),
more_pt);
560
561
562 vector<MdcTrack*> vec_MdcTrack_pos;
563 for( unsigned int i =0;i<vec_track_pos.size();i++){
565 vec_MdcTrack_pos.push_back(mdcTrack);
566 if(m_debug>0) cout<<"trackpos : "<<i<<" pt "<<vec_track_pos[i]->getPt3D()<<endl;
567 if(m_debug>0) vec_track_pos[i]->print();
568 }
569 if(m_debug>0) cout<<"step6 : judge pos track list "<<endl;
570 judgeHit(mdcTrackList_pos,vec_MdcTrack_pos);
571 }
572
573
574
575 if(m_combine){
576 compareHough(mdcTrackList_neg);
577 compareHough(mdcTrackList_pos);
578 }
579 if( mdcTrackList_neg.length()!=0 && mdcTrackList_pos.length()!=0 ) judgeChargeTrack(mdcTrackList_neg,mdcTrackList_pos);
580
581 mdcTrackList_neg+=mdcTrackList_pos;
582
583
584 if(m_combineTracking) nTdsTk = comparePatTsf(mdcTrackList_neg,trackList_tds);
585
586
587 if(m_debug>0) cout<<"step8 : store tds "<<endl;
588 if(m_debug>0) cout<<"store tds "<<endl;
589 int tkId = nTdsTk ;
590 for( unsigned int i =0;i<mdcTrackList_neg.length();i++){
591 if(m_debug>0) cout<<"- charge size i : "<<i<<" "<<mdcTrackList_neg.length()<<endl;
592 int tkStat = 4;
593 mdcTrackList_neg[i]->storeTrack(tkId, trackList_tds, hitList_tds, tkStat);
594 tkId++;
595 delete mdcTrackList_neg[i];
596 }
598
600 double t_teventTime = m_timer_all->
elapsed();
601 if(m_hist) m_time = t_teventTime;
602
603 if( m_hist ) ntuple_evt->write();
604
605 delete m_map;
606 delete m_map2;
607 if(m_debug>0) cout<<"after delete map "<<endl;
608 for(int ihit=0;ihit<mdcHitCol_neg.size();ihit++){
609 delete mdcHitCol_neg[ihit];
610 delete mdcHitCol_pos[ihit];
611 }
612
613 if(m_debug>0) cout<<"after delete hit"<<endl;
614
615 if(m_debug>0) cout<<"end event "<<endl;
616
617 return StatusCode::SUCCESS;
618}
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