Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:23

0001 #include "L1Trigger/L1TTrackMatch/interface/pTFrom2Stubs.h"
0002 #include "DataFormats/Math/interface/deltaPhi.h"
0003 #include "Geometry/CommonTopologies/interface/Topology.h"
0004 #include <cassert>
0005 #include <cmath>
0006 #include <iostream>
0007 #include <memory>
0008 
0009 static constexpr float local_c_light = 0.00299792;
0010 static constexpr float B_field = 3.8;
0011 
0012 namespace pTFrom2Stubs {
0013 
0014   //====================

0015   float rInvFrom2(std::vector<TTTrack<Ref_Phase2TrackerDigi_> >::const_iterator trk,
0016                   const TrackerGeometry* tkGeometry) {
0017     //vector of R, r and phi for each stub

0018     std::vector<std::vector<float> > riPhiStubs(0);
0019     //get stub reference

0020     std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
0021         vecStubRefs = trk->getStubRefs();
0022 
0023     //loop over L1Track's stubs

0024     int rsize = vecStubRefs.size();
0025     for (int j = 0; j < rsize; ++j) {
0026       edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > stubRef =
0027           vecStubRefs.at(j);
0028       const TTStub<Ref_Phase2TrackerDigi_>* stub = &(*stubRef);
0029       MeasurementPoint localPos = stub->clusterRef(0)->findAverageLocalCoordinates();
0030 
0031       DetId detid = stub->clusterRef(0)->getDetId();
0032 
0033       if (detid.det() != DetId::Detector::Tracker)
0034         continue;
0035       if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID)
0036         continue;
0037       const GeomDet* geomDet = tkGeometry->idToDet(detid);
0038       if (geomDet) {
0039         const GeomDetUnit* gDetUnit = tkGeometry->idToDetUnit(detid);
0040         GlobalPoint stubPosition = geomDet->surface().toGlobal(gDetUnit->topology().localPosition(localPos));
0041 
0042         std::vector<float> tmp(0);
0043         float Rad = sqrt(stubPosition.x() * stubPosition.x() + stubPosition.y() * stubPosition.y() + stubPosition.z() +
0044                          stubPosition.z());
0045         float r_i = sqrt(stubPosition.x() * stubPosition.x() + stubPosition.y() * stubPosition.y());
0046         float phi_i = stubPosition.phi();
0047 
0048         tmp.push_back(Rad);
0049         tmp.push_back(r_i);
0050         tmp.push_back(phi_i);
0051 
0052         riPhiStubs.push_back(tmp);
0053       }
0054     }
0055 
0056     std::sort(riPhiStubs.begin(), riPhiStubs.end());
0057     //now calculate the curvature from first 2 stubs

0058     float nr1 = (riPhiStubs[0])[1];
0059     float nphi1 = (riPhiStubs[0])[2];
0060 
0061     float nr2 = (riPhiStubs[1])[1];
0062     float nphi2 = (riPhiStubs[1])[2];
0063 
0064     float dPhi = reco::deltaPhi(nphi1, nphi2);
0065 
0066     float ndist = sqrt(nr2 * nr2 + nr1 * nr1 - 2 * nr1 * nr2 * cos(dPhi));
0067 
0068     float curvature = 2 * sin(dPhi) / ndist;
0069     return curvature;
0070   }
0071   //====================

0072   float pTFrom2(std::vector<TTTrack<Ref_Phase2TrackerDigi_> >::const_iterator trk, const TrackerGeometry* tkGeometry) {
0073     float rinv = rInvFrom2(trk, tkGeometry);
0074     return std::abs(local_c_light * B_field / rinv);
0075   }
0076   //====================

0077 }  // namespace pTFrom2Stubs