CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TrackingTools/DetLayers/src/BarrelDetLayer.cc

Go to the documentation of this file.
00001 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00002 #include "DataFormats/GeometrySurface/interface/Surface.h" 
00003 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" 
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00006 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
00007 
00008 using namespace std;
00009 
00010 BarrelDetLayer::~BarrelDetLayer() {}
00011 
00012 
00013 
00014 //--- Extension of the interface
00015 void BarrelDetLayer::setSurface( BoundCylinder* cp) { 
00016   theCylinder = cp;
00017 }
00018 
00019 bool BarrelDetLayer::contains(const Local3DPoint& p) const {
00020   return surface().bounds().inside(p);
00021 }
00022 
00023 void BarrelDetLayer::initialize() 
00024 {
00025   setSurface( computeSurface());
00026 }
00027 
00028 
00029 
00030 //--- protected methods
00031 BoundCylinder* BarrelDetLayer::computeSurface() {
00032   vector< const GeomDet*> comps = basicComponents();
00033 
00034   // Find extension in Z
00035   float theRmin = comps.front()->position().perp();   
00036   float theRmax = theRmin;
00037   float theZmin = comps.front()->position().z(); 
00038   float theZmax = theZmin;
00039   for ( vector< const GeomDet*>::const_iterator deti = comps.begin(); 
00040         deti != comps.end(); deti++) {
00041     vector<GlobalPoint> corners = 
00042       BoundingBox().corners( dynamic_cast<const BoundPlane&>((*deti)->surface()));
00043     for (vector<GlobalPoint>::const_iterator ic = corners.begin();
00044          ic != corners.end(); ic++) {
00045       float r = ic->perp();
00046       float z = ic->z();
00047       theRmin = min( theRmin, r);
00048       theRmax = max( theRmax, r);
00049       theZmin = min( theZmin, z);
00050       theZmax = max( theZmax, z);
00051     }
00052     // in addition to the corners we have to check the middle of the 
00053     // det +/- thickness/2
00054     // , since the min  radius for some barrel dets is reached there
00055     float rdet = (**deti).position().perp();
00056     float thick = (**deti).surface().bounds().thickness();
00057     theRmin = min( theRmin, rdet-thick/2.F);
00058     theRmax = max( theRmax, rdet+thick/2.F);
00059   }
00060   
00061   // By default the barrel layers are positioned at the center of the 
00062   // global frame, and the axes of their local frame coincide with 
00063   // those of the global grame (z along the cylinder axis)
00064   PositionType pos(0.,0.,0.);
00065   RotationType rot;
00066 
00067   return new BoundCylinder( pos, rot, 
00068                             SimpleCylinderBounds( theRmin, theRmax, 
00069                                                   theZmin, theZmax));
00070 }  
00071 
00072 
00073 pair<bool, TrajectoryStateOnSurface>
00074 BarrelDetLayer::compatible( const TrajectoryStateOnSurface& ts, 
00075                             const Propagator& prop, 
00076                             const MeasurementEstimator& est) const
00077 {
00078   if(theCylinder == 0)  edm::LogError("DetLayers") 
00079     << "ERROR: BarrelDetLayer::compatible() is used before the layer surface is initialized" ;
00080   // throw an exception? which one?
00081 
00082   TrajectoryStateOnSurface myState = prop.propagate( ts, specificSurface());
00083   if ( !myState.isValid()) return make_pair( false, myState);
00084 
00085   // take into account the thickness of the layer
00086   float deltaZ = surface().bounds().thickness()/2. / 
00087     fabs( tan( myState.globalDirection().theta()));
00088 
00089   // take into account the error on the predicted state
00090   const float nSigma = 3.;
00091   if (myState.hasError()) {
00092     deltaZ += nSigma * sqrt( myState.cartesianError().position().czz());
00093   }
00094   //
00095   // check z assuming symmetric bounds around position().z()
00096   //
00097   deltaZ += surface().bounds().length()/2;
00098   return make_pair(fabs(myState.globalPosition().z()-surface().position().z())<deltaZ,
00099                    myState);  
00100 }