23 for (
const auto& module : inputEDstubs) {
25 DetId thisStackedDetId = module.id();
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) {
218 typename std::vector<TTStub<Ref_Phase2TrackerDigi_>>::iterator tempIter = tempOutput.begin();
224 tempOutput.erase(tempIter, tempOutput.end());
232 for (
auto& tempTTStub : tempOutput) {
237 tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
238 tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
239 tempStubAcc.push_back(tempTTStub);
244 MeasurementPoint mp0 = tempTTStub.clusterRef(0)->findAverageLocalCoordinates();
245 int seg = static_cast<int>(mp0.
y());
247 seg = seg / numMacroPixels;
249 int chip = 1000 * nmod + 10 *
int(tempTTStub.innerClusterPosition() / chipSize) + seg;
251 int CIC_chip = 10 * nmod + seg;
254 maxStubs = isPS ? maxStubs_PS : maxStubs_2S;
258 if (moduleStubs_MPA[chip] <
int(
maxStubs)) {
259 moduleStubs_MPA[chip]++;
265 if (moduleStubs_CBC[chip] <
int(
maxStubs)) {
266 moduleStubs_CBC[chip]++;
278 tempTTStub.setRawBend(CBCFailOffset + 2. * tempTTStub.rawBend());
279 tempTTStub.setBendOffset(CBCFailOffset + 2. * tempTTStub.bendOffset());
280 tempClusLowerRej.push_back(*(tempTTStub.clusterRef(0)));
281 tempClusUpperRej.push_back(*(tempTTStub.clusterRef(1)));
282 tempStubRej.push_back(tempTTStub);
286 maxStubs = isPS ? maxStubs_PS_CIC_5 : maxStubs_2S_CIC_5;
291 bool CIC_reject =
true;
293 moduleStubs_CIC[CIC_chip].push_back(tempTTStub);
296 tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
297 tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
298 tempStubAcc.push_back(tempTTStub);
307 bendMap.reserve(moduleStubs_CIC[CIC_chip].
size());
309 for (
unsigned int i = 0;
i < moduleStubs_CIC[CIC_chip].size(); ++
i) {
310 bendMap.emplace_back(
i, moduleStubs_CIC[CIC_chip].at(
i).bendFE());
319 if (bendMap[
i].
first == moduleStubs_CIC[CIC_chip].
size() - 1) {
326 tempTTStub.setRawBend(CICFailOffset + 2. * tempTTStub.rawBend());
327 tempTTStub.setBendOffset(CICFailOffset + 2. * tempTTStub.bendOffset());
328 tempClusLowerRej.push_back(*(tempTTStub.clusterRef(0)));
329 tempClusUpperRej.push_back(*(tempTTStub.clusterRef(1)));
330 tempStubRej.push_back(tempTTStub);
332 tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
333 tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
334 tempStubAcc.push_back(tempTTStub);
342 if (not tempClusLowerAcc.empty())
343 this->
fill(*ttClusterDSVForOutputAcc, lowerDetid, tempClusLowerAcc);
344 if (not tempClusLowerRej.empty())
345 this->
fill(*ttClusterDSVForOutputRej, lowerDetid, tempClusLowerRej);
346 if (not tempClusUpperAcc.empty())
347 this->
fill(*ttClusterDSVForOutputAcc, upperDetid, tempClusUpperAcc);
348 if (not tempClusUpperRej.empty())
349 this->
fill(*ttClusterDSVForOutputRej, upperDetid, tempClusUpperRej);
350 if (not tempStubAcc.empty())
351 this->
fill(*ttStubDSVForOutputAccTemp, stackDetid, tempStubAcc);
352 if (not tempStubRej.empty())
353 this->
fill(*ttStubDSVForOutputRejTemp, stackDetid, tempStubRej);
368 this->updateStubs(ttClusterAccHandle, *ttStubDSVForOutputAccTemp, *ttStubDSVForOutputAcc);
369 this->updateStubs(ttClusterRejHandle, *ttStubDSVForOutputRejTemp, *ttStubDSVForOutputRej);
377 moduleStubs_CIC.clear();
379 moduleStubs_MPA.clear();
380 moduleStubs_CBC.clear();