23 for (
const auto&
module : inputEDstubs) {
31 DetId lowerDetid = thisStackedDetId + 1;
32 DetId upperDetid = thisStackedDetId + 2;
44 for (
const auto& stub : theseStubs) {
50 lowerClusterToBeReplaced = stub.clusterRef(0);
52 upperClusterToBeReplaced = stub.clusterRef(1);
57 for (clusterIter = lowerClusters.
begin(); clusterIter != lowerClusters.
end() && !lowerOK; ++clusterIter) {
58 if (clusterIter->getHits() == lowerClusterToBeReplaced->getHits()) {
64 for (clusterIter = upperClusters.
begin(); clusterIter != upperClusters.
end() && !upperOK; ++clusterIter) {
65 if (clusterIter->getHits() == upperClusterToBeReplaced->getHits()) {
72 if (!lowerOK || !upperOK)
76 tempTTStub.setRawBend(2. * stub.rawBend());
77 tempTTStub.setBendOffset(2. * stub.bendOffset());
78 tempTTStub.setBendBE(stub.bendBE());
79 tempTTStub.setModuleTypePS(stub.moduleTypePS());
99 auto ttClusterDSVForOutputAcc = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
100 auto ttClusterDSVForOutputRej = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
102 auto ttStubDSVForOutputAccTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
103 auto ttStubDSVForOutputRejTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
105 auto ttStubDSVForOutputAcc = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
106 auto ttStubDSVForOutputRej = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
110 iEvent.getByToken(clustersToken, clusterHandle);
116 for (
const auto& gd : theTrackerGeom->
dets()) {
117 DetId detid = (*gd).geographicalId();
122 DetId lowerDetid = detid;
127 bool is10G_PS =
false;
134 if (tTopo->
layer(detid) <= high_rate_max_layer)
137 if (tTopo->
tidRing(detid) <= high_rate_max_ring[tTopo->
tidWheel(detid) - 1])
144 std::vector<std::pair<unsigned int, double>> bendMap;
147 if (clusterHandle->find(lowerDetid) == clusterHandle->end() ||
148 clusterHandle->find(upperDetid) == clusterHandle->end())
157 if (lowerClusters.
empty() || upperClusters.
empty())
161 std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusLowerAcc;
162 std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusLowerRej;
163 std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusUpperAcc;
164 std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusUpperRej;
165 std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempStubAcc;
166 std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempStubRej;
167 tempClusLowerAcc.clear();
168 tempClusLowerRej.clear();
169 tempClusUpperAcc.clear();
170 tempClusUpperRej.clear();
176 const int chipSize = isPS ? 120 : 127;
178 constexpr
int numMacroPixels = 16;
181 for (
auto lowerClusterIter = lowerClusters.
begin(); lowerClusterIter != lowerClusters.
end(); ++lowerClusterIter) {
183 std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempOutput;
185 for (
auto upperClusterIter = upperClusters.
begin(); upperClusterIter != upperClusters.
end(); ++upperClusterIter) {
193 bool thisConfirmation =
false;
194 int thisDisplacement = 999999;
196 float thisHardBend = 0;
198 theStubFindingAlgoHandle->PatternHitCorrelation(
199 thisConfirmation, thisDisplacement, thisOffset, thisHardBend, tempTTStub);
203 if (thisConfirmation) {
207 tempOutput.push_back(tempTTStub);
213 if (ForbidMultipleStubs && tempOutput.size() > 1 + static_cast<unsigned int>(isPS)) {
218 typename std::vector<TTStub<Ref_Phase2TrackerDigi_>>::iterator tempIter = tempOutput.begin();
225 tempOutput.erase(tempIter, tempOutput.end());
233 for (
auto& tempTTStub : tempOutput) {
238 tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
239 tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
240 tempStubAcc.push_back(tempTTStub);
245 MeasurementPoint mp0 = tempTTStub.clusterRef(0)->findAverageLocalCoordinates();
246 int seg = static_cast<int>(mp0.
y());
248 seg = seg / numMacroPixels;
250 int chip = 1000 * nmod + 10 *
int(tempTTStub.innerClusterPosition() / chipSize) + seg;
252 int CIC_chip = 10 * nmod + seg;
255 maxStubs = isPS ? maxStubs_PS : maxStubs_2S;
259 if (moduleStubs_MPA[chip] <
int(
maxStubs)) {
260 moduleStubs_MPA[chip]++;
266 if (moduleStubs_CBC[chip] <
int(
maxStubs)) {
267 moduleStubs_CBC[chip]++;
279 tempTTStub.setRawBend(CBCFailOffset + 2. * tempTTStub.rawBend());
280 tempTTStub.setBendOffset(CBCFailOffset + 2. * tempTTStub.bendOffset());
281 tempClusLowerRej.push_back(*(tempTTStub.clusterRef(0)));
282 tempClusUpperRej.push_back(*(tempTTStub.clusterRef(1)));
283 tempStubRej.push_back(tempTTStub);
287 maxStubs = isPS ? maxStubs_PS_CIC_5 : maxStubs_2S_CIC_5;
292 bool CIC_reject =
true;
294 moduleStubs_CIC[CIC_chip].push_back(tempTTStub);
297 tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
298 tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
299 tempStubAcc.push_back(tempTTStub);
308 bendMap.reserve(moduleStubs_CIC[CIC_chip].
size());
310 for (
unsigned int i = 0;
i < moduleStubs_CIC[CIC_chip].size(); ++
i) {
311 bendMap.emplace_back(
i, moduleStubs_CIC[CIC_chip].at(
i).bendFE());
320 if (bendMap[
i].
first == moduleStubs_CIC[CIC_chip].
size() - 1) {
327 tempTTStub.setRawBend(CICFailOffset + 2. * tempTTStub.rawBend());
328 tempTTStub.setBendOffset(CICFailOffset + 2. * tempTTStub.bendOffset());
329 tempClusLowerRej.push_back(*(tempTTStub.clusterRef(0)));
330 tempClusUpperRej.push_back(*(tempTTStub.clusterRef(1)));
331 tempStubRej.push_back(tempTTStub);
333 tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
334 tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
335 tempStubAcc.push_back(tempTTStub);
343 if (not tempClusLowerAcc.empty())
344 this->
fill(*ttClusterDSVForOutputAcc, lowerDetid, tempClusLowerAcc);
345 if (not tempClusLowerRej.empty())
346 this->
fill(*ttClusterDSVForOutputRej, lowerDetid, tempClusLowerRej);
347 if (not tempClusUpperAcc.empty())
348 this->
fill(*ttClusterDSVForOutputAcc, upperDetid, tempClusUpperAcc);
349 if (not tempClusUpperRej.empty())
350 this->
fill(*ttClusterDSVForOutputRej, upperDetid, tempClusUpperRej);
351 if (not tempStubAcc.empty())
352 this->
fill(*ttStubDSVForOutputAccTemp, stackDetid, tempStubAcc);
353 if (not tempStubRej.empty())
354 this->
fill(*ttStubDSVForOutputRejTemp, stackDetid, tempStubRej);
369 this->updateStubs(ttClusterAccHandle, *ttStubDSVForOutputAccTemp, *ttStubDSVForOutputAcc);
370 this->updateStubs(ttClusterRejHandle, *ttStubDSVForOutputRejTemp, *ttStubDSVForOutputRej);
378 moduleStubs_CIC.clear();
380 moduleStubs_MPA.clear();
381 moduleStubs_CBC.clear();