Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-24 04:40:49

0001 #ifndef MeasurementDet_H
0002 #define MeasurementDet_H
0003 
0004 #include "TrackingTools/MeasurementDet/interface/TempMeasurements.h"
0005 
0006 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0007 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0008 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
0009 #include "DataFormats/TrackingRecHit/interface/InvalidTrackingRecHit.h"
0010 
0011 class TrajectoryStateOnSurface;
0012 class Propagator;
0013 class MeasurementEstimator;
0014 class MeasurementTrackerEvent;
0015 
0016 class MeasurementDet {
0017 public:
0018   typedef tracking::TempMeasurements TempMeasurements;
0019   typedef TrackingRecHit::ConstRecHitContainer RecHitContainer;
0020 
0021   using SimpleHitContainer = std::vector<BaseTrackerRecHit*>;
0022 
0023   MeasurementDet(const GeomDet* gdet)
0024       : theGeomDet(gdet),
0025         theMissingHit(std::make_shared<InvalidTrackingRecHit>(fastGeomDet(), TrackingRecHit::missing)),
0026         theInactiveHit(std::make_shared<InvalidTrackingRecHit>(fastGeomDet(), TrackingRecHit::inactive)) {}
0027 
0028   virtual ~MeasurementDet() = default;
0029   virtual RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent&) const = 0;
0030 
0031   // use a MeasurementEstimator to filter the hits (same algo as below..)
0032   // default as above
0033   virtual bool recHits(const TrajectoryStateOnSurface& stateOnThisDet,
0034                        const MeasurementEstimator&,
0035                        const MeasurementTrackerEvent& data,
0036                        RecHitContainer& result,
0037                        std::vector<float>&) const {
0038     result = recHits(stateOnThisDet, data);
0039     return !result.empty();
0040   }
0041 
0042   // default for non-tracker dets...
0043   virtual bool recHits(SimpleHitContainer& result,
0044                        const TrajectoryStateOnSurface& stateOnThisDet,
0045                        const MeasurementEstimator&,
0046                        const MeasurementTrackerEvent& data) const {
0047     return false;
0048   }
0049 
0050   /** obsolete version in case the TrajectoryState on the surface of the
0051    *  Det is already available. The first TrajectoryStateOnSurface is on the surface of this 
0052    *  Det, and the second TrajectoryStateOnSurface is not used, as the propagator...
0053    * The stateOnThisDet should the result of <BR>
0054    *  prop.propagate( startingState, this->surface())
0055    */
0056   std::vector<TrajectoryMeasurement> fastMeasurements(const TrajectoryStateOnSurface& stateOnThisDet,
0057                                                       const TrajectoryStateOnSurface&,
0058                                                       const Propagator&,
0059                                                       const MeasurementEstimator& est,
0060                                                       const MeasurementTrackerEvent& data) const {
0061     TempMeasurements tmps;
0062     measurements(stateOnThisDet, est, data, tmps);
0063     std::vector<TrajectoryMeasurement> result;
0064     result.reserve(tmps.size());
0065     int* index = new int[tmps.size()];
0066     tmps.sortIndex(index);
0067     for (std::size_t i = 0; i != tmps.size(); ++i) {
0068       auto j = index[i];
0069       result.emplace_back(stateOnThisDet, std::move(tmps.hits[j]), tmps.distances[j]);
0070     }
0071     delete[] index;
0072     return result;
0073   }
0074 
0075   // return false if missing ( if inactive is true and one hit)
0076   virtual bool measurements(const TrajectoryStateOnSurface& stateOnThisDet,
0077                             const MeasurementEstimator& est,
0078                             const MeasurementTrackerEvent& data,
0079                             TempMeasurements& result) const = 0;
0080 
0081   const GeomDet& fastGeomDet() const { return *theGeomDet; }
0082   virtual const GeomDet& geomDet() const { return *theGeomDet; }
0083 
0084   const Surface& surface() const { return geomDet().surface(); }
0085 
0086   const Surface::PositionType& position() const { return geomDet().position(); }
0087 
0088   virtual bool isActive(const MeasurementTrackerEvent& data) const = 0;
0089   virtual bool hasBadComponents(const TrajectoryStateOnSurface& tsos, const MeasurementTrackerEvent& data) const = 0;
0090 
0091 private:
0092   const GeomDet* theGeomDet;
0093 
0094 protected:
0095   TrackingRecHit::ConstRecHitPointer theMissingHit;
0096   TrackingRecHit::ConstRecHitPointer theInactiveHit;
0097 };
0098 
0099 #endif