20 #include "TrackCand.h"
21 #include "Exception.h"
22 #include "TDatabasePDG.h"
31 TrackCand::TrackCand() :
42 TrackCand::~TrackCand() {
43 for (
unsigned int i=0; i<hits_.size(); ++i) {
52 mcTrackId_(other.mcTrackId_),
55 state6D_(other.state6D_),
60 hits_.reserve(other.hits_.size());
61 for (
unsigned int i=0; i<other.hits_.size(); ++i) {
62 hits_.push_back( (other.hits_[i])->clone() );
78 std::swap(this->hits_, other.hits_);
84 std::swap(this->
q_, other.
q_);
88 TrackCandHit* TrackCand::getHit(
int i)
const {
96 void TrackCand::getHit(
int i,
int& detId,
int& hitId)
const {
100 detId = hits_.at(i)->getDetId();
101 hitId = hits_[i]->getHitId();
105 void TrackCand::getHit(
int i,
int& detId,
int& hitId,
double& sortingParameter)
const {
109 detId = hits_.at(i)->getDetId();
110 hitId = hits_[i]->getHitId();
111 sortingParameter = hits_[i]->getSortingParameter();
119 detId = hits_.at(i)->getDetId();
120 hitId = hits_[i]->getHitId();
121 planeId = hits_[i]->getPlaneId();
125 void TrackCand::addHit(
int detId,
int hitId,
int planeId,
double sortingParameter)
127 hits_.push_back(
new TrackCandHit(detId, hitId, planeId, sortingParameter));
131 std::vector<int> result;
132 for(
unsigned int i=0; i<hits_.size(); ++i){
133 if(detId==-2 || hits_[i]->getDetId() == detId) {
134 result.push_back(hits_[i]->getHitId());
141 std::vector<int> result;
142 for(
unsigned int i=0; i<hits_.size(); ++i){
143 result.push_back(hits_[i]->getDetId());
149 std::vector<double> result;
150 for(
unsigned int i=0; i<hits_.size(); ++i){
151 result.push_back(hits_[i]->getSortingParameter());
156 std::set<int> TrackCand::getUniqueDetIDs()
const {
157 std::set<int> retVal;
158 for (
unsigned int i = 0; i < hits_.size(); ++i) {
159 retVal.insert(hits_[i]->getDetId());
167 TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(
pdg_);
168 q_ = part->Charge() / (3.);
174 for (
unsigned int i=0; i<hits_.size(); ++i) {
183 for (
unsigned int i = 0; i < hits_.size(); ++i){
184 if (detId == hits_[i]->getDetId() && hitId == hits_[i]->getHitId())
192 if(lhs.getNHits() != rhs.getNHits())
return false;
193 for (
unsigned int i = 0; i < lhs.getNHits(); ++i){
195 if (*(lhs.getHit(i)) != *(rhs.getHit(i)))
203 printOut <<
"======== TrackCand::print ========\n";
205 printOut <<
"seed values for 6D state: \n";
209 for(
unsigned int i=0; i<hits_.size(); ++i){
216 for(
unsigned int i=0; i<rhs.getNHits(); ++i){
217 addHit(rhs.getHit(i)->clone());
223 std::stable_sort(hits_.begin(), hits_.end(), compareTrackCandHits);
229 const unsigned int nHits(getNHits());
230 if (indices.size() != nHits){
232 Exception exc(
"TrackCand::sortHits ==> Size of indices != number of hits!",__LINE__,__FILE__);
237 std::vector<TrackCandHit*> sortedHits(nHits);
238 for (
unsigned int i=0; i<nHits; ++i){
239 sortedHits[i] = hits_[indices[i]];
247 if (
pdg_ != 0 &&
q_ != charge)
259 if (
pdg_ != 0 &&
q_ != charge)
286 const TVector3& mom,
const double charge)
293 const TVector3& mom,
const int pdgCode)
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Hit object for use in TrackCand.
Track candidate – seed values and indices.
void getHitWithPlane(int i, int &detId, int &hitId, int &planeId) const
Get detector Id, hit Id and plane id for hit number i.
void set6DSeed(const TVectorD &state6D, const double charge)
sets the state to seed the track fitting.
TVectorD state6D_
global 6D position plus momentum state
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...
int mcTrackId_
if MC simulation, store the mc track id here
TMatrixDSym cov6D_
global 6D position plus momentum state
void setTime6DSeed(double time, const TVectorD &state6D, const double charge)
sets the state to seed the track fitting and its time.
double time_
Time at which the seed is given.
void Print(const Option_t *="") const
Write the content of all private attributes to the terminal.
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...
void setPosMomSeed(const TVector3 &pos, const TVector3 &mom, const double charge)
sets the state to seed the track fitting.
std::vector< double > getSortingParameters() const
Get sorting parameterts of all hits.
bool hitInTrack(int detId, int hitId) const
Is there a hit with detId and hitId in the TrackCand?
void setTimePosMomSeed(double time, const TVector3 &pos, const TVector3 &mom, const double charge)
sets the state to seed the track fitting and its time.
int pdg_
particle data groupe's id for a particle
void sortHits()
Sort the hits that were already added to the trackCand using the sorting parameters.
double q_
the charge of the particle in units of elementary charge
void append(const TrackCand &)
Clone the TrackCandHit objects from the other TrackCand and append them to this TrackCand.
std::vector< int > getDetIDs() const
Get detector IDs of all hits.
void reset()
Delete and clear the TrackCandHits.
std::vector< int > getHitIDs(int detId=-2) const
Get hit ids of from a specific detector.
TrackCand & operator=(TrackCand other)
assignment operator
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...
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 setPdgCode(int pdgCode)
Set a particle hypothesis in form of a PDG code. This will also set the charge attribute.
Defines for I/O streams used for error and debug printing.
std::ostream printOut
Default stream for output of Print calls.