CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/TrackingTools/DetLayers/src/ForwardDetLayer.cc

Go to the documentation of this file.
00001 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00002 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
00005 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
00006 
00007 using namespace std;
00008 
00009 
00010 ForwardDetLayer::~ForwardDetLayer() {
00011 }
00012 
00013 
00014 //--- Extension of the interface
00015 void ForwardDetLayer::setSurface( BoundDisk* cp) { 
00016   theDisk = cp;
00017 }
00018 
00019 bool ForwardDetLayer::contains(const Local3DPoint& p) const {
00020   return surface().bounds().inside(p);
00021 }
00022 
00023 
00024 void ForwardDetLayer::initialize() {
00025   setSurface( computeSurface());
00026 }
00027 
00028 
00029 BoundDisk* ForwardDetLayer::computeSurface() {
00030   LogDebug("DetLayers") << "ForwaLayer::computeSurface callded" ;
00031   vector<const GeomDet*> comps= basicComponents();
00032 
00033   vector<const GeomDet*>::const_iterator ifirst = comps.begin();
00034   vector<const GeomDet*>::const_iterator ilast  = comps.end();
00035 
00036   // Find extension in R
00037   float theRmin = components().front()->position().perp(); 
00038   float theRmax = theRmin;
00039   float theZmin = components().back()->position().z();
00040   float theZmax = theZmin;
00041   for ( vector<const GeomDet*>::const_iterator deti = ifirst;
00042         deti != ilast; deti++) {
00043     vector<GlobalPoint> corners = 
00044       BoundingBox().corners( dynamic_cast<const Plane&>((**deti).surface()));
00045     for (vector<GlobalPoint>::const_iterator ic = corners.begin();
00046          ic != corners.end(); ic++) {
00047       float r = ic->perp();
00048       LogDebug("DetLayers") << "corner.perp(): " << r ;
00049       float z = ic->z();
00050       theRmin = min( theRmin, r);
00051       theRmax = max( theRmax, r);
00052       theZmin = min( theZmin, z);
00053       theZmax = max( theZmax, z);
00054     }
00055 
00056     // in addition to the corners we have to check the middle of the 
00057     // det +/- length/2
00058     // , since the min (max) radius for typical fw dets is reached there
00059 
00060     float rdet  = (**deti).position().perp();
00061     float len   = (**deti).surface().bounds().length();
00062     float width = (**deti).surface().bounds().width();
00063 
00064     GlobalVector xAxis = (**deti).toGlobal(LocalVector(1,0,0));
00065     GlobalVector yAxis = (**deti).toGlobal(LocalVector(0,1,0));
00066     GlobalVector perpDir = GlobalVector( (**deti).position() - GlobalPoint(0,0,(**deti).position().z()) );
00067 
00068     double xAxisCos = xAxis.unit().dot(perpDir.unit());
00069     double yAxisCos = yAxis.unit().dot(perpDir.unit());
00070 
00071     LogDebug("DetLayers") << "in ForwardDetLayer::computeSurface(),xAxisCos,yAxisCos: " << xAxisCos << " , " << yAxisCos ;
00072     LogDebug("DetLayers") << "det pos.perp,length,width: " 
00073                           << rdet << " , " 
00074                           << len  << " , "
00075                           << width ;
00076 
00077     if( fabs(xAxisCos) > fabs(yAxisCos) ) {
00078       theRmin = min( theRmin, rdet-width/2.F);
00079       theRmax = max( theRmax, rdet+width/2.F);
00080     }else{
00081       theRmin = min( theRmin, rdet-len/2.F);
00082       theRmax = max( theRmax, rdet+len/2.F);
00083     }
00084   }
00085 
00086 
00087   LogDebug("DetLayers") << "creating SimpleDiskBounds with r range" << theRmin << " " 
00088                         << theRmax << " and z range " << theZmin << " " << theZmax ;
00089 
00090   // By default the forward layers are positioned around the z axis of the
00091   // global frame, and the axes of their local frame coincide with 
00092   // those of the global grame (z along the disk axis)
00093   float zPos = (theZmax+theZmin)/2.;
00094   PositionType pos(0.,0.,zPos);
00095   RotationType rot;
00096 
00097   return new BoundDisk( pos, rot, 
00098                         new SimpleDiskBounds( theRmin, theRmax, 
00099                                               theZmin-zPos, theZmax-zPos));
00100 }  
00101 
00102 
00103 pair<bool, TrajectoryStateOnSurface>
00104 ForwardDetLayer::compatible( const TrajectoryStateOnSurface& ts, 
00105                              const Propagator& prop, 
00106                              const MeasurementEstimator&) const
00107 {
00108   if unlikely(theDisk == 0)  edm::LogError("DetLayers") 
00109     << "ERROR: BarrelDetLayer::compatible() is used before the layer surface is initialized" ;
00110   // throw an exception? which one?
00111 
00112   TrajectoryStateOnSurface myState = prop.propagate( ts, specificSurface());
00113   if unlikely( !myState.isValid()) return make_pair( false, myState);
00114 
00115   // take into account the thickness of the layer
00116   float deltaR = 0.5f*surface().bounds().thickness() *
00117     myState.localDirection().perp()/std::abs(myState.localDirection().z());
00118 
00119   // take into account the error on the predicted state
00120   const float nSigma = 3.;
00121   if (myState.hasError()) {
00122     LocalError err = myState.localError().positionError();
00123     // ignore correlation for the moment...
00124     deltaR += nSigma * sqrt(err.xx() + err.yy());
00125   }
00126 
00127   float zPos = 0.5f*(zmax()+zmin());
00128   SimpleDiskBounds tmp( rmin()-deltaR, rmax()+deltaR, 
00129                         zmin()-zPos, zmax()-zPos);
00130 
00131   return make_pair( tmp.inside(myState.localPosition()), myState);
00132 }