CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Geometry/CommonTopologies/src/TrapezoidalStripTopology.cc

Go to the documentation of this file.
00001 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
00002 
00003 #include <iostream>
00004 #include <cmath>
00005 #include <algorithm>
00006 
00007 TrapezoidalStripTopology::TrapezoidalStripTopology(int ns, float p, 
00008                                                    float l,
00009                                                    float r0) :
00010   theNumberOfStrips(ns), thePitch(p),
00011   theDistToBeam(r0), theDetHeight(l) {
00012   theOffset = -theNumberOfStrips/2. * thePitch;
00013   theYAxOr = 1;
00014 #ifdef VERBOSE
00015   cout<<"Constructing TrapezoidalStripTopology with"
00016       <<" nstrips = "<<ns
00017       <<" pitch = "<<p
00018       <<" length = "<<l
00019       <<" r0 ="<<r0
00020       <<endl;
00021 #endif
00022 }
00023 
00024 TrapezoidalStripTopology::TrapezoidalStripTopology(int ns, float p, 
00025                                                    float l,
00026                                                    float r0, int yAx) :
00027   theNumberOfStrips(ns), thePitch(p),
00028   theDistToBeam(r0), theDetHeight(l), theYAxOr(yAx){
00029   theOffset = -theNumberOfStrips/2. * thePitch;
00030 #ifdef VERBOSE
00031   cout<<"Constructing TrapezoidalStripTopology with"
00032       <<" nstrips = "<<ns
00033       <<" pitch = "<<p
00034       <<" length = "<<l
00035       <<" r0 ="<<r0
00036       <<" yAxOrientation ="<<yAx
00037       <<endl;
00038 #endif
00039 }
00040 
00041 LocalPoint
00042 TrapezoidalStripTopology::localPosition(float strip) const {
00043   return LocalPoint( strip*thePitch + theOffset, 0.0);
00044 }
00045 
00046 LocalPoint
00047 TrapezoidalStripTopology::localPosition(const MeasurementPoint& mp) const {
00048   float y = mp.y()*theDetHeight;
00049   float x = (mp.x()*thePitch + 
00050              theOffset)*(theYAxOr*y+theDistToBeam)/theDistToBeam;
00051   return LocalPoint(x,y);
00052 }
00053 
00054 LocalError
00055 TrapezoidalStripTopology::localError(float strip, float stripErr2) const {
00056   float lt,lc2,ls2,lslc;
00057   float localL2,localP2;
00058   float sl2,sp2;
00059   // angle from strip to local frame (see CMS TN / 95-170)
00060   lt = -(strip*thePitch + theOffset)*theYAxOr/theDistToBeam;
00061   lc2 = 1.f/(1.+lt*lt);
00062   lslc = lt*lc2;
00063   ls2 = 1.f-lc2;
00064   localL2 = theDetHeight*theDetHeight / lc2;
00065   localP2 = thePitch*thePitch*lc2;
00066   sl2 = localL2/12.;
00067   sp2 = stripErr2*localP2;
00068   return LocalError(lc2*sp2+ls2*sl2,
00069                     lslc*(sp2-sl2),
00070                     ls2*sp2+lc2*sl2);
00071 }
00072 
00073 LocalError
00074 TrapezoidalStripTopology::localError(const MeasurementPoint& mp,
00075                                      const MeasurementError& merr) const {
00076   float lt,lc2,ls2,lslc;
00077   float localL,localP;
00078   float sl2,sp2,spl;
00079   // angle from strip to local frame (see CMS TN / 95-170)
00080   lt = -(mp.x()*thePitch + theOffset)*theYAxOr/theDistToBeam;
00081   lc2 = 1./(1.+lt*lt);
00082   lslc = lt*lc2;
00083   ls2 = 1.f-lc2;
00084   localL = theDetHeight / std::sqrt(lc2);
00085   localP = localPitch(localPosition(mp));
00086   sp2 = merr.uu() * localP*localP;
00087   sl2 = merr.vv() * localL*localL;
00088   spl = merr.uv() * localP*localL;
00089   return LocalError(lc2*sp2+ls2*sl2-2*lslc*spl,
00090                     lslc*(sp2-sl2)+(lc2-ls2)*spl,
00091                     ls2*sp2+lc2*sl2+2*lslc*spl);
00092 }
00093 
00094 float
00095 TrapezoidalStripTopology::strip(const LocalPoint& lp) const {
00096   float aStrip =
00097      ((lp.x()*theDistToBeam/(theYAxOr*lp.y()+theDistToBeam))-theOffset)/thePitch;
00098    if (aStrip < 0 ) aStrip = 0;
00099   else if (aStrip > theNumberOfStrips)  aStrip = theNumberOfStrips;
00100   return aStrip;
00101 }
00102 
00103 MeasurementPoint
00104 TrapezoidalStripTopology::measurementPosition(const LocalPoint& lp) const {
00105   return 
00106     MeasurementPoint(((lp.x()*theDistToBeam/(theYAxOr*lp.y()+theDistToBeam))-theOffset)/thePitch,
00107                      lp.y()/theDetHeight);
00108 }
00109 
00110 MeasurementError
00111 TrapezoidalStripTopology::measurementError(const LocalPoint& lp,
00112                                            const LocalError& lerr) const {
00113   float lt,lc2,ls2,lslc;
00114   float localL,localP;
00115   float sl2,sp2,spl;
00116   lt = -lp.x()/(theYAxOr*lp.y()+theDistToBeam)*theYAxOr;
00117   lc2 = 1./(1.+lt*lt);
00118   lslc = lt*lc2;
00119   ls2 = 1.-lc2;
00120   localL = theDetHeight / std::sqrt(lc2);
00121   localP = localPitch(lp);
00122   sp2 = lc2*lerr.xx()+ls2*lerr.yy()+2*lslc*lerr.xy();
00123   sl2 = ls2*lerr.xx()+lc2*lerr.yy()-2*lslc*lerr.xy();
00124   spl = lslc*(lerr.yy()-lerr.xx())+(lc2-ls2)*lerr.xy();
00125   return MeasurementError(sp2/(localP*localP),
00126                           spl/(localP*localL),
00127                           sl2/(localL*localL));
00128 
00129 }
00130 
00131 int
00132 TrapezoidalStripTopology::channel(const LocalPoint& lp) const {
00133   return std::min(int(strip(lp)),theNumberOfStrips-1);
00134 }
00135 
00136 float
00137 TrapezoidalStripTopology::pitch() const {
00138   return thePitch;
00139 }
00140 
00141 float
00142 TrapezoidalStripTopology::localPitch(const LocalPoint& lp) const {
00143   float x=lp.x();
00144   float y=theYAxOr*lp.y()+theDistToBeam;
00145   return thePitch*y/(theDistToBeam*std::sqrt(1.f+x*x/(y*y)));
00146 }
00147 
00148 float
00149 TrapezoidalStripTopology::stripAngle(float strip) const {
00150   return std::atan( -(strip*thePitch + theOffset)*theYAxOr/theDistToBeam );
00151 }
00152 
00153 int
00154 TrapezoidalStripTopology::nstrips() const {
00155   return theNumberOfStrips;
00156 }
00157 
00158 float TrapezoidalStripTopology::shiftOffset( float pitch_fraction) {
00159   theOffset += thePitch * pitch_fraction;
00160   return theOffset;
00161 }
00162 
00163 float TrapezoidalStripTopology::localStripLength(const LocalPoint& lp) 
00164   const {
00165   float ltan = -lp.x()/(theYAxOr*lp.y()+theDistToBeam)*theYAxOr;
00166   float localL = theDetHeight * std::sqrt(1.f+ltan*ltan);
00167   //  float lcos2 = 1.f/(1.f+ltan*ltan);
00168   //  float localL = theDetHeight / std::sqrt(lcos2);
00169 
00170   return localL;
00171 }
00172