PandaRoot
TrackCand.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
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 genfit_TrackCand_h
23 #define genfit_TrackCand_h
24 
25 #include "TrackCandHit.h"
26 
27 #include <vector>
28 #include <set>
29 #include <assert.h>
30 
31 #include <TObject.h>
32 #include <TVector3.h>
33 #include <TVectorD.h>
34 #include <TMatrixD.h>
35 #include <TMatrixDSym.h>
36 #include <TDatabasePDG.h>
37 
38 #include <cmath>
39 
40 namespace genfit {
41 
68 class TrackCand : public TObject {
69 
70  public:
71  // Constructors/Destructors ---------
72  TrackCand();
73  ~TrackCand();
74 
76  TrackCand(const TrackCand &other);
79  void swap(TrackCand &other); // nothrow
80 
82  friend bool operator==(const TrackCand &lhs, const TrackCand &rhs);
83  friend bool operator!=(const TrackCand &lhs, const TrackCand &rhs) { return !(lhs == rhs); }
84 
85  static bool compareTrackCandHits(const TrackCandHit *lhs, const TrackCandHit *rhs) { return (*lhs < *rhs); } // operator< defined in TrackCandHit.h
86 
87  // Accessors -----------------------
88  TrackCandHit *getHit(int i) const;
89 
91  void getHit(int i, int &detId, int &hitId) const;
92 
94  void getHit(int i, int &detId, int &hitId, double &sortingParameter) const;
95 
97  void getHitWithPlane(int i, int &detId, int &hitId, int &planeId) const;
98 
99  unsigned int getNHits() const { return hits_.size(); }
100 
106  std::vector<int> getHitIDs(int detId = -2) const;
107 
109  std::vector<int> getDetIDs() const;
111  std::vector<double> getSortingParameters() const;
112  std::set<int> getUniqueDetIDs() const;
113 
115  int getMcTrackId() const { return mcTrackId_; }
116 
118  double getTimeSeed() const { return time_; }
119 
121  TVector3 getPosSeed() const { return TVector3(state6D_(0), state6D_(1), state6D_(2)); }
122 
124  TVector3 getMomSeed() const { return TVector3(state6D_(3), state6D_(4), state6D_(5)); }
125 
127  const TMatrixDSym &getCovSeed() const { return cov6D_; }
128 
130  const TVectorD &getStateSeed() const { return state6D_; }
131 
132  double getChargeSeed() const { return q_; }
133 
135  int getPdgCode() const { return pdg_; }
136 
138  bool hitInTrack(int detId, int hitId) const;
139 
140  // Modifiers -----------------------
141 
142  void addHit(int detId, int hitId, int planeId = -1, double sortingParameter = 0);
143 
144  void addHit(TrackCandHit *hit) { hits_.push_back(hit); }
145 
147  void setMcTrackId(int i) { mcTrackId_ = i; }
148 
150  void setPdgCode(int pdgCode);
151 
153  void append(const TrackCand &);
154 
156  void sortHits();
157 
158  void sortHits(const std::vector<unsigned int> &indices);
159 
160  // Operations ----------------------
162  void reset();
163 
165  void Print(const Option_t * = "") const;
166 
168  void setTimeSeed(double time) { time_ = time; }
169 
171  void setCovSeed(const TMatrixDSym &cov6D) { cov6D_ = cov6D; /* always 6D, no need to resize */ }
172 
176  void set6DSeed(const TVectorD &state6D, const double charge);
177 
180  void set6DSeedAndPdgCode(const TVectorD &state6D, const int pdgCode);
181 
185  void setPosMomSeed(const TVector3 &pos, const TVector3 &mom, const double charge);
186 
189  void setPosMomSeedAndPdgCode(const TVector3 &pos, const TVector3 &mom, const int pdgCode);
190 
197  void setTime6DSeed(double time, const TVectorD &state6D, const double charge);
198 
203  void setTime6DSeedAndPdgCode(double time, const TVectorD &state6D, const int pdgCode);
204 
210  void setTimePosMomSeed(double time, const TVector3 &pos, const TVector3 &mom, const double charge);
211 
216  void setTimePosMomSeedAndPdgCode(double time, const TVector3 &pos, const TVector3 &mom, const int pdgCode);
217 
218  private:
219  // Private Data Members ------------
220  std::vector<TrackCandHit *> hits_; //->
221 
222  int mcTrackId_;
223  int pdg_;
225  double time_;
226  TVectorD state6D_;
227  TMatrixDSym cov6D_;
228  double q_;
230  public:
231  ClassDef(TrackCand, 2)
232  // Version history:
233  // ver 2: keep track of time in state (schema evolution rule added).
234 };
235 
236 } /* End of namespace genfit */
239 #endif // genfit_TrackCand_h
Track candidate – seed values and indices.
Definition: TrackCand.h:68
const TVectorD & getStateSeed() const
Returns the 6D seed state; should be in global coordinates.
Definition: TrackCand.h:130
friend bool operator==(const TrackCand &lhs, const TrackCand &rhs)
== operator checks equality of TrackCandHits. Does not check for sorting parameters.
void append(const TrackCand &)
Clone the TrackCandHit objects from the other TrackCand and append them to this TrackCand.
void sortHits()
Sort the hits that were already added to the trackCand using the sorting parameters.
void addHit(int detId, int hitId, int planeId=-1, double sortingParameter=0)
void set6DSeed(const TVectorD &state6D, const double charge)
sets the state to seed the track fitting. State has to be a TVectorD(6). First 3 elements are the sta...
std::vector< double > getSortingParameters() const
Get sorting parameterts of all hits.
void setTime6DSeed(double time, const TVectorD &state6D, const double charge)
sets the state to seed the track fitting and its time. State has to be a TVectorD(6). First 3 elements are the staring postion second 3 elements the starting momentum. Everything in global coordinates charge is the charge hypotheses of the particle charge.
double getChargeSeed() const
Definition: TrackCand.h:132
friend bool operator!=(const TrackCand &lhs, const TrackCand &rhs)
Definition: TrackCand.h:83
void Print(const Option_t *="") const
Write the content of all private attributes to the terminal.
TrackCandHit * getHit(int i) const
void setTimePosMomSeedAndPdgCode(double time, const TVector3 &pos, const TVector3 &mom, const int pdgCode)
This function works the same as setPosMomSeed but instead of a charge hypothesis you can set a pdg co...
std::set< int > getUniqueDetIDs() const
unsigned int i
Definition: P4_F32vec4.h:21
void reset()
Delete and clear the TrackCandHits.
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
Definition: TrackCand.h:127
bool hitInTrack(int detId, int hitId) const
Is there a hit with detId and hitId in the TrackCand?
Hit object for use in TrackCand. Provides IDs and sorting parameters.
Definition: TrackCandHit.h:33
void setTimeSeed(double time)
Set the time at which the seed is defined.
Definition: TrackCand.h:168
int getPdgCode() const
Get the PDG code.
Definition: TrackCand.h:135
TrackCand & operator=(TrackCand other)
assignment operator
void getHitWithPlane(int i, int &detId, int &hitId, int &planeId) const
Get detector Id, hit Id and plane id for hit number i.
TVector3 getMomSeed() const
get the seed value for track: mom. Identical to the last 3 components of getStateSeed ...
Definition: TrackCand.h:124
unsigned int getNHits() const
Definition: TrackCand.h:99
void setPosMomSeed(const TVector3 &pos, const TVector3 &mom, const double charge)
sets the state to seed the track fitting. State has to be a TVector3 for position and a TVector3 for ...
void swap(TrackCand &other)
void setTime6DSeedAndPdgCode(double time, const TVectorD &state6D, const int pdgCode)
This function works the same as set6DSeed but instead of a charge hypothesis you can set a pdg code w...
void set6DSeedAndPdgCode(const TVectorD &state6D, const int pdgCode)
This function works the same as set6DSeed but instead of a charge hypothesis you can set a pdg code w...
std::vector< int > getHitIDs(int detId=-2) const
Get hit ids of from a specific detector.
void addHit(TrackCandHit *hit)
Definition: TrackCand.h:144
void setPdgCode(int pdgCode)
Set a particle hypothesis in form of a PDG code. This will also set the charge attribute.
std::vector< int > getDetIDs() const
Get detector IDs of all hits.
void setTimePosMomSeed(double time, const TVector3 &pos, const TVector3 &mom, const double charge)
sets the state to seed the track fitting and its time. State has to be a TVector3 for position and a ...
void setPosMomSeedAndPdgCode(const TVector3 &pos, const TVector3 &mom, const int pdgCode)
This function works the same as setPosMomSeed but instead of a charge hypothesis you can set a pdg co...
static bool compareTrackCandHits(const TrackCandHit *lhs, const TrackCandHit *rhs)
Definition: TrackCand.h:85
TVector3 getPosSeed() const
get the seed value for track: pos. Identical to the first 3 components of getStateSeed ...
Definition: TrackCand.h:121
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
Definition: TrackCand.h:147
void setCovSeed(const TMatrixDSym &cov6D)
set the covariance matrix seed (6D).
Definition: TrackCand.h:171
int getMcTrackId() const
Get the MCT track id, for MC simulations - default value = -1.
Definition: TrackCand.h:115
double getTimeSeed() const
Get the time at which the seed state is defined.
Definition: TrackCand.h:118
Matrix inversion tools.
Definition: AbsBField.h:28