Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:21

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 /** @addtogroup genfit
0020  * @{
0021  */
0022 
0023 #ifndef genfit_TrackPoint_h
0024 #define genfit_TrackPoint_h
0025 
0026 #include "AbsMeasurement.h"
0027 #include "AbsFitterInfo.h"
0028 #include "ThinScatterer.h"
0029 
0030 #include <TObject.h>
0031 
0032 #include <map>
0033 #include <vector>
0034 #include <memory>
0035 
0036 
0037 namespace genfit {
0038 
0039 class Track;
0040 class KalmanFitterInfo;
0041 
0042 /**
0043  * @brief Object containing AbsMeasurement and AbsFitterInfo objects.
0044  *
0045  */
0046 class TrackPoint : public TObject {
0047 
0048  public:
0049 
0050   TrackPoint();
0051   explicit TrackPoint(Track* track);
0052 
0053   /**
0054    * @brief Contructor taking list of measurements.
0055    *
0056    * AbsMeasurement::setTrackPoint() of each measurement will be called.
0057    * TrackPoint takes ownership over rawMeasurements.
0058    */
0059   TrackPoint(const std::vector< genfit::AbsMeasurement* >& rawMeasurements, Track* track);
0060 
0061   /**
0062    * @brief Contructor taking one measurement.
0063    *
0064    * AbsMeasurement::setTrackPoint() of the measurement will be called.
0065    * TrackPoint takes ownership over the rawMeasurement.
0066    */
0067   TrackPoint(genfit::AbsMeasurement* rawMeasurement, Track* track);
0068 
0069   TrackPoint(const TrackPoint&); // copy constructor
0070   TrackPoint& operator=(TrackPoint); // assignment operator
0071   void swap(TrackPoint& other);
0072 
0073   /**
0074    * custom copy constructor where all TrackRep pointers are exchanged according to the map.
0075    * FitterInfos with a rep in repsToIgnore will NOT be copied.
0076    */
0077   TrackPoint(const TrackPoint& rhs,
0078       const std::map<const genfit::AbsTrackRep*, genfit::AbsTrackRep*>& map,
0079       const std::vector<const genfit::AbsTrackRep*> * repsToIgnore = nullptr);
0080 
0081   virtual ~TrackPoint();
0082 
0083 
0084   double getSortingParameter() const {return sortingParameter_;}
0085 
0086   Track* getTrack() const {return track_;}
0087   void setTrack(Track* track) {track_ = track;}
0088 
0089   const std::vector< genfit::AbsMeasurement* >& getRawMeasurements() const {return rawMeasurements_;}
0090   AbsMeasurement* getRawMeasurement(int i = 0) const;
0091   unsigned int getNumRawMeasurements() const {return rawMeasurements_.size();}
0092   bool hasRawMeasurements() const {return (rawMeasurements_.size() != 0);}
0093   //! Get list of all fitterInfos
0094   std::vector< genfit::AbsFitterInfo* > getFitterInfos() const;
0095   //! Get fitterInfo for rep. Per default, use cardinal rep
0096   AbsFitterInfo* getFitterInfo(const AbsTrackRep* rep = nullptr) const;
0097   //! Helper to avoid casting
0098   KalmanFitterInfo* getKalmanFitterInfo(const AbsTrackRep* rep = nullptr) const;
0099   bool hasFitterInfo(const AbsTrackRep* rep) const {
0100     return (fitterInfos_.find(rep) != fitterInfos_.end());
0101   }
0102 
0103   ThinScatterer* getMaterialInfo() const {return thinScatterer_.get();}
0104   bool hasThinScatterer() const {return thinScatterer_.get() != nullptr;}
0105 
0106 
0107   void setSortingParameter(double sortingParameter) {sortingParameter_ = sortingParameter;}
0108   //! Takes ownership and sets this as measurement's trackPoint
0109   void addRawMeasurement(genfit::AbsMeasurement* rawMeasurement) {assert(rawMeasurement!=nullptr); rawMeasurement->setTrackPoint(this); rawMeasurements_.push_back(rawMeasurement);}
0110   void deleteRawMeasurements();
0111   //! Takes Ownership
0112   void setFitterInfo(genfit::AbsFitterInfo* fitterInfo);
0113   void deleteFitterInfo(const AbsTrackRep* rep) {delete fitterInfos_[rep]; fitterInfos_.erase(rep);}
0114 
0115   void setScatterer(ThinScatterer* scatterer) {thinScatterer_.reset(scatterer);}
0116 
0117   void Print(const Option_t* = "") const;
0118 
0119   /**
0120    * This function is used when reading the TrackPoint and is called
0121    * by the owner in order to build fitterInfos_ from vFitterInfos_.
0122    * This requires that the track_ be set.  It also empties
0123    * vFitterInfos_ which has served its purpose after this function is
0124    * called.
0125    */
0126   void fixupRepsForReading();
0127 
0128  private:
0129   double sortingParameter_;
0130 
0131   //! Pointer to Track where TrackPoint belongs to
0132   Track* track_; //! No ownership
0133 
0134   //! Can be more than one, e.g. multiple measurements in the same Si detector, left and right measurements of a wire detector etc.
0135   std::vector<AbsMeasurement*> rawMeasurements_; // Ownership
0136 
0137   std::map< const AbsTrackRep*, AbsFitterInfo* > fitterInfos_; //! Ownership over FitterInfos
0138 
0139   /**
0140    * The following map is read while streaming.  After reading the
0141    * TrackPoint, the Track's streamer will call fixupRepsForReading,
0142    * and this map will be translated into the map fitterInfos. The
0143    * map is indexed by the ids of the corresponding TrackReps.
0144    */
0145   std::map<unsigned int, AbsFitterInfo*> vFitterInfos_; //!
0146 
0147   std::unique_ptr<ThinScatterer> thinScatterer_; // Ownership
0148 
0149  public:
0150 
0151   ClassDef(TrackPoint,1)
0152 
0153 };
0154 
0155 } /* End of namespace genfit */
0156 /** @} */
0157 
0158 #endif // genfit_TrackPoint_h