CMS 3D CMS Logo

CMSSW_4_4_3_patch1/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 const float DTTopology::sensibleWidth() const{
00041   return theWidth-IBeamThickness;
00042 }
00043 
00044 const float DTTopology::sensibleHeight() const{
00045   return theHeight-plateThickness;
00046 }
00047 
00048 LocalPoint DTTopology::localPosition( const MeasurementPoint& mp) const{
00049     return LocalPoint( (mp.x() - theFirstChannel)*theWidth + theOffSet.x() , 
00050                        (1-mp.y())*theLength + theOffSet.y());
00051 }
00052 
00053 LocalError DTTopology::localError( const MeasurementPoint& mp, const MeasurementError& me) const{
00054   return LocalError(me.uu()*(theWidth*theWidth), 0,
00055                     me.vv()*(theLength*theLength));
00056 }
00057 
00058 MeasurementPoint DTTopology::measurementPosition( const LocalPoint& lp) const{
00059   return MeasurementPoint( static_cast<int>( (lp.x()-theOffSet.x())/theWidth + theFirstChannel),
00060                            1 - (lp.y()-theOffSet.y())/theLength);
00061 }
00062 
00063 MeasurementError DTTopology::measurementError( const LocalPoint& lp, const LocalError& le) const{
00064   return MeasurementError(le.xx()/(theWidth*theWidth),0,
00065                           le.yy()/(theLength*theLength));
00066 }
00067 
00068 int DTTopology::channel( const LocalPoint& lp) const{
00069   return static_cast<int>( (lp.x()-theOffSet.x())/theWidth + theFirstChannel);
00070 }
00071 
00072 // return the x wire position in the layer, starting from its wire number.
00073 float DTTopology::wirePosition(int wireNumber) const{
00074   if (wireNumber - (theFirstChannel-1) <= 0 || wireNumber > lastChannel() )
00075     throw cms::Exception("InvalidWireNumber") << "DTTopology::wirePosition:" 
00076                                               << " Requested wire number: "<< wireNumber 
00077                                               << " ,but the first wire number is "<< theFirstChannel
00078                                               << " and the last wire number is "<< lastChannel()
00079                                               << std::endl;
00080   else
00081     return  (wireNumber - (theFirstChannel-1) - 0.5)*theWidth + theOffSet.x();
00082 }
00083 
00084 /*
00085 // return the x wire position in the layer r.f., starting from its wire number.
00086 float DTTopology::wirePosition(int wireNumber) const{
00087   int layerCoord = theNChannels - wireNumber + theFirstChannel;
00088   return  (layerCoord - 0.5)*theWidth + theOffSet.x();
00089 }
00090 */
00091 
00092 
00093 //New cell geometry
00094 DTTopology::Side DTTopology::onWhichBorder(float x, float y, float z) const{
00095   
00096   // epsilon = Tolerance to determine if a hit starts/ends on the cell border.
00097   // Current value comes from CMSIM, where hit position is
00098   // always ~10um far from surface. For OSCAR the discrepancy is < 1um.
00099   const float epsilon = 0.0015; // 15 um
00100   
00101   // with new geometry the cell shape is not rectangular, but is a
00102   // rectangular with the I-beam "Wing" subtracted.
00103   // The height of the Wing is 1.0 mm and the length is 6.35 mm: these 4
00104   // volumens must be taken into account when the border is computed
00105    
00106   Side side = none;
00107   
00108   if ( fabs(z) > ( sensibleHeight()/2.-epsilon) ||
00109        (fabs(x) > ( sensibleWidth()/2.-IBeamWingLength-epsilon) &&
00110         fabs(z) > ( sensibleHeight()/2.-IBeamWingThickness-epsilon) ) ){ //FIXME 
00111 
00112     if (z > 0.) side = zMax; // This is currently the INNER surface.
00113     else side = zMin;
00114   }
00115   
00116   else if ( fabs(x) > ( sensibleWidth()/2.-epsilon) ){ 
00117     if (x > 0.) side = xMax;
00118     else side = xMin;
00119   }   // FIXME: else if ymax, ymin...
00120 
00121   return side;
00122 }
00123   
00124 
00125 //Old geometry of the DT
00126 DTTopology::Side DTTopology::onWhichBorder_old(float x, float y, float z) const{
00127 
00128   // epsilon = Tolerance to determine if a hit starts/ends on the cell border.
00129   // Current value comes from CMSIM, where hit position is
00130   // always ~10um far from surface. For OSCAR the discrepancy is < 1um.
00131   const float epsilon = 0.0015; // 15 um
00132 
00133   Side side = none;
00134 
00135   if ( fabs(z) > ( sensibleHeight()/2.-epsilon)) {
00136     if (z > 0.) { 
00137       side = zMax; // This is currently the INNER surface.
00138     } else {
00139       side = zMin;
00140     }
00141   } else if ( fabs(x) > ( sensibleWidth()/2.-epsilon)) {
00142     if (x > 0.) {
00143       side = xMax; 
00144     } else {
00145       side = xMin;
00146     }
00147   }   // FIXME: else if ymax, ymin...
00148   
00149   return side;
00150 }
00151