All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFTrackCand.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 */
19 /** @addtogroup genfit
20  * @{ */
21 
22 #ifndef GFTRACKCAND_H
23 #define GFTRACKCAND_H
24 
25 #include <iostream>
26 #include <vector>
27 #include <set>
28 
29 #include "TObject.h"
30 #include "TVector3.h"
31 
33 
34 /** @brief Track candidate -- a list of cluster indices
35  *
36  * @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
37  * @author Sebastian Neubert (Technische Universit&auml;t M&uuml;nchen, original author)
38  *
39  * The main task of the GFTrackCand object is to store a list of indices to
40  * cluster objects. Each cluster in the Track is identified by it's
41  * detector ID and it's index in the corresponding TClonesArray.
42  * Also there is a ordering parameter rho, to order hits.
43  * Optionally, plane indices for the hits can be stored (most importantly
44  * for fitting with the GFDaf).
45  * This information is used by the RecoHitFactory to automatically load
46  * RecoHits into a Track. Through this it is possible to define Tracks over
47  * an arbitrary number of different detectors.
48  *
49  * In addition GFTrackCand offers members to store starting values for the fit.
50  * However this information is not autmatically used in genfit!!!
51  *
52  * @sa RecoHitFactory
53  */
54 namespace genf {
55 
56  class GFTrackCand : public TObject {
57  public:
58 
59  // Constructors/Destructors ---------
60  GFTrackCand();
61  ~GFTrackCand();
62 
63  /** @brief Initializing constructor
64  *
65  * @param curv Curvature from prefit. There is no stringent definition what
66  * this parameter means at the moment.
67  * @param dip Dip angle from prefit. There is no stringent definition what
68  * this parameter means at the moment.
69  * @param inv Dummy paramter. Has been used to mark inverted tracks
70  * in the past.
71  * @param detIDs collection of detector IDs. Each detector ID needs
72  * a corresponding GFRecoHitProducer. See RecoHitFactory for details.
73  * @param hitIDs collection of hit indices.
74  */
75  GFTrackCand(double curv, double dip, double inv, std::vector<unsigned int> detIDs, std::vector<unsigned int> hitIDs);
76  /* @brief same as previous ctor, but with ordering parameters */
77  GFTrackCand(double curv, double dip, double inv, std::vector<unsigned int> detIDs, std::vector<unsigned int> hitIDs, std::vector<double> rhos);
78 
79  /* @brief == operator does not check for rho */
80  friend bool operator== (const GFTrackCand& lhs, const GFTrackCand& rhs);
81 
82  // Accessors -----------------------
83  /** @brief Get detector ID and cluster index (hitId) for hit number i
84  */
85  void getHit(unsigned int i,
86  unsigned int& detId,
87  unsigned int& hitId) const {
88  if (i >= getNHits())
89  throw GFException("genf::GFTrackCand::getHit(int, int, int): hit index out of range", __LINE__, __FILE__).setFatal();
90  detId=fDetId.at(i);hitId=fHitId.at(i);
91  }
92  /** @brief Get detector ID and cluster index (hitId) for
93  * hit number i with ordering parameter rho
94  */
95  void getHit(unsigned int i,
96  unsigned int& detId,
97  unsigned int& hitId,
98  double &rho) const {
99  if (i >= getNHits())
100  throw GFException("genf::GFTrackCand::getHit(int, int, int, double): hit index out of range", __LINE__, __FILE__).setFatal();
101  detId=fDetId.at(i);hitId=fHitId.at(i);
102  rho=fRho.at(i);
103  }
104  /** @brief Get detector ID and cluster index (hitId) for
105  * hit number i with plane id
106  */
107  void getHitWithPlane(unsigned int i,
108  unsigned int& detId,
109  unsigned int& hitId,
110  unsigned int& planeId) const {
111  if (i >= getNHits())
112  throw GFException("genf::GFTrackCand::getHitWithPlane(): hit index out of range", __LINE__, __FILE__).setFatal();
113  detId=fDetId.at(i);hitId=fHitId.at(i);
114  planeId=fPlaneId.at(i);
115  }
116 
117  unsigned int getNHits() const {return fDetId.size();}
118  double getCurv() const {return fCurv;}
119  double getDip() const {return fDip;}
120  bool inverted() const {return fInv;}
121  std::vector<unsigned int> GetHitIDs(int detId=-1);
122  std::vector<unsigned int> GetDetIDs() const {return fDetId;}
123  std::vector<double> GetRhos() const {return fRho;}
124  std::set<unsigned int> GetUniqueDetIDs() const {
125  std::set<unsigned int> retVal;
126  for(unsigned int i=0;i<fDetId.size();++i){
127  retVal.insert(fDetId.at(i));
128  }
129  return retVal;
130  }
131  /** @brief get the MCT track id, for MC simulations - def. value -1
132  */
133  int getMcTrackId() const {return fMcTrackId;}
134  /** @brief get the seed value for track: pos */
135  TVector3 getPosSeed() const {return fPosSeed;}
136  /** @brief get the seed value for track: direction */
137  TVector3 getDirSeed() const {return fDirSeed;}
138  /** @brief get the seed value for track: qoverp */
139  double getQoverPseed() const {return fQoverpSeed;}
140  TVector3 getPosError() const {return fPosError;}
141  /** @brief get the seed value for track: error on direction (standard deviation)*/
142  TVector3 getDirError() const {return fDirError;}
143  /** @brief get the PDG code*/
144  int getPdgCode() const {return fPdg;}
145 
146  // Modifiers -----------------------
147  void addHit(unsigned int detId, unsigned int hitId, double rho=0., unsigned int planeId=0);
148  void setCurv(double c){fCurv=c;}
149  void setDip(double d){fDip=d;}
150  void setInverted(bool f=true) {fInv=f;}
151  /** @brief set the MCT track id, for MC simulations
152  */
153  void setMcTrackId(int i){fMcTrackId=i;}
154  /** @brief Test if hit already is part of this track candidate
155  */
156  bool HitInTrack(unsigned int detId, unsigned int hitId);
157  /** @brief set the seed values for track: pos, direction, q/p
158  */
159  void setTrackSeed(const TVector3& p,const TVector3& d,double qop){
161  }
162 
163  void setComplTrackSeed(const TVector3& pos,const TVector3& mom, const int pdgCode, TVector3 posError = TVector3(1.0,1.0,1.0), TVector3 dirError = TVector3(1.0,1.0,1.0));
164  /** @brief set a particle hypothesis in form of a PDG code
165  */
166  void setPdgCode(int pdgCode){fPdg=pdgCode;}
167 
168  void append(const GFTrackCand&);
169 
170  // Operations ----------------------
171  void reset();
172  void Print(std::ostream& out = std::cout) const ;
173 
174  private:
175 
176  // Private Data Members ------------
177  std::vector<unsigned int> fDetId;
178  std::vector<unsigned int> fHitId;
179  std::vector<unsigned int> fPlaneId;
180  std::vector<double> fRho;
181 
182  double fCurv; // curvature from pattern reco
183  double fDip; // dip angle from pattern reco
184  bool fInv; // true if inverted track
185 
186  TVector3 fPosSeed; //seed value for the track: pos
187  TVector3 fDirSeed; //direction
188  double fQoverpSeed; //q/p
189  TVector3 fPosError; //error on position seed given as a standard deviation
190  TVector3 fDirError; //error on direction seed given as a standard deviation
191  int fPdg; // particle data groupe's id for a particle
192 
193  int fMcTrackId; //if MC simulation, store the mct track id here
194  // Private Methods -----------------
195 
196  virtual void Print(Option_t*) const
197  { throw GFException(std::string(__func__) + "::Print(Option_t*) not available", __LINE__, __FILE__).setFatal(); }
198 
199  //public:
200  //ClassDef(GFTrackCand,3)
201  };
202 
203  bool operator==(const genf::GFTrackCand&, const genf::GFTrackCand&);
204 } // namespace genf
205 #endif
206 
207 /** @} */
friend bool operator==(const GFTrackCand &lhs, const GFTrackCand &rhs)
TVector3 getPosError() const
Definition: GFTrackCand.h:140
double getCurv() const
Definition: GFTrackCand.h:118
void setTrackSeed(const TVector3 &p, const TVector3 &d, double qop)
set the seed values for track: pos, direction, q/p
Definition: GFTrackCand.h:159
TVector3 getPosSeed() const
get the seed value for track: pos
Definition: GFTrackCand.h:135
void setPdgCode(int pdgCode)
set a particle hypothesis in form of a PDG code
Definition: GFTrackCand.h:166
TVector3 fPosError
Definition: GFTrackCand.h:189
void Print(std::ostream &out=std::cout) const
Definition: GFTrackCand.cxx:95
pdgs p
Definition: selectors.fcl:22
void getHitWithPlane(unsigned int i, unsigned int &detId, unsigned int &hitId, unsigned int &planeId) const
Get detector ID and cluster index (hitId) for hit number i with plane id.
Definition: GFTrackCand.h:107
virtual void Print(Option_t *) const
Definition: GFTrackCand.h:196
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId, double &rho) const
Get detector ID and cluster index (hitId) for hit number i with ordering parameter rho...
Definition: GFTrackCand.h:95
TVector3 getDirSeed() const
get the seed value for track: direction
Definition: GFTrackCand.h:137
void append(const GFTrackCand &)
void setComplTrackSeed(const TVector3 &pos, const TVector3 &mom, const int pdgCode, TVector3 posError=TVector3(1.0, 1.0, 1.0), TVector3 dirError=TVector3(1.0, 1.0, 1.0))
bool HitInTrack(unsigned int detId, unsigned int hitId)
Test if hit already is part of this track candidate.
Definition: GFTrackCand.cxx:78
bool operator==(const genf::GFDetPlane &, const genf::GFDetPlane &)
Definition: GFDetPlane.cxx:270
std::vector< double > GetRhos() const
Definition: GFTrackCand.h:123
std::vector< unsigned int > fPlaneId
Definition: GFTrackCand.h:179
double getDip() const
Definition: GFTrackCand.h:119
void setCurv(double c)
Definition: GFTrackCand.h:148
int getPdgCode() const
get the PDG code
Definition: GFTrackCand.h:144
void setDip(double d)
Definition: GFTrackCand.h:149
bool inverted() const
Definition: GFTrackCand.h:120
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId) const
Get detector ID and cluster index (hitId) for hit number i.
Definition: GFTrackCand.h:85
unsigned int getNHits() const
Definition: GFTrackCand.h:117
void setMcTrackId(int i)
set the MCT track id, for MC simulations
Definition: GFTrackCand.h:153
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:48
std::vector< unsigned int > GetHitIDs(int detId=-1)
Definition: GFTrackCand.cxx:58
std::set< unsigned int > GetUniqueDetIDs() const
Definition: GFTrackCand.h:124
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:78
void addHit(unsigned int detId, unsigned int hitId, double rho=0., unsigned int planeId=0)
Definition: GFTrackCand.cxx:49
void setInverted(bool f=true)
Definition: GFTrackCand.h:150
TVector3 getDirError() const
get the seed value for track: error on direction (standard deviation)
Definition: GFTrackCand.h:142
int getMcTrackId() const
get the MCT track id, for MC simulations - def. value -1
Definition: GFTrackCand.h:133
std::vector< unsigned int > fDetId
Definition: GFTrackCand.h:177
std::vector< unsigned int > GetDetIDs() const
Definition: GFTrackCand.h:122
TVector3 fDirError
Definition: GFTrackCand.h:190
std::vector< unsigned int > fHitId
Definition: GFTrackCand.h:178
double getQoverPseed() const
get the seed value for track: qoverp
Definition: GFTrackCand.h:139
BEGIN_PROLOG could also be cout
std::vector< double > fRho
Definition: GFTrackCand.h:180