270 if (
fVerbose>0) std::cout<<
"PndCATracking::Exec"<<std::endl;
274 FairField* MF=FairRunAna::Instance()->GetField();
278 MF->Field(xyz,fieldValue);
279 double Bz = fieldValue[2];
281 static int iEvent = -1;
284 string filePrefix =
"./CATrackerData";
285 TString fadata_name =
"CATrackerData/event";
287 static TFile* perfHistoFile = 0;
289 fadata_name += iEvent;
296 if( !perfHistoFile ){
297 perfHistoFile =
new TFile( (filePrefix +
"CATrackerPerformance.root").data(),
"RECREATE" );
298 if( !perfHistoFile->IsOpen() ){
299 gSystem->Exec(
"mkdir ./CATrackerData");
300 perfHistoFile =
new TFile( (filePrefix +
"CATrackerPerformance.root").data(),
"RECREATE" );
344 map<int, unsigned int> nHitsInMCTrack, nMCPointsInMCTrack, FirstMCPointIDInMCTrack;
352 TGeoHMatrix* transMat =
gGeoManager->GetCurrentMatrix();
353 Double_t *mmm = transMat->GetRotationMatrix();
354 if(
fabs(mmm[6]) < 0.999 &&
fabs(mmm[7]) < 0.999) {
continue; }
357 MCTrackSortedArray[MvdPoint->GetTrackID()].
MvdArray.push_back(MvdPoint);
382 MCTrackSortedArray[SttPoint->GetTrackID()].
SttArray.push_back(SttPoint);
387 outH << nHits << endl;
388 outHL << nHits << endl;
389 outMCP << nPoints << endl;
390 outMCT << nMCTracks << endl;
393 std::vector<PndCAGBHit> vHits;
398 WriteMVDHits( vHits, outH, outHL, outMCT, outMCP, iHit, nHitsInMCTrack, 1);
401 WriteMVDHits( vHits, outH, outHL, outMCT, outMCP, iHit, nHitsInMCTrack, 0);
406 Int_t sttLinkType = FairRootManager::Instance()->GetBranchId(
"STTPoint");
408 std::map<Int_t,Int_t> tubeMap;
409 std::map<Int_t,Int_t>::iterator mapIt;
412 for(
int iHStt=0; iHStt<
fSttHitsArray->GetEntriesFast(); iHStt++)
416 mapIt = tubeMap.find(
'b');
417 if( mapIt == tubeMap.end() ){
418 tubeMap.insert( std::pair<Int_t,Int_t>(tubeID,1) );
421 if( mapIt->second >3 )
continue;
430 const Double_t errXY2 = errXY*errXY;
434 TMatrixT<Double_t>
C(3,3);
438 C[0][1] =
C[0][2] =
C[1][0] =
C[1][2] =
C[2][0] =
C[2][1] = 0;
440 TMatrixT<Double_t>
CR =
C;
443 CR = CR*RM.Transpose(RM);
458 A = atan(
fabs(y/x) );
461 if ( y >= 0 && x >= 0 ) A = pi2 - A;
462 if ( y < 0 && x >= 0 ) A = pi2 + A;
463 if ( y < 0 && x < 0 ) A = 3*pi2 - A;
464 if ( y >= 0 && x < 0 ) A = 3*pi2 + A;
466 A = floor(A/pi/2*6)*pi/3;
472 if ( iS < 7.5 ) iSta = floor(iS+0.5);
473 else if ( iS-.1547 < 9.5 ) iSta = floor(iS-.1547+0.5);
474 else if ( iS-.5883 < 11.5 ) iSta = floor(iS-.5883+0.5);
475 else if ( iS-1.022 < 13.5 ) iSta = floor(iS-1.022+0.5);
476 else if ( iS-1.4556 < 15.5 ) iSta = floor(iS-1.4556+0.5);
477 else iSta = floor(iS-2+0.5);
482 FairMultiLinkedData links = currenthit->GetLinksWithType(sttLinkType);
483 if( links.GetNLinks() >0 ){
484 int iPoint = links.GetLink(0).GetIndex();
487 cout<<
"CA tracker: wrong index of Stt point: "<<iPoint<<
" of "<<
fSttPointsArray->GetEntriesFast()<<endl;
490 trackID = point->GetTrackID();
493 cout<<
"CA tracker: stt hit has no link to stt point"<<endl;
507 h.
SetErr2R( closestDistanceError*closestDistanceError );
522 outHL << trackID <<
" " << -1 <<
" " << -1 << endl;
536 if ( nHitsInMCTrack.find(trackID) != nHitsInMCTrack.end() ) {
537 nHitsInMCTrack[trackID]++;
539 nHitsInMCTrack[trackID] = 1;
545 for (
int iTr = 0; iTr < nMCTracks; iTr++ ){
551 for(
int iPStt=0; iPStt<MCTrackSortedArray[iTr].
GetNMvdPoints(); iPStt++)
554 int trackID = point->GetTrackID();
561 TParticlePDG * part = TDatabasePDG::Instance()->GetParticle(mcTr->
GetPdgCode());
563 q = part->Charge()/3.f;
565 else { cout <<
"CA tracker: Bad MCTracks2" << endl; }
567 else { cout <<
"CA traker: Bad MCTracks" << endl; }
570 Double_t x = point->GetX(), y = point->GetY();
573 if( (r>0.) && (r<3.5) ) iSta = 0;
574 if( (r>3.5) && (r<7.5) ) iSta = 1;
575 if( (r>7.5) && (r<11.0) ) iSta = 2;
576 if( (r>11.0) && (r<15.0) ) iSta = 3;
591 outMCP << point->GetX() <<
" " << point->GetY() <<
" " << point->GetZ() << endl;
592 outMCP << px <<
" " << py <<
" " << pz <<
" "
594 outMCP << 0 <<
" " << iSta <<
" " << trackID <<
" " << trackID << endl;
597 if ( nMCPointsInMCTrack.find(trackID) != nMCPointsInMCTrack.end() ) {
598 nMCPointsInMCTrack[trackID]++;
600 nMCPointsInMCTrack[trackID] = 1;
601 FirstMCPointIDInMCTrack[trackID] = nMCPoints;
607 for(
int iPStt=0; iPStt<MCTrackSortedArray[iTr].
GetNSttPoints(); iPStt++)
610 int trackID = point->GetTrackID();
617 TParticlePDG * part = TDatabasePDG::Instance()->GetParticle(mcTr->
GetPdgCode());
619 q = part->Charge()/3.f;
621 else { cout <<
"CA tracker: Bad MCTracks2" << endl; }
623 else { cout <<
"CA tracker: Bad MCTracks" << endl; }
635 A = atan(
fabs(y/x) );
638 if ( y >= 0 && x >= 0 ) A = pi2 - A;
639 if ( y < 0 && x >= 0 ) A = pi2 + A;
640 if ( y < 0 && x < 0 ) A = 3*pi2 - A;
641 if ( y >= 0 && x < 0 ) A = 3*pi2 + A;
643 A = floor(A/pi/2*6)*pi/3;
649 if ( iS < 7.5 ) iSta = floor(iS+0.5);
650 else if ( iS-.1547 < 9.5 ) iSta = floor(iS-.1547+0.5);
651 else if ( iS-.5883 < 11.5 ) iSta = floor(iS-.5883+0.5);
652 else if ( iS-1.022 < 13.5 ) iSta = floor(iS-1.022+0.5);
653 else if ( iS-1.4556 < 15.5 ) iSta = floor(iS-1.4556+0.5);
654 else iSta = floor(iS-2+0.5);
671 outMCP << point->GetX() <<
" " << point->GetY() <<
" " << point->GetZ() << endl;
672 outMCP << px <<
" " << py <<
" " << pz <<
" "
674 outMCP << 0 <<
" " << iSta <<
" " << trackID <<
" " << trackID << endl;
677 if ( nMCPointsInMCTrack.find(trackID) != nMCPointsInMCTrack.end() ) {
678 nMCPointsInMCTrack[trackID]++;
680 nMCPointsInMCTrack[trackID] = 1;
681 FirstMCPointIDInMCTrack[trackID] = nMCPoints;
691 outMCT << -1 <<
" " << -1 << endl;
692 outMCT << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 << endl;
693 outMCT << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 << endl;
694 outMCT << 0 <<
" " << 0 << endl;
695 outMCT << 0 <<
" " << 0 <<
" " << 0 << endl;
696 outMCT << 0 <<
" " << 0 <<
" " << 1 << endl;
711 TParticlePDG * part = TDatabasePDG::Instance()->GetParticle(pdg);
713 q = part->Charge()/3.f;
716 outMCT << mcTr->
GetMotherID() <<
" " << pdg << endl;
718 << px/
fabs(p) <<
" " << py/
fabs(p) <<
" " << pz/
fabs(p) <<
" " << q/p << endl;
719 outMCT << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 <<
" " << 0 << endl;
720 outMCT << p <<
" " <<
sqrt( px*px + py*py ) << endl;
721 outMCT << nHitsInMCTrack[iTr] <<
" " << nMCPointsInMCTrack[iTr] <<
" " << FirstMCPointIDInMCTrack[iTr] << endl;
722 outMCT << 0 <<
" " << 0 <<
" " << 1 << endl;
727 if(MCTrackSortedArray)
delete[] MCTrackSortedArray;
739 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
740 perf = &PndCAPerformance::Instance();
756 0 2 0.0048 1.6 0 2 2 \
757 1 4 0.0048 1.6 0 2 2 \
758 2 9 0.0048 1.6 0 2 2 \
759 3 12 0.0048 1.6 0 2 2 \
760 4 16.619 0.0006 0.016 0 1 4 \
761 5 17.4937 0.0006 0.016 0 1 4 \
762 6 18.3684 0.0006 0.016 0 1 4 \
763 7 19.2431 0.0006 0.016 0 1 4 \
764 8 20.1178 0.0006 0.016 0 1 4 \
765 9 20.9924 0.0006 0.016 0 1 6 \
766 10 21.8671 0.0006 0.016 0 1 6 \
767 11 22.7418 0.0006 0.016 0 1 6 \
768 12 23.7518 0.0006 0.016 0.0523596 1 6 \
769 13 24.6265 0.0006 0.016 0.0523596 1 6 \
770 14 25.8805 0.0006 0.016 -0.0523596 1 6 \
771 15 26.7552 0.0006 0.016 -0.0523596 1 6 \
772 16 28.0092 0.0006 0.016 0.0523596 1 6 \
773 17 28.8839 0.0006 0.016 0.0523596 1 6 \
774 18 30.1378 0.0006 0.016 -0.0523596 1 6 \
775 19 31.0126 0.0006 0.016 -0.0523596 1 6 \
776 20 32.3634 0.0006 0.016 0 1 5 \
777 21 33.2381 0.0006 0.016 0 1 4 \
778 22 34.1128 0.0006 0.016 0 1 4 \
779 23 34.9874 0.0006 0.016 0 1 4 \
780 24 35.8621 0.0006 0.016 0 1 4 \
781 25 36.7368 0.0006 0.016 0 1 4 \
782 26 37.6115 0.0006 0.016 0 1 4 \
783 27 38.4862 0.0006 0.016 0 1 4 \
784 28 39.3609 0.0006 0.016 0 1 4 \
785 29 40.2356 0.0006 0.016 0 1 4";
787 std::istringstream settings(str);
794 trackerConst = tracker;
797 int kEvents = iEvent;
799 sprintf( buf,
"%d", kEvents );
800 const string fileName = filePrefix +
"event" + string(buf) +
"_";
812 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
815 perf->SetOutputFile(perfHistoFile);
816 perf->SetTracker(tracker);
817 std::cout <<
"Loading Monte-Carlo Data for Event " << kEvents <<
"..." << std::endl;
818 if (!perf->ReadDataFromFiles(fileName)) {
819 cout <<
"Monte-Carlo Data for Event " << kEvents <<
" can't be read." << std::endl;
834 for(
int itr=0; itr<tracker->
NTracks(); itr++){
838 for(
int ih=0; ih<tr.
NHits(); ih++ ){
848 FairTrackParP paramFirst;
849 FairTrackParP paramLast;
856 PndTrack *outTrack =
new((*fSttMvdPndTrackArray)[nOutTracks])
PndTrack(paramFirst,paramLast,outCand);
858 outTrack->SetFlag(0);
863 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
865 cout<<
"Run performance.. "<<endl;
867 if (trackerConst->
NHits() > 0) {
868 perf->InitSubPerformances();
869 perf->ExecPerformance();
872 cout <<
"Event " << kEvents <<
" contains 0 hits." << std::endl;
879 const bool ifAvarageTime = 1;
881 std::cout <<
"Reconstruction Time"
882 <<
" Real = " << std::setw( 10 ) << (trackerConst->
SliceTrackerTime() + trackerConst->
StatTime( 9 )) * 1.e3 <<
" ms,"
887 const int NTimers = trackerConst->
NTimers();
888 static int statIEvent = 0;
889 static double *statTime =
new double[NTimers];
890 static double statTime_SliceTrackerTime = 0;
891 static double statTime_SliceTrackerCpuTime = 0;
894 for (
int i = 0;
i < NTimers;
i++){
900 for (
int i = 0;
i < NTimers;
i++){
906 std::cout <<
"Reconstruction Time"
907 <<
" Real = " << std::setw( 10 ) << 1./statIEvent*(statTime_SliceTrackerTime+statTime[ 9 ]) * 1.e3 <<
" ms,"
908 <<
" CPU = " << std::setw( 10 ) << 1./statIEvent*(statTime_SliceTrackerCpuTime+statTime[ 10 ]) * 1.e3 <<
" ms,"
TClonesArray * fSttMvdPndTrackArray
friend F32vec4 cos(const F32vec4 &a)
void SetRefIndex(TString branch, Int_t i)
const PndCAGBHit & Hit(int index) const
friend F32vec4 sqrt(const F32vec4 &a)
static T Sqrt(const T &x)
friend F32vec4 sin(const F32vec4 &a)
const PndCATrackParam & OuterParam() const
static void CATrackParToFairTrackParP(FairTrackParP *fairParam, const PndCATrackParam *caParam)
TVector3 GetMomentum() const
cout<< "POINTs for new FwEndCap == "<< tsim-> GetEntriesFast()
TGeoManager * gGeoManager
Int_t GetSensorID() const
double StatTime(int iTimer) const
int TrackHit(int i) const
bool compareSttPoints(PndSttPoint *const a, PndSttPoint *const b)
vector< PndSdsMCPoint * > MvdArray
const PndCAGBTrack & Track(int i) const
TClonesArray * fMvdPixelHitsArray
void AddHit(UInt_t detId, UInt_t hitId, Double_t rho)
double SliceTrackerTime() const
void SetC(float v, int i1, int i2)
Double_t GetIsochrone() const
TClonesArray * fMCTrackArray
int GetNSttPoints() const
Double_t GetIsochroneError() const
TClonesArray * fSttPointsArray
TClonesArray * fMvdPointsArray
friend F32vec4 fabs(const F32vec4 &a)
void SetHits(std::vector< PndCAGBHit > &hits)
TString fSttHitsBranchName
static PndGeoHandling * Instance()
void SetTubeHalfLength(float v)
PndCAParam & GetParametersNonConst()
TClonesArray * fSttHitsArray
bool compareSdsPoints(PndSdsMCPoint *const a, PndSdsMCPoint *const b)
vector< PndSttPoint * > SttArray
void WriteMVDHits(std::vector< PndCAGBHit > &vHits, std::fstream &outH, std::fstream &outHL, std::fstream &outMCT, std::fstream &outMCP, int &iHit, map< int, unsigned int > &nHitsInMCTrack, bool isPixel)
int GetNMvdPoints() const
double SliceTrackerCpuTime() const
TVector3 GetStartVertex() const
TClonesArray * fTubeArray
Int_t GetMotherID() const
TClonesArray * fMvdStripHitsArray
const PndCATrackParam & InnerParam() const
TMatrixT< Double_t > GetRotationMatrix()
TVector3 GetWireDirection()
void ReadSettings(std::istringstream &in)