Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 02:27:38

0001 #ifndef RectangularEtaPhiTrackingRegion_H
0002 #define RectangularEtaPhiTrackingRegion_H
0003 
0004 /** \class RectangularEtaPhiTrackingRegion
0005  * A concrete implementation of TrackingRegion. 
0006  * Apart of vertex constraint from TrackingRegion in this implementation
0007  * the region of interest is further constrainted in phi and eta 
0008  * around the direction of the region 
0009  */
0010 
0011 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
0012 #include "RecoTracker/TkTrackingRegions/interface/TkTrackingRegionsMargin.h"
0013 //#include "CommonDet/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
0014 #include "RecoTracker/TkTrackingRegions/interface/HitRZConstraint.h"
0015 
0016 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
0017 #include "DataFormats/TrackingRecHit/interface/mayown_ptr.h"
0018 
0019 class OuterHitPhiPrediction;
0020 class BarrelDetLayer;
0021 class ForwardDetLayer;
0022 class MeasurementTrackerEvent;
0023 class MagneticField;
0024 class MultipleScatteringParametrisationMaker;
0025 
0026 class RectangularEtaPhiTrackingRegion final : public TrackingRegion {
0027 public:
0028   enum class UseMeasurementTracker { kNever = -1, kForSiStrips = 0, kAlways = 1 };
0029 
0030   static UseMeasurementTracker intToUseMeasurementTracker(int value) {
0031     assert(value >= -1 && value <= 1);
0032     return static_cast<UseMeasurementTracker>(value);
0033   }
0034 
0035   static UseMeasurementTracker doubleToUseMeasurementTracker(double value) {
0036     // mimic the old behaviour
0037     if (value > 0.5)
0038       return UseMeasurementTracker::kAlways;
0039     if (value > -0.5)
0040       return UseMeasurementTracker::kForSiStrips;
0041     return UseMeasurementTracker::kNever;
0042   }
0043 
0044   static UseMeasurementTracker stringToUseMeasurementTracker(const std::string& name);
0045 
0046   RectangularEtaPhiTrackingRegion() {}
0047 
0048   RectangularEtaPhiTrackingRegion(RectangularEtaPhiTrackingRegion const& rh)
0049       : TrackingRegion(rh),
0050         theEtaRange(rh.theEtaRange),
0051         theLambdaRange(rh.theLambdaRange),
0052         thePhiMargin(rh.thePhiMargin),
0053         theMeanLambda(rh.theMeanLambda),
0054         theMeasurementTrackerUsage(rh.theMeasurementTrackerUsage),
0055         thePrecise(rh.thePrecise),
0056         theUseEtaPhi(rh.theUseEtaPhi),
0057         theMeasurementTracker(rh.theMeasurementTracker),
0058         theField(rh.theField),
0059         theMSMaker(rh.theMSMaker) {}
0060   RectangularEtaPhiTrackingRegion& operator=(RectangularEtaPhiTrackingRegion const&) = delete;
0061   RectangularEtaPhiTrackingRegion(RectangularEtaPhiTrackingRegion&&) = default;
0062   RectangularEtaPhiTrackingRegion& operator=(RectangularEtaPhiTrackingRegion&&) = delete;
0063 
0064   typedef TkTrackingRegionsMargin<float> Margin;
0065 
0066   /** constructor (symmetric eta and phi margins). <BR>
0067   * dir        - the direction around which region is constructed <BR>
0068   *              the initial direction of the momentum of the particle 
0069   *              should be in the range <BR> 
0070   *              phi of dir +- deltaPhi <BR>
0071   *              eta of dir +- deltaEta <BR> 
0072   *              
0073   * vertexPos  - the position of the vertex (origin) of the of the region.<BR>
0074   *              It is a centre of cylinder constraind with rVertex, zVertex.
0075   *              The track of the particle should cross the cylinder <BR>
0076   *              WARNING: in the current implementaion the vertexPos is
0077   *              supposed to be placed on the beam line, i.e. to be of the form
0078   *              (0,0,float)
0079   *
0080   * ptMin      - minimal pt of interest <BR>
0081   * rVertex    - radius of the cylinder around beam line where the tracks
0082   *              of interest should point to. <BR>
0083   * zVertex    - half height of the cylinder around the beam line
0084   *              where the tracks of interest should point to.   <BR>
0085   * deltaEta   - allowed deviation of the initial direction of particle
0086   *              in eta in respect to direction of the region <BR>
0087   *  deltaPhi  - allowed deviation of the initial direction of particle
0088   *              in phi in respect to direction of the region 
0089   *  whereToUseMeasurementTracker: 1=everywhere, 0=outside pixles, -1=nowhere
0090   * msmaker    - Needed if either precise or useMS is true
0091   */
0092   RectangularEtaPhiTrackingRegion(const GlobalVector& dir,
0093                                   const GlobalPoint& vertexPos,
0094                                   float ptMin,
0095                                   float rVertex,
0096                                   float zVertex,
0097                                   float deltaEta,
0098                                   float deltaPhi,
0099                                   const MagneticField& field,
0100                                   const MultipleScatteringParametrisationMaker* msmaker,
0101                                   bool precise = true,
0102                                   UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever,
0103                                   const MeasurementTrackerEvent* measurementTracker = nullptr,
0104                                   bool etaPhiRegion = false)
0105       : RectangularEtaPhiTrackingRegion(dir,
0106                                         vertexPos,
0107                                         Range(-1 / ptMin, 1 / ptMin),
0108                                         rVertex,
0109                                         zVertex,
0110                                         Margin(std::abs(deltaEta), std::abs(deltaEta)),
0111                                         Margin(std::abs(deltaPhi), std::abs(deltaPhi)),
0112                                         field,
0113                                         msmaker,
0114                                         precise,
0115                                         whereToUseMeasurementTracker,
0116                                         measurementTracker,
0117                                         etaPhiRegion) {}
0118 
0119   /** constructor (asymmetrinc eta and phi margins). <BR>
0120   * non equal left-right eta and phi bounds around direction are
0121   * possible. The ranges are defined using \c Margin.
0122   * the meaning of other arguments is the same as in the case of 
0123   * symmetring bounds to direction of the region.
0124   */
0125   RectangularEtaPhiTrackingRegion(const GlobalVector& dir,
0126                                   const GlobalPoint& vertexPos,
0127                                   float ptMin,
0128                                   float rVertex,
0129                                   float zVertex,
0130                                   Margin etaMargin,
0131                                   Margin phiMargin,
0132                                   const MagneticField& field,
0133                                   const MultipleScatteringParametrisationMaker* msmaker,
0134                                   bool precise = true,
0135                                   UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever,
0136                                   const MeasurementTrackerEvent* measurementTracker = nullptr,
0137                                   bool etaPhiRegion = false)
0138       : RectangularEtaPhiTrackingRegion(dir,
0139                                         vertexPos,
0140                                         Range(-1 / ptMin, 1 / ptMin),
0141                                         rVertex,
0142                                         zVertex,
0143                                         etaMargin,
0144                                         phiMargin,
0145                                         field,
0146                                         msmaker,
0147                                         precise,
0148                                         whereToUseMeasurementTracker,
0149                                         measurementTracker,
0150                                         etaPhiRegion) {}
0151 
0152   /** constructor (explicit pt range, asymmetrinc eta and phi margins). <BR>
0153   * the meaning of other arguments is the same as in the case of 
0154   * symmetring bounds to direction of the region.
0155   */
0156   RectangularEtaPhiTrackingRegion(const GlobalVector& dir,
0157                                   const GlobalPoint& vertexPos,
0158                                   Range invPtRange,
0159                                   float rVertex,
0160                                   float zVertex,
0161                                   Margin etaMargin,
0162                                   Margin phiMargin,
0163                                   const MagneticField& field,
0164                                   const MultipleScatteringParametrisationMaker* msmaker,
0165                                   bool precise = true,
0166                                   UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever,
0167                                   const MeasurementTrackerEvent* measurementTracker = nullptr,
0168                                   bool etaPhiRegion = false,
0169                                   bool useMS = true)
0170       : TrackingRegionBase(dir, vertexPos, invPtRange, rVertex, zVertex),
0171         thePhiMargin(phiMargin),
0172         theMeasurementTrackerUsage(whereToUseMeasurementTracker),
0173         thePrecise(precise),
0174         theUseMS(useMS),
0175         theUseEtaPhi(etaPhiRegion),
0176         theMeasurementTracker(measurementTracker),
0177         theField(&field),
0178         theMSMaker(msmaker) {
0179     initEtaRange(dir, etaMargin);
0180   }
0181 
0182   /// allowed eta range [eta_min, eta_max] interval
0183   const Range& etaRange() const { return theEtaRange; }
0184   const Range& tanLambdaRange() const { return theLambdaRange; }
0185 
0186   /// defined phi range around phi0, margin is [phi_left,phi_right].
0187   /// region is defined in a range: [phi0-phi_left, phi0+phi_right]
0188   const Margin& phiMargin() const { return thePhiMargin; }
0189 
0190   /// is precise error calculation switched on
0191   bool isPrecise() const { return thePrecise; }
0192 
0193   TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer& layer) const override;
0194 
0195   /// Set the elements of the mask corresponding to the tracks that are compatable with the region.
0196   /// Does not reset the elements corresponding to the tracks that are not compatible.
0197   void checkTracks(reco::TrackCollection const& tracks, std::vector<bool>& mask) const override;
0198 
0199   std::unique_ptr<HitRZCompatibility> checkRZ(const DetLayer* layer,
0200                                               const Hit& outerHit,
0201                                               const DetLayer* outerlayer = nullptr,
0202                                               float lr = 0,
0203                                               float gz = 0,
0204                                               float dr = 0,
0205                                               float dz = 0) const override {
0206     return checkRZOld(layer, outerHit, outerlayer);
0207   }
0208 
0209   std::unique_ptr<TrackingRegion> clone() const override {
0210     return std::make_unique<RectangularEtaPhiTrackingRegion>(*this);
0211   }
0212 
0213   std::string name() const override { return "RectangularEtaPhiTrackingRegion"; }
0214   std::string print() const override;
0215 
0216 private:
0217   std::unique_ptr<HitRZCompatibility> checkRZOld(const DetLayer* layer,
0218                                                  const Hit& outerHit,
0219                                                  const DetLayer* outerlayer) const;
0220 
0221   std::unique_ptr<MeasurementEstimator> estimator(const BarrelDetLayer* layer) const dso_internal;
0222   std::unique_ptr<MeasurementEstimator> estimator(const ForwardDetLayer* layer) const dso_internal;
0223 
0224   OuterHitPhiPrediction phiWindow(const MagneticField& field) const dso_internal;
0225   HitRZConstraint rzConstraint() const dso_internal;
0226 
0227   void initEtaRange(const GlobalVector& dir, const Margin& margin);
0228 
0229 private:
0230   Range theEtaRange;
0231   Range theLambdaRange;  // this is actually tanLambda
0232   Margin thePhiMargin;
0233   float theMeanLambda;
0234   const UseMeasurementTracker theMeasurementTrackerUsage = UseMeasurementTracker::kNever;
0235   bool thePrecise = false;
0236   bool theUseMS = false;
0237   bool theUseEtaPhi = false;
0238   const MeasurementTrackerEvent* theMeasurementTracker = nullptr;
0239   const MagneticField* theField = nullptr;
0240   const MultipleScatteringParametrisationMaker* theMSMaker = nullptr;
0241 
0242   using cacheHitPointer = mayown_ptr<BaseTrackerRecHit>;
0243   using cacheHits = std::vector<cacheHitPointer>;
0244 
0245   /*  wait... think! 
0246    *  done? questions?  think again, look where this region is constructed
0247    *  still question? study tracker code for the next couple of weeks, then we may discuss.  
0248    */
0249   mutable cacheHits cache;
0250 };
0251 
0252 #endif