CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoTracker/TkMSParametrization/src/MultipleScatteringGeometry.cc

Go to the documentation of this file.
00001 #include "MultipleScatteringGeometry.h"
00002 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00003 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00004 
00005 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00006 #include "TrackingTools/GeomPropagators/interface/StraightLinePropagator.h"
00007 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
00008 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
00009 #include "MagneticField/Engine/interface/MagneticField.h"
00010 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 
00013 using namespace GeomDetEnumerators;
00014 using namespace std;
00015 
00016 //------------------------------------------------------------------------------
00017 const float MultipleScatteringGeometry::beamPipeR =  2.94;
00018 const float MultipleScatteringGeometry::endflangesZ = 30;
00019 const float MultipleScatteringGeometry::supportR = 19.;
00020 
00021 //------------------------------------------------------------------------------
00022 MultipleScatteringGeometry::MultipleScatteringGeometry(const edm::EventSetup &iSetup)
00023 {
00024 
00025   edm::ESHandle<GeometricSearchTracker> track;
00026   iSetup.get<TrackerRecoGeometryRecord>().get( track ); 
00027 
00028   vector<BarrelDetLayer*> barrelLayers=track->barrelLayers();
00029   vector<BarrelDetLayer*>::const_iterator ib;
00030   vector<ForwardDetLayer*> forwardPosLayers=track->posForwardLayers();
00031   vector<ForwardDetLayer*> forwardNegLayers=track->negForwardLayers();
00032   vector<ForwardDetLayer*>::const_iterator ie;
00033   // barrelLayers = accessor.barrelLayers();
00034   for (ib = barrelLayers.begin(); ib != barrelLayers.end(); ib++)
00035     theLayers.push_back(*ib);
00036 
00037 //   forwardLayers = accessor.negativeEndcapLayers();
00038   for (ie = forwardPosLayers.begin(); ie != forwardPosLayers.end(); ie++)
00039     theLayers.push_back(*ie);
00040   for (ie = forwardNegLayers.begin(); ie != forwardNegLayers.end(); ie++)
00041     theLayers.push_back(*ie);
00042 
00043 }
00044 
00045 //------------------------------------------------------------------------------
00046 vector<MSLayer> MultipleScatteringGeometry::detLayers(const edm::EventSetup &iSetup) const
00047 {
00048   vector<MSLayer> result;
00049   vector<const DetLayer*>::const_iterator il;
00050   for (il=theLayers.begin();il!=theLayers.end();il++) result.push_back(MSLayer(*il)); 
00051   return result;
00052 }
00053     
00054 //------------------------------------------------------------------------------
00055 vector<MSLayer> MultipleScatteringGeometry::detLayers(float eta, float z,const edm::EventSetup &iSetup) const
00056 {
00057   vector<MSLayer> result;
00058   GlobalPoint zero(0,0,z);
00059   float r=1; float dirZ = r*sinh(eta);
00060   GlobalVector dir(r,0.,dirZ);
00061   edm::ESHandle<MagneticField> pSetup;
00062   iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
00063   FreeTrajectoryState fts( GlobalTrajectoryParameters(zero,dir,1,&(*pSetup)) );
00064   StraightLinePropagator propagator(&(*pSetup),alongMomentum);
00065   vector<const DetLayer*>::const_iterator il;
00066   TrajectoryStateOnSurface tsos;
00067   for (il = theLayers.begin(); il != theLayers.end(); il++) {
00068     bool contains=false;
00069 //  if ((*il)->subDetector() != PixelBarrel && (*il)->subDetector()!= PixelEndcap) continue;
00070 
00071     if ( (*il)->location() == barrel ) {
00072       const BarrelDetLayer * bl = dynamic_cast<const BarrelDetLayer*>(*il);
00073       if (!bl) continue;
00074       tsos = propagator.propagate(fts, bl->specificSurface());
00075       if (!tsos.isValid()) continue;
00076       float r=bl->specificSurface().radius();
00077       float dr = bl->specificSurface().bounds().thickness();
00078       float z=bl->position().z();
00079       float dz = bl->specificSurface().bounds().length(); 
00080       PixelRecoRange<float> rRange(r-dr/2., r+dr/2.);
00081       PixelRecoRange<float> zRange(z-dz/2., z+dz/2.);
00082       contains =    rRange.inside(tsos.globalPosition().perp()) 
00083                  && zRange.inside(tsos.globalPosition().z());
00084       //     contains = bl->contains((*il)->toLocal(tsos.globalPosition()));
00085     }
00086     else if ((*il)->location() == endcap) {
00087       const ForwardDetLayer * fl = dynamic_cast<const ForwardDetLayer*>(*il);
00088       if (!fl) continue;
00089       if (fl->position().z() * eta < 0) continue;
00090       const BoundDisk & disk = fl->specificSurface();
00091       tsos = propagator.propagate(fts, disk);
00092       if (!tsos.isValid()) continue;
00093       float zMin = disk.position().z()-disk.bounds().thickness()/2;
00094       float zMax = disk.position().z()+disk.bounds().thickness()/2;
00095       PixelRecoRange<float> rRange(disk.innerRadius(), disk.outerRadius());
00096       PixelRecoRange<float> zRange(zMin, zMax);
00097       contains = rRange.inside(tsos.globalPosition().perp()) 
00098               && zRange.inside(tsos.globalPosition().z());
00099       //     contains = fl->contains(fl->toLocal(tsos.globalPosition()));
00100     }
00101     if (contains) result.push_back(MSLayer(*il));
00102   }
00103   return result;
00104 }
00105 //------------------------------------------------------------------------------
00106 vector<MSLayer> MultipleScatteringGeometry::otherLayers(float eta,const edm::EventSetup &iSetup) const
00107 {
00108   vector<MSLayer> result;
00109   // zero
00110   //  MSLayer zero(barrel, 0., MSLayer::Range(-15,15));
00111   //  result.push_back(zero);
00112 
00113   // beampipe
00114   MSLayer beampipe(barrel, beamPipeR, MSLayer::Range(-100,100));
00115 
00116   result.push_back(beampipe);
00117 
00118   // endflanges
00119   PixelRecoPointRZ endfPoint = (eta > 0) ?
00120       PixelRecoPointRZ(endflangesZ/sinh(eta), endflangesZ)
00121     : PixelRecoPointRZ(-endflangesZ/sinh(eta), -endflangesZ);
00122   if (0 < endfPoint.r() && endfPoint.r() < supportR) {
00123     MSLayer endflanges(endcap,endfPoint.z(),MSLayer::Range(0.1,supportR-0.1));
00124     result.push_back(endflanges);
00125   }
00126 
00127   // support
00128   MSLayer support( barrel,supportR, MSLayer::Range(-280,280));
00129   result.push_back(support);
00130 
00131   return result;
00132 }
00133 
00134   
00135