LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 */
22 #ifndef GFTRACKCAND_H
23 #define GFTRACKCAND_H
24 
25 #include <iostream>
26 #include <set>
27 #include <vector>
28 
29 #include "TObject.h"
30 #include "TVector3.h"
31 
33 
54 namespace genf {
55 
56  class GFTrackCand : public TObject {
57  public:
58  // Constructors/Destructors ---------
59  GFTrackCand();
60  ~GFTrackCand();
61 
74  GFTrackCand(double curv,
75  double dip,
76  double inv,
77  std::vector<unsigned int> detIDs,
78  std::vector<unsigned int> hitIDs);
79  /* @brief same as previous ctor, but with ordering parameters */
80  GFTrackCand(double curv,
81  double dip,
82  double inv,
83  std::vector<unsigned int> detIDs,
84  std::vector<unsigned int> hitIDs,
85  std::vector<double> rhos);
86 
87  /* @brief == operator does not check for rho */
88  friend bool operator==(const GFTrackCand& lhs, const GFTrackCand& rhs);
89 
90  // Accessors -----------------------
93  void getHit(unsigned int i, unsigned int& detId, unsigned int& hitId) const
94  {
95  if (i >= getNHits())
96  throw GFException(
97  "genf::GFTrackCand::getHit(int, int, int): hit index out of range", __LINE__, __FILE__)
98  .setFatal();
99  detId = fDetId.at(i);
100  hitId = fHitId.at(i);
101  }
105  void getHit(unsigned int i, unsigned int& detId, unsigned int& hitId, double& rho) const
106  {
107  if (i >= getNHits())
108  throw GFException(
109  "genf::GFTrackCand::getHit(int, int, int, double): hit index out of range",
110  __LINE__,
111  __FILE__)
112  .setFatal();
113  detId = fDetId.at(i);
114  hitId = fHitId.at(i);
115  rho = fRho.at(i);
116  }
120  void getHitWithPlane(unsigned int i,
121  unsigned int& detId,
122  unsigned int& hitId,
123  unsigned int& planeId) const
124  {
125  if (i >= getNHits())
126  throw GFException(
127  "genf::GFTrackCand::getHitWithPlane(): hit index out of range", __LINE__, __FILE__)
128  .setFatal();
129  detId = fDetId.at(i);
130  hitId = fHitId.at(i);
131  planeId = fPlaneId.at(i);
132  }
133 
134  unsigned int getNHits() const { return fDetId.size(); }
135  double getCurv() const { return fCurv; }
136  double getDip() const { return fDip; }
137  bool inverted() const { return fInv; }
138  std::vector<unsigned int> GetHitIDs(int detId = -1);
139  std::vector<unsigned int> GetDetIDs() const { return fDetId; }
140  std::vector<double> GetRhos() const { return fRho; }
141  std::set<unsigned int> GetUniqueDetIDs() const
142  {
143  std::set<unsigned int> retVal;
144  for (unsigned int i = 0; i < fDetId.size(); ++i) {
145  retVal.insert(fDetId.at(i));
146  }
147  return retVal;
148  }
151  int getMcTrackId() const { return fMcTrackId; }
153  TVector3 getPosSeed() const { return fPosSeed; }
155  TVector3 getDirSeed() const { return fDirSeed; }
157  double getQoverPseed() const { return fQoverpSeed; }
158  TVector3 getPosError() const { return fPosError; }
160  TVector3 getDirError() const { return fDirError; }
162  int getPdgCode() const { return fPdg; }
163 
164  // Modifiers -----------------------
165  void addHit(unsigned int detId, unsigned int hitId, double rho = 0., unsigned int planeId = 0);
166  void setCurv(double c) { fCurv = c; }
167  void setDip(double d) { fDip = d; }
168  void setInverted(bool f = true) { fInv = f; }
171  void setMcTrackId(int i) { fMcTrackId = i; }
174  bool HitInTrack(unsigned int detId, unsigned int hitId);
177  void setTrackSeed(const TVector3& p, const TVector3& d, double qop)
178  {
179  fPosSeed = p;
180  fDirSeed = d;
181  fQoverpSeed = qop;
182  }
183 
184  void setComplTrackSeed(const TVector3& pos,
185  const TVector3& mom,
186  const int pdgCode,
187  TVector3 posError = TVector3(1.0, 1.0, 1.0),
188  TVector3 dirError = TVector3(1.0, 1.0, 1.0));
191  void setPdgCode(int pdgCode) { fPdg = pdgCode; }
192 
193  void append(const GFTrackCand&);
194 
195  // Operations ----------------------
196  void reset();
197  void Print(std::ostream& out = std::cout) const;
198 
199  private:
200  // Private Data Members ------------
201  std::vector<unsigned int> fDetId;
202  std::vector<unsigned int> fHitId;
203  std::vector<unsigned int> fPlaneId;
204  std::vector<double> fRho;
205 
206  double fCurv; // curvature from pattern reco
207  double fDip; // dip angle from pattern reco
208  bool fInv; // true if inverted track
209 
210  TVector3 fPosSeed; //seed value for the track: pos
211  TVector3 fDirSeed; //direction
212  double fQoverpSeed; //q/p
213  TVector3 fPosError; //error on position seed given as a standard deviation
214  TVector3 fDirError; //error on direction seed given as a standard deviation
215  int fPdg; // particle data groupe's id for a particle
216 
217  int fMcTrackId; //if MC simulation, store the mct track id here
218  // Private Methods -----------------
219 
220  virtual void Print(Option_t*) const
221  {
222  throw GFException(
223  std::string(__func__) + "::Print(Option_t*) not available", __LINE__, __FILE__)
224  .setFatal();
225  }
226 
227  //public:
228  //ClassDef(GFTrackCand,3)
229  };
230 
231  bool operator==(const genf::GFTrackCand&, const genf::GFTrackCand&);
232 } // namespace genf
233 #endif
234 
friend bool operator==(const GFTrackCand &lhs, const GFTrackCand &rhs)
TVector3 getPosError() const
Definition: GFTrackCand.h:158
double getCurv() const
Definition: GFTrackCand.h:135
void setTrackSeed(const TVector3 &p, const TVector3 &d, double qop)
set the seed values for track: pos, direction, q/p
Definition: GFTrackCand.h:177
TVector3 getPosSeed() const
get the seed value for track: pos
Definition: GFTrackCand.h:153
void setPdgCode(int pdgCode)
set a particle hypothesis in form of a PDG code
Definition: GFTrackCand.h:191
TVector3 fPosError
Definition: GFTrackCand.h:213
void Print(std::ostream &out=std::cout) const
Generic Interface to magnetic fields in GENFIT.
Definition: GFAbsBField.h:34
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:120
virtual void Print(Option_t *) const
Definition: GFTrackCand.h:220
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:105
TVector3 getDirSeed() const
get the seed value for track: direction
Definition: GFTrackCand.h:155
void append(const GFTrackCand &)
TFile f
Definition: plotHisto.C:6
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.
std::vector< double > GetRhos() const
Definition: GFTrackCand.h:140
std::vector< unsigned int > fPlaneId
Definition: GFTrackCand.h:203
double getDip() const
Definition: GFTrackCand.h:136
Float_t d
Definition: plot.C:235
void setCurv(double c)
Definition: GFTrackCand.h:166
int getPdgCode() const
get the PDG code
Definition: GFTrackCand.h:162
void setDip(double d)
Definition: GFTrackCand.h:167
bool inverted() const
Definition: GFTrackCand.h:137
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:93
unsigned int getNHits() const
Definition: GFTrackCand.h:134
void setMcTrackId(int i)
set the MCT track id, for MC simulations
Definition: GFTrackCand.h:171
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:47
std::vector< unsigned int > GetHitIDs(int detId=-1)
Definition: GFTrackCand.cxx:85
std::set< unsigned int > GetUniqueDetIDs() const
Definition: GFTrackCand.h:141
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:75
void addHit(unsigned int detId, unsigned int hitId, double rho=0., unsigned int planeId=0)
Definition: GFTrackCand.cxx:74
void setInverted(bool f=true)
Definition: GFTrackCand.h:168
TVector3 getDirError() const
get the seed value for track: error on direction (standard deviation)
Definition: GFTrackCand.h:160
int getMcTrackId() const
get the MCT track id, for MC simulations - def. value -1
Definition: GFTrackCand.h:151
std::vector< unsigned int > fDetId
Definition: GFTrackCand.h:201
std::vector< unsigned int > GetDetIDs() const
Definition: GFTrackCand.h:139
TVector3 fDirError
Definition: GFTrackCand.h:214
std::vector< unsigned int > fHitId
Definition: GFTrackCand.h:202
double getQoverPseed() const
get the seed value for track: qoverp
Definition: GFTrackCand.h:157
std::vector< double > fRho
Definition: GFTrackCand.h:204