CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Geometry/DTGeometry/src/DTTopology.cc

Go to the documentation of this file.
00001 
00008 #include "Geometry/DTGeometry/interface/DTTopology.h"
00009 #include <FWCore/Utilities/interface/Exception.h>
00010 
00011 #include <iostream>
00012 
00013 // FIXME now put by hand, check the number!
00014 
00015 const float DTTopology::theWidth  = 4.2;  // cm 
00016 const float DTTopology::theHeight = 1.3; // cm ...
00017 
00018 const float DTTopology::IBeamWingThickness = 0.13;   // cm 
00019 const float DTTopology::IBeamWingLength    = 0.635; // cm
00020 
00021 const float DTTopology::plateThickness = 0.15;  // aluminium plate:  1.5 mm
00022 const float DTTopology::IBeamThickness = 0.13;  // I-beam thickness: 1.3 mm
00023   
00024 DTTopology::DTTopology(int firstWire, int nChannels,float semilenght): theFirstChannel(firstWire),
00025                                                                    theNChannels(nChannels),
00026                                                                    theLength(semilenght*2){
00027   theOffSet = Local2DPoint(-theNChannels/2. * theWidth, -theLength/2.);
00028   
00029 #ifdef VERBOSE
00030   cout <<"Constructing DTTopology with:"<<endl
00031        <<"number of wires = "<<theNChannels
00032        <<", first wire number = "<<theFirstChannel<<endl
00033        <<", width = "<<theWidth
00034        <<", height = "<<theHeight
00035        <<", length = "<<theLength
00036        <<endl;
00037 #endif
00038 }
00039 
00040 float
00041 DTTopology::sensibleWidth() const
00042 {
00043   return theWidth-IBeamThickness;
00044 }
00045 
00046 float
00047 DTTopology::sensibleHeight() const
00048 {
00049   return theHeight-plateThickness;
00050 }
00051 
00052 LocalPoint
00053 DTTopology::localPosition( const MeasurementPoint& mp) const
00054 {
00055     return LocalPoint( (mp.x() - theFirstChannel)*theWidth + theOffSet.x() , 
00056                        (1-mp.y())*theLength + theOffSet.y());
00057 }
00058 
00059 LocalError
00060 DTTopology::localError( const MeasurementPoint& /*mp*/, const MeasurementError& me) const
00061 {
00062   return LocalError(me.uu()*(theWidth*theWidth), 0,
00063                     me.vv()*(theLength*theLength));
00064 }
00065 
00066 MeasurementPoint
00067 DTTopology::measurementPosition( const LocalPoint& lp) const
00068 {
00069   return MeasurementPoint( static_cast<int>( (lp.x()-theOffSet.x())/theWidth + theFirstChannel),
00070                            1 - (lp.y()-theOffSet.y())/theLength);
00071 }
00072 
00073 MeasurementError
00074 DTTopology::measurementError( const LocalPoint& /*lp*/, const LocalError& le) const
00075 {
00076   return MeasurementError(le.xx()/(theWidth*theWidth),0,
00077                           le.yy()/(theLength*theLength));
00078 }
00079 
00080 int
00081 DTTopology::channel( const LocalPoint& lp) const
00082 {
00083   return static_cast<int>( (lp.x()-theOffSet.x())/theWidth + theFirstChannel);
00084 }
00085 
00086 // return the x wire position in the layer, starting from its wire number.
00087 float
00088 DTTopology::wirePosition(int wireNumber) const
00089 {
00090   if (!isWireValid( wireNumber ))//- (theFirstChannel-1) <= 0. || wireNumber > lastChannel() )
00091     throw cms::Exception("InvalidWireNumber") << "DTTopology::wirePosition:" 
00092                                               << " Requested wire number: "<< wireNumber 
00093                                               << " ,but the first wire number is "<< theFirstChannel
00094                                               << " and the last wire number is "<< lastChannel()
00095                                               << std::endl;
00096   else
00097     return  (wireNumber - (theFirstChannel-1) - 0.5)*theWidth + theOffSet.x();
00098 }
00099 
00100 /*
00101 // return the x wire position in the layer r.f., starting from its wire number.
00102 float DTTopology::wirePosition(int wireNumber) const{
00103   int layerCoord = theNChannels - wireNumber + theFirstChannel;
00104   return  (layerCoord - 0.5)*theWidth + theOffSet.x();
00105 }
00106 */
00107 
00108 
00109 //New cell geometry
00110 DTTopology::Side
00111 DTTopology::onWhichBorder(float x, float /*y*/, float z) const
00112 {
00113   
00114   // epsilon = Tolerance to determine if a hit starts/ends on the cell border.
00115   // Current value comes from CMSIM, where hit position is
00116   // always ~10um far from surface. For OSCAR the discrepancy is < 1um.
00117   const float epsilon = 0.0015; // 15 um
00118   
00119   // with new geometry the cell shape is not rectangular, but is a
00120   // rectangular with the I-beam "Wing" subtracted.
00121   // The height of the Wing is 1.0 mm and the length is 6.35 mm: these 4
00122   // volumens must be taken into account when the border is computed
00123    
00124   Side side = none;
00125   
00126   if ( fabs(z) > ( sensibleHeight()/2.-epsilon) ||
00127        (fabs(x) > ( sensibleWidth()/2.-IBeamWingLength-epsilon) &&
00128         fabs(z) > ( sensibleHeight()/2.-IBeamWingThickness-epsilon) ) ){ //FIXME 
00129 
00130     if (z > 0.) side = zMax; // This is currently the INNER surface.
00131     else side = zMin;
00132   }
00133   
00134   else if ( fabs(x) > ( sensibleWidth()/2.-epsilon) ){ 
00135     if (x > 0.) side = xMax;
00136     else side = xMin;
00137   }   // FIXME: else if ymax, ymin...
00138 
00139   return side;
00140 }
00141   
00142 
00143 //Old geometry of the DT
00144 DTTopology::Side
00145 DTTopology::onWhichBorder_old(float x, float /*y*/, float z) const
00146 {
00147 
00148   // epsilon = Tolerance to determine if a hit starts/ends on the cell border.
00149   // Current value comes from CMSIM, where hit position is
00150   // always ~10um far from surface. For OSCAR the discrepancy is < 1um.
00151   const float epsilon = 0.0015; // 15 um
00152 
00153   Side side = none;
00154 
00155   if ( fabs(z) > ( sensibleHeight()/2.-epsilon)) {
00156     if (z > 0.) { 
00157       side = zMax; // This is currently the INNER surface.
00158     } else {
00159       side = zMin;
00160     }
00161   } else if ( fabs(x) > ( sensibleWidth()/2.-epsilon)) {
00162     if (x > 0.) {
00163       side = xMax; 
00164     } else {
00165       side = xMin;
00166     }
00167   }   // FIXME: else if ymax, ymin...
00168   
00169   return side;
00170 }
00171