CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoLocalTracker/SiStripRecHitConverter/src/StripCPE.cc

Go to the documentation of this file.
00001 #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h"
00002 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00003 #include "Geometry/CommonTopologies/interface/RadialStripTopology.h"
00004 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
00005 #include "boost/bind.hpp"
00006 #include "boost/lambda/lambda.hpp"
00007 #include <algorithm>
00008 #include<cmath>
00009 
00010 StripCPE::StripCPE( edm::ParameterSet & conf, 
00011                     const MagneticField& mag, 
00012                     const TrackerGeometry& geom, 
00013                     const SiStripLorentzAngle& LorentzAngle,
00014                     const SiStripConfObject& confObj,
00015                     const SiStripLatency& latency)
00016   : peakMode_(latency.singleReadOutMode() == 1),
00017     geom_(geom),
00018     magfield_(mag),
00019     LorentzAngleMap_(LorentzAngle)
00020 {
00021   typedef std::map<std::string,SiStripDetId::ModuleGeometry> map_t;
00022   map_t modules;
00023   modules["IB1"]=SiStripDetId::IB1;  
00024   modules["IB2"]=SiStripDetId::IB2;
00025   modules["OB1"]=SiStripDetId::OB1;  
00026   modules["OB2"]=SiStripDetId::OB2;
00027   modules["W1A"]=SiStripDetId::W1A;    
00028   modules["W2A"]=SiStripDetId::W2A;  
00029   modules["W3A"]=SiStripDetId::W3A;  
00030   modules["W1B"]=SiStripDetId::W1B;
00031   modules["W2B"]=SiStripDetId::W2B;
00032   modules["W3B"]=SiStripDetId::W3B;
00033   modules["W4"] =SiStripDetId::W4;
00034   modules["W5"] =SiStripDetId::W5;
00035   modules["W6"] =SiStripDetId::W6;
00036   modules["W7"] =SiStripDetId::W7;
00037   
00038   const unsigned size = max_element( modules.begin(),modules.end(),
00039                                      boost::bind(&map_t::value_type::second,boost::lambda::_1) < 
00040                                      boost::bind(&map_t::value_type::second,boost::lambda::_2) )->second + 1;
00041   shift.resize(size);
00042   xtalk1.resize(size);
00043   xtalk2.resize(size);
00044 
00045   for(map_t::const_iterator it=modules.begin(); it!=modules.end(); it++) {
00046     const std::string 
00047       modeS(peakMode_?"Peak":"Deco"),
00048       shiftS( "shift_"  + it->first + modeS ),
00049       xtalk1S("xtalk1_" + it->first + modeS ),
00050       xtalk2S("xtalk2_" + it->first + modeS );
00051 
00052     if(!confObj.isParameter(shiftS)) throw cms::Exception("SiStripConfObject does not contain: ") << shiftS;
00053     if(!confObj.isParameter(xtalk1S)) throw cms::Exception("SiStripConfObject does not contain: ") << xtalk1S;
00054     if(!confObj.isParameter(xtalk2S)) throw cms::Exception("SiStripConfObject does not contain: ") << xtalk2S;
00055 
00056     shift[it->second] = confObj.get<double>(shiftS);
00057     xtalk1[it->second] = confObj.get<double>(xtalk1S);
00058     xtalk2[it->second] = confObj.get<double>(xtalk2S);
00059   }
00060 }
00061 
00062 StripClusterParameterEstimator::LocalValues StripCPE::
00063 localParameters( const SiStripCluster& cluster) const {
00064   StripCPE::Param const & p = param(cluster.geographicalId());
00065   const float barycenter = cluster.barycenter();
00066   const float fullProjection = p.coveredStrips( p.drift + LocalVector(0,0,-p.thickness), LocalPoint(barycenter,0,0));
00067   const float strip = barycenter - 0.5 * (1-shift[p.moduleGeom]) * fullProjection;
00068 
00069   return std::make_pair( p.topology->localPosition(strip),
00070                          p.topology->localError(strip, 1/12.) );
00071 }
00072 
00073 float StripCPE::Param::
00074 coveredStrips(const LocalVector& lvec, const LocalPoint& lpos) const {  
00075   return 
00076     topology->measurementPosition(lpos + 0.5*lvec).x() 
00077     - topology->measurementPosition(lpos - 0.5*lvec).x();
00078 }
00079 
00080 LocalVector StripCPE::
00081 driftDirection(const StripGeomDetUnit* det) const { 
00082   LocalVector lbfield = (det->surface()).toLocal(magfield_.inTesla(det->surface().position()));  
00083   
00084   float tanLorentzAnglePerTesla = LorentzAngleMap_.getLorentzAngle(det->geographicalId().rawId());
00085   
00086   float dir_x = -tanLorentzAnglePerTesla * lbfield.y();
00087   float dir_y =  tanLorentzAnglePerTesla * lbfield.x();
00088   float dir_z =  1.; // E field always in z direction
00089   
00090   return LocalVector(dir_x,dir_y,dir_z);
00091 }
00092 
00093 StripCPE::Param const & StripCPE::
00094 param(const uint32_t detid) const {
00095   Param & p = const_cast<StripCPE*>(this)->m_Params[detid];
00096   if (p.topology) return p;
00097   else return const_cast<StripCPE*>(this)->fillParam(p, geom_.idToDetUnit(detid));
00098 }
00099 
00100 StripCPE::Param & StripCPE::
00101 fillParam(StripCPE::Param & p, const GeomDetUnit *  det) {  
00102   const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
00103   const Bounds& bounds = stripdet->specificSurface().bounds();
00104   
00105   p.maxLength = std::sqrt( std::pow(bounds.length(),2)+std::pow(bounds.width(),2) );
00106   p.thickness = bounds.thickness();
00107   p.drift = driftDirection(stripdet) * p.thickness;
00108   p.topology=(StripTopology*)(&stripdet->topology());    
00109   p.nstrips = p.topology->nstrips(); 
00110   p.moduleGeom = SiStripDetId(stripdet->geographicalId()).moduleGeometry();
00111   
00112   const RadialStripTopology* rtop = dynamic_cast<const RadialStripTopology*>(&stripdet->specificType().specificTopology());
00113   p.pitch_rel_err2 = (rtop) 
00114     ? pow( 0.5 * rtop->angularWidth() * rtop->stripLength()/rtop->localPitch(LocalPoint(0,0,0)), 2) / 12.
00115     : 0;
00116   
00117   return p;
00118 }