EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFTrack.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFTrack.h
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 
40 class TVirtualGeoTrack;
41 
61 class GFTrack : public TObject {
62 private:
63 
64 
74  TObjArray* fTrackReps; //->
75 
78  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;
102 
103 public:
104 
106  GFTrack();
107 
109  GFTrack(const GFTrack&);
110 
112  GFTrack& operator=(const GFTrack&);
113 
119  GFTrack(GFAbsTrackRep*, bool smooth = false);
120 
121  virtual ~GFTrack();
122 
123  // -----------------------
124  // Accessors
125  // -----------------------
126 
129  void reset(); // deletes the RecoHits!
130 
134  int getFailedHits(int repId=-1){
135  int theRep;
136  if(repId==-1) theRep=fCardinal_rep;
137  else theRep = repId;
138  return fBookkeeping.at(theRep)->getNumFailed();
139  }
140 
143  std::vector<GFAbsRecoHit*> getHits() {return fHits;}
144 
149  std::map<GFAbsRecoHit*, unsigned int> getHitMap();
150 
151  const GFTrackCand& getCand() const {return fCand;}
152 
153  GFAbsRecoHit* getHit(int id) const {
154  return fHits.at(id);
155  }
156 
157  unsigned int getNumHits() const {
158  return fHits.size();
159  }
160 
171  void mergeHits(GFTrack* trk);
172 
173 
177  void sortHits();
178 
183  void releaseHits(){fHits.clear();}
184 
189  void releaseTrackReps(){ fTrackReps->SetOwner(kFALSE); fTrackReps->Clear();}
190 
193  unsigned int getNextHitToFit() const {return fNextHitToFit;}
194 
197  void setNextHitToFit(unsigned int i) {fNextHitToFit=i;}
198 
201  GFAbsTrackRep* getTrackRep(int id) const {
202  return reinterpret_cast<GFAbsTrackRep*>(fTrackReps->At(id));
203  }
204 
207  unsigned int getNumReps() const {
208  return fTrackReps->GetEntriesFast();
209  }
210 
218 
221  unsigned int getCardinalRepID() const {return fCardinal_rep;}
222 
227  TVector3 getMom() const {return getCardinalRep()->getMom();}
228 
234  TVector3 getMom(const GFDetPlane& pl) const {return getCardinalRep()->getMom(pl);}
235 
240  TVector3 getPos() const {return getCardinalRep()->getPos();}
241 
247  TVector3 getPos(const GFDetPlane& pl) const {return getCardinalRep()->getPos(pl);}
248 
253  void getPosMomCov(TVector3& pos,TVector3& mom,TMatrixT<double>& cov){
254  getCardinalRep()->getPosMomCov(pos,mom,cov);
255  }
256 
262  void getPosMomCov(const GFDetPlane& pl,TVector3& pos,TVector3& mom,TMatrixT<double>& cov){
263  getCardinalRep()->getPosMomCov(pl,pos,mom,cov);
264  }
265 
270  double getChiSqu() const {return getCardinalRep()->getChiSqu();}
271 
276  double getForwardChiSqu() const {return getCardinalRep()->getForwardChiSqu();}
277 
282  unsigned int getNDF() const {return getCardinalRep()->getNDF();}
283 
288  double getRedChiSqu() const {return getCardinalRep()->getRedChiSqu();}
289 
294  double getCharge() const {return getCardinalRep()->getCharge();}
295 
298  void fillGeoTrack(TVirtualGeoTrack* tr) const {fillGeoTrack(tr,fCardinal_rep);}
299 
302  void fillGeoTrack(TVirtualGeoTrack* tr,unsigned int repid) const;
303 
304  // ---------------------
305  // Modifiers
306  // ---------------------
307 
308  void addFailedHit(unsigned int irep,unsigned int id){
309  assert(irep<fBookkeeping.size());
310  fBookkeeping.at(irep)->addFailedHit(id);
311  }
312 
315  inline void addHit(GFAbsRecoHit* theHit) {
316  fHits.push_back(theHit);
317  }
318 
321  void addHit(GFAbsRecoHit* theHit,
322  unsigned int detId,
323  unsigned int hitId,
324  double rho=0.,
325  unsigned int planeId=0){
326  fHits.push_back(theHit);
327  fCand.addHit(detId,hitId,rho,planeId);
328  }
329 
334  void addHitVector(std::vector<GFAbsRecoHit*> hits) {
335  fHits = hits;
336  }
337 
342  void addTrackRep(GFAbsTrackRep* theTrackRep) {
343  if(fTrackReps==NULL)fTrackReps=new TObjArray(fDefNumTrackReps);
344  fTrackReps->Add(theTrackRep);
345  fBookkeeping.push_back( new GFBookkeeping() );
346  fRepAtHit.push_back(-1);
347  }
348 
350  GFBookkeeping* getBK(int index=-1) const {
351  if(index==-1) return fBookkeeping.at(fCardinal_rep);
352  assert((unsigned int)index<getNumReps());
353  return fBookkeeping.at(index);
354  }
355 
357  void setCandidate(const GFTrackCand& cand, bool doreset=false);
358 
363  void setCardinalRep(unsigned int r){if((int)r<fTrackReps->GetEntriesFast())fCardinal_rep=r;}
364 
365 
373  void getResiduals(unsigned int detId, // which detector?
374  unsigned int dim, // which projection?
375  unsigned int rep, // which trackrep ?
376  std::vector<double>& result);
377 
378 
381  void setRepAtHit(unsigned int irep,int ihit){
382  assert(irep<getNumReps());
383  fRepAtHit.at(irep) = ihit;
384  }
385 
388  int getRepAtHit(unsigned int irep) const {
389  assert(irep<getNumReps());
390  return fRepAtHit.at(irep);
391  }
392 
396  for(unsigned int i=0;i<getNumReps();++i){
397  fRepAtHit.at(i)=-1;
398  }
399  }
400 
403  void printBookkeeping();
404 
405  void Print(const Option_t* = "") const;
406 
408  for(unsigned int i=0;i<getNumReps();++i){
409  fBookkeeping.at(i)->clearAll();
410  }
411  }
412 
414  for(unsigned int i=0;i<getNumReps();++i){
415  fBookkeeping.at(i)->clearFailedHits();
416  }
417  }
418 
421  bool getHitsByPlane(std::vector<std::vector<int>*>& retVal);
422 
429  void setSmoothing(bool smooth = true, bool fast = false) { fSmooth = smooth; fSmoothFast = fast;}
430 
433  bool getSmoothing() const { return fSmooth; }
434 
437  bool getSmoothingFast() const { return fSmoothFast; }
438 
442  void blowUpCovs(double blowUpFactor);
443 
444 
445 public:
446  ClassDef(GFTrack,3)
447 };
448 
449 #endif
450