SND@LHC Software
Loading...
Searching...
No Matches
genfit::TrackCand Class Reference

Track candidate – seed values and indices. More...

#include <TrackCand.h>

Inheritance diagram for genfit::TrackCand:
Collaboration diagram for genfit::TrackCand:

Public Member Functions

 TrackCand ()
 
 ~TrackCand ()
 
 TrackCand (const TrackCand &other)
 copy constructor
 
TrackCandoperator= (TrackCand other)
 assignment operator
 
void swap (TrackCand &other)
 
TrackCandHitgetHit (int i) const
 
void getHit (int i, int &detId, int &hitId) const
 Get detector Id and hit Id for hit number i.
 
void getHit (int i, int &detId, int &hitId, double &sortingParameter) const
 Get detector Id, hit Id and sorting parameter for hit number i.
 
void getHitWithPlane (int i, int &detId, int &hitId, int &planeId) const
 Get detector Id, hit Id and plane id for hit number i.
 
unsigned int getNHits () const
 
std::vector< int > getHitIDs (int detId=-2) const
 Get hit ids of from a specific detector.
 
std::vector< int > getDetIDs () const
 Get detector IDs of all hits.
 
std::vector< double > getSortingParameters () const
 Get sorting parameterts of all hits.
 
std::set< int > getUniqueDetIDs () const
 
int getMcTrackId () const
 Get the MCT track id, for MC simulations - default value = -1.
 
TVector3 getPosSeed () const
 get the seed value for track: pos. Identical to the first 3 components of getStateSeed
 
TVector3 getMomSeed () const
 get the seed value for track: mom. Identical to the last 3 components of getStateSeed
 
void setCovSeed (const TMatrixDSym &cov6D)
 set the covariance matrix seed (6D).

 
const TMatrixDSym & getCovSeed () const
 get the covariance matrix seed (6D).

 
const TVectorD & getStateSeed () const
 Returns the 6D seed state; should be in global coordinates.
 
double getChargeSeed () const
 
int getPdgCode () const
 Get the PDG code.
 
bool hitInTrack (int detId, int hitId) const
 Is there a hit with detId and hitId in the TrackCand?
 
void addHit (int detId, int hitId, int planeId=-1, double sortingParameter=0)
 
void addHit (TrackCandHit *hit)
 
void setMcTrackId (int i)
 Set the MCT track id, for MC simulations.
 
void setPdgCode (int pdgCode)
 Set a particle hypothesis in form of a PDG code. This will also set the charge attribute.
 
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 sortHits (const std::vector< unsigned int > &indices)
 
void reset ()
 Delete and clear the TrackCandHits.
 
void Print (const Option_t *="") const
 Write the content of all private attributes to the terminal.
 
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 staring postion second 3 elements the starting momentum. Everything in global coordinates charge is the charge hypotheses of the particle charge
 
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 which will set the charge automatically.
 
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 momentum. Everything in global coordinates charge is the charge hypotheses of the particle charge
 
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 code which will set the charge automatically.
 

Static Public Member Functions

static bool compareTrackCandHits (const TrackCandHit *lhs, const TrackCandHit *rhs)
 

Private Attributes

std::vector< TrackCandHit * > hits_
 
int mcTrackId_
 
int pdg_
 
TVectorD state6D_
 
TMatrixDSym cov6D_
 
double q_
 

Friends

bool operator== (const TrackCand &lhs, const TrackCand &rhs)
 == operator checks equality of TrackCandHits. Does not check for sorting parameters.
 
bool operator!= (const TrackCand &lhs, const TrackCand &rhs)
 

Detailed Description

Track candidate – seed values and indices.

Author
Christian Höppner (Technische Universität München, original author)
Sebastian Neubert (Technische Universität München, original author)
Moritz Nadler (maintainer during 2012)

The main task of the TrackCand object is to store a list of indices to cluster objects. Each cluster in the Track is identified by it's detector ID and it's index in the corresponding TClonesArray. Also there is a ordering parameter to order hits. Optionally, plane indices for the hits can be stored (most importantly for fitting with the Daf). This information is used by the RecoHitFactory to automatically load RecoHits into a Track. Through this it is possible to define Tracks over an arbitrary number of different detectors.

In addition TrackCand offers members to store starting values for the fit. The starting values (seeds) for the fit are stored as a 6D state (x,y,z,px,py,pz) and its corresponding 6x6 covariance matrix. All seed getter and setter manipulate these two members but the user can chose using TVector3 or TMatrixD to get/set the seed state. However this information is not automatically used in genfit. But a pointer to a TrackCand can be passed to the a RKTrackRep constructor to make use of this information without manually extracting it from the TrackCand object.

See also
RecoHitFactory

Definition at line 69 of file TrackCand.h.

Constructor & Destructor Documentation

◆ TrackCand() [1/2]

genfit::TrackCand::TrackCand ( )

Definition at line 31 of file TrackCand.cc.

31 :
32 mcTrackId_(-1),
33 pdg_(0),
34 state6D_(6),
35 cov6D_(6),
36 q_(0)
37{
38 ;
39}
TMatrixDSym cov6D_
Definition TrackCand.h:199
TVectorD state6D_
Definition TrackCand.h:198

◆ ~TrackCand()

genfit::TrackCand::~TrackCand ( )

Definition at line 41 of file TrackCand.cc.

41 {
42 for (unsigned int i=0; i<hits_.size(); ++i) {
43 delete hits_[i];
44 }
45 hits_.clear();
46}
std::vector< TrackCandHit * > hits_
Definition TrackCand.h:193
int i
Definition ShipAna.py:86

◆ TrackCand() [2/2]

genfit::TrackCand::TrackCand ( const TrackCand other)

copy constructor

Definition at line 49 of file TrackCand.cc.

49 :
50 TObject(other),
51 mcTrackId_(other.mcTrackId_),
52 pdg_(0),
53 state6D_(other.state6D_),
54 cov6D_(other.cov6D_),
55 q_(other.q_)
56{
57 // deep copy
58 hits_.reserve(other.hits_.size());
59 for (unsigned int i=0; i<other.hits_.size(); ++i) {
60 hits_.push_back( (other.hits_[i])->clone() );
61 }
62
63 if (other.pdg_ != 0)
64 setPdgCode(other.pdg_);
65}
void setPdgCode(int pdgCode)
Set a particle hypothesis in form of a PDG code. This will also set the charge attribute.
Definition TrackCand.cc:162

Member Function Documentation

◆ addHit() [1/2]

void genfit::TrackCand::addHit ( int  detId,
int  hitId,
int  planeId = -1,
double  sortingParameter = 0 
)

Definition at line 122 of file TrackCand.cc.

123{
124 hits_.push_back(new TrackCandHit(detId, hitId, planeId, sortingParameter));
125}

◆ addHit() [2/2]

void genfit::TrackCand::addHit ( TrackCandHit hit)
inline

Definition at line 148 of file TrackCand.h.

148{hits_.push_back(hit);}

◆ append()

void genfit::TrackCand::append ( const TrackCand rhs)

Clone the TrackCandHit objects from the other TrackCand and append them to this TrackCand.

Definition at line 210 of file TrackCand.cc.

210 {
211 for(unsigned int i=0; i<rhs.getNHits(); ++i){
212 addHit(rhs.getHit(i)->clone());
213 }
214}
void addHit(int detId, int hitId, int planeId=-1, double sortingParameter=0)
Definition TrackCand.cc:122

◆ compareTrackCandHits()

static bool genfit::TrackCand::compareTrackCandHits ( const TrackCandHit lhs,
const TrackCandHit rhs 
)
inlinestatic

Definition at line 89 of file TrackCand.h.

89{return (*lhs < *rhs);} // operator< defined in TrackCandHit.h

◆ getChargeSeed()

double genfit::TrackCand::getChargeSeed ( ) const
inline

Definition at line 136 of file TrackCand.h.

136{return q_;}

◆ getCovSeed()

const TMatrixDSym & genfit::TrackCand::getCovSeed ( ) const
inline

get the covariance matrix seed (6D).

Definition at line 131 of file TrackCand.h.

131{return cov6D_;}

◆ getDetIDs()

std::vector< int > genfit::TrackCand::getDetIDs ( ) const

Get detector IDs of all hits.

Definition at line 137 of file TrackCand.cc.

137 {
138 std::vector<int> result;
139 for(unsigned int i=0; i<hits_.size(); ++i){
140 result.push_back(hits_[i]->getDetId());
141 }
142 return result;
143}

◆ getHit() [1/3]

TrackCandHit * genfit::TrackCand::getHit ( int  i) const

Definition at line 85 of file TrackCand.cc.

85 {
86 if (i < 0)
87 i += hits_.size();
88
89 return hits_.at(i);
90}

◆ getHit() [2/3]

void genfit::TrackCand::getHit ( int  i,
int &  detId,
int &  hitId 
) const

Get detector Id and hit Id for hit number i.

Definition at line 93 of file TrackCand.cc.

93 {
94 if (i < 0)
95 i += hits_.size();
96
97 detId = hits_.at(i)->getDetId();
98 hitId = hits_[i]->getHitId();
99}

◆ getHit() [3/3]

void genfit::TrackCand::getHit ( int  i,
int &  detId,
int &  hitId,
double &  sortingParameter 
) const

Get detector Id, hit Id and sorting parameter for hit number i.

Definition at line 102 of file TrackCand.cc.

102 {
103 if (i < 0)
104 i += hits_.size();
105
106 detId = hits_.at(i)->getDetId();
107 hitId = hits_[i]->getHitId();
108 sortingParameter = hits_[i]->getSortingParameter();
109}

◆ getHitIDs()

std::vector< int > genfit::TrackCand::getHitIDs ( int  detId = -2) const

Get hit ids of from a specific detector.

DetId -1 gives hitIds of hits with default detId -1. The default argument -2 gives hit Ids of all hits.

Definition at line 127 of file TrackCand.cc.

127 {
128 std::vector<int> result;
129 for(unsigned int i=0; i<hits_.size(); ++i){
130 if(detId==-2 || hits_[i]->getDetId() == detId) {
131 result.push_back(hits_[i]->getHitId());
132 }
133 }
134 return result;
135}

◆ getHitWithPlane()

void genfit::TrackCand::getHitWithPlane ( int  i,
int &  detId,
int &  hitId,
int &  planeId 
) const

Get detector Id, hit Id and plane id for hit number i.

Definition at line 112 of file TrackCand.cc.

112 {
113 if (i < 0)
114 i += hits_.size();
115
116 detId = hits_.at(i)->getDetId();
117 hitId = hits_[i]->getHitId();
118 planeId = hits_[i]->getPlaneId();
119}

◆ getMcTrackId()

int genfit::TrackCand::getMcTrackId ( ) const
inline

Get the MCT track id, for MC simulations - default value = -1.

Definition at line 119 of file TrackCand.h.

119{return mcTrackId_;}

◆ getMomSeed()

TVector3 genfit::TrackCand::getMomSeed ( ) const
inline

get the seed value for track: mom. Identical to the last 3 components of getStateSeed

Definition at line 125 of file TrackCand.h.

125{return TVector3(state6D_(3), state6D_(4), state6D_(5));}

◆ getNHits()

unsigned int genfit::TrackCand::getNHits ( ) const
inline

Definition at line 103 of file TrackCand.h.

103{return hits_.size();}

◆ getPdgCode()

int genfit::TrackCand::getPdgCode ( ) const
inline

Get the PDG code.

Definition at line 139 of file TrackCand.h.

139{return pdg_;}

◆ getPosSeed()

TVector3 genfit::TrackCand::getPosSeed ( ) const
inline

get the seed value for track: pos. Identical to the first 3 components of getStateSeed

Definition at line 122 of file TrackCand.h.

122{return TVector3(state6D_(0), state6D_(1), state6D_(2));}

◆ getSortingParameters()

std::vector< double > genfit::TrackCand::getSortingParameters ( ) const

Get sorting parameterts of all hits.

Definition at line 145 of file TrackCand.cc.

145 {
146 std::vector<double> result;
147 for(unsigned int i=0; i<hits_.size(); ++i){
148 result.push_back(hits_[i]->getSortingParameter());
149 }
150 return result;
151}

◆ getStateSeed()

const TVectorD & genfit::TrackCand::getStateSeed ( ) const
inline

Returns the 6D seed state; should be in global coordinates.

Definition at line 134 of file TrackCand.h.

134{return state6D_;}

◆ getUniqueDetIDs()

std::set< int > genfit::TrackCand::getUniqueDetIDs ( ) const

Definition at line 153 of file TrackCand.cc.

153 {
154 std::set<int> retVal;
155 for (unsigned int i = 0; i < hits_.size(); ++i) {
156 retVal.insert(hits_[i]->getDetId());
157 }
158 return retVal;
159}

◆ hitInTrack()

bool genfit::TrackCand::hitInTrack ( int  detId,
int  hitId 
) const

Is there a hit with detId and hitId in the TrackCand?

Definition at line 178 of file TrackCand.cc.

179{
180 for (unsigned int i = 0; i < hits_.size(); ++i){
181 if (detId == hits_[i]->getDetId() && hitId == hits_[i]->getHitId())
182 return true;
183 }
184 return false;
185}

◆ operator=()

TrackCand & genfit::TrackCand::operator= ( TrackCand  other)

assignment operator

Definition at line 67 of file TrackCand.cc.

67 {
68 swap(other);
69 return *this;
70}
void swap(TrackCand &other)
Definition TrackCand.cc:73

◆ Print()

void genfit::TrackCand::Print ( const Option_t *  option = "") const

Write the content of all private attributes to the terminal.

Definition at line 197 of file TrackCand.cc.

197 {
198 std::cout << "======== TrackCand::print ========\n";
199 std::cout << "mcTrackId=" << mcTrackId_ << "\n";
200 std::cout << "seed values for 6D state: \n";
201 state6D_.Print(option);
202 std::cout << "q" << q_ << "\n";
203 std::cout << "PDG code= " << pdg_ << "\n";
204 for(unsigned int i=0; i<hits_.size(); ++i){
205 hits_[i]->Print();
206 }
207}

◆ reset()

void genfit::TrackCand::reset ( )

Delete and clear the TrackCandHits.

Definition at line 169 of file TrackCand.cc.

170{
171 for (unsigned int i=0; i<hits_.size(); ++i) {
172 delete hits_[i];
173 }
174 hits_.clear();
175}

◆ set6DSeed()

void genfit::TrackCand::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 staring postion second 3 elements the starting momentum. Everything in global coordinates charge is the charge hypotheses of the particle charge

Definition at line 241 of file TrackCand.cc.

241 {
242 if (pdg_ != 0 && q_ != charge)
243 pdg_ = -pdg_;
244 q_ = charge;
245 state6D_ = state6D;
246}

◆ set6DSeedAndPdgCode()

void genfit::TrackCand::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 which will set the charge automatically.

Definition at line 248 of file TrackCand.cc.

248 {
249 setPdgCode(pdgCode);
250 state6D_ = state6D;
251}

◆ setCovSeed()

void genfit::TrackCand::setCovSeed ( const TMatrixDSym &  cov6D)
inline

set the covariance matrix seed (6D).

Definition at line 128 of file TrackCand.h.

128{cov6D_ = cov6D; /* always 6D, no need to resize */}

◆ setMcTrackId()

void genfit::TrackCand::setMcTrackId ( int  i)
inline

Set the MCT track id, for MC simulations.

Definition at line 151 of file TrackCand.h.

151{mcTrackId_ = i;}

◆ setPdgCode()

void genfit::TrackCand::setPdgCode ( int  pdgCode)

Set a particle hypothesis in form of a PDG code. This will also set the charge attribute.

Definition at line 162 of file TrackCand.cc.

162 {
163 pdg_ = pdgCode;
164 TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(pdg_);
165 q_ = part->Charge() / (3.);
166}

◆ setPosMomSeed()

void genfit::TrackCand::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 momentum. Everything in global coordinates charge is the charge hypotheses of the particle charge

Definition at line 253 of file TrackCand.cc.

253 {
254 if (pdg_ != 0 && q_ != charge)
255 pdg_ = -pdg_;
256 q_ = charge;
257 state6D_[0] = pos[0]; state6D_[1] = pos[1]; state6D_[2] = pos[2];
258 state6D_[3] = mom[0]; state6D_[4] = mom[1]; state6D_[5] = mom[2];
259}

◆ setPosMomSeedAndPdgCode()

void genfit::TrackCand::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 code which will set the charge automatically.

Definition at line 261 of file TrackCand.cc.

261 {
262 setPdgCode(pdgCode);
263 state6D_[0] = pos[0]; state6D_[1] = pos[1]; state6D_[2] = pos[2];
264 state6D_[3] = mom[0]; state6D_[4] = mom[1]; state6D_[5] = mom[2];
265}

◆ sortHits() [1/2]

void genfit::TrackCand::sortHits ( )

Sort the hits that were already added to the trackCand using the sorting parameters.

Definition at line 217 of file TrackCand.cc.

217 {
218 std::stable_sort(hits_.begin(), hits_.end(), compareTrackCandHits);
219}
static bool compareTrackCandHits(const TrackCandHit *lhs, const TrackCandHit *rhs)
Definition TrackCand.h:89

◆ sortHits() [2/2]

void genfit::TrackCand::sortHits ( const std::vector< unsigned int > &  indices)

Definition at line 222 of file TrackCand.cc.

222 {
223
224 const unsigned int nHits(getNHits());
225 if (indices.size() != nHits){
226 abort();
227 Exception exc("TrackCand::sortHits ==> Size of indices != number of hits!",__LINE__,__FILE__);
228 throw exc;
229 }
230
231 //these containers will hold the sorted results. They are created to avoid probably slower in-place sorting
232 std::vector<TrackCandHit*> sortedHits(nHits);
233 for (unsigned int i=0; i<nHits; ++i){
234 sortedHits[i] = hits_[indices[i]];
235 }
236 //write the changes back to the private data members:
237 hits_ = sortedHits;
238}
unsigned int getNHits() const
Definition TrackCand.h:103

◆ swap()

void genfit::TrackCand::swap ( TrackCand other)

Definition at line 73 of file TrackCand.cc.

73 {
74 // by swapping the members of two classes,
75 // the two classes are effectively swapped
76 std::swap(this->hits_, other.hits_);
77 std::swap(this->mcTrackId_, other.mcTrackId_);
78 std::swap(this->pdg_, other.pdg_);
79 std::swap(this->state6D_, other.state6D_);
80 std::swap(this->cov6D_, other.cov6D_);
81 std::swap(this->q_, other.q_);
82}

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const TrackCand lhs,
const TrackCand rhs 
)
friend

Definition at line 87 of file TrackCand.h.

87{return !(lhs == rhs);}

◆ operator==

bool operator== ( const TrackCand lhs,
const TrackCand rhs 
)
friend

== operator checks equality of TrackCandHits. Does not check for sorting parameters.

Definition at line 188 of file TrackCand.cc.

188 {
189 if(lhs.getNHits() != rhs.getNHits()) return false;
190 for (unsigned int i = 0; i < lhs.getNHits(); ++i){
191 if (lhs.getHit(i) != rhs.getHit(i)) return false;
192 }
193 return true;
194}

Member Data Documentation

◆ cov6D_

TMatrixDSym genfit::TrackCand::cov6D_
private

global 6D position plus momentum state

Definition at line 199 of file TrackCand.h.

◆ hits_

std::vector<TrackCandHit*> genfit::TrackCand::hits_
private

Definition at line 193 of file TrackCand.h.

◆ mcTrackId_

int genfit::TrackCand::mcTrackId_
private

if MC simulation, store the mc track id here

Definition at line 195 of file TrackCand.h.

◆ pdg_

int genfit::TrackCand::pdg_
private

particle data groupe's id for a particle

Definition at line 196 of file TrackCand.h.

◆ q_

double genfit::TrackCand::q_
private

the charge of the particle in units of elementary charge

Definition at line 200 of file TrackCand.h.

◆ state6D_

TVectorD genfit::TrackCand::state6D_
private

global 6D position plus momentum state

Definition at line 198 of file TrackCand.h.


The documentation for this class was generated from the following files: