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