//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of resCalc // Uses existing GFTracks and calculates // residua in XY. // Developed as part of the GEM-TPC project // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Felix Boehmer (original author) // Physik Department E18, TUM // //----------------------------------------------------------- #include "TpcRefGFTrkTpcClusterResCalc.h" #include "TClonesArray.h" #include "TpcCluster.h" #include "TpcResidual.h" #include "TpcRefResidualCollection.h" #include "TpcSPHit.h" #include "TpcAlignmentManager.h" #include "GFTrack.h" #include "GFException.h" #include "GFAbsTrackRep.h" #include "GFRecoHitFactory.h" #include "GFRecoHitProducer.h" #include "RKTrackRep.h" #include "GFTrackCand.h" #include #include #include #include ClassImp(TpcRefGFTrkTpcClusterResCalc) TpcRefGFTrkTpcClusterResCalc::TpcRefGFTrkTpcClusterResCalc() : fGFTrackBranchName("GFTrack"), fTpcClusterBranchName("TpcCluster"), fTpcSPHitBranchName("TpcCluster"), fNRep(-1), fDetID(-1), fRequireGoodFit(true), fMomCutRefTrack(0.5), fQAFileName("TpcRefGFTrkTpcClusterResCalcQA.root"), fIdealTpcTrackTpcClusterMatching(false) { fNExpectedBranches = 2; rHist=new TH1D("rHist","rHist",1000,0,100); rHistCut=new TH1D("rHistCut","rHistCut",1000,0,100); momHist=new TH1D("momHist","momHist",1000,0,5); momHistCut=new TH1D("momHistCut","momHistCut",1000,0,5); } TpcRefGFTrkTpcClusterResCalc::~TpcRefGFTrkTpcClusterResCalc() { } bool TpcRefGFTrkTpcClusterResCalc::init() { if(fIdealTpcTrackTpcClusterMatching){ fNExpectedBranches=3; } if(fBranchMap.size() != fNExpectedBranches) { std::cout<<"TpcRefGFTrkTpcClusterResCalc::init(): "<::const_iterator it; for(it=fBranchMap.begin(); it!=fBranchMap.end(); it++) { std::string type((it->second)->GetClass()->GetName()); if(type.find(GFTrackRefType)second; fGFTrackBranchName = it->first; foundGFTrack=true; std::cout<<"TpcRefGFTrkTpcClusterResCalc::init(): "<first <second; foundTpcCluster=true; std::cout<<"TpcRefGFTrkTpcClusterResCalc::init(): "<first <second; foundTpcSPHit=true; std::cout<<"TpcRefGFTrkTpcClusterResCalc::init(): "<first <GetEntriesFast(); // GF trackfit loop for(unsigned int itr=0; itr=0) rep = itrack->getTrackRep(fNRep); else rep = itrack->getCardinalRep(); GFTrackCand cand = itrack->getCand(); int val = rep->getStatusFlag(); if(val!=0 && fRequireGoodFit) continue; TVector3 refMom=rep->getMom(); TVector3 refPos=rep->getPos(); rHist->Fill(refPos.Perp()); momHist->Fill(refMom.Mag()); if(refMom.Mag()Fill(refPos.Perp()); momHistCut->Fill(refMom.Mag()); //create residualCollection for this track fResults.push_back(new TpcRefResidualCollection(fTpcClusterBranchName.Data(),itr)); //calculate residuals in XYZ -------------------------- unsigned int ncl =0; if(fIdealTpcTrackTpcClusterMatching){ ncl=cand.getNHits(); if(abs(rep->getPDG())>10000){ continue; } }else{ ncl = fTpcClusterArray->GetEntriesFast(); } TVector3 poca, norm; for(unsigned int icl=0; icl<(ncl-2); icl+=3) { TMatrixT cov(3,3); TpcCluster* theCl; if(fIdealTpcTrackTpcClusterMatching){ int detID; int hitID; cand.getHit(icl,detID,hitID); TpcSPHit* hit= (TpcSPHit*) fTpcSPHitArray->At(hitID); theCl=(TpcCluster*) fTpcClusterArray->At(hit->getClusterID()); if(theCl==NULL){ std::cout<<"########################## " <<"detID: "<GetEntriesFast() <<" ###########################"<At(icl); } TVector3 pos =theCl->pos(); //pos.Print(); TVector3 sig = theCl->sig(); cov[0][0] = sig.X()*sig.X(); cov[1][1] = sig.Y()*sig.Y(); cov[2][2] = sig.Z()*sig.Z(); pos = TpcAlignmentManager::getInstance()->localToMaster("tpc",pos); cov = TpcAlignmentManager::getInstance()->localToMaster("tpc",cov); TVector3 hpos =pos; double tracklength=0; bool ok=true; TVector3 pos1, mom1; TMatrixDSym cov6; try { //std::cout<<" "<setResXYZ(poca-hpos); theRes->setRefPos(poca); theRes->setHitPos(hpos); theRes->setHitIndex(icl); theRes->setTrackDir(mom1.Unit()); theRes->setHitCov(cov); TMatrixD cov3=cov6.GetSub(0,2,0,2); theRes->setTrackCov(cov3); theRes->setTrackLength(tracklength); fResults.back()->addResidual(theRes); } //delete recoHit; } //end Cluster loop }//end GF trackfit loop } void TpcRefGFTrkTpcClusterResCalc::writeHists(){ TFile* file = new TFile(fQAFileName,"recreate"); file->cd(); rHist->Write(); rHistCut->Write(); momHist->Write(); momHistCut->Write(); file->Close(); }