PandaRoot
TrackCand.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30  */
34 #ifndef genfit_TrackCand_h
35 #define genfit_TrackCand_h
36 
37 #include "TrackCandHit.h"
38 
39 #include <vector>
40 #include <set>
41 #include <assert.h>
42 
43 #include <TObject.h>
44 #include <TVector3.h>
45 #include <TVectorD.h>
46 #include <TMatrixD.h>
47 #include <TMatrixDSym.h>
48 #include <TDatabasePDG.h>
49 
50 #include <cmath>
51 
52 namespace genfit {
53 
80 class TrackCand : public TObject {
81 
82  public:
83  // Constructors/Destructors ---------
84  TrackCand();
85  ~TrackCand();
86 
88  TrackCand(const TrackCand &other);
91  void swap(TrackCand &other); // nothrow
92 
94  friend bool operator==(const TrackCand &lhs, const TrackCand &rhs);
95  friend bool operator!=(const TrackCand &lhs, const TrackCand &rhs) { return !(lhs == rhs); }
96 
97  static bool compareTrackCandHits(const TrackCandHit *lhs, const TrackCandHit *rhs) { return (*lhs < *rhs); } // operator< defined in TrackCandHit.h
98 
99  // Accessors -----------------------
100  TrackCandHit *getHit(int i) const;
101 
103  void getHit(int i, int &detId, int &hitId) const;
104 
106  void getHit(int i, int &detId, int &hitId, double &sortingParameter) const;
107 
109  void getHitWithPlane(int i, int &detId, int &hitId, int &planeId) const;
110 
111  unsigned int getNHits() const { return hits_.size(); }
112 
118  std::vector<int> getHitIDs(int detId = -2) const;
119 
121  std::vector<int> getDetIDs() const;
123  std::vector<double> getSortingParameters() const;
124  std::set<int> getUniqueDetIDs() const;
125 
127  int getMcTrackId() const { return mcTrackId_; }
128 
130  double getTimeSeed() const { return time_; }
131 
133  TVector3 getPosSeed() const { return TVector3(state6D_(0), state6D_(1), state6D_(2)); }
134 
136  TVector3 getMomSeed() const { return TVector3(state6D_(3), state6D_(4), state6D_(5)); }
137 
139  const TMatrixDSym &getCovSeed() const { return cov6D_; }
140 
142  const TVectorD &getStateSeed() const { return state6D_; }
143 
144  double getChargeSeed() const { return q_; }
145 
147  int getPdgCode() const { return pdg_; }
148 
150  bool hitInTrack(int detId, int hitId) const;
151 
152  // Modifiers -----------------------
153 
154  void addHit(int detId, int hitId, int planeId = -1, double sortingParameter = 0);
155 
156  void addHit(TrackCandHit *hit) { hits_.push_back(hit); }
157 
159  void setMcTrackId(int i) { mcTrackId_ = i; }
160 
162  void setPdgCode(int pdgCode);
163 
165  void append(const TrackCand &);
166 
168  void sortHits();
169 
170  void sortHits(const std::vector<unsigned int> &indices);
171 
172  // Operations ----------------------
174  void reset();
175 
177  void Print(const Option_t * = "") const;
178 
180  void setTimeSeed(double time) { time_ = time; }
181 
183  void setCovSeed(const TMatrixDSym &cov6D) { cov6D_ = cov6D; /* always 6D, no need to resize */ }
184 
188  void set6DSeed(const TVectorD &state6D, const double charge);
189 
192  void set6DSeedAndPdgCode(const TVectorD &state6D, const int pdgCode);
193 
197  void setPosMomSeed(const TVector3 &pos, const TVector3 &mom, const double charge);
198 
201  void setPosMomSeedAndPdgCode(const TVector3 &pos, const TVector3 &mom, const int pdgCode);
202 
209  void setTime6DSeed(double time, const TVectorD &state6D, const double charge);
210 
215  void setTime6DSeedAndPdgCode(double time, const TVectorD &state6D, const int pdgCode);
216 
222  void setTimePosMomSeed(double time, const TVector3 &pos, const TVector3 &mom, const double charge);
223 
228  void setTimePosMomSeedAndPdgCode(double time, const TVector3 &pos, const TVector3 &mom, const int pdgCode);
229 
230  private:
231  // Private Data Members ------------
232  std::vector<TrackCandHit *> hits_; //->
233 
234  int mcTrackId_;
235  int pdg_;
237  double time_;
238  TVectorD state6D_;
239  TMatrixDSym cov6D_;
240  double q_;
242  public:
243  ClassDef(TrackCand, 2)
244  // Version history:
245  // ver 2: keep track of time in state (schema evolution rule added).
246 };
247 
248 } /* End of namespace genfit */
251 #endif // genfit_TrackCand_h
Track candidate – seed values and indices.
Definition: TrackCand.h:80
const TVectorD & getStateSeed() const
Returns the 6D seed state; should be in global coordinates.
Definition: TrackCand.h:142
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:144
friend bool operator!=(const TrackCand &lhs, const TrackCand &rhs)
Definition: TrackCand.h:95
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:33
void reset()
Delete and clear the TrackCandHits.
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
Definition: TrackCand.h:139
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:45
void setTimeSeed(double time)
Set the time at which the seed is defined.
Definition: TrackCand.h:180
int getPdgCode() const
Get the PDG code.
Definition: TrackCand.h:147
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:136
unsigned int getNHits() const
Definition: TrackCand.h:111
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:156
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:97
TVector3 getPosSeed() const
get the seed value for track: pos. Identical to the first 3 components of getStateSeed ...
Definition: TrackCand.h:133
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
Definition: TrackCand.h:159
void setCovSeed(const TMatrixDSym &cov6D)
set the covariance matrix seed (6D).
Definition: TrackCand.h:183
int getMcTrackId() const
Get the MCT track id, for MC simulations - default value = -1.
Definition: TrackCand.h:127
double getTimeSeed() const
Get the time at which the seed state is defined.
Definition: TrackCand.h:130
Matrix inversion tools.
Definition: AbsBField.h:40