00001 #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h"
00002 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00003
00004 #include <algorithm>
00005 #include<cmath>
00006
00007
00008 StripCPE::Param & StripCPE::fillParam(StripCPE::Param & p, const GeomDetUnit * det) {
00009
00010 const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
00011 p.topology=(StripTopology*)(&stripdet->topology());
00012
00013 p.drift = driftDirection(stripdet);
00014
00015 p.thickness=stripdet->specificSurface().bounds().thickness();
00016 p.drift*=p.thickness;
00017
00018
00019
00020
00021
00022 const Bounds& bounds = stripdet->surface().bounds();
00023
00024 p.maxLength = std::sqrt( std::pow(bounds.length(),2)+std::pow(bounds.width(),2) );
00025
00026
00027
00028
00029 p.nstrips = p.topology->nstrips();
00030 return p;
00031 }
00032
00033
00034
00035 StripCPE::Param const & StripCPE::param(DetId detId) const {
00036 Param & p = const_cast<StripCPE*>(this)->m_Params[detId.rawId()];
00037 if (p.topology) return p;
00038 else return const_cast<StripCPE*>(this)->fillParam(p, geom_->idToDetUnit(detId));
00039 }
00040
00041
00042
00043 StripCPE::StripCPE(edm::ParameterSet & conf, const MagneticField * mag, const TrackerGeometry* geom, const SiStripLorentzAngle* LorentzAngle)
00044 {
00045 magfield_ = mag;
00046 geom_ = geom;
00047 LorentzAngleMap_=LorentzAngle;
00048 }
00049
00050 StripClusterParameterEstimator::LocalValues StripCPE::localParameters( const SiStripCluster & cl)const {
00051
00052
00053
00054
00055 StripCPE::Param const & p = param(DetId(cl.geographicalId()));
00056
00057 const StripTopology &topol= *(p.topology);
00058
00059 LocalPoint position = topol.localPosition(cl.barycenter());
00060 LocalError eresult = topol.localError(cl.barycenter(),1/12.);
00061
00062 LocalPoint result=LocalPoint(position.x()-0.5*p.drift.x(),position.y()-0.5*p.drift.y(),0);
00063 return std::make_pair(result,eresult);
00064 }
00065
00066 LocalVector StripCPE::driftDirection(const StripGeomDetUnit* det)const{
00067
00068 LocalVector lbfield=(det->surface()).toLocal(magfield_->inTesla(det->surface().position()));
00069
00070 float tanLorentzAnglePerTesla=LorentzAngleMap_->getLorentzAngle(det->geographicalId().rawId());
00071
00072
00073 float dir_x =-tanLorentzAnglePerTesla * lbfield.y();
00074 float dir_y =tanLorentzAnglePerTesla * lbfield.x();
00075 float dir_z = 1.;
00076
00077 LocalVector theDrift = LocalVector(dir_x,dir_y,dir_z);
00078
00079 return theDrift;
00080
00081 }