//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Residual calculator for existing GFTracks // Just extracts residuals from the GFTrack object // for hits inside the TPC // // Environment: // Software developed for the GEM-TPC detector // // Author List: // Felix Boehmer TUM (original author) // //----------------------------------------------------------- #include "TpcGFTrackResCalc.h" #include "TClonesArray.h" #include "TClass.h" #include "CdcTrack.h" #include "TpcCluster.h" #include "TpcResidual.h" #include "TpcRefResidualCollection.h" #include "TpcSPHit.h" //#include "GFRecoHitFactory.h" #include "GFTrack.h" #include "GFTools.h" #include "RecoHits/GFAbsRecoHit.h" #include "TMatrixT.h" #include TpcGFTrackResCalc::TpcGFTrackResCalc() : fSmoothedInput(false), fRepID(-1), fClBranchName("TpcCluster"), //fFactory(NULL), //fInitTracks(false), fRequireGoodFit(true) { fNExpectedBranches = 1; } TpcGFTrackResCalc::~TpcGFTrackResCalc() { // if(fFactory!=NULL) // delete fFactory; ; } bool TpcGFTrackResCalc::init() { if(fBranchMap.size() != fNExpectedBranches) { std::cout<<"TpcGFTrackResCalc::init(): "<::const_iterator it; for(it=fBranchMap.begin(); it!=fBranchMap.end(); it++) { std::string type((it->second)->GetClass()->GetName()); if(type.find(trackType)second; fGFTrackBranchName = it->first; foundTracks=true; std::cout<<"TpcGFTrackResCalc::init(): "<GetEntriesFast(); int TpcID = FairRootManager::Instance()->GetBranchId(fClBranchName); // GFTrack loop for(unsigned int itr=0; itrgetCardinalRep()->getStatusFlag(); else status = itrack->getTrackRep(fRepID)->getStatusFlag(); if(fRequireGoodFit && status > 0) continue; //create residualCollection for this track fResults.push_back(new TpcRefResidualCollection(fGFTrackBranchName.Data(),itr)); //get list of hits lying in the TPC std::vector tpcHits = itrack->getCand().getHitIDs(TpcID); //decide whether or not to calc. unbiased residuals: if(fSmoothedInput) { //unbiased residuals TMatrixT smState; TMatrixT smCov; GFDetPlane smPlane; TVector3 trackPos; //loop over TPC hits: for(unsigned int ih=0; ihgetHit(ih); //test if TPC hit: TpcSPHit* test = dynamic_cast(recoHit); if(test==NULL) continue; TVectorD rc(3); rc = recoHit->getRawHitCoord(); TMatrixT cov = recoHit->getRawHitCov(); TVector3 hpos = TVector3(rc[0], rc[1], rc[2]); TpcResidual* theRes = new TpcResidual(); theRes->setResXYZ(hpos-trackPos); theRes->setRefPos(trackPos); theRes->setHitPos(hpos); theRes->setHitIndex(ih); theRes->setHitCov(cov); fResults.back()->addResidual(theRes); } } //end unbiased res calc. else { //biased residuals: TESTED AND VERIFIED WITH LASER TRACKS GFAbsTrackRep* rep; if(fRepID < 0) rep = itrack->getCardinalRep(); else rep = itrack->getTrackRep(fRepID); //loop over TPC hits: for(unsigned int ih=0; ihgetHit(ih); //test if TPC hit: TpcSPHit* test = dynamic_cast(recoHit); if(test==NULL) continue; TVectorD rc(3); rc = recoHit->getRawHitCoord(); TMatrixT cov = recoHit->getRawHitCov(); TVector3 hpos = TVector3(rc[0], rc[1], rc[2]); TVector3 poca, norm; bool ok=true; try { rep->extrapolateToPoint(hpos, poca, norm); } catch(GFException& ex) { std::cout<<"TpcGFTrackResCalc::calc(): Error during extrapolation: \n" <<" "<setResXYZ(hpos-poca); theRes->setRefPos(poca); theRes->setHitPos(hpos); theRes->setHitIndex(ih); theRes->setHitCov(cov); fResults.back()->addResidual(theRes); } } } //end biased res calc. }//end GFTrack loop }