190 {
191
192 MsgStream log(
msgSvc(), name());
193 log << MSG::INFO << "in execute()" << endreq;
194
195
196 StatusCode sc = StatusCode::SUCCESS;
197
198
199 int event, run;
200
201 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
202 if (!eventHeader) {
203 log << MSG::FATAL << "Could not find Event Header" << endreq;
204
205 }
206 m_totalEvent ++;
207 log << MSG::INFO << "Event: "<<m_totalEvent<<"\tcurrent run: "<<eventHeader->runNumber()<<"\tcurrent event: "<< eventHeader->eventNumber()<<endreq;
208
209event = eventHeader->eventNumber();
210run = eventHeader->runNumber();
211
212 string release = getenv(
"BES_RELEASE");
213
214
215
216 for (std::vector<FilterEvent>::iterator it = m_filter_event.begin();
217 it != m_filter_event.end(); ++it) {
218 const FilterEvent& fe = (*it);
219 if (
release == fe.bossver && run == fe.runid && event == fe.eventid) {
220 cout << "SKIP: " << fe.bossver << " "
221 << fe.runid << " "
222 << fe.eventid << std::endl;
223 return StatusCode::SUCCESS;
224 }
225 }
226
227
228 if(m_CompareWithMcHit==1){
229 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
230 if (!mcParticleCol) {
231 log << MSG::FATAL << "Could not find McParticle" << endreq;
232
233 }
234
235 McParticleCol::iterator iter_mc = mcParticleCol->begin();
236
237
238
239 int pid = (*iter_mc)->particleProperty();
240 int charge = 0;
242
243 if( pid >0 )
244 {
245 if(m_particleTable->particle( pid )){
246 charge = (int)m_particleTable->particle( pid )->charge();
247 mass = m_particleTable->particle( pid )->mass();
248 }
249 else log << MSG::ERROR << "no this particle id in particle table, please check data" <<endreq;
250 } else if ( pid <0 ) {
251 if(m_particleTable->particle( -pid )){
252 charge = (int)m_particleTable->particle( -pid )->charge();
253 charge *= -1;
254 mass = m_particleTable->particle( -pid )->mass();
255 }
256 else log << MSG::ERROR << "no this particle id in particle table, please check data" <<endreq;
257 } else {
258 log << MSG::WARNING << "wrong particle id, please check data" <<endreq;
259 }
260
261
262
263
264
265
266
267 HepLorentzVector initialMomentum = (*iter_mc)->initialFourMomentum();
268 HepLorentzVector initialPos = (*iter_mc)->initialPosition();
269 if(m_NtOutput>=1){
270 m_px_mc = initialMomentum.px();
271 m_py_mc = initialMomentum.py();
272 m_pz_mc = initialMomentum.pz();
273 }
274
275
276 log << MSG::INFO << " particleId = " << (*iter_mc)->particleProperty() << endreq;
277 }
278
279
280 int digiId = 0;
281 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),"/Event/Digi/MucDigiCol");
282 if (!mucDigiCol) {
283 log << MSG::FATAL << "Could not find MUC digi" << endreq;
284 return( StatusCode::FAILURE);
285 }
286 MucDigiCol::iterator iter4 = mucDigiCol->begin();
287 for (;iter4 != mucDigiCol->end(); iter4++, digiId++) {
288 }
289 log << MSG::INFO << "Total MUC digis:\t" << digiId << endreq;
290 if( digiId == 0 ) return ( StatusCode::SUCCESS);
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
319
320
321
322
323 if (m_CompareWithMcHit) {
326
327 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
328 if (!mcParticleCol) {
329 log << MSG::FATAL << "Could not find McParticle" << endreq;
330
331 }
332 McParticleCol::iterator iter_mc = mcParticleCol->begin();
333
334
335 SmartDataPtr<Event::MucMcHitCol> aMucMcHitCol(eventSvc(),"/Event/MC/MucMcHitCol");
336 if (!aMucMcHitCol) {
337 log << MSG::WARNING << "Could not find MucMcHitCol" << endreq;
338
339 }
340
341 log << MSG::DEBUG << "MucMcHitCol contains " << aMucMcHitCol->size() << " Hits " << endreq;
342 MucMcHitCol::iterator iter_MucMcHit = aMucMcHitCol->begin();
343 for (; iter_MucMcHit != aMucMcHitCol->end(); iter_MucMcHit++) {
344 mucID = (*iter_MucMcHit)->identify();
345
346 log << MSG::DEBUG << " MucMcHit " << " : "
351 << " Track Id " << (*iter_MucMcHit)->getTrackIndex()
352 << " pos x " << (*iter_MucMcHit)->getPositionX()
353 << " pos y " << (*iter_MucMcHit)->getPositionY()
354 << " pos z " << (*iter_MucMcHit)->getPositionZ()
355 << endreq;
356
358 for (iter_mc = mcParticleCol->begin(); iter_mc != mcParticleCol->end(); iter_mc++) {
359 if ( (*iter_mc)->trackIndex() == (*iter_MucMcHit)->getTrackIndex() ) {
360 assocMcPart = *iter_mc;
361 break;
362 }
363 }
364 if (assocMcPart == 0) {
365 log << MSG::WARNING << "No Corresponding Mc Particle found for this MucMcHit" << endreq;
366 }
367
368 MucMcHit *assocMucMcHit = *iter_MucMcHit;
371 if (relMcMuc == 0) log << MSG::DEBUG << "relMcMuc not created " << endreq;
372 else {
374 if(!addstat) delete relMcMuc;
375 }
376 }
377
378 log << MSG::DEBUG <<
" Fill McPartToMucHitTab, size " << assocMcMuc.
size() << endreq;
379 iter_mc = mcParticleCol->begin();
380 for (;iter_mc != mcParticleCol->end(); iter_mc++) {
381 log << MSG::DEBUG << " Track index " << (*iter_mc)->trackIndex()
382 << " particleId = " << (*iter_mc)->particleProperty()
383 << endreq;
384
385 vector< McPartToMucHitRel* > vecMucMcHit = assocMcMuc.
getRelByFirst(*iter_mc);
386 vector< McPartToMucHitRel* >::iterator iter_MucMcHit = vecMucMcHit.begin();
387 for (; iter_MucMcHit != vecMucMcHit.end(); iter_MucMcHit++) {
388 mucID = (*iter_MucMcHit)->getSecond()->identify();
389
390 log << MSG::DEBUG
391
392 << " MC Particle index "
393 << (*iter_MucMcHit)->getFirst()->trackIndex()
394 << " contains " << " MucMcHit "
399
400
401
402 << endreq;
403 }
404 }
405
406
407
408
409
410
411
412
413
414
415
416
417 }
418
419
420
421 if (!m_MucRecHitContainer) {
423 }
424 m_MucRecHitContainer->
Clear();
427
428 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
429 DataObject *mucRecHitCol;
430 eventSvc()->findObject("/Event/Recon/MucRecHitCol",mucRecHitCol);
431 if(mucRecHitCol != NULL) {
432 dataManSvc->clearSubTree("/Event/Recon/MucRecHitCol");
433 eventSvc()->unregisterObject("/Event/Recon/MucRecHitCol");
434 }
435
436 sc = eventSvc()->registerObject("/Event/Recon/MucRecHitCol", aMucRecHitCol);
437 if (!sc) {
438 log << MSG::ERROR << "/Event/Recon/MucRecHitCol not registerd!" << endreq;
439 return( StatusCode::FAILURE);
440 }
441
442 log << MSG::INFO << "Add digis" << endreq;
443 MucDigiCol::iterator iter_Muc = mucDigiCol->begin();
444 int mucDigiId = 0;
445 for (;iter_Muc != mucDigiCol->end(); iter_Muc++, mucDigiId++) {
446 mucID = (*iter_Muc)->identify();
451
452 m_MucRecHitContainer->
AddHit(part, seg, gap, strip);
453
454 log << MSG::DEBUG << " digit" << mucDigiId << " : "
455 << " part " << part
456 << " seg " << seg
457 << " gap " << gap
458 << " strip " << strip
459 << endreq;
460 }
461
462
463
465
466
467 DataObject *aReconEvent ;
468 eventSvc()->findObject("/Event/Recon",aReconEvent);
469 if(aReconEvent==NULL) {
470
472 StatusCode sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
473 if(sc!=StatusCode::SUCCESS) {
474 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
475 return( StatusCode::FAILURE);
476 }
477 }
478 StatusCode fr = eventSvc()->findObject("/Event/Recon",aReconEvent);
479 if(fr!=StatusCode::SUCCESS) {
480 log << MSG::WARNING << "Could not find register ReconEvent, will create it" <<endreq;
481 StatusCode sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
482 if(sc!=StatusCode::SUCCESS) {
483 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
484 return( StatusCode::FAILURE);
485 }
486 }
487
488 DataObject *mucTrackCol;
489 eventSvc()->findObject("/Event/Recon/RecMucTrackCol",mucTrackCol);
490 if(mucTrackCol != NULL) {
491 dataManSvc->clearSubTree("/Event/Recon/RecMucTrackCol");
492 eventSvc()->unregisterObject("/Event/Recon/RecMucTrackCol");
493 }
494
495 sc = eventSvc()->registerObject("/Event/Recon/RecMucTrackCol", aRecMucTrackCol);
496 if(sc!=StatusCode::SUCCESS) {
497 log << MSG::FATAL << "Could not register MUC track collection" << endreq;
498 return( StatusCode::FAILURE);
499 }
500
501
502 SmartDataPtr<RecMucTrackCol> findRecMucTrackCol(eventSvc(),"/Event/Recon/RecMucTrackCol");
503 if (!findRecMucTrackCol) {
504 log << MSG::FATAL << "Could not find RecMucTrackCol" << endreq;
505 return( StatusCode::FAILURE);
506 }
507 aRecMucTrackCol->clear();
508
509
510
511
512
513 SmartDataPtr<RecExtTrackCol> aExtTrackCol(eventSvc(),"/Event/Recon/RecExtTrackCol");
514 if (!aExtTrackCol) {
515 log << MSG::WARNING << "Can't find ExtTrackCol in TDS!" << endreq;
516
517 }
518
519 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
520 if (!aMdcTrackCol) {
521 log << MSG::WARNING << "Can't find MdcTrackCol in TDS!" << endreq;
522
523 }
524
525
526
527 SmartDataPtr<RecEmcShowerCol> aShowerCol(eventSvc(),"/Event/Recon/RecEmcShowerCol");
528 if (!aShowerCol) {
529 log << MSG::WARNING << "Could not find RecEmcShowerCol" << endreq;
530
531 }
532
533
534
535
536
537
538
539
540
541 int muctrackId = 0;
542
543 log << MSG::INFO << "Add tracks info, ExtTrackSeedMode = " << m_ExtTrackSeedMode << ", EmcShowerSeedMode = " << m_EmcShowerSeedMode << endreq;
544
545 if (m_ExtTrackSeedMode == 1)
546 {
547 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
548 if (!mcParticleCol) {
549 log << MSG::FATAL << "Could not find McParticle" << endreq;
550
551 return( StatusCode::SUCCESS);
552 }
553 McParticleCol::iterator iter_mc = mcParticleCol->begin();
554
555 int trackIndex = -99;
556 for (int iTrack = 0;iter_mc != mcParticleCol->end(); iter_mc++, iTrack++) {
557 if(!(*iter_mc)->primaryParticle()) continue;
558 int pid = (*iter_mc)->particleProperty();
559 int charge = 0;
561 if( pid >0 )
562 {
563 if(m_particleTable->particle( pid )){
564 charge = (int)m_particleTable->particle( pid )->charge();
565 mass = m_particleTable->particle( pid )->mass();
566 }
567 else log << MSG::ERROR << "no this particle id in particle table, please check data" <<endreq;
568 } else if ( pid <0 )
569 {
570 if(m_particleTable->particle( -pid )){
571 charge = (int)m_particleTable->particle( -pid )->charge();
572 charge *= -1;
573 mass = m_particleTable->particle( -pid )->mass();
574 }
575 else log << MSG::ERROR << "no this particle id in particle table, please check data" <<endreq;
576 } else {
577 log << MSG::WARNING << "wrong particle id, please check data" <<endreq;
578 }
579
580 if(!charge) {
581 log << MSG::WARNING
582 << " neutral particle charge = 0!!! ...just skip it !"
583 << endreq;
584 continue;
585 }
586
587 trackIndex = (*iter_mc)->trackIndex();
588 log << MSG::DEBUG << "iTrack " << iTrack << " index " << trackIndex
589 << " particleId = " << (*iter_mc)->particleProperty()
590 << endreq;
591
594 aTrack->
setId(muctrackId);
595
596 HepLorentzVector initialMomentum = (*iter_mc)->initialFourMomentum();
597 HepLorentzVector initialPos = (*iter_mc)->initialPosition();
598 float theta0 = initialMomentum.theta();
599 float phi0 = initialMomentum.phi();
600
601
602
603 float x0 = initialPos.x();
604 float y0 = initialPos.y();
605 float z0 = initialPos.z();
606
607 Hep3Vector startPos(x0, y0, z0);
608 Hep3Vector startP(initialMomentum.px(), initialMomentum.py(), initialMomentum.pz());
609 log << MSG::DEBUG << "startP " << startP <<" startPos "<<startPos<< endreq;
610 Hep3Vector endPos(0, 0, 0), endP;
611
616 aTrack->
SetExtMucPos( endPos.x(), endPos.y(), endPos.z() );
618 aTrack->
SetMucPos( endPos.x(), endPos.y(), endPos.z() );
622
623
624
625
626
627
628
629
630
631
632 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId << endreq;
633 aRecMucTrackCol->add(aTrack);
634 muctrackId ++ ;
635 }
636 }
637 else if (m_ExtTrackSeedMode == 2)
638 {
639 if (!aExtTrackCol || !aMdcTrackCol) {
640 log << MSG::WARNING << "Can't find ExtTrackCol or MdcTrackCol in TDS!" << endreq;
641 return StatusCode::SUCCESS;
642 }
643
644 int trackIndex = -99;
645 double kdep = -99;
646 double krechi = 0.;
647 int kdof = 0;
648 int kbrLay = -1;
649 int kecLay = -1;
650
651 RecExtTrackCol::iterator iter_ExtTrack = aExtTrackCol->begin();
652 RecMdcTrackCol::iterator iter_MdcTrack = aMdcTrackCol->begin();
653 int iExtTrack = 0;
654 for (;iter_ExtTrack != aExtTrackCol->end() && iter_MdcTrack != aMdcTrackCol->end(); iter_ExtTrack++, iter_MdcTrack++, iExtTrack++)
655 {
656 trackIndex = (*iter_ExtTrack)->GetTrackId();
657 log << MSG::DEBUG << "iExtTrack " << iExtTrack << " index " << trackIndex << " MucPos "
658 << iExtTrack << (*iter_ExtTrack)->mucPosition().x() << " "
659 << (*iter_ExtTrack)->mucPosition().y() << " "
660 << (*iter_ExtTrack)->mucPosition().z() << " r "
661 << (*iter_ExtTrack)->mucPosition().r() << endreq;
662
663 if((*iter_ExtTrack)->mucPosition().x() == -99 &&
664 (*iter_ExtTrack)->mucPosition().y() == -99 &&
665 (*iter_ExtTrack)->mucPosition().z() == -99)
666 {
667 log << MSG::INFO <<"Bad ExtTrack, trackIndex: " << trackIndex << ", skip" << endreq;
668 continue;
669 }
670
671
672 krechi = (*iter_ExtTrack)->MucKalchi2();
673 kdof= (*iter_ExtTrack)->MucKaldof();
674 kdep = (*iter_ExtTrack)->MucKaldepth();
675 kbrLay = (*iter_ExtTrack)->MucKalbrLastLayer();
676 kecLay = (*iter_ExtTrack)->MucKalecLastLayer();
677 if(kdof<=0)krechi = 0.;
678 else krechi = krechi/kdof;
679 kdep = kdep/10.;
680
683 aTrack->
setId(muctrackId);
684
686
688
689
695
696
697 Hep3Vector mdcMomentum = (*iter_MdcTrack)->p3();
698 Hep3Vector mucPos = (*iter_ExtTrack)->mucPosition();
699 Hep3Vector mucMomentum = (*iter_ExtTrack)->mucMomentum();
700
701
702 aTrack->
SetMdcMomentum( mdcMomentum.x(), mdcMomentum.y(), mdcMomentum.z() );
703 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
704
706 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
707 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
709 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
711
712 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId << endreq;
713 aRecMucTrackCol->add(aTrack);
714 muctrackId ++ ;
715 }
716 }
717 else if(m_ExtTrackSeedMode == 3)
718 {
719
720 if (!aMdcTrackCol) {
721 log << MSG::WARNING << "Can't find MdcTrackCol in TDS!" << endreq;
722 return StatusCode::SUCCESS;
723
724 }
725 log<< MSG::INFO << "Mdc track size: "<<aMdcTrackCol->size()<<endreq;
726
727 int trackIndex = -99;
728 for(RecMdcTrackCol::iterator iter_mdc1 = aMdcTrackCol->begin(); iter_mdc1 != aMdcTrackCol->end(); iter_mdc1++){
729
730
731
732
733 trackIndex = (*iter_mdc1)->trackId();
734 HepVector helix = (*iter_mdc1)->helix();
735
736
737 float x0 = helix[0] *
cos(helix[1]);
738 float y0 = helix[0] *
sin(helix[1]);
739 float z0 = helix[3];
740
741
742
743
744
745 float dx = -1*
sin(helix[1]);
746 float dy =
cos(helix[1]);
747 float dz = helix[4];
748
749
750
753 aTrack->
setId(muctrackId);
754 muctrackId ++ ;
755
757
758
759 Hep3Vector mucPos(x0,y0,z0);
760 Hep3Vector mucMomentum(dx,dy,dz);
761
764
770
771 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId << endreq;
772 aRecMucTrackCol->add(aTrack);
773 muctrackId ++ ;
774 }
775 }
776 else {log << MSG::INFO <<"ExtTrackSeedMode error!"<<endreq; }
777
778
779 if(m_EmcShowerSeedMode == 1)
780 {
781 int trackIndex = 999;
782 RecEmcShowerCol::iterator iShowerCol;
783 for(iShowerCol=aShowerCol->begin(); iShowerCol!=aShowerCol->end(); iShowerCol++)
784 {
785
786
787
788
791 aTrack->
setId(muctrackId);
793
794 Hep3Vector mucPos = (*iShowerCol)->position();
795 Hep3Vector mucMomentum = (*iShowerCol)->position();
796
797 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
798
800 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
801 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
803 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
805
806
807 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId << endreq;
808 aRecMucTrackCol->add(aTrack);
809 muctrackId ++ ;
810
811 m_emcrec = 1;
812 }
813 }
814 log << MSG::DEBUG << " track container filled " << endreq;
815
816
817 log << MSG::INFO << "Start tracking..." << endreq;
818 int runVerbose = 1;
820 for(int iTrack = 0; iTrack < (int)aRecMucTrackCol->size(); iTrack++)
821 {
822 log << MSG::DEBUG << "iTrack " << iTrack << endreq;
823 aTrack = (*aRecMucTrackCol)[iTrack];
824
825
828 if(currentPos.mag() <
kMinor) {
829 log << MSG::WARNING << "No MUC intersection in track " << iTrack << endreq;
830 continue;
831 }
832
833
834 int firstHitFound[2] = { 0, 0};
835 int firstHitGap[2] = {-1, -1};
837 {
840 {
841
842 int seg = -1;
844
845 float xInsct, yInsct, zInsct;
846 aTrack->
Project(iPart, iGap, xInsct, yInsct, zInsct, seg);
847 if(m_MsOutput) cout << "part " << iPart << " gap " << iGap << " x " << xInsct << " y " << yInsct << " z " << zInsct << " seg " << seg << endl;
848
849 if(seg == -1) continue;
850
852
853 for(
int iDeltaSeg = 0; iDeltaSeg <
kNSegSearch; iDeltaSeg++)
854 {
858
859
860
861
862
863
866
868 for (
int iHit = 0; iHit < m_MucRecHitContainer->
GetGapHitCount(iPart, iSeg, iGap); iHit++)
869 {
870 log << MSG::DEBUG << "iSeg " << iSeg << " iHit " << iHit << endreq;
871 MucRecHit* pHit = m_MucRecHitContainer->
GetHit(iPart, iSeg, iGap, iHit);
872
873
874 if (!pHit) {
875 log << MSG::WARNING << "MucRecTrkExt: null pointer to pHit" << endreq;
876 continue;
877 }
878 else
879 {
880
881
882
884 log << MSG::DEBUG << "distance = " << setw(8) << dX << " size " << setw(4) << window << endreq;
885
886 if(m_NtOutput >= 2){
887 m_distance = dX;
888 m_part = iPart; m_seg = iSeg; m_gap = iGap; m_strip = pHit->
Strip();
889 m_diff = -99; m_tuple->write();
890 }
891
892 if (fabs(dX) < window)
893 {
894
895
896
897
901
902 }
904
908 }
909 }
910
911
913
914 if (firstHitGap[orient] == -1) firstHitGap[orient] = iGap;
915 firstHitFound[orient] = 1;
916
917
918 log << MSG::DEBUG << " part " << iPart << " seg " << iSeg << " gap " << iGap
919 <<
" strip " << setw(2) << pHit->
Strip() <<
" attatched" << endreq;
920 log << MSG::DEBUG <<
"current total hits " << aTrack->
GetTotalHits() << endreq;
921 }
922 else {
923 m_NHitsLostInGap[iGap]++;
924
925
926
927 }
928 }
929 }
931 }
932
933
934 if(m_ExtTrackSeedMode != 3 && !m_Blind) {
935 if (firstHitFound[orient] && firstHitGap[orient] != iGap) aTrack->
CorrectDir();
937 }
938
939
941 }
942 }
943 aTrack->
LineFit(m_fittingMethod);
945 log << MSG::INFO <<
"Fit track done! trackIndex: " << aTrack->
trackId() <<
", mucId: " << aTrack->
id() <<
", RecMode: " << aTrack->
GetRecMode() << endreq;
946
947 if(m_NtOutput>=1)
948 {
949 m_depth = aTrack->
depth();
952 m_Chi2 = aTrack->
chi2();
959
960 m_emctrack = m_emcrec;
961 }
962
963
964 if(m_NtOutput>=2)
965 {
966 vector<MucRecHit*> attachedHits = aTrack->
GetHits();
968 vector<float> distanceHits = aTrack->
getDistHits();
971
972 for(int i=0; i< expectedHits.size(); i++)
973 {
975
976 }
977
978 for(int j=0; j< attachedHits.size(); j++)
979 {
981
982 if(attachedHits.size()==distanceHits.size())
983 {
984 m_part = jhit->
Part(); m_seg = jhit->
Seg(); m_gap = jhit->
Gap();
985 m_strip = jhit->
Strip();
986 m_distance = distanceHits[j];
987 m_Distance = distanceHits_quad[j];
988 m_diff = -9999;
989
990
991
992 m_tuple->write();
993 }
994 }
995 }
996
998
999
1000 log << MSG::DEBUG <<
"track Index " << aTrack->
trackId()
1001 << setw(2) << mucDigiCol->size() - nHitsAttached << " of "
1002 << setw(2) << mucDigiCol->size() << " lost " << endreq;
1003
1004 }
1005
1006
1007
1008
1009
1010
1011
1012 if(m_MucHitSeedMode == 1)
1013 {
1014 MucRecHit *pHit = 0 ,*pHit0 = 0, *pHit1 = 0;
1016
1018 {
1020 {
1021 bool hit0 = false, hit1 = false; int firstgap0 = -1, firstgap1 = -1; int nStrip0 = 0, nStrip1 = 0;
1022 Hep3Vector posHit0, posHit1;
1024 {
1026 for (
int iHit0 = 0; iHit0 <
count; iHit0++)
1027 {
1028
1029 pHit = m_MucRecHitContainer->
GetHit(iPart, iSeg, iGap, iHit0);
1030 if (!pHit) {
1031 log << MSG::FATAL << "MucRecRoadFinder-E10 " << " part " << iPart
1032 << " seg " << iSeg << " gap " << iGap << " null pointer"
1033 << endl;
1034 }
1035 else
1036 {
1037
1039 {
1041 if(orient == 1 && hit0 == false){
1042 hit0 = true;
1043 firstgap0 = iGap;
1044 }
1045 if(iGap == firstgap0){
1047 nStrip0++;
1048 }
1049
1050 if(orient == 0 && hit1 == false){
1051 hit1 = true;
1052 firstgap1 = iGap;
1053 }
1054 if(iGap == firstgap1){
1056 nStrip1++;
1057 }
1058
1059
1060
1061
1062
1063
1064
1065
1066 }
1067 }
1068 }
1069 }
1070
1071
1072 if(hit0 && hit1)
1073 {
1074 posHit0 /= nStrip0;
1075 posHit1 /= nStrip1;
1076
1077
1078
1079 int trackIndex = 999;
1082 aTrack->
setId(muctrackId);
1083 muctrackId ++ ;
1084
1086
1087 Hep3Vector mucPos, mucMomentum;
1088 if(iPart==1) {
1089 mucMomentum.set(posHit0.x(),posHit0.y(),posHit1.z());
1090 mucPos = mucMomentum * 0.9;
1091 }
1092 else{
1093 mucMomentum.set(posHit0.x(),posHit1.y(),posHit0.z()*0.5+posHit1.z()*0.5);
1094 mucPos = mucMomentum * 0.9;
1095 }
1096
1097 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
1098
1100 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
1101 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
1103 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
1104
1106 aRecMucTrackCol->add(aTrack);
1107
1109 }
1110
1111 if(m_NtOutput>=1){
1112 m_depth = aTrack->
depth();
1115 m_Chi2 = aTrack->
chi2();
1122
1123 m_emctrack = 2;
1124 }
1125
1126 }
1127 }
1128 }
1129
1130
1131 int nTracksTotal = 0;
1132 int nTracksFound = 0;
1133 int nTracksLost = 0;
1134 int nTracksLostByExt = 0;
1135 int nTracksMisFound = 0;
1136
1137 int nDigisTotal = 0;
1138 int nHitsTotal = 0;
1139 int nHitsFound = 0;
1140 int nHitsLost = 0;
1141 int nHitsMisFound = 0;
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347 m_NDigisTotal += nDigisTotal;
1348 m_NHitsTotal += nHitsTotal;
1349 m_NHitsFoundTotal += nHitsFound;
1350 m_NHitsLostTotal += nHitsLost;
1351 m_NHitsMisFoundTotal += nHitsMisFound;
1352
1353
1354 m_NTracksTotal += nTracksTotal;
1355 m_NTracksRecoTotal += nTracksFound;
1356 m_NTracksLostByMdcTotal += nTracksLost;
1357 m_NTracksLostByExtTotal += nTracksLostByExt;
1358 m_NTracksMdcGhostTotal += nTracksMisFound;
1359 if (aRecMucTrackCol->size() > 0)
1360 {
1361 RecMucTrack *aRecMucTrack = (*aRecMucTrackCol)[0];
1362
1363 if(m_NtOutput>=1){
1367
1371 }
1372
1373
1374 }
1375
1376 if(m_NtOutput>=1) m_tuple->write();
1377 return StatusCode::SUCCESS;
1378}
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< MucRecHit > MucRecHitCol
const int kDeltaSeg[kNSegSearch]
const float kFirstHitWindowRatio
ObjectVector< RecMucTrack > RecMucTrackCol
void setkalbrLastLayer(int br)
int maxHitsInLayer() const
void setkalecLastLayer(int ec)
void setkalRechi2(double ch)
void setkalDepth(double de)
void init()
Initialize the internal pointer to an ObjectList of relations.
unsigned long size() const
This method returns the number of relations in the table.
bool addRelation(Relation< T1, T2 > *rel)
std::vector< Relation< T1, T2 > * > getRelByFirst(const T1 *pobj) const
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
static int barrel_ec(const Identifier &id)
Values of different levels.
static int layer(const Identifier &id)
static int channel(const Identifier &id)
static int segment(const Identifier &id)
static value_type getPartNum()
static value_type getSegNum(int part)
static value_type getGapNum(int part)
void Clear()
Remove all hit objects from the container, and destroy them.
MucRecHit * GetHit(const MucRecHitID hitID)
Get a MucRecHit object by hit identifier.
void AddHit(const Identifier id)
void SetMucRecHitCol(MucRecHitCol *p)
int GetGapHitCount(const MucRecHitID gapID)
How many hits are there in this gap?
Hep3Vector GetCenterPos() const
Get Center position of the strip (global coords).
int Part() const
Get Part.
int Strip() const
Get Strip.
void SetHitMode(int recmode)
void TrackFinding(RecMucTrack *aTrack)
float getWindowSize(Hep3Vector mom, int part, int seg, int gap)
int GetTotalHits() const
How many hits in all does this track contain?
void LineFit(int fittingMethod)
Line fit with hits on a seg with max hits.
void CorrectPos()
Correct current position of this trajectory.
void CorrectDir()
Correct direction of this trajectory.
void ComputeTrackInfo(int fittingmethod)
Get corresponding monte carlo track pointer.
void pushExtDistHits(float dist)
vector< float > getExtDistHits() const
void SetMdcMomentum(const float px, const float py, const float pz)
set start moment of the track in Mdc.
Hep3Vector getMucPos() const
start position of this track in Muc.
Hep3Vector getMucPosSigma() const
void AttachInsct(Hep3Vector insct)
Attach the intersection to this trajectory.
void SetExtMucPos(const float x, const float y, const float z)
set start position of ext track in Muc. (compute from MdcPos MdcMomentum or get from ExtTrack)
void SetExtTrackID(int id)
set Ext track id. for compute from mdc myself
void SetMdcPos(const float x, const float y, const float z)
set start position of the track in Mdc.
void SetCurrentDir(const float x, const float y, const float z)
set current direction of the trajectory.
void SetExtTrack(RecExtTrack *extTrack)
set Ext track point.
void setTrackId(const int trackId)
set the index for this track.
Hep3Vector GetExtMucDistance() const
Distance match of the ext track with muc track in first layer.
void GetMdcExtTrack(Hep3Vector mdcStartPos, Hep3Vector mdcStartMomentum, int charge, Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
compute ext track myself from mdc.
Hep3Vector GetMucStripPos() const
Hep3Vector GetCurrentDir() const
Current direction.
Hep3Vector getMdcMomentum() const
momentum of this track in Mdc
Hep3Vector CalculateInsct(const int part, const int seg, const int gap)
Calculate intersection from all hits attached on this gap.
void Project(const int &part, const int &gap, float &x, float &y, float &z, int &seg)
Where does the trajectory of this track intersect a specific gap?
vector< float > getQuadDistHits() const
void SetMucMomentum(const float px, const float py, const float pz)
set start moment of the track in Muc.
Hep3Vector GetCurrentInsct() const
Current intersection.
void SetExtMucMomentum(const float px, const float py, const float pz)
set start moment of ext track in Muc.
vector< MucRecHit * > GetHits() const
Get all hits on this track.
void AttachHit(MucRecHit *hit)
set corresponding monte carlo track pointer.
Hep3Vector GetCurrentPos() const
Current position.
void SetCurrentInsct(const float x, const float y, const float z)
set current intersection of the trajectory with strip plane.
void SetCurrentPos(const float x, const float y, const float z)
set current position of the trajectory.
vector< MucRecHit * > GetExpectedHits() const
void SetRecMode(int recmode)
void SetMucPos(const float x, const float y, const float z)
set start position of the track in Muc. (after line fit and correction)
float GetHitDistance2(const MucRecHit *hit)
no abs value
vector< float > getDistHits() const
Event::Relation< Event::McParticle, Event::MucMcHit > McPartToMucHitRel