FairRoot/PandaRoot
GFTrackCand.cxx
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 #include "GFTrackCand.h"
20 #include"TDatabasePDG.h"
21 #include <algorithm>
22 #include <iostream>
23 
25 
26 GFTrackCand::GFTrackCand():fCurv(0),fDip(0),fInv(false), fQoverpSeed(0.),fMcTrackId(-1),fPdg(0){}
27 
29 
30 GFTrackCand::GFTrackCand(double curv, double dip, double inv, std::vector<unsigned int> detIDs, std::vector<unsigned int> hitIDs)
31  : fDetId(detIDs),fHitId(hitIDs),fCurv(curv), fDip(dip), fInv(inv),fQoverpSeed(0.), fMcTrackId(-1),fPdg(0)
32 {
33  assert(fDetId.size()==fHitId.size());
34  fRho.resize(fDetId.size(),0.);
35 }
36 GFTrackCand::GFTrackCand(double curv, double dip, double inv, std::vector<unsigned int> detIDs, std::vector<unsigned int> hitIDs,std::vector<double> rhos)
37  : fDetId(detIDs),fHitId(hitIDs),fRho(rhos),fCurv(curv), fDip(dip), fInv(inv),fQoverpSeed(0.), fMcTrackId(-1),fPdg(0)
38 {
39  assert(fDetId.size()==fHitId.size());
40  assert(fDetId.size()==fRho.size());
41 }
42 
43 void
44 GFTrackCand::addHit(unsigned int detId, unsigned int hitId, double rho, unsigned int planeId)
45 {
46  fDetId.push_back(detId);
47  fHitId.push_back(hitId);
48  fPlaneId.push_back(planeId);
49  fRho.push_back(rho);
50 }
51 
52 std::vector<unsigned int>
54  if(detId<0){ // return hits from all detectors
55  return fHitId;
56  }
57  else {
58  std::vector<unsigned int> result;
59  unsigned int n=fHitId.size();
60  for(unsigned int i=0;i<n;++i){
61  if(fDetId[i]==(unsigned int)detId)result.push_back(fHitId[i]);
62  }
63  return result;
64  }
65 }
66 
67 void
69 {
70  fDetId.clear();fHitId.clear();
71 }
72 
73 bool GFTrackCand::HitInTrack(unsigned int detId, unsigned int hitId)
74 {
75  for (unsigned int i = 0; i < fDetId.size(); i++){
76  if (detId == fDetId[i])
77  if (hitId == fHitId[i])
78  return true;
79  }
80  return false;
81 }
82 
83 bool operator== (const GFTrackCand& lhs, const GFTrackCand& rhs){
84  if(lhs.getNHits()!=rhs.getNHits()) return false;
85  bool result=std::equal(lhs.fDetId.begin(),lhs.fDetId.end(),rhs.fDetId.begin());
86  result &=std::equal(lhs.fHitId.begin(),lhs.fHitId.end(),rhs.fHitId.begin());
87  return result;
88 }
89 
90 void GFTrackCand::Print() const {
91  std::cout << "======== GFTrackCand::print ========" << std::endl;
92  if(fMcTrackId>=0) std::cout << "mcTrackId=" << fMcTrackId << std::endl;
93  std::cout << "seed values for pos,direction, and q/p: " << std::endl;
94  fPosSeed.Print();
95  fDirSeed.Print();
96  std::cout << "q/p=" << fQoverpSeed << std::endl;
97  assert(fDetId.size()==fHitId.size());
98  std::cout << "detId|hitId|rho ";
99  for(unsigned int i=0;i<fDetId.size();++i){
100  std::cout << fDetId.at(i) << "|" << fHitId.at(i)
101  << "|" << fRho.at(i) << " ";
102  }
103  std::cout << std::endl;
104 }
105 
107  unsigned int detId,hitId;
108  double rho;
109  for(unsigned int i=0;i<rhs.getNHits();++i){
110  rhs.getHit(i,detId,hitId,rho);
111  addHit(detId,hitId,rho);
112  }
113 
114 
115 }
116 
117 void GFTrackCand::setComplTrackSeed(const TVector3& pos,const TVector3& mom, const int pdgCode, TVector3 posError, TVector3 dirError){
118  fPosSeed=pos;fDirSeed=mom; fPdg = pdgCode; fPosError = posError; fDirError = dirError;
119  TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(fPdg);
120  double charge = part->Charge()/(3.);
121  fQoverpSeed=charge/mom.Mag();
122 }
TVector3 pos
bool operator==(const GFTrackCand &lhs, const GFTrackCand &rhs)
Definition: GFTrackCand.cxx:83
Int_t i
Definition: run_full.C:25
bool HitInTrack(unsigned int detId, unsigned int hitId)
Test if hit already is part of this track candidate.
Definition: GFTrackCand.cxx:73
TVector3 fPosError
Definition: GFTrackCand.h:184
unsigned int getNHits() const
Definition: GFTrackCand.h:113
int n
Double_t mom
Definition: plot_dirc.C:14
std::vector< unsigned int > fHitId
Definition: GFTrackCand.h:174
std::vector< unsigned int > fPlaneId
Definition: GFTrackCand.h:175
TVector3 fPosSeed
Definition: GFTrackCand.h:182
std::vector< unsigned int > GetHitIDs(int detId=-1)
Definition: GFTrackCand.cxx:53
void reset()
Definition: GFTrackCand.cxx:68
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:84
void append(const GFTrackCand &)
Track candidate – a list of cluster indices.
Definition: GFTrackCand.h:55
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))
set the seed values for track: pos, momentum, pdgCode, pos error, momentum error (errors are optional...
std::vector< double > fRho
Definition: GFTrackCand.h:176
double fQoverpSeed
Definition: GFTrackCand.h:186
TVector3 fDirSeed
Definition: GFTrackCand.h:183
std::vector< unsigned int > fDetId
Definition: GFTrackCand.h:173
void addHit(unsigned int detId, unsigned int hitId, double rho=0., unsigned int planeId=0)
Definition: GFTrackCand.cxx:44
void Print() const
Definition: GFTrackCand.cxx:90
ClassImp(GFTrackCand) GFTrackCand
Definition: GFTrackCand.cxx:24
TVector3 fDirError
Definition: GFTrackCand.h:185