File indexing completed on 2024-04-06 11:59:48
0001 #include "CalibTracker/SiStripCommon/interface/ShallowTools.h"
0002
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0005 #include "MagneticField/Engine/interface/MagneticField.h"
0006 #include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h"
0007 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
0008
0009 namespace shallow {
0010
0011 CLUSTERMAP
0012 make_cluster_map(const edm::Event& iEvent,
0013 const edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> >& cluster_token) {
0014 CLUSTERMAP clustermap;
0015 edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusters;
0016 iEvent.getByToken(cluster_token, clusters);
0017
0018 unsigned int clusterindex = 0;
0019 for (auto const& ds : *clusters)
0020 for (auto const& cluster : ds)
0021 clustermap.insert(std::make_pair(std::make_pair(ds.detId(), cluster.firstStrip()), clusterindex++));
0022 return clustermap;
0023 }
0024
0025 int findTrackIndex(const edm::Handle<edm::View<reco::Track> >& tracks, const reco::Track* track) {
0026 edm::View<reco::Track>::const_iterator it = tracks->begin(), end = tracks->end();
0027
0028 for (; it != end; it++) {
0029 if (&(*it) == track) {
0030 return it - tracks->begin();
0031 }
0032 }
0033 return -2;
0034 }
0035
0036 LocalVector drift(const StripGeomDetUnit* stripDet,
0037 const MagneticField& magfield,
0038 const SiStripLorentzAngle& lorentzAngle) {
0039 LocalVector lbfield = (stripDet->surface()).toLocal(magfield.inTesla(stripDet->surface().position()));
0040 float tanLorentzAnglePerTesla = lorentzAngle.getLorentzAngle(stripDet->geographicalId());
0041 float driftz = stripDet->specificSurface().bounds().thickness();
0042 float driftx = -tanLorentzAnglePerTesla * lbfield.y() * driftz;
0043 float drifty = tanLorentzAnglePerTesla * lbfield.x() * driftz;
0044 return LocalVector(driftx, drifty, driftz);
0045 }
0046
0047 }