CMS 3D CMS Logo

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