Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:55

0001 #ifndef HitRCheck_H
0002 #define HitRCheck_H
0003 
0004 /** provides allowed range of radius R from HitRZConstraint 
0005     at a given Z coordinate */
0006 
0007 #include "RecoTracker/TkTrackingRegions/interface/HitRZCompatibility.h"
0008 #include "RecoTracker/TkTrackingRegions/interface/HitRZConstraint.h"
0009 
0010 class HitRCheck final : public HitRZCompatibility {
0011 public:
0012   static constexpr Algo me = rAlgo;
0013 
0014   typedef TkTrackingRegionsMargin<float> Margin;
0015 
0016   HitRCheck() : HitRZCompatibility(me) {}
0017   HitRCheck(const HitRZConstraint& rz, Margin margin = Margin(0, 0))
0018       : HitRZCompatibility(me), theRZ(rz), theTolerance(margin) {}
0019 
0020   bool operator()(const float& r, const float& z) const override { return range(z).inside(r); }
0021 
0022   inline Range range(const float& z) const override;
0023 
0024   HitRCheck* clone() const override { return new HitRCheck(*this); }
0025 
0026   void setTolerance(const Margin& tolerance) { theTolerance = tolerance; }
0027 
0028 private:
0029   HitRZConstraint theRZ;
0030   Margin theTolerance;
0031 };
0032 
0033 HitRCheck::Range HitRCheck::range(const float& z) const {
0034   constexpr float rBig = 150.;  //something above the detector ranges
0035   const auto& lineLeft = theRZ.lineLeft();
0036   const auto& lineRight = theRZ.lineRight();
0037 
0038   float rR = lineRight.rAtZ(z);
0039   float rL = lineLeft.rAtZ(z);
0040   float rMin = (rR < rL) ? rR : rL;
0041   float rMax = (rR < rL) ? rL : rR;
0042   // in reality all this never happens!
0043   float aMin = (rMin > 0) ? rMin : rMax;
0044   float aMax = (rMin > 0) ? rMax : rBig;
0045   aMin = (rMax > 0) ? aMin : rBig;
0046   return Range(aMin - theTolerance.left(), aMax + theTolerance.right());
0047 
0048   /* check
0049   Range v(aMin-theTolerance.left(),aMax+theTolerance.right());
0050   Range ori;
0051   if (z > 0.) {
0052     if (lineRight.cotLine() <= 0.) ori = Range(rBig, 0); //empty
0053     else {
0054       float rMin = lineRight.rAtZ(z);
0055       if (lineLeft.cotLine() <= 0) ori= Range(rMin-theTolerance.left(),rBig);
0056       else {
0057     float rMax = lineLeft.rAtZ(z);
0058     ori = Range(rMin-theTolerance.left(),rMax+theTolerance.right());
0059       }
0060     } 
0061   } else {
0062     if (lineLeft.cotLine() >= 0.)  ori = Range(rBig, 0); //empty
0063     else {
0064       float rMin = lineLeft.rAtZ(z);
0065       if (lineRight.cotLine()>= 0) ori = Range(rMin-theTolerance.left(),rBig);
0066       else {
0067     float rMax = lineRight.rAtZ(z);
0068     ori= Range(rMin-theTolerance.left(),rMax+theTolerance.right());
0069       }
0070     }
0071   }
0072 
0073   if (ori!=v) 
0074     std::cout << "v,ori " << v.first << ',' << v.second <<" "  
0075           << ori.first << ',' << ori.second << std::endl;
0076   return ori;
0077   */
0078 
0079   /*  original code
0080   if (z > 0.) {
0081     if (lineRight.cotLine() <= 0.) return Range(rBig, 0); //empty
0082     float rMin = lineRight.rAtZ(z);
0083     if (lineLeft.cotLine() <= 0) return Range(rMin-theTolerance.left(),rBig);
0084     float rMax = lineLeft.rAtZ(z);
0085     return Range(rMin-theTolerance.left(),rMax+theTolerance.right()); 
0086   } else {
0087     if (lineLeft.cotLine() >= 0.) return Range(rBig, 0); //empty 
0088     float rMin = lineLeft.rAtZ(z);
0089     if (lineRight.cotLine()>= 0) return Range(rMin-theTolerance.left(),rBig);
0090     float rMax = lineRight.rAtZ(z);
0091     return Range(rMin-theTolerance.left(),rMax+theTolerance.right());
0092   }
0093   */
0094 }
0095 #endif