// ------------------------------------------------------------------------- // ----- PndLmdTrackFinderCATask ----- // ----- Created 18/05/11 by A. Karavdina ----- // ------------------------------------------------------------------------- #include #include "TClonesArray.h" #include "TArrayD.h" #include "TVectorD.h" #include "TGeoManager.h" #include "FairRootManager.h" #include "FairRun.h" #include "FairRuntimeDb.h" #include "PndLmdTrackFinderCATask.h" #include "PndSdsDigiStrip.h" #include "TStopwatch.h" // #include "PndSdsPixelCluster.h" // ----- Default constructor ------------------------------------------- PndLmdTrackFinderCATask::PndLmdTrackFinderCATask() : FairTask("LMD Track Finding Task (Cellular Automation)") { missPlAlgo = false; fHitBranchStrip = "LMDHitsStrip"; fClusterBranchStrip = "LMDStripClusterCand"; fDigiBranchStrip = "LMDStripDigis"; dXY = 0.5; // dXY = 0.01;//TEST } // ------------------------------------------------------------------------- // ----- Constructor ------------------------------------------- PndLmdTrackFinderCATask::PndLmdTrackFinderCATask(const bool missPl) : FairTask("LMD Track Finding Task (Cellular Automation) with/without <> algoritm") { missPlAlgo = missPl; fHitBranchStrip = "LMDHitsStrip"; fClusterBranchStrip = "LMDStripClusterCand"; fDigiBranchStrip = "LMDStripDigis"; dXY = 0.5; // dXY = 0.01;//TEST } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndLmdTrackFinderCATask::~PndLmdTrackFinderCATask() {} // ------------------------------------------------------------------------- // ----- Initialization of Parameter Containers ------------------------- void PndLmdTrackFinderCATask::SetParContainers() { // Get Base Container /* FairRun* ana = FairRun::Instance(); FairRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar = (PndSdsGeoPar*)(rtdb->getContainer("PndSdsGeoPar")); */ } InitStatus PndLmdTrackFinderCATask::ReInit() { InitStatus stat=kERROR; return stat; /* FairRun* ana = FairRun::Instance(); FairRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar=(PndSdsGeoPar*)(rtdb->getContainer("PndSdsGeoPar")); return kSUCCESS; */ } // ----- Public method Init -------------------------------------------- InitStatus PndLmdTrackFinderCATask::Init() { FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) { std::cout << "-E- PndLmdTrackFinderCATask::Init: " << "RootManager not instantiated!" << std::endl; return kFATAL; } // Get input array fStripHitArray = (TClonesArray*) ioman->GetObject(fHitBranchStrip); if ( !fStripHitArray){ std::cout << "-W- PndLmdTrackFinderCATask::Init: " << "No fStripHitArray!" << std::endl; return kERROR; } fStripClusterArray = (TClonesArray*) ioman->GetObject(fClusterBranchStrip); if ( !fStripClusterArray){ std::cout << "-W- PndLmdTrackFinderCATask::Init: " << "No StripclusterArray!" << std::endl; return kERROR; } fStripDigiArray = (TClonesArray*) ioman->GetObject(fDigiBranchStrip); if ( !fStripDigiArray){ std::cout << "-W- PndLmdTrackFinderCATask::Init: " << "No StripdigiArray!" << std::endl; return kERROR; } fTrackCandArrayTemp = new TClonesArray("PndTrackCand"); fTrackCandArray = new TClonesArray("PndTrackCand"); ioman->Register("LMDTrackCand", "PndLmd", fTrackCandArray, kTRUE); std::cout << "-I- PndLmdTrackFinderCATask: Initialisation successfull" << std::endl; return kSUCCESS; } // ------------------------------------------------------------------------- // ----- Public method Exec -------------------------------------------- void PndLmdTrackFinderCATask::Exec(Option_t* opt) { // TStopwatch *timer_exec = new TStopwatch(); // timer_exec->Start(); // TStopwatch *timer_start = new TStopwatch(); // timer_start->Start(); // fTrackCandArrayTemp = new TClonesArray("PndTrackCand"); if(fVerbose>2) cout << "Evt started--------------"<Clear(); fTrackCandArrayTemp->Clear(); Int_t nStripHits = fStripHitArray->GetEntriesFast(); // cout<<"nStripHits = "<2) cout << "Evt finsihed: too less hits-----"< > hitsd(4); //hit'ids splitted by detectorplane for(Int_t iHit = 0; iHit < nStripHits; iHit++){ PndSdsHit* myHit = (PndSdsHit*)(fStripHitArray->At(iHit)); Int_t sensid = myHit->GetSensorID(); // Sensors: 1..32 // cout<<"sencor ID: "< Planes: 0..3 hitsd.at(planeid).push_back(iHit); } Int_t nPlanes=0; for(Int_t iPlane = 0; iPlane < 4; iPlane++){ if(hitsd.at(iPlane).size()>0) nPlanes++; } if(nPlanes<3){ if(fVerbose>2) cout << "Evt finsihed: too less planes-----"<2){ if(hitsd.at(0).size()>0){ for (Int_t i=0; iAt(hitsd.at(0).at(i)); cout<<"Plane0 Hit=("<GetX()<<", "<GetY()<<", "<GetZ()<<") with err=(" <GetDx()<<", "<GetDy()<<", "<GetDz()<<")"<0){ for (Int_t i=0; iAt(hitsd.at(1).at(i)); cout<<"Plane1 Hit=("<GetX()<<", "<GetY()<<", "<GetZ()<<") with err=(" <GetDx()<<", "<GetDy()<<", "<GetDz()<<")"<0){ for (Int_t i=0; iAt(hitsd.at(2).at(i)); cout<<"Plane2 Hit=("<GetX()<<", "<GetY()<<", "<GetZ()<<") with err=(" <GetDx()<<", "<GetDy()<<", "<GetDz()<<")"<0){ for (Int_t i=0; iAt(hitsd.at(3).at(i)); cout<<"Plane3 Hit=("<GetX()<<", "<GetY()<<", "<GetZ()<<") with err=(" <GetDx()<<", "<GetDy()<<", "<GetDz()<<")"<Stop(); // timer_start->Print("u"); // Double_t rtime = timer_start->RealTime(); // Double_t ctime = timer_start->CpuTime(); // cout << "Real time_start " << rtime << " s, CPU time_start " << ctime << " s" << endl; // // cout << endl; // delete timer_start; ///Track-Finder ---------------------------------------------------------- // TStopwatch *timer_makingcells = new TStopwatch(); // timer_makingcells->Start(); int Npoints=0; // const int nplanes = nPlanes; const int nplanes = 4; int NpointsI[nplanes]; for(int i=0;i4) cout<<" ncI["<RealTime(); // ctime = timer_makingcells->CpuTime(); // cout << "Real time_makingcells " << rtime << " s, CPU time_makingcells " << ctime << " s" << endl; // delete timer_makingcells; // TStopwatch *timer_makingneighbour = new TStopwatch(); // timer_makingneighbour->Start(); double d_max = 0.01; // double d_max1 = 0.01, d_max2 = 0.01, d_max; // double d_max1 = ., d_max2 = 4., d_max; //TEST int cd=0; bool stop=false; vector connect; vector conn_flag; // int nCon; while(!stop){ double d1=0, d2=0; for(int ipl=0;ipl<(nplanes-2);ipl++){ for(int p=ncI[ipl];p0;jg--){ // cout<<"pv[connect[jg]] = "<3) cout<<"Taking into account missing planes!"<4) cout<<" connect.size() = "<-1;t--){ if(fVerbose>4) cout<<"pv["<5e-2 || fabs(dir.Phi())>0.26) continue; if(fVerbose>2){ cout<<"posSeed:"<setTrackSeed(posSeed,dir,-1); // cout<<"trk.size()-1 = "<At(hitsd.at(pl).at(id))); PndSdsClusterStrip* myCluster = (PndSdsClusterStrip*)(fStripClusterArray->At(myHit->GetClusterIndex())); PndSdsDigiStrip* astripdigi = (PndSdsDigiStrip*)fStripDigiArray->At(myCluster->GetDigiIndex(0)); myTCand->AddHit(astripdigi->GetDetID(),hitsd.at(pl).at(id),myHit->GetPosition().Mag()); } int id = cells.at(7).at(trk[trk.size()-1]); int pl = cells.at(9).at(trk[trk.size()-1]); PndSdsHit* myHit = (PndSdsHit*)(fStripHitArray->At(hitsd.at(pl).at(id))); PndSdsClusterStrip* myCluster = (PndSdsClusterStrip*)(fStripClusterArray->At(myHit->GetClusterIndex())); PndSdsDigiStrip* astripdigi = (PndSdsDigiStrip*)fStripDigiArray->At(myCluster->GetDigiIndex(0)); myTCand->AddHit(astripdigi->GetDetID(),hitsd.at(pl).at(id),myHit->GetPosition().Mag()); // cout<<"Save hit#"<RealTime(); // ctime = timer_makingtrk->CpuTime(); // cout << "Real time_makingtrk " << rtime << " s, CPU time_makingtrk " << ctime << " s" << endl; // // cout << endl; // delete timer_makingtrk; //if(fVerbose>2) cout<<"connect.size()="<5e-2 || fabs(dir.Phi())>0.26) continue; myTCand1->setTrackSeed(posSeed,dir,-1); if(fVerbose>2){ cout<<"posSeed:"<At(hitsd.at(pl).at(id))); PndSdsClusterStrip* myCluster = (PndSdsClusterStrip*)(fStripClusterArray->At(myHit->GetClusterIndex())); PndSdsDigiStrip* astripdigi = (PndSdsDigiStrip*)fStripDigiArray->At(myCluster->GetDigiIndex(0)); myTCand1->AddHit(astripdigi->GetDetID(),hitsd.at(pl).at(id),myHit->GetPosition().Mag()); } int id = cells.at(7).at(trk[trk.size()-1]); int pl = cells.at(9).at(trk[trk.size()-1]); // cout<<"Save hit#"<At(hitsd.at(pl).at(id))); PndSdsClusterStrip* myCluster = (PndSdsClusterStrip*)(fStripClusterArray->At(myHit->GetClusterIndex())); PndSdsDigiStrip* astripdigi = (PndSdsDigiStrip*)fStripDigiArray->At(myCluster->GetDigiIndex(0)); myTCand1->AddHit(astripdigi->GetDetID(),hitsd.at(pl).at(id),myHit->GetPosition().Mag()); new((*fTrackCandArrayTemp)[NtrkRec]) PndTrackCand(*(myTCand1)); //save Track Candidate // new((*fTrackCandArray)[NtrkRec]) PndTrackCand(*(myTCand1)); //save Track Candidate NtrkRec++; // cout<<"Ntrk No. "<2) cout << "Evt finsihed--------------"<RealTime(); // ctime = timer_exec->CpuTime(); // cout << "Real time_exec " << rtime << " s, CPU time_exec " << ctime << " s" << endl; // cout << endl; // delete timer_exec; //} if(missPlAlgo && nPlanes==4){ if(fVerbose>2) cout<<" ------- Track-Candidates Fillter ------"<GetEntriesFast(); TMatrixD trkcan_point(ntcand,4); for(int trkcID=0;trkcIDAt(trkcID); const int numPts = trcnd->GetNHits(); //read how many points in this track // if(numPts==4) continue; for(unsigned int ihit=0; ihitGetSortedHit(ihit); //get hit Int_t index = theHit.GetHitId(); double rho = theHit.GetRho(); int pos_num; if(rho<1105) pos_num=0; else{ if(rho<1115) pos_num=1; else{ if(rho<1125) pos_num=2; else{ pos_num=3; } } } // Int_t detId = theHit.GetDetId(); // cout<<"index: "<At(index); // if(numPts==3) trkcan_point(trkcID,ihit+1)=index; // else trkcan_point(trkcID,ihit)=index; trkcan_point(trkcID,pos_num)=index; }//end of Hits in TCand } // cout<<"trkcan_point:"<4) trkcan_point.Print(); TMatrixD coincidence(ntcand,4); for(int trkcID=0;trkcID-1;trkcID1--){ for(int trkcID2=ntcand-2;trkcID2>-1;trkcID2--){ if(trkcID1==trkcID2) continue; for(unsigned int ihit=0; ihit<4; ihit++){ //loop on the hits if(trkcan_point(trkcID1,ihit)==-1 || trkcan_point(trkcID2,ihit)==-1) continue; if(trkcan_point(trkcID1,ihit)==trkcan_point(trkcID2,ihit)){ // cout<<"trkcID1 = "<4) coincidence.Print(); TVectorD distance(ntcand); TVectorF flag(ntcand); for(int trkcID=0;trkcIDAt(trkcID); const int numPts = trcnd->GetNHits(); //read how many points in this track int repE[ntcand]; if(numPts==4){ if(fVerbose>4) cout<<"trk-cand #"<GetEntriesFast(); if(fVerbose>4) cout<<"ntcand from ArrayTemp is "<At(trkcID); new((*fTrackCandArray)[NsaveTrk]) PndTrackCand(*(trcnd)); //save Track Candidate NsaveTrk++; } } // Delete fTrackCandArrayTemp; Int_t ntcandFin=fTrackCandArray->GetEntriesFast(); if(fVerbose>2) cout<<"Number of Trk-Cands is "<2) cout << "Evt finsihed--------------"<GetMomentum(); return (2/TMath::Sqrt(p.Px()*p.Px() + p.Py()*p.Py())); } // ------------------------------------------------------------------------- Double_t PndLmdTrackFinderCATask::GetTrackDip(PndMCTrack* myTrack) { TVector3 p= myTrack->GetMomentum(); return (p.Mag()/TMath::Sqrt(p.Px()*p.Px() + p.Py()*p.Py())); } // ------------------------------------------------------------------------- ClassImp(PndLmdTrackFinderCATask);