Go to the documentation of this file.00001
00002 #include "RecoTracker/TkMSParametrization/interface/MSLayersAtAngle.h"
00003
00004 #include "RecoTracker/TkMSParametrization/interface/PixelRecoLineRZ.h"
00005 using namespace std;
00006
00007 template <class T> inline T sqr( T t) {return t*t;}
00008
00009
00010 MSLayersAtAngle::MSLayersAtAngle(const vector<MSLayer> & layers)
00011 : theLayers(layers)
00012 { sort(theLayers.begin(), theLayers.end()); }
00013
00014 const MSLayer * MSLayersAtAngle::findLayer(const MSLayer & layer) const
00015 {
00016 vector<MSLayer>::const_iterator it =
00017 find(theLayers.begin(), theLayers.end(), layer);
00018 return it==theLayers.end() ? 0 : &(*it);
00019 }
00020
00021
00022 void MSLayersAtAngle::update(const MSLayer & layer)
00023 {
00024 vector<MSLayer>::iterator it = find(theLayers.begin(),theLayers.end(),layer);
00025 if (it == theLayers.end()) {
00026 theLayers.push_back(layer);
00027 sort(theLayers.begin(), theLayers.end());
00028 } else {
00029 *it = layer;
00030 }
00031 }
00032
00033
00034 float MSLayersAtAngle::sumX0D(
00035 const PixelRecoPointRZ & pointI,
00036 const PixelRecoPointRZ & pointO,
00037 float tip) const
00038 {
00039 LayerItr iO = findLayer(pointO, theLayers.begin(), theLayers.end());
00040
00041 LayerItr iI = findLayer(pointI, theLayers.begin(), iO);
00042
00043
00044 return sqrt(sum2RmRn(iI,iO, pointO.r(),
00045 PixelRecoLineRZ(pointI, pointO, tip)));
00046 }
00047
00048 float MSLayersAtAngle::sumX0D(
00049 const PixelRecoPointRZ & pointI,
00050 const PixelRecoPointRZ & pointM,
00051 const PixelRecoPointRZ & pointO,
00052 float tip) const
00053 {
00054 LayerItr iO = findLayer(pointO, theLayers.begin(), theLayers.end());
00055 LayerItr iI = findLayer(pointI, theLayers.begin(), iO);
00056 LayerItr iM = findLayer(pointM, iI, iO);
00057
00058 float drOI = pointO.r() - pointI.r();
00059 float drMO = pointO.r() - pointM.r();
00060 float drMI = pointM.r() - pointI.r();
00061
00062 PixelRecoLineRZ line(pointI, pointO, tip);
00063 float sum2I = sum2RmRn(iI+1, iM, pointI.r(), line);
00064 float sum2O = sum2RmRn(iM, iO, pointO.r(), line);
00065
00066 return sqrt( sum2I* sqr(drMO) + sum2O*sqr(drMI) )/drOI;
00067 }
00068
00069
00070 float MSLayersAtAngle::sum2RmRn(
00071 MSLayersAtAngle::LayerItr i1,
00072 MSLayersAtAngle::LayerItr i2,
00073 float rTarget,
00074 const PixelRecoLineRZ & line) const
00075 {
00076 float sum2 = 0.f;
00077 float cotTh = line.cotLine();
00078 for (LayerItr it = i1; it < i2; it++) {
00079 pair<PixelRecoPointRZ,bool> cross = it->crossing(line);
00080 if (cross.second) {
00081 float x0 = it->x0(cotTh);
00082 float dr = rTarget-cross.first.r();
00083 if (x0 > 1.e-5f) dr *= 1.f+0.038f*std::log(x0);
00084 sum2 += x0*dr*dr;
00085 }
00086
00087 }
00088 return sum2;
00089 }
00090
00091 MSLayersAtAngle::LayerItr MSLayersAtAngle::findLayer(
00092 const PixelRecoPointRZ & point,
00093 MSLayersAtAngle::LayerItr ibeg,
00094 MSLayersAtAngle::LayerItr iend) const
00095 {
00096 const float BIG=99999.f;
00097 const float EPSILON = 1.e-4f;
00098 LayerItr theIt = ibeg; float dist = BIG;
00099 for (LayerItr it = ibeg; it < iend; it++) {
00100 float d = it->distance(point);
00101 if (d < dist) {
00102 if (d < EPSILON) return it;
00103 dist = d;
00104 theIt = it;
00105 }
00106 }
00107 return theIt;
00108 }
00109
00110
00111 void MSLayersAtAngle::print() const
00112 {
00113 for (LayerItr it = theLayers.begin(); it != theLayers.end(); it++)
00114 cout <<*it<<endl;
00115 }
00116