EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFTrackCand.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFTrackCand.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  */
22 #ifndef GFTRACKCAND_H
23 #define GFTRACKCAND_H
24 
25 #include <vector>
26 #include <set>
27 #include <iostream>
28 #include <assert.h>
29 
30 #include <TObject.h>
31 #include <TVector3.h>
32 #include <TMatrixD.h>
33 #include <TDatabasePDG.h>
34 
35 #include <cmath>
36 
63 class GFTrackCand : public TObject {
64 public:
65 
66  // Constructors/Destructors ---------
67  GFTrackCand();
68  ~GFTrackCand();
69 
70  /* @brief == operator does not check for rho */
71  friend bool operator== (const GFTrackCand& lhs, const GFTrackCand& rhs);
72 
73  // Accessors -----------------------
76  void getHit(unsigned int i,
77  unsigned int& detId,
78  unsigned int& hitId) const {
79  assert(i < getNHits());
80  detId = fDetId.at(i); hitId = fHitId.at(i);
81  }
85  void getHit(unsigned int i,
86  unsigned int& detId,
87  unsigned int& hitId,
88  double& rho) const {
89  assert(i < getNHits());
90  detId = fDetId.at(i); hitId = fHitId.at(i);
91  rho = fRho.at(i);
92  }
96  void getHitWithPlane(unsigned int i,
97  unsigned int& detId,
98  unsigned int& hitId,
99  unsigned int& planeId) const {
100  assert(i < getNHits());
101  detId = fDetId.at(i); hitId = fHitId.at(i);
102  planeId = fPlaneId.at(i);
103  }
104 
105  unsigned int getNHits() const {return fDetId.size();}
106  double getCurv() const {
107  std::cerr << "the method GFTrackCand::getCurv() is deprecated. Use the setter/getter for the 6D state or pos,mom instead instead\n";
108  return fCurv;}
109  double getDip() const {
110  std::cerr << "the method GFTrackCand::getDip() is deprecated. Use the setter/getter for the 6D state or pos,mom instead instead\n";
111  return fDip;}
112  //bool inverted() const {return fInv;} //nobody seems to use it so I commented it out
113  std::vector<unsigned int> getHitIDs(int detId = -1) const;
114  std::vector<unsigned int> GetHitIDs(int detId = -1) const;
115  std::vector<unsigned int> getDetIDs() const {return fDetId;}
116  std::vector<unsigned int> GetDetIDs() const { std::cerr << "the method GFTrackCand::GetDetIDs() is deprecated. Use GFTrackCand::getDetIDs() instead\n"; return fDetId;}
117  std::vector<double> getRhos() const {return fRho;}
118  std::vector<double> GetRhos() const {
119  std::cerr << "the method GFTrackCand::GetRhos() is deprecated. Use GFTrackCand::getRhos() instead\n";
120  return fRho;
121  }
122  std::set<unsigned int> getUniqueDetIDs() const {
123  std::set<unsigned int> retVal;
124  for (unsigned int i = 0; i < fDetId.size(); ++i) {
125  retVal.insert(fDetId.at(i));
126  }
127  return retVal;
128  }
131  int getMcTrackId() const {return fMcTrackId;}
133  TVector3 getPosSeed() const {
134  TVector3 posSeed(fState6D(0,0), fState6D(1,0), fState6D(2,0));
135  return posSeed;
136  }
138  TVector3 getMomSeed() const {
139  TVector3 momSeed(fState6D(3,0), fState6D(4,0), fState6D(5,0));
140  return momSeed;
141  }
143  TVector3 getDirSeed() const {
144  std::cerr << "the method GFTrackCand::getDirSeed() is deprecated. Use GFTrackCand::getStateSeed() or GFTrackCand::getMomSeed() instead\n";
145  double p = std::sqrt(fState6D(3,0) * fState6D(3,0) + fState6D(4,0) * fState6D(4,0) + fState6D(5,0) * fState6D(5,0));
146  TVector3 dirSeed(fState6D(3,0)/p, fState6D(4,0)/p, fState6D(5,0)/p);
147  return dirSeed;
148  }
150  double getQoverPseed() const {
151  std::cerr << "the method GFTrackCand::getQoverPseed() is deprecated. Use GFTrackCand::getStateSeed() or GFTrackCand::getMomSeed() and/or getChargeSeed() instead\n";
152  double p = std::sqrt(fState6D(3,0) * fState6D(3,0) + fState6D(4,0) * fState6D(4,0) + fState6D(5,0) * fState6D(5,0));
153  return fQ / p;
154  }
156  TMatrixD getStateSeed() const {
157  return fState6D;
158  }
160  TMatrixD getCovSeed() const {
161  return fCov6D;
162  }
163  double getChargeSeed()const {
164  return fQ;
165  }
167  int getPdgCode() const {return fPdg;}
168  // Modifiers -----------------------
169  void addHit(unsigned int detId, unsigned int hitId, double rho = 0., unsigned int planeId = 0);
170  void setCurv(double c) {
171  std::cerr << "the method GFTrackCand::setCurv is deprecated. Use GFTrackCand::set6DSeed instead\n";
172  fCurv = c;
173  }
174  void setDip(double d) {
175  std::cerr << "the method GFTrackCand::setDip is deprecated. Use GFTrackCand::set6DSeed instead\n";
176  fDip = d;
177  }
178  //void setInverted(bool f=true) {fInv=f;} //nobody seems to use it so I commented it out
181  void setMcTrackId(int i) {fMcTrackId = i;}
184  bool hitInTrack(unsigned int detId, unsigned int hitId) const;
185 
188  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));
191  void setPdgCode(int pdgCode) {
192  fPdg = pdgCode;
193  TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(fPdg);
194  fQ = part->Charge() / (3.);
195  }
196  void append(const GFTrackCand&);
197 
201  void sortHits();
202 
203  void sortHits(std::vector<unsigned int> indices);
204 
205  // Operations ----------------------
206  void reset();
209  void Print(const Option_t* = "") const ;
214  void set6DSeed(const TMatrixD& state6D, const double charge, TMatrixD cov6D = -1.0 * TMatrixD(TMatrixD::kUnit, TMatrixD(6, 6))) {
215  fQ = charge;
216  fState6D = state6D;
217  fCov6D = cov6D;
218  }
222  void set6DSeedAndPdgCode(const TMatrixD& state6D, const int pdgCode, TMatrixD cov6D = -1.0 * TMatrixD(TMatrixD::kUnit, TMatrixD(6, 6))) {
223  setPdgCode(pdgCode);
224  fState6D = state6D;
225  fCov6D = cov6D;
226  }
231  void setPosMomSeed(const TVector3& pos, const TVector3& mom, const double charge, TMatrixD cov6D = -1.0 * TMatrixD(TMatrixD::kUnit, TMatrixD(6, 6))) {
232  fQ = charge;
233  fState6D(0,0) = pos[0];
234  fState6D(1,0) = pos[1];
235  fState6D(2,0) = pos[2];
236  fState6D(3,0) = mom[0];
237  fState6D(4,0) = mom[1];
238  fState6D(5,0) = mom[2];
239  fCov6D = cov6D;
240  }
244  void setPosMomSeedAndPdgCode(const TVector3& pos, const TVector3& mom, const int pdgCode, TMatrixD cov6D = -1.0 * TMatrixD(TMatrixD::kUnit, TMatrixD(6, 6))) {
245  setPdgCode(pdgCode);
246  fState6D(0,0) = pos[0];
247  fState6D(1,0) = pos[1];
248  fState6D(2,0) = pos[2];
249  fState6D(3,0) = mom[0];
250  fState6D(4,0) = mom[1];
251  fState6D(5,0) = mom[2];
252  fCov6D = cov6D;
253  }
254 private:
255 
256  // Private Data Members ------------
257  std::vector<unsigned int> fDetId;
258  std::vector<unsigned int> fHitId;
259  std::vector<unsigned int> fPlaneId;
260  std::vector<double> fRho;
261 
262  double fCurv; // curvature from pattern reco. Deprecated! Will be deleted soon.
263  double fDip; // dip angle from pattern reco. Deprecated! Will be deleted soon.
264 
266  int fPdg;
268  TMatrixD fState6D;
269  TMatrixD fCov6D;
270  double fQ;
273  // Private Methods -----------------
274 
275 public:
276  ClassDef(GFTrackCand, 9)
277 };
278 
279 #endif
280