File indexing completed on 2024-04-06 12:22:00
0001
0002 #include "L1Trigger/TrackFindingTracklet/interface/Projection.h"
0003 #include "L1Trigger/TrackFindingTracklet/interface/Settings.h"
0004
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <algorithm>
0007
0008 using namespace std;
0009 using namespace trklet;
0010
0011 void Projection::init(Settings const& settings,
0012 unsigned int layerdisk,
0013 int iphiproj,
0014 int irzproj,
0015 int iphider,
0016 int irzder,
0017 double phiproj,
0018 double rzproj,
0019 double phiprojder,
0020 double rzprojder,
0021 double phiprojapprox,
0022 double rzprojapprox,
0023 double phiprojderapprox,
0024 double rzprojderapprox,
0025 bool isPSseed) {
0026 assert(layerdisk < N_LAYER + N_DISK);
0027
0028 valid_ = true;
0029
0030 fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__);
0031
0032 if (layerdisk < N_LAYER) {
0033 fpgarzproj_.set(irzproj, settings.nzbitsstub(layerdisk), false, __LINE__, __FILE__);
0034 } else {
0035 fpgarzproj_.set(irzproj, settings.nrbitsstub(layerdisk), false, __LINE__, __FILE__);
0036 }
0037
0038 if (layerdisk < N_LAYER) {
0039 if (layerdisk < N_PSLAYER) {
0040 fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__);
0041 fpgarzprojder_.set(irzder, settings.nbitszprojderL123(), false, __LINE__, __FILE__);
0042 } else {
0043 fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL456(), false, __LINE__, __FILE__);
0044 fpgarzprojder_.set(irzder, settings.nbitszprojderL456(), false, __LINE__, __FILE__);
0045 }
0046 } else {
0047 fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__);
0048 fpgarzprojder_.set(irzder, settings.nrbitsprojderdisk(), false, __LINE__, __FILE__);
0049 }
0050
0051 if (layerdisk < N_LAYER) {
0052
0053
0054
0055
0056 int offset = isPSseed ? 1 : 4;
0057
0058 int ztemp = fpgarzproj_.value() >> (fpgarzproj_.nbits() - settings.MEBinsBits() - NFINERZBITS);
0059 unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp - offset) >> NFINERZBITS);
0060 unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp + offset) >> NFINERZBITS);
0061
0062 if (zbin1 >= settings.MEBins()) {
0063 zbin1 = 0;
0064 }
0065 if (zbin2 >= settings.MEBins()) {
0066 zbin2 = settings.MEBins() - 1;
0067 }
0068
0069 assert(zbin1 <= zbin2);
0070 assert(zbin2 - zbin1 <= 1);
0071
0072 fpgarzbin1projvm_.set(zbin1, settings.MEBinsBits(), true, __LINE__, __FILE__);
0073
0074 int nextbin = zbin1 != zbin2;
0075 fpgarzbin2projvm_.set(nextbin, 1, true, __LINE__, __FILE__);
0076
0077
0078 int finez = ((1 << (settings.MEBinsBits() + NFINERZBITS - 1)) + ztemp) - (zbin1 << NFINERZBITS);
0079
0080 fpgafinerzvm_.set(finez, NFINERZBITS + 1, true, __LINE__, __FILE__);
0081
0082 } else {
0083
0084
0085 double roffset = 3.0;
0086 int rbin1 = 8.0 * (irzproj * settings.krprojshiftdisk() - roffset - settings.rmindiskvm()) /
0087 (settings.rmaxdisk() - settings.rmindiskvm());
0088 int rbin2 = 8.0 * (irzproj * settings.krprojshiftdisk() + roffset - settings.rmindiskvm()) /
0089 (settings.rmaxdisk() - settings.rmindiskvm());
0090
0091 if (rbin1 < 0) {
0092 rbin1 = 0;
0093 }
0094 rbin2 = clamp(rbin2, 0, 7);
0095
0096 assert(rbin1 <= rbin2);
0097 assert(rbin2 - rbin1 <= 1);
0098
0099 int finer = 64 *
0100 ((irzproj * settings.krprojshiftdisk() - settings.rmindiskvm()) -
0101 rbin1 * (settings.rmaxdisk() - settings.rmindiskvm()) / 8.0) /
0102 (settings.rmaxdisk() - settings.rmindiskvm());
0103
0104 finer = clamp(finer, 0, 15);
0105
0106 int diff = rbin1 != rbin2;
0107 if (irzder < 0)
0108 rbin1 += 8;
0109
0110 fpgarzbin1projvm_.set(rbin1, 4, true, __LINE__, __FILE__);
0111 fpgarzbin2projvm_.set(diff, 1, true, __LINE__, __FILE__);
0112
0113 fpgafinerzvm_.set(finer, 4, true, __LINE__, __FILE__);
0114 }
0115
0116
0117 int projfinephi =
0118 (fpgaphiproj_.value() >>
0119 (fpgaphiproj_.nbits() - (settings.nbitsallstubs(layerdisk) + settings.nbitsvmme(layerdisk) + NFINEPHIBITS))) &
0120 ((1 << NFINEPHIBITS) - 1);
0121 fpgafinephivm_.set(projfinephi, NFINEPHIBITS, true, __LINE__, __FILE__);
0122
0123 phiproj_ = phiproj;
0124 rzproj_ = rzproj;
0125 phiprojder_ = phiprojder;
0126 rzprojder_ = rzprojder;
0127
0128 phiprojapprox_ = phiprojapprox;
0129 rzprojapprox_ = rzprojapprox;
0130 phiprojderapprox_ = phiprojderapprox;
0131 rzprojderapprox_ = rzprojderapprox;
0132 }