/* Copyright 2008-2010, Technische Universitaet Muenchen, Authors: Christian Hoeppner & Sebastian Neubert This file is part of GENFIT. GENFIT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GENFIT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GENFIT. If not, see . */ #include #include #include "GFTrack.h" #include "TVirtualGeoTrack.h" GFTrack::GFTrack(GFAbsTrackRep* defaultRep, bool smooth) : fTrackReps(NULL),fCardinal_rep(0), fNextHitToFit(0), fSmooth(false) { addTrackRep(defaultRep); fSmooth = smooth; } GFTrack::GFTrack() : fTrackReps(NULL), fCardinal_rep(0), fNextHitToFit(0), fSmooth(false) { //trackReps = new TObjArray(defNumTrackReps); } GFTrack::~GFTrack() { if(fTrackReps!=NULL){ for(unsigned int i=0;iAt(i); } delete fTrackReps; } for(unsigned int i=0;iclone()); } fTrackReps = NULL; for(unsigned int i=0; i<_tr.getNumReps();i++) { addTrackRep( (_tr.getTrackRep(i))->clone() ); } for(unsigned int i=0; iAt(i); } delete fTrackReps; fTrackReps=NULL; } for(unsigned int i=0;iclone()); } fCand=_tr.fCand; fCardinal_rep=_tr.fCardinal_rep; fNextHitToFit=_tr.fNextHitToFit; fSmooth=_tr.fSmooth; for(unsigned int i=0;i<_tr.getNumHits();i++) { fHits.push_back((_tr.getHit(i))->clone()); } //clear the empty bookeeping objs made by addTrackRep and copy the others for(unsigned int i=0; iAt(i)!=NULL) delete fTrackReps->At(i); } } for(unsigned int i=0;igetNumHits(); for(unsigned int i=0;igetCand().getHit(i,detId,hitId); GFAbsRecoHit* hit=trk->getHit(i); addHit(hit,detId,hitId); } trk->fHits.clear(); } void GFTrack::setCandidate(const GFTrackCand& cand, bool doreset) { fCand=cand; // reset fits if(doreset) { for(unsigned int i=0;iAt(i))->reset(); } } } void GFTrack::fillGeoTrack(TVirtualGeoTrack* geotrk,unsigned int repid) const { GFAbsTrackRep* rep=getTrackRep(repid); unsigned int n=fCand.getNHits(); rep->getState().Print(); for(unsigned int i=0; igetDetPlane(rep); TVector3 pos=rep->getPos(pl); std::cout<AddPoint(pos.X(),pos.Y(),pos.Z(),0); }// end loop over hits } void GFTrack::getResiduals(unsigned int detId, // which detector? unsigned int dim, // which projection? unsigned int repid, // which trackrep ? std::vector& result) { unsigned int nhits=getNumHits(); if(repid>=getNumReps())return; GFAbsTrackRep* rep=getTrackRep(repid);//->clone(); assert(rep->getState()==getTrackRep(repid)->getState()); for(unsigned int ih=0; ihgetDim(); TMatrixT state(repDim,1); GFDetPlane pl=hit->getDetPlane(rep); rep->extrapolate(pl,state); //rep->setState(state); //rep->setReferencePlane(pl); double res=hit->residualVector(rep,state,pl)[dim][0]; //std::cout<Print(); } } void GFTrack::Print(){ for(unsigned int i=0;iPrint(); fBookkeeping.at(i)->Print(); } std::cout << "GFTrack has " << getNumHits() << " detector hits." << std::endl; } void GFTrack::getHitsByPlane(std::vector*>& retVal){ for(int i=0;retVal.size();++i){ delete retVal.at(i); } retVal.clear(); //this method can only be called when all hits have been loaded assert(fHits.size()==fCand.getNHits()); assert(fHits.size()>1); unsigned int detId,hitId,planeId; fCand.getHitWithPlane(0,detId,hitId,planeId); // std::cout << "$$$ " << 0 << " " << detId << " " << hitId << " " << planeId << std::endl; unsigned int lastPlane=planeId; retVal.push_back(new std::vector); retVal.at(0)->push_back(0); for(unsigned int i=1;ipush_back(i); } else{ lastPlane=planeId; retVal.push_back(new std::vector); retVal.at(retVal.size()-1)->push_back(i); } } } void GFTrack::blowUpCovs(double blowUpFactor){ int nreps=getNumReps(); for(int irep=0; irepgetStatusFlag()==0) { TMatrixT cov = arep->getCov(); for(int i=0;isetCov(cov); } } } ClassImp(GFTrack)