//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class PndTpcSLPatternRecoTask // see PndTpcSLPatternRecoTask.hh for details // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Felix Boehmer TUM (original author) // // //----------------------------------------------------------- // Panda Headers ---------------------- // This Class' Header ------------------ #include "PndTpcSLPatternRecoTask.h" // C/C++ Headers ---------------------- #include #include #include #include // Collaborating Class Headers -------- #include "FairRootManager.h" #include "TClonesArray.h" #include "GFException.h" #include "PndTpcCluster.h" #include "PndTpcClusterZ.h" #include "PndTpcClusterDist.h" #include "GFTrackCand.h" #include "GFTrack.h" #include "TF1.h" #include "TVector3.h" #include "FairRunAna.h" #include "RKTrackRep.h" #include "Hypersurface2D.h" #include "Hough2DNode.h" #include "FairField.h" #include "PndFieldAdaptor.h" #include "GFFieldManager.h" // Class Member definitions ----------- ClassImp(PndTpcSLPatternRecoTask) PndTpcSLPatternRecoTask::PndTpcSLPatternRecoTask() : FairTask("PndTpc SL Hough Pattern Reco"), fPersistence(kFALSE),fDistSorting(kTRUE), fDepth(6), fThresh(6), fMin(5), counter(0), fXZ(true), fZY(false) { fClusterBranchName = "PndTpcCluster"; fRep = new TF1("rep","[0]*cos(x)+[1]*sin(x)",-6,6); //standard rep } PndTpcSLPatternRecoTask::~PndTpcSLPatternRecoTask(){ } //helper functor for node sorting bool compareNodes (Hough2DNode* n1, Hough2DNode* n2) { return (n1->getVote() > n2->getVote()); } void PndTpcSLPatternRecoTask::SetParameterSpace(double* mins, double* maxs) { fMins[0] = mins[0]; fMins[1] = mins[1]; fMaxs[0] = maxs[0]; fMaxs[1] = maxs[1]; } void PndTpcSLPatternRecoTask::SetParameterSpace(double min1, double min2, double max1, double max2){ fMins[0] = min1; fMins[1] = min2; fMaxs[0] = max1; fMaxs[1] = max2; } InitStatus PndTpcSLPatternRecoTask::Init() { //Get ROOT Manager FairRootManager* ioman= FairRootManager::Instance(); if(ioman==0) { Error("PndTpcSLPatternRecoTask::Init","RootManager not instantiated!"); return kERROR; } // Get input collection fClusterArray=(TClonesArray*) ioman->GetObject(fClusterBranchName); if(fClusterArray==0) { Error("PndTpcSLPatternRecoTask::Init","Cluster-array not found!"); return kERROR; } // create and register output array fTrackArray = new TClonesArray("GFTrack"); ioman->Register("TrackPreFit","GenFit",fTrackArray,fPersistence); return kSUCCESS; } void PndTpcSLPatternRecoTask::Exec(Option_t* opt) { counter++; double MIN0 = fMins[0]; double MIN1 = fMins[1]; double MAX0 = fMaxs[0]; double MAX1 = fMaxs[1]; double x_OFF=0.; //TODO: make member, settable from outside. if(fXZ) x_OFF = 5.; //offset; TODO: read from par //get the magnetic field for curvature seeding FairField* field=FairRunAna::Instance()->GetField(); GFFieldManager::getInstance()->init(new PndFieldAdaptor(field)); std::cout<<"PndTpcSLPatternRecoTask::Exec"<Delete(); // copy into vector std::vector cll; //all clusters std::vector hitreps; //their representation in the par. space unsigned int totCl=fClusterArray->GetEntriesFast(); TVector3 pos; for(unsigned int i=0;iAt(i); cl->SetIndex(i); //INDEXNG cll.push_back(cl); pos = cl->pos(); //TODO: parameter management and specifiable projection plane double x = pos.X()+x_OFF; double y = pos.Y(); double z = pos.Z(); //std::cout<<"x: "<setParamSpace(fMins, fMaxs); } //end loop over clusters // Begin FHT search ----------------------------------------------------- //initialize root node: double center[2] = {0.f, 0.f}; Hough2DNode* root = new Hough2DNode(center,0,totCl); for(int i=0; itestIntersect(root); //test if every hit was inside that node int rootvotes = root->getVote(); std::cerr<<"DEBUG - Clusters: "< survivors; std::vector sons; survivors.push_back(root); for(unsigned int t=1; tgetSonArray(); for (int s=0; s<4; s++) { sons.push_back(new Hough2DNode(son_arr+2*s,the_node->getLevel()+1, totCl)); } delete survivors.at(n); //clean up last generation } //end loop over survivors survivors.clear(); for(int s=0; stestIntersect(node); if(node->getVote()>=fThresh) survivors.push_back(node); else delete sons.at(s); } sons.clear(); } //finished tree search //End FHT search; Begin candidate extraction ----------------------------- unsigned int surs = survivors.size(); //exit: PR failed if(surs==0) return; std::cout<<"DEBUG: Begin candidate extraction"<*> solutions; //track candidates std::vector cand_nodes; //extract tracks until solutions have less clusters than minCL while(true) { //sort nodes by final votes sort(survivors.begin(), survivors.end(), compareNodes); //extract clusters from best node const bool* bestHitList = survivors.front()->getHitList(); std::vector* sol = new std::vector(); for(int c=0; cpush_back(cll[c]); } //discard track candidates with less than fMin hits: if(sol->size()checkHit(p)) survivors[n]->removeHit(p); } solutions.push_back(sol); } // End candidate extraction ---------------------------------------------- // sort clusters if(fDistSorting) { std::sort(cll.begin(),cll.end(),PndTpcClusterDist(false)); std::cout<<"\n **** using DISTANCE presorting of PndTpcClusters ****"< candlist; for(unsigned int i=0; isize(); c++) { if(cand==NULL){ cand=new GFTrackCand(); candlist[i]=cand; } PndTpcCluster* cl = (solutions[i])->at(c); cand->addHit(2,cl->index()); } //extract candidate seed information Hough2DNode* cand_node = cand_nodes[i]; if(cand_node==NULL) continue; const double* cent = cand_node->getCenter(); std::cout<<"Debug: got cent"<1.e-4) m = -1./(tan(theta)); else m = 1.e3; //double t = r/(sin(theta)); //TODO: flexible geometry TVector3 mom; mom.SetXYZ(0.1,0.,m*0.1); mom=mom.Unit(); //requires nicely sorted candidates. TVector3 clpos=(solutions[i])->at(0)->pos(); TVector3 poserr(1.,1.,1.); //large mom error in the unknown projection: TVector3 momerr(mom.X()*0.1,0.5,mom.Z()*0.1); //init the trackrep int pdg = 11; RKTrackRep* rep = new RKTrackRep(clpos,mom,poserr,momerr,pdg); //build GFTrack object GFTrack* trk=new((*fTrackArray)[fTrackArray->GetEntriesFast()]) GFTrack(rep); trk->setCandidate(*cand); // here the candidate is copied! } std::cout<<"PndTpcSLPatternRecoTask::Exec() " <GetEntriesFast()<<" tracks created"<