File indexing completed on 2023-10-25 09:56:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "L1Trigger/TrackTrigger/interface/TTStubAlgorithm_official.h"
0012
0013
0014 template <>
0015 void TTStubAlgorithm_official<Ref_Phase2TrackerDigi_>::PatternHitCorrelation(
0016 bool& aConfirmation,
0017 int& aDisplacement,
0018 int& anOffset,
0019 float& anHardBend,
0020 const TTStub<Ref_Phase2TrackerDigi_>& aTTStub) const {
0021
0022
0023 MeasurementPoint mp0 = aTTStub.clusterRef(0)->findAverageLocalCoordinates();
0024 MeasurementPoint mp1 = aTTStub.clusterRef(1)->findAverageLocalCoordinates();
0025
0026 bool isPS = aTTStub.moduleTypePS();
0027
0028
0029
0030 DetId stDetId(aTTStub.getDetId());
0031 const GeomDetUnit* det0 = theTrackerGeom_->idToDetUnit(stDetId + 1);
0032 const GeomDetUnit* det1 = theTrackerGeom_->idToDetUnit(stDetId + 2);
0033
0034
0035 const PixelGeomDetUnit* pix0 = dynamic_cast<const PixelGeomDetUnit*>(det0);
0036 const PixelGeomDetUnit* pix1 = dynamic_cast<const PixelGeomDetUnit*>(det1);
0037 const PixelTopology* top0 = dynamic_cast<const PixelTopology*>(&(pix0->specificTopology()));
0038 const PixelTopology* top1 = dynamic_cast<const PixelTopology*>(&(pix1->specificTopology()));
0039 std::pair<float, float> pitch0 = top0->pitch();
0040 std::pair<float, float> pitch1 = top1->pitch();
0041
0042
0043 int cols0 = top0->ncolumns();
0044 int cols1 = top1->ncolumns();
0045 int ratio = cols0 / cols1;
0046 int segment0 = floor(mp0.y() / ratio);
0047
0048
0049 if (!isPS) {
0050 if (mPerformZMatching2S && (segment0 != floor(mp1.y())))
0051 return;
0052 } else
0053 {
0054 if (mPerformZMatchingPS && (segment0 != floor(mp1.y())))
0055 return;
0056 }
0057
0058
0059 double R0 = det0->position().perp();
0060 double R1 = det1->position().perp();
0061 double Z0 = det0->position().z();
0062 double Z1 = det1->position().z();
0063
0064 double DR = R1 - R0;
0065 double DZ = Z1 - Z0;
0066
0067 double alpha = atan2(DR, DZ);
0068 double delta = sqrt(DR * DR + DZ * DZ) / (R0 * sin(alpha) + Z0 * cos(alpha));
0069
0070 int window = 0;
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 double dispD = 2 * (mp1.x() - mp0.x()) * (pitch0.first / pitch1.first);
0088 int dispI = ((dispD > 0) - (dispD < 0)) * floor(std::abs(dispD));
0089
0090
0091
0092
0093
0094
0095 double offsetD = 2 * delta * (mp0.x() - (top0->nrows() / 2 - 0.5)) * (pitch0.first / pitch1.first);
0096 int offsetI = ((offsetD > 0) - (offsetD < 0)) * floor(std::abs(offsetD));
0097
0098 if (stDetId.subdetId() == StripSubdetector::TOB) {
0099 int layer = theTrackerTopo_->layer(stDetId);
0100 int ladder = theTrackerTopo_->tobRod(stDetId);
0101 int type = 2 * theTrackerTopo_->tobSide(stDetId) - 3;
0102 double corr = 0;
0103
0104 if (type < 3)
0105 {
0106 corr = (barrelNTilt.at(layer) + 1) / 2.;
0107
0108 ladder = corr - (corr - ladder) * type;
0109 window = 2 * (tiltedCut.at(layer)).at(ladder);
0110 } else
0111 {
0112 window = 2 * barrelCut.at(layer);
0113 }
0114
0115 } else if (stDetId.subdetId() == StripSubdetector::TID) {
0116 window = 2 * (ringCut.at(theTrackerTopo_->tidWheel(stDetId))).at(theTrackerTopo_->tidRing(stDetId));
0117 }
0118
0119
0120 if (std::abs(dispI - offsetI) <= window)
0121 {
0122 aConfirmation = true;
0123 aDisplacement = dispI;
0124 anOffset = offsetI;
0125 anHardBend = this->degradeBend(isPS, window, (aDisplacement - anOffset));
0126 }
0127 }
0128
0129
0130 template <>
0131 float TTStubAlgorithm_official<Ref_Phase2TrackerDigi_>::degradeBend(bool psModule, int window, int bend) const {
0132
0133 const unsigned int bitsPS_ = 3;
0134 const unsigned int bits2S_ = 4;
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 float degradedB;
0146 unsigned int numBends = 2 * window + 1;
0147 unsigned int numAllowed = (psModule) ? pow(2, bitsPS_) : pow(2, bits2S_);
0148
0149
0150 numAllowed -= 1;
0151 if (numBends <= numAllowed) {
0152
0153 degradedB = static_cast<double>(bend);
0154 } else
0155 {
0156 unsigned int inSmallGroup = numBends / numAllowed;
0157 unsigned int numLargeGroups = numBends % numAllowed;
0158 unsigned int inLargeGroup = inSmallGroup + 1;
0159 unsigned int numSmallGroups = numAllowed - numLargeGroups;
0160
0161 std::vector<unsigned int> groups;
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172 for (unsigned int i = 0; i < numLargeGroups / 2; i++)
0173 groups.push_back(inLargeGroup);
0174 for (unsigned int i = 0; i < numSmallGroups / 2; i++)
0175 groups.push_back(inSmallGroup);
0176
0177
0178
0179 if (numLargeGroups % 2 == 1 && inLargeGroup % 2 == 1) {
0180 groups.push_back(inLargeGroup);
0181 } else if (numSmallGroups % 2 == 1 && inSmallGroup % 2 == 1) {
0182 groups.push_back(inSmallGroup);
0183 } else {
0184 throw cms::Exception("DegradeBend: logic error with odd numbers");
0185 }
0186
0187 for (unsigned int i = 0; i < numSmallGroups / 2; i++)
0188 groups.push_back(inSmallGroup);
0189 for (unsigned int i = 0; i < numLargeGroups / 2; i++)
0190 groups.push_back(inLargeGroup);
0191
0192 degradedB = 999;
0193 int iUp = -static_cast<int>(window) - 1;
0194 int iDown;
0195
0196 for (unsigned int& inGroup : groups) {
0197 iUp += inGroup;
0198 iDown = iUp - inGroup + 1;
0199 if (bend <= iUp && bend >= iDown) {
0200 degradedB = 0.5 * (iUp + iDown);
0201 }
0202 }
0203 if (degradedB == 999)
0204 throw cms::Exception(
0205 "DegradeStubResolution: error in the group creation, method has been called with wrong inputs");
0206 }
0207
0208
0209 return static_cast<float>(degradedB) / 2.;
0210 }
0211
0212