CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoTracker/TkTrackingRegions/interface/HitRCheck.h

Go to the documentation of this file.
00001 #ifndef HitRCheck_H
00002 #define HitRCheck_H
00003 
00007 #include "RecoTracker/TkTrackingRegions/interface/HitRZCompatibility.h"
00008 #include "RecoTracker/TkTrackingRegions/interface/HitRZConstraint.h"
00009 
00010 class HitRCheck GCC11_FINAL : public HitRZCompatibility {
00011 public:
00012   static constexpr Algo me =rAlgo;
00013 
00014   typedef TkTrackingRegionsMargin<float> Margin;
00015 
00016   HitRCheck()  : HitRZCompatibility(me) { }
00017   HitRCheck(const HitRZConstraint & rz, Margin margin = Margin(0,0)) 
00018     :  HitRZCompatibility(me), theRZ(rz), theTolerance(margin) { } 
00019 
00020   virtual bool operator() (const float & r, const float & z) const
00021     { return range(z).inside(r); }
00022 
00023   inline Range range(const float & z) const;
00024 
00025   virtual HitRCheck * clone() const { return new HitRCheck(*this); }
00026 
00027   void setTolerance(const Margin & tolerance) { theTolerance = tolerance; }
00028 
00029 private:
00030   HitRZConstraint theRZ;
00031   Margin theTolerance;
00032 };
00033 
00034 
00035 
00036 HitRCheck::Range HitRCheck::range(const float & z) const
00037 {
00038   constexpr float rBig = 150.; //something above the detector ranges
00039   const auto & lineLeft =  theRZ.lineLeft();
00040   const auto & lineRight = theRZ.lineRight();
00041   
00042   float rR = lineRight.rAtZ(z);
00043   float rL = lineLeft.rAtZ(z);
00044   float rMin = (rR<rL) ? rR : rL;  
00045   float rMax = (rR<rL) ? rL : rR;
00046   // in reality all this never happens!
00047   float aMin = (rMin>0) ? rMin : rMax;
00048   float aMax = (rMin>0) ? rMax : rBig;
00049   aMin = (rMax>0) ? aMin : rBig;
00050   return Range(aMin-theTolerance.left(),aMax+theTolerance.right());
00051 
00052   /* check
00053   Range v(aMin-theTolerance.left(),aMax+theTolerance.right());
00054   Range ori;
00055   if (z > 0.) {
00056     if (lineRight.cotLine() <= 0.) ori = Range(rBig, 0); //empty
00057     else {
00058       float rMin = lineRight.rAtZ(z);
00059       if (lineLeft.cotLine() <= 0) ori= Range(rMin-theTolerance.left(),rBig);
00060       else {
00061         float rMax = lineLeft.rAtZ(z);
00062         ori = Range(rMin-theTolerance.left(),rMax+theTolerance.right());
00063       }
00064     } 
00065   } else {
00066     if (lineLeft.cotLine() >= 0.)  ori = Range(rBig, 0); //empty
00067     else {
00068       float rMin = lineLeft.rAtZ(z);
00069       if (lineRight.cotLine()>= 0) ori = Range(rMin-theTolerance.left(),rBig);
00070       else {
00071         float rMax = lineRight.rAtZ(z);
00072         ori= Range(rMin-theTolerance.left(),rMax+theTolerance.right());
00073       }
00074     }
00075   }
00076 
00077   if (ori!=v) 
00078     std::cout << "v,ori " << v.first << ',' << v.second <<" "  
00079               << ori.first << ',' << ori.second << std::endl;
00080   return ori;
00081   */
00082 
00083   /*  original code
00084   if (z > 0.) {
00085     if (lineRight.cotLine() <= 0.) return Range(rBig, 0); //empty
00086     float rMin = lineRight.rAtZ(z);
00087     if (lineLeft.cotLine() <= 0) return Range(rMin-theTolerance.left(),rBig);
00088     float rMax = lineLeft.rAtZ(z);
00089     return Range(rMin-theTolerance.left(),rMax+theTolerance.right()); 
00090   } else {
00091     if (lineLeft.cotLine() >= 0.) return Range(rBig, 0); //empty 
00092     float rMin = lineLeft.rAtZ(z);
00093     if (lineRight.cotLine()>= 0) return Range(rMin-theTolerance.left(),rBig);
00094     float rMax = lineRight.rAtZ(z);
00095     return Range(rMin-theTolerance.left(),rMax+theTolerance.right());
00096   }
00097   */
00098 }
00099 #endif