CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/Geometry/CSCGeometry/src/CSCWireTopology.cc

Go to the documentation of this file.
00001 #include "Geometry/CSCGeometry/interface/CSCWireTopology.h"
00002 
00003 #include "Geometry/CSCGeometry/src/CSCGangedWireGrouping.h"
00004 #include "Geometry/CSCGeometry/src/CSCNonslantedWireGeometry.h"
00005 #include "Geometry/CSCGeometry/src/CSCSlantedWireGeometry.h"
00006 
00007 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00008 
00009 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00010 
00011 #include <cmath>
00012 
00013 CSCWireTopology::~CSCWireTopology() { 
00014   delete theWireGrouping;
00015   delete theWireGeometry; 
00016 }
00017 
00018 CSCWireTopology::CSCWireTopology( 
00019                      const CSCWireGroupPackage& wg,
00020                      double yOfFirstWire,
00021                      float wireAngleInDegrees ) :
00022       theWireGrouping( 0 ), theWireGeometry( 0 ),
00023       theAlignmentPinToFirstWire( wg.alignmentPinToFirstWire / 10. ) {
00024 
00025      // Pass consecutiveGroups and wiresInConsecutiveGroups
00026      // directly on to theWireGrouping ctor. These vectors
00027      // are transient info and can go once ctor is complete.
00028          
00029   theWireGrouping = new CSCGangedWireGrouping( wg.consecutiveGroups,
00030                            wg.wiresInEachGroup, wg.numberOfGroups );
00031 
00032   const float zeroprecision = 1.E-06; // blur zero a bit, for comparisons
00033 
00034   float wireAngleInRadians = wireAngleInDegrees*degree;
00035 
00036   //@@ Conversion from mm to cm
00037   float wireSpacing = wg.wireSpacing   / 10.; // in cm
00038   float nw = wg.narrowWidthOfWirePlane / 10.; // in cm
00039   float ww = wg.wideWidthOfWirePlane   / 10.; // in cm
00040   float lw = wg.lengthOfWirePlane      / 10.; // in cm
00041 
00042    LogTrace("CSCWireTopology|CSC") <<  
00043        "CSCWireTopology constructing CSCWireGeometry with:\n" <<
00044        " wireSpacing = " << wireSpacing*10. << " (mm) " <<
00045        ", yOfFirstWire = " << yOfFirstWire << " (cm) " << 
00046      ", wireAngle = " << wireAngleInDegrees << " (deg) = " << wireAngleInRadians << " (rads)" <<
00047      ", extent: n, w, l = " << nw << ", " << ww << ", " << lw << " (cm)";
00048 
00049   if ( fabs(wireAngleInDegrees) > zeroprecision ) { 
00050     theWireGeometry = new CSCSlantedWireGeometry( wireSpacing, yOfFirstWire, nw, ww, lw, wireAngleInRadians );
00051   }
00052   else {
00053     theWireGeometry = new CSCNonslantedWireGeometry( wireSpacing, yOfFirstWire, nw, ww, lw );
00054   }
00055 }
00056 
00057 CSCWireTopology::CSCWireTopology( const CSCWireTopology& mewt ) :
00058   theAlignmentPinToFirstWire(mewt.theAlignmentPinToFirstWire) {
00059   if (mewt.theWireGrouping) theWireGrouping = mewt.theWireGrouping->clone();
00060   if (mewt.theWireGeometry) theWireGeometry = mewt.theWireGeometry->clone();
00061   
00062 }
00063 
00064 CSCWireTopology& CSCWireTopology::operator=( const CSCWireTopology& mewt ) {
00065   if ( &mewt != this ) {
00066     delete theWireGrouping;
00067     if ( mewt.theWireGrouping ) 
00068       theWireGrouping = mewt.theWireGrouping->clone();
00069     else 
00070       theWireGrouping = 0;
00071     
00072     delete theWireGeometry;
00073     if ( mewt.theWireGeometry ) 
00074       theWireGeometry = mewt.theWireGeometry->clone();
00075     else 
00076       theWireGeometry = 0;
00077 
00078     theAlignmentPinToFirstWire = mewt.theAlignmentPinToFirstWire;
00079     
00080   }
00081   return *this;
00082 }
00083 
00084 LocalPoint CSCWireTopology::localPosition( const MeasurementPoint& ) const {
00085   edm::LogWarning("CSC") << "CSCWireTopology: localPosition unimplemented. Don't use it." << "\n";
00086   return LocalPoint();
00087 }
00088 
00089 LocalError CSCWireTopology::localError( const MeasurementPoint&, 
00090                                           const MeasurementError& ) const {
00091   edm::LogWarning("CSC") << "CSCWireTopology: localError unimplemented. Don't use it." << "\n";
00092   return LocalError();
00093 }
00094 
00095 MeasurementPoint CSCWireTopology::measurementPosition( 
00096                                        const LocalPoint& ) const {
00097   edm::LogWarning("CSC") << "CSCWireTopology: measurementPosition unimplemented. Don't use it." << "\n";
00098   return MeasurementPoint();
00099 }
00100 
00101 MeasurementError CSCWireTopology::measurementError( const LocalPoint&, 
00102                                            const LocalError& ) const {
00103   edm::LogWarning("CSC") << "CSCWireTopology: measurementError unimplemented. Don't use it." << "\n";
00104   return MeasurementError();
00105 }
00106 
00107 int CSCWireTopology::channel( const LocalPoint& p ) const {
00108   int wire = theWireGeometry->nearestWire( p );
00109   int group = theWireGrouping->wireGroup( wire );
00110   return group; // 0 means out of range or dead region
00111 }
00112 
00113 float CSCWireTopology::yOfWireGroup(int wireGroup, float x) const {
00114    float wire = middleWireOfGroup( wireGroup );
00115    return theWireGeometry->yOfWire( wire, x );
00116 }
00117  
00118 float CSCWireTopology::yResolution( int wireGroup ) const {
00119   // Return the resolution in the wire group measurement (in cm).
00120   // To really be resolution in local y this should be scaled by Sin
00121   // factors involving strip and wire angles, and also add a contribution
00122   // from strip measurement (which is negligible w.r.t. wire resolution.)
00123   // These factors can increase the number here by up to 1.26.
00124 
00125   // Should be improvable for smaller partial wire groups
00126 
00127   return wireSpacing() * theWireGrouping->numberOfWiresPerGroup( wireGroup ) / sqrt(12.);
00128 }
00129 
00130 std::pair<float, float> CSCWireTopology::equationOfWire( float wire ) const {
00131   return theWireGeometry->equationOfWire( wire );
00132 }
00133 
00134 float CSCWireTopology::restrictToYOfWirePlane( float y ) const {
00135   // Reset y to lie within bounds of wire plane at top and bottom.
00136   
00137   std::pair<float, float> ylim = theWireGeometry->yLimitsOfWirePlane();
00138 
00139   if ( y < ylim.first ) {
00140     y = ylim.first;
00141   }
00142   else if ( y > ylim.second ) {
00143     y = ylim.second;
00144   }
00145   return y;
00146 }
00147 
00148 bool CSCWireTopology::insideYOfWirePlane( float y ) const {
00149   // Returns true if arg falls within y limits of wire plane; false otherwise.
00150       
00151   std::pair<float, float> ylim = theWireGeometry->yLimitsOfWirePlane();
00152 
00153   if ( y < ylim.first ) {
00154     return false;
00155   }
00156   else if ( y > ylim.second ) {
00157     return false;
00158   }
00159   return true;
00160 }