File indexing completed on 2024-07-16 02:43:05
0001 #include "L1Trigger/Phase2L1GMT/interface/TrackConverter.h"
0002
0003 using namespace Phase2L1GMT;
0004
0005 TrackConverter::TrackConverter(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter<int>("verbose")) {}
0006
0007 std::vector<ConvertedTTTrack> TrackConverter::convertTracks(
0008 const std::vector<edm::Ptr<l1t::TrackerMuon::L1TTTrackType> >& tracks) {
0009 std::vector<ConvertedTTTrack> out;
0010 out.reserve(tracks.size());
0011 for (const auto& t : tracks)
0012 out.push_back(convert(t));
0013 return out;
0014 }
0015
0016 ConvertedTTTrack TrackConverter::convert(const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> >& track) {
0017 uint charge = (track->rInv() < 0) ? 1 : 0;
0018 ap_int<BITSTTCURV> curvature = ap_int<BITSTTCURV>(track->getRinvBits());
0019 ap_int<BITSPHI> phisec = ap_int<BITSPHI>(ap_int<BITSTTPHI>(track->getPhiBits()) / 2);
0020 ap_int<BITSTTTANL> tanLambda = ap_int<BITSTTTANL>(track->getTanlBits());
0021 ap_int<BITSZ0> z0 = ap_int<BITSZ0>(ap_int<BITSTTZ0>(track->getZ0Bits()) / (1 << (BITSTTZ0 - BITSZ0)));
0022 ap_int<BITSD0> d0 = ap_int<BITSD0>(ap_int<BITSTTD0>(track->getD0Bits()) / (1 << (BITSTTD0 - BITSD0)));
0023
0024 ap_uint<BITSTTCURV - 1> absCurv =
0025 curvature > 0 ? ap_uint<BITSTTCURV - 1>(curvature) : ap_uint<BITSTTCURV - 1>(-curvature);
0026 ap_uint<BITSPT> pt = ptLUT[ptLookup(absCurv)];
0027 ap_uint<1> quality = generateQuality(track);
0028 ap_uint<BITSTTTANL - 1> absTanL =
0029 tanLambda > 0 ? ap_uint<BITSTTTANL - 1>(tanLambda) : ap_uint<BITSTTTANL - 1>(-tanLambda);
0030 ap_uint<BITSETA - 1> absEta = etaLUT[etaLookup(absTanL)];
0031 ap_int<BITSETA> eta = tanLambda > 0 ? ap_int<BITSETA>(absEta) : ap_int<BITSETA>(-absEta);
0032
0033 ap_int<BITSPHI> phi = ap_int<BITSPHI>(phisec + track->phiSector() * 910);
0034
0035 wordtype word = 0;
0036 int bstart = 0;
0037 bstart = wordconcat<wordtype>(word, bstart, curvature, BITSTTCURV);
0038 bstart = wordconcat<wordtype>(word, bstart, phi, BITSPHI);
0039 bstart = wordconcat<wordtype>(word, bstart, tanLambda, BITSTTTANL);
0040 bstart = wordconcat<wordtype>(word, bstart, z0, BITSZ0);
0041 bstart = wordconcat<wordtype>(word, bstart, d0, BITSD0);
0042 bstart = wordconcat<wordtype>(word, bstart, uint(track->chi2()), 4);
0043
0044 ConvertedTTTrack convertedTrack(charge, curvature, absEta, pt, eta, phi, z0, d0, quality, word);
0045 convertedTrack.setOfflineQuantities(LSBpt * pt, LSBeta * eta, LSBphi * phi);
0046 if (verbose_)
0047 convertedTrack.print();
0048 convertedTrack.setTrkPtr(track);
0049 return convertedTrack;
0050 }