22 #include "TrackPoint.h"
23 #include "Exception.h"
24 #include "KalmanFitterInfo.h"
32 TrackPoint::TrackPoint() :
33 sortingParameter_(0), track_(nullptr), thinScatterer_(nullptr)
38 TrackPoint::TrackPoint(Track* track) :
39 sortingParameter_(0), track_(track), thinScatterer_(nullptr)
44 TrackPoint::TrackPoint(
const std::vector< genfit::AbsMeasurement* >& rawMeasurements,
Track* track) :
45 sortingParameter_(0), track_(track), thinScatterer_(nullptr)
49 for (std::vector<AbsMeasurement*>::const_iterator m = rawMeasurements.begin(); m != rawMeasurements.end(); ++m) {
55 sortingParameter_(0), track_(track), thinScatterer_(nullptr)
61 TrackPoint::TrackPoint(
const TrackPoint& rhs) :
63 sortingParameter_(rhs.sortingParameter_), track_(rhs.track_), thinScatterer_(nullptr)
72 for (std::map<const AbsTrackRep*, AbsFitterInfo* >::const_iterator it = rhs.fitterInfos_.begin(); it != rhs.fitterInfos_.end(); ++it ) {
73 AbsFitterInfo* fi = it->second->clone();
74 fi->setTrackPoint(
this);
78 if (rhs.thinScatterer_ !=
nullptr)
79 thinScatterer_.reset(
new ThinScatterer(*(rhs.thinScatterer_)));
83 const std::map<const AbsTrackRep*, AbsTrackRep*>& map,
84 const std::vector<const genfit::AbsTrackRep*> * repsToIgnore) :
85 sortingParameter_(rhs.sortingParameter_), track_(rhs.track_), thinScatterer_(nullptr)
94 for (std::map<const AbsTrackRep*, AbsFitterInfo* >::const_iterator it = rhs.fitterInfos_.begin(); it != rhs.fitterInfos_.end(); ++it ) {
95 if (repsToIgnore !=
nullptr) {
96 if (std::find(repsToIgnore->begin(), repsToIgnore->end(), it->first) != repsToIgnore->end())
100 fi->setRep(map.at(it->first));
101 fi->setTrackPoint(
this);
105 if (rhs.thinScatterer_ !=
nullptr)
106 thinScatterer_.reset(
new ThinScatterer(*(rhs.thinScatterer_)));
114 (*it)->setTrackPoint(
this);
117 for (std::map<const AbsTrackRep*, AbsFitterInfo* >::const_iterator it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it ) {
118 it->second->setTrackPoint(
this);
125 void TrackPoint::swap(TrackPoint& other) {
126 std::swap(this->sortingParameter_, other.sortingParameter_);
127 std::swap(this->
track_, other.track_);
129 std::swap(this->fitterInfos_, other.fitterInfos_);
130 this->thinScatterer_.swap(other.thinScatterer_);
134 TrackPoint::~TrackPoint() {
142 std::map< const AbsTrackRep*, AbsFitterInfo* >::iterator it;
143 for (it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it)
148 AbsMeasurement* TrackPoint::getRawMeasurement(
int i)
const {
157 std::vector< AbsFitterInfo* > retVal;
159 if (fitterInfos_.empty())
162 for (std::map<const AbsTrackRep*, AbsFitterInfo* >::const_iterator it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it ) {
163 retVal.push_back(it->second);
173 std::map<const AbsTrackRep*, AbsFitterInfo*>::const_iterator it = fitterInfos_.find(rep);
174 if (it == fitterInfos_.end())
176 return fitterInfos_.at(rep);
186 void TrackPoint::deleteRawMeasurements() {
195 assert (fitterInfo !=
nullptr);
196 if (hasFitterInfo(fitterInfo->getRep()))
197 delete fitterInfos_[fitterInfo->getRep()];
199 fitterInfos_[fitterInfo->getRep()] = fitterInfo;
203 void TrackPoint::Print(
const Option_t*)
const {
204 printOut <<
"genfit::TrackPoint, belonging to Track " <<
track_ <<
"; sorting parameter = " << sortingParameter_ <<
"\n";
208 printOut <<
"RawMeasurement Nr. " << i <<
"\n";
213 for (std::map< const AbsTrackRep*, AbsFitterInfo* >::const_iterator it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it ) {
214 printOut <<
"FitterInfo for TrackRep " << it->first <<
"\n";
220 thinScatterer_->Print();
228 void TrackPoint::Streamer(TBuffer &R__b)
232 typedef ::genfit::TrackPoint thisClass;
234 if (R__b.IsReading()) {
235 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v) { }
237 R__b >> sortingParameter_;
239 std::vector<genfit::AbsMeasurement*,std::allocator<genfit::AbsMeasurement*> > &R__stl =
rawMeasurements_;
243 Error(
"rawMeasurements_ streamer",
"Missing the TClass object for genfit::AbsMeasurement!");
248 R__stl.reserve(R__n);
249 for (R__i = 0; R__i < R__n; R__i++) {
252 R__stl.push_back(R__t);
258 for (
size_t i = 0; i < nTrackReps; ++i) {
261 AbsFitterInfo* p = 0;
265 thinScatterer_.reset();
271 thinScatterer_.reset(
new ThinScatterer(*scatterer));
273 R__b.CheckByteCount(R__s, R__c, thisClass::IsA());
281 AbsFitterInfo* fitterInfo = trackRepIDWithFitterInfo.second;
283 fitterInfo->setTrackPoint(
this);
286 R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE);
288 R__b << sortingParameter_;
290 std::vector<genfit::AbsMeasurement*,std::allocator<genfit::AbsMeasurement*> > &R__stl =
rawMeasurements_;
291 int R__n= int(R__stl.size());
294 std::vector<genfit::AbsMeasurement*,std::allocator<genfit::AbsMeasurement*> >::iterator R__k;
295 for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {
300 R__b << fitterInfos_.size();
301 for (std::map<const AbsTrackRep*, AbsFitterInfo*>::const_iterator it = fitterInfos_.begin();
302 it != fitterInfos_.end(); ++it)
308 if (thinScatterer_) {
310 R__b << thinScatterer_.get();
314 R__b.SetByteCount(R__c, kTRUE);
323 const unsigned int id = trackRepIDWithFitterInfo.first;
331 fitterInfos_[trackRep] = fitterInfo;
332 fitterInfos_[trackRep]->setRep(trackRep);
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Contains the measurement and covariance in raw detector coordinates.
virtual AbsMeasurement * clone() const =0
Deep copy ctor for polymorphic class.
Abstract base class for a track representation.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
Object containing AbsMeasurement and AbsFitterInfo objects.
AbsFitterInfo * getFitterInfo(const AbsTrackRep *rep=nullptr) const
Get fitterInfo for rep. Per default, use cardinal rep.
std::map< unsigned int, AbsFitterInfo * > vFitterInfos_
Ownership over FitterInfos.
void fixupRepsForReading()
This function is used when reading the TrackPoint and is called by the owner in order to build fitter...
void addRawMeasurement(genfit::AbsMeasurement *rawMeasurement)
Takes ownership and sets this as measurement's trackPoint.
std::vector< genfit::AbsFitterInfo * > getFitterInfos() const
Get list of all fitterInfos.
std::vector< AbsMeasurement * > rawMeasurements_
No ownership.
void setFitterInfo(genfit::AbsFitterInfo *fitterInfo)
Takes Ownership.
KalmanFitterInfo * getKalmanFitterInfo(const AbsTrackRep *rep=nullptr) const
Helper to avoid casting.
Track * track_
Pointer to Track where TrackPoint belongs to.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
int getIdForRep(const AbsTrackRep *rep) const
This is used when streaming TrackPoints.
Defines for I/O streams used for error and debug printing.
std::ostream printOut
Default stream for output of Print calls.