CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CalibTracker/SiStripCommon/src/ShallowTools.cc

Go to the documentation of this file.
00001 
00002 #include "CalibTracker/SiStripCommon/interface/ShallowTools.h"
00003 
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00006 #include "MagneticField/Engine/interface/MagneticField.h"
00007 #include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h"
00008 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00009 #include "boost/foreach.hpp"
00010 
00011 
00012 namespace shallow {
00013 
00014 CLUSTERMAP 
00015 make_cluster_map( const edm::Event& iEvent, edm::InputTag& clusterLabel) {
00016   CLUSTERMAP clustermap;
00017   edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusters;
00018   iEvent.getByLabel(clusterLabel, clusters);
00019   
00020   unsigned int clusterindex = 0;  
00021   BOOST_FOREACH(const edmNew::DetSet<SiStripCluster>& ds, *clusters)
00022     BOOST_FOREACH(const SiStripCluster& cluster, ds)
00023     clustermap.insert( std::make_pair( std::make_pair(ds.detId(),cluster.firstStrip()),
00024                                        clusterindex++));
00025   return clustermap;
00026 }
00027 
00028 int 
00029 findTrackIndex(const edm::Handle<edm::View<reco::Track> >& tracks, const reco::Track* track) {
00030   edm::View<reco::Track>::const_iterator
00031     it = tracks->begin(),
00032     end = tracks->end();
00033   //Compare addresses
00034   for(; it!=end; it++) {    if (&(*it)==track) { return it - tracks->begin(); }  }
00035   return -2;
00036 }
00037 
00038 LocalVector 
00039 drift( const StripGeomDetUnit* stripDet, const MagneticField& magfield, const SiStripLorentzAngle& lorentzAngle ) {
00040   LocalVector lbfield=( stripDet->surface()).toLocal( magfield.inTesla(stripDet->surface().position()));
00041   float tanLorentzAnglePerTesla = lorentzAngle.getLorentzAngle(stripDet->geographicalId());  
00042   float driftz = stripDet->specificSurface().bounds().thickness();
00043   float driftx =-tanLorentzAnglePerTesla * lbfield.y() * driftz;
00044   float drifty = tanLorentzAnglePerTesla * lbfield.x() * driftz;
00045   return LocalVector(driftx,drifty,driftz);
00046 }
00047 
00048 }