FairRoot/PandaRoot
GFTrack.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
24 #ifndef GFTRACK_H
25 #define GFTRACK_H
26 
27 #include"assert.h"
28 #include<map>
29 
30 #include "GFAbsTrackRep.h"
31 #include "GFAbsRecoHit.h"
32 
33 #include "TClonesArray.h"
34 #include "TObjArray.h"
35 
36 #include "GFTrackCand.h"
37 #include "GFBookkeeping.h"
38 
39 class TVirtualGeoTrack;
40 
60 class GFTrack : public TObject {
61 private:
62 
63 
73  TObjArray* fTrackReps; //->
74 
77  std::vector<GFAbsRecoHit*> fHits;
79 
83  std::vector< GFBookkeeping* > fBookkeeping;
84 
88  std::vector<int> fRepAtHit;
89 
93  GFTrackCand fCand; // list of hits
94 
95  static const int fDefNumTrackReps = 10;
96  unsigned int fCardinal_rep; // THE selected rep, default=0;
97 
98  unsigned int fNextHitToFit;
99 
100  bool fSmooth;
101 
102 public:
103 
105  GFTrack();
106 
108  GFTrack(const GFTrack&);
109 
111  GFTrack& operator=(const GFTrack&);
112 
118  GFTrack(GFAbsTrackRep*, bool smooth = false);
119 
120  virtual ~GFTrack();
121 
122  // -----------------------
123  // Accessors
124  // -----------------------
125 
128  void reset(); // deletes the RecoHits!
129 
133  int getFailedHits(int repId=-1){
134  int theRep;
135  if(repId==-1) theRep=fCardinal_rep;
136  else theRep = repId;
137  return fBookkeeping.at(theRep)->getNumFailed();
138  }
139 
140  std::vector<GFAbsRecoHit*> getHits() {return fHits;}
141 
142  const GFTrackCand& getCand() const {return fCand;}
143 
144  GFAbsRecoHit* getHit(int id) const {
145  return fHits.at(id);
146  }
147 
148  unsigned int getNumHits() const {
149  return fHits.size();
150  }
151 
162  void mergeHits(GFTrack* trk);
163 
168  void releaseHits(){fHits.clear();}
169 
174  void releaseTrackReps(){ fTrackReps->SetOwner(kFALSE); fTrackReps->Clear();}
175 
178  unsigned int getNextHitToFit() const {return fNextHitToFit;}
179 
182  void setNextHitToFit(unsigned int i) {fNextHitToFit=i;}
183 
186  GFAbsTrackRep* getTrackRep(int id) const {
187  return reinterpret_cast<GFAbsTrackRep*>(fTrackReps->At(id));
188  }
189 
192  unsigned int getNumReps() const {
193  return fTrackReps->GetEntriesFast();
194  }
195 
203 
204 
209  TVector3 getMom() const {return getCardinalRep()->getMom();}
210 
216  TVector3 getMom(const GFDetPlane& pl) const {return getCardinalRep()->getMom(pl);}
217 
222  TVector3 getPos() const {return getCardinalRep()->getPos();}
223 
229  TVector3 getPos(const GFDetPlane& pl) const {return getCardinalRep()->getPos(pl);}
230 
235  void getPosMomCov(TVector3& pos,TVector3& mom,TMatrixT<double>& cov){
236  getCardinalRep()->getPosMomCov(pos,mom,cov);
237  }
238 
244  void getPosMomCov(const GFDetPlane& pl,TVector3& pos,TVector3& mom,TMatrixT<double>& cov){
245  getCardinalRep()->getPosMomCov(pl,pos,mom,cov);
246  }
247 
252  double getChiSqu() const {return getCardinalRep()->getChiSqu();}
253 
258  unsigned int getNDF() const {return getCardinalRep()->getNDF();}
259 
264  double getRedChiSqu() const {return getCardinalRep()->getRedChiSqu();}
265 
270  double getCharge() const {return getCardinalRep()->getCharge();}
271 
274  void fillGeoTrack(TVirtualGeoTrack* tr) const {fillGeoTrack(tr,fCardinal_rep);}
275 
278  void fillGeoTrack(TVirtualGeoTrack* tr,unsigned int repid) const;
279 
280  // ---------------------
281  // Modifiers
282  // ---------------------
283 
284  void addFailedHit(unsigned int irep,unsigned int id){
285  assert(irep<fBookkeeping.size());
286  fBookkeeping.at(irep)->addFailedHit(id);
287  }
288 
291  inline void addHit(GFAbsRecoHit* theHit) {
292  fHits.push_back(theHit);
293  }
294 
297  void addHit(GFAbsRecoHit* theHit,
298  unsigned int detId,
299  unsigned int hitId,
300  double rho=0.,
301  unsigned int planeId=0){
302  fHits.push_back(theHit);
303  fCand.addHit(detId,hitId,rho,planeId);
304  }
305 
310  void addHitVector(std::vector<GFAbsRecoHit*> hits) {
311  fHits = hits;
312  }
313 
318  void addTrackRep(GFAbsTrackRep* theTrackRep) {
319  if(fTrackReps==NULL)fTrackReps=new TObjArray(fDefNumTrackReps);
320  fTrackReps->Add(theTrackRep);
321  fBookkeeping.push_back( new GFBookkeeping() );
322  fRepAtHit.push_back(-1);
323  }
324 
326  GFBookkeeping* getBK(int index=-1){
327  if(index==-1) return fBookkeeping.at(fCardinal_rep);
328  assert((unsigned int)index<getNumReps());
329  return fBookkeeping.at(index);
330  }
331 
333  void setCandidate(const GFTrackCand& cand, bool doreset=false);
334 
339  void setCardinalRep(unsigned int r){if((int)r<fTrackReps->GetEntriesFast())fCardinal_rep=r;}
340 
341 
349  void getResiduals(unsigned int detId, // which detector?
350  unsigned int dim, // which projection?
351  unsigned int rep, // which trackrep ?
352  std::vector<double>& result);
353 
354 
357  void setRepAtHit(unsigned int irep,int ihit){
358  assert(irep<getNumReps());
359  fRepAtHit.at(irep) = ihit;
360  }
361 
364  int getRepAtHit(unsigned int irep){
365  assert(irep<getNumReps());
366  return fRepAtHit.at(irep);
367  }
368 
372  for(unsigned int i=0;i<getNumReps();++i){
373  fRepAtHit.at(i)=-1;
374  }
375  }
376 
379  void printBookkeeping();
380 
381  void Print();
382 
384  for(unsigned int i=0;i<getNumReps();++i){
385  fBookkeeping.at(i)->clearAll();
386  }
387  }
388 
390  for(unsigned int i=0;i<getNumReps();++i){
391  fBookkeeping.at(i)->clearFailedHits();
392  }
393  }
394 
397  void getHitsByPlane(std::vector<std::vector<int>*>& retVal);
398 
401  void setSmoothing(bool smooth = true) { fSmooth = smooth; }
402 
405  bool getSmoothing() { return fSmooth; }
406 
410  void blowUpCovs(double blowUpFactor);
411 
412 
413 public:
414  ClassDef(GFTrack,1)
415 };
416 
417 #endif
418 
TVector3 pos
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:80
GFBookkeeping * getBK(int index=-1)
get GFBookKeeping object for particular track rep (default is cardinal rep)
Definition: GFTrack.h:326
double getChiSqu() const
void addFailedHit(unsigned int irep, unsigned int id)
Definition: GFTrack.h:284
double getRedChiSqu() const
returns chi2/ndf
unsigned int getNumHits() const
Definition: GFTrack.h:148
GFTrack()
Default constructor – needed for compatibility with ROOT.
Definition: GFTrack.cxx:32
double r
Definition: RiemannTest.C:14
unsigned int getNextHitToFit() const
Accessor for fNextHitToFit.
Definition: GFTrack.h:178
void Print()
Definition: GFTrack.cxx:217
bool fSmooth
Definition: GFTrack.h:100
Int_t i
Definition: run_full.C:25
void addHit(GFAbsRecoHit *theHit)
deprecated!
Definition: GFTrack.h:291
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
Track object for genfit. genfit algorithms work on these objects.
Definition: GFTrack.h:60
bool getSmoothing()
Read back if smoothing is/was turned on or off for this track.
Definition: GFTrack.h:405
unsigned int getNDF() const
Get NDF.
Definition: GFTrack.h:258
void clearBookkeeping()
Definition: GFTrack.h:383
double getChiSqu() const
Get chi2.
Definition: GFTrack.h:252
void getHitsByPlane(std::vector< std::vector< int > * > &retVal)
Definition: GFTrack.cxx:227
TVector3 getPos() const
Get present position.
Definition: GFTrack.h:222
std::vector< GFAbsRecoHit * > getHits()
Definition: GFTrack.h:140
void setSmoothing(bool smooth=true)
Switch smoothing on or off for this track.
Definition: GFTrack.h:401
void addHitVector(std::vector< GFAbsRecoHit * > hits)
Add collection of hits.
Definition: GFTrack.h:310
cout<< "POINTs for new FwEndCap == "<< tsim-> GetEntriesFast()
void getResiduals(unsigned int detId, unsigned int dim, unsigned int rep, std::vector< double > &result)
Get residuals.
Definition: GFTrack.cxx:175
void setCandidate(const GFTrackCand &cand, bool doreset=false)
set track candidate
Definition: GFTrack.cxx:148
Double_t mom
Definition: plot_dirc.C:14
TVector3 getMom() const
Get momentum at the present position.
Definition: GFTrack.h:209
unsigned int fNextHitToFit
Definition: GFTrack.h:98
static const int fDefNumTrackReps
Definition: GFTrack.h:95
std::vector< GFAbsRecoHit * > fHits
Collection of RecoHits.
Definition: GFTrack.h:77
virtual void getPosMomCov(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom, TMatrixT< double > &cov)
method which gets position, momentum and 6x6 covariance matrix
void getPosMomCov(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom, TMatrixT< double > &cov)
Get position, momentum, and 6x6 covariance at GFDetPlane.
Definition: GFTrack.h:244
TObjArray * fTrackReps
Collection of track representations.
Definition: GFTrack.h:73
double getRedChiSqu() const
Get chi2/NDF.
Definition: GFTrack.h:264
GFTrack & operator=(const GFTrack &)
assignement operator
Definition: GFTrack.cxx:75
virtual TVector3 getMom(const GFDetPlane &pl)=0
unsigned int getNumReps() const
Get number of track represenatations.
Definition: GFTrack.h:192
virtual TVector3 getPos(const GFDetPlane &pl)=0
GFTrackCand fCand
Helper to store the indices of the hits in the track. See GFTrackCand for details.
Definition: GFTrack.h:93
std::vector< int > fRepAtHit
repAtHit keeps track of at which hit index which rep is currently defined, to avoid null extrapolatio...
Definition: GFTrack.h:88
TVector3 getMom(const GFDetPlane &pl) const
Get momentum at GFDetPlane.
Definition: GFTrack.h:216
void clearFailedHits()
Definition: GFTrack.h:389
void blowUpCovs(double blowUpFactor)
this is needed to blow up the covariance matrix before a fitting pass drops off-diagonal elements and...
Definition: GFTrack.cxx:257
void setRepAtHit(unsigned int irep, int ihit)
set the hit index at which plane,state&amp;cov of rep irep is defined
Definition: GFTrack.h:357
void releaseHits()
Clear hit vector. Note that hits will not be deleted!
Definition: GFTrack.h:168
void clearRepAtHit()
clear the hit indices at which plane,state&amp;cov of reps are defined
Definition: GFTrack.h:371
std::vector< GFBookkeeping * > fBookkeeping
Collection of Bookeeping objects for failed hits in every trackrep.
Definition: GFTrack.h:83
void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixT< double > &cov)
Get position, momentum, and 6x6 covariance at current position.
Definition: GFTrack.h:235
double getCharge() const
Get charge from fit.
Definition: GFTrack.h:270
void reset()
Resets the GFTrack – deletes RecoHits!
Definition: GFTrack.cxx:116
Track candidate – a list of cluster indices.
Definition: GFTrackCand.h:55
int getRepAtHit(unsigned int irep)
get the hit index at which plane,state&amp;cov of rep irep is defined
Definition: GFTrack.h:364
void addHit(GFAbsRecoHit *theHit, unsigned int detId, unsigned int hitId, double rho=0., unsigned int planeId=0)
Add single hit. Updates the GFTrackCand.
Definition: GFTrack.h:297
Base Class for representing a Hit in GENFIT.
Definition: GFAbsRecoHit.h:73
unsigned int getNDF() const
int getFailedHits(int repId=-1)
return the number of failed Hits in track fit repId == -1 will use cardinal rep
Definition: GFTrack.h:133
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
void releaseTrackReps()
Clear TrackRep vector. Note that the Reps will not be deleted!
Definition: GFTrack.h:174
GFTrack * trk
Definition: checkgenfit.C:13
GFAbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition: GFTrack.h:202
const GFTrackCand & getCand() const
Definition: GFTrack.h:142
void addTrackRep(GFAbsTrackRep *theTrackRep)
Add track represenation.
Definition: GFTrack.h:318
void addHit(unsigned int detId, unsigned int hitId, double rho=0., unsigned int planeId=0)
Definition: GFTrackCand.cxx:44
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
virtual ~GFTrack()
Definition: GFTrack.cxx:38
void setCardinalRep(unsigned int r)
Choose cardinal track represenatation.
Definition: GFTrack.h:339
void fillGeoTrack(TVirtualGeoTrack *tr) const
Fill TVirtualGeoTrack object Cardinal representation is used.
Definition: GFTrack.h:274
void mergeHits(GFTrack *trk)
Merge two GFTracks. Only hits will be merged.
Definition: GFTrack.cxx:134
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
void printBookkeeping()
print bookkeeping
Definition: GFTrack.cxx:208
void setNextHitToFit(unsigned int i)
Set next hit to be used in a fit.
Definition: GFTrack.h:182
virtual double getCharge() const =0
TVector3 getPos(const GFDetPlane &pl) const
Get position at GFDetPlane.
Definition: GFTrack.h:229
unsigned int fCardinal_rep
Definition: GFTrack.h:96