26 auto ttClusterDSVForOutput = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
27 auto ttStubDSVForOutputTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
28 auto ttStubDSVForOutputAccepted = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
29 auto ttStubDSVForOutputRejected = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
31 static constexpr
int CBCFailOffset = 500;
32 static constexpr
int CICFailOffset = 1000;
36 iEvent.getByToken(clustersToken, clusterHandle);
43 for (
const auto& gd : theTrackerGeom->
dets()) {
44 DetId detid = (*gd).geographicalId();
49 DetId lowerDetid = detid;
54 bool is10G_PS =
false;
63 if (tTopo->
layer(detid) == 1)
66 if (tTopo->
tidRing(detid) <= high_rate_max_ring[tTopo->
tidWheel(detid) - 1])
72 unsigned int maxStubs;
73 std::vector<std::pair<unsigned int, double>> bendMap;
76 if (clusterHandle->find(lowerDetid) == clusterHandle->end() ||
77 clusterHandle->find(upperDetid) == clusterHandle->end())
87 if (lowerClusters.
empty() || upperClusters.
empty())
91 std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempInner;
92 std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempOuter;
93 std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempAccepted;
104 for (
auto lowerClusterIter = lowerClusters.
begin(); lowerClusterIter != lowerClusters.
end(); ++lowerClusterIter) {
107 std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempOutput;
109 for (
auto upperClusterIter = upperClusters.
begin(); upperClusterIter != upperClusters.
end(); ++upperClusterIter) {
117 bool thisConfirmation =
false;
118 int thisDisplacement = 999999;
120 float thisHardBend = 0;
122 theStubFindingAlgoHandle->PatternHitCorrelation(
123 thisConfirmation, thisDisplacement, thisOffset, thisHardBend, tempTTStub);
127 if (thisConfirmation) {
131 tempOutput.push_back(tempTTStub);
137 if (ForbidMultipleStubs && tempOutput.size() > 1) {
142 typename std::vector<TTStub<Ref_Phase2TrackerDigi_>>::iterator tempIter = tempOutput.begin();
148 tempOutput.erase(tempIter, tempOutput.end());
155 for (
unsigned int iTempStub = 0; iTempStub < tempOutput.size(); ++iTempStub) {
163 tempTTStub2.addClusterRef((tempTTStub.
clusterRef(1)));
164 tempTTStub2.setRawBend(2. * tempTTStub.
rawBend());
165 tempTTStub2.setBendOffset(2. * tempTTStub.
bendOffset());
166 tempTTStub2.setBendBE(tempTTStub.
bendBE());
173 tempInner.push_back(*(tempTTStub.
clusterRef(0)));
174 tempOuter.push_back(*(tempTTStub.
clusterRef(1)));
175 tempAccepted.push_back(tempTTStub);
177 bool FEreject =
false;
181 int seg = static_cast<int>(mp0.
y());
186 int CIC_chip = 10 * nmod + seg;
189 (isPS) ? maxStubs = maxStubs_PS : maxStubs = maxStubs_2S;
193 if (moduleStubs_MPA.find(chip) == moduleStubs_MPA.end())
196 moduleStubs_MPA.emplace(chip, 1);
198 if (moduleStubs_MPA[chip] <
int(maxStubs)) {
199 ++moduleStubs_MPA[chip];
206 if (moduleStubs_CBC.find(chip) == moduleStubs_CBC.end())
209 moduleStubs_CBC.emplace(chip, 1);
211 if (moduleStubs_CBC[chip] <
int(maxStubs)) {
212 ++moduleStubs_CBC[chip];
225 tempTTStub2.setRawBend(CBCFailOffset + 2. * tempTTStub.
rawBend());
226 tempTTStub2.setBendOffset(CBCFailOffset + 2. * tempTTStub.
bendOffset());
228 tempInner.push_back(*(tempTTStub2.clusterRef(0)));
229 tempOuter.push_back(*(tempTTStub2.clusterRef(1)));
230 tempAccepted.push_back(tempTTStub2);
234 maxStubs = isPS ? maxStubs_PS_CIC_5 : maxStubs_2S_CIC_5;
237 maxStubs = maxStubs_PS_CIC_10;
239 if (moduleStubs_CIC.find(CIC_chip) == moduleStubs_CIC.end())
241 if (moduleStubs_MPA.find(chip) == moduleStubs_MPA.end())
244 moduleStubs_MPA.emplace(chip, 1);
246 if (moduleStubs_MPA[chip] <
int(maxStubs)) {
247 ++moduleStubs_MPA[chip];
254 if (moduleStubs_CBC.find(chip) == moduleStubs_CBC.end())
257 moduleStubs_CBC.emplace(chip, 1);
259 if (moduleStubs_CBC[chip] <
int(maxStubs)) {
260 ++moduleStubs_CBC[chip];
273 tempTTStub2.setRawBend(CBCFailOffset + 2. * tempTTStub.
rawBend());
274 tempTTStub2.setBendOffset(CBCFailOffset + 2. * tempTTStub.
bendOffset());
276 tempInner.push_back(*(tempTTStub2.clusterRef(0)));
277 tempOuter.push_back(*(tempTTStub2.clusterRef(1)));
278 tempAccepted.push_back(tempTTStub2);
282 (isPS) ? maxStubs = maxStubs_PS_CIC_5 : maxStubs = maxStubs_2S_CIC_5;
285 maxStubs = maxStubs_PS_CIC_10;
287 if (moduleStubs_CIC.find(CIC_chip) == moduleStubs_CIC.end())
289 bool CIC_reject =
true;
291 if (moduleStubs_CIC[CIC_chip].
size() < maxStubs) {
292 moduleStubs_CIC[CIC_chip].push_back(tempTTStub);
293 tempInner.push_back(*(tempTTStub.
clusterRef(0)));
294 tempOuter.push_back(*(tempTTStub.
clusterRef(1)));
295 tempAccepted.push_back(tempTTStub);
297 moduleStubs_CIC[CIC_chip].push_back(tempTTStub);
301 bendMap.reserve(moduleStubs_CIC[CIC_chip].
size());
303 for (
unsigned int i = 0;
i < moduleStubs_CIC[CIC_chip].size(); ++
i) {
304 bendMap.emplace_back(
i, moduleStubs_CIC[CIC_chip].at(
i).bendFE());
311 for (
unsigned int i = 0;
i < maxStubs; ++
i) {
313 if (bendMap[
i].
first == moduleStubs_CIC[CIC_chip].
size() - 1) {
320 tempTTStub2.setRawBend(CICFailOffset + 2. * tempTTStub.
rawBend());
321 tempTTStub2.setBendOffset(CICFailOffset + 2. * tempTTStub.
bendOffset());
323 tempInner.push_back(*(tempTTStub2.clusterRef(0)));
324 tempOuter.push_back(*(tempTTStub2.clusterRef(1)));
325 tempAccepted.push_back(tempTTStub2);
327 tempInner.push_back(*(tempTTStub.
clusterRef(0)));
328 tempOuter.push_back(*(tempTTStub.
clusterRef(1)));
329 tempAccepted.push_back(tempTTStub);
338 if (!tempInner.empty()) {
340 *ttClusterDSVForOutput, lowerDetid);
341 for (
unsigned int m = 0;
m < tempInner.size();
m++) {
344 if (lowerOutputFiller.
empty())
345 lowerOutputFiller.abort();
348 if (!tempOuter.empty()) {
350 *ttClusterDSVForOutput, upperDetid);
351 for (
unsigned int m = 0;
m < tempOuter.size();
m++) {
354 if (upperOutputFiller.
empty())
355 upperOutputFiller.abort();
358 if (!tempAccepted.empty()) {
360 *ttStubDSVForOutputTemp, stackDetid);
361 for (
unsigned int m = 0;
m < tempAccepted.size();
m++) {
362 tempAcceptedFiller.
push_back(tempAccepted.at(
m));
364 if (tempAcceptedFiller.
empty())
365 tempAcceptedFiller.abort();
378 for (stubDetIter = ttStubDSVForOutputTemp->
begin(); stubDetIter != ttStubDSVForOutputTemp->
end(); ++stubDetIter) {
380 DetId thisStackedDetId = stubDetIter->
id();
382 *ttStubDSVForOutputAccepted, thisStackedDetId);
386 DetId lowerDetid = thisStackedDetId + 1;
387 DetId upperDetid = thisStackedDetId + 2;
400 for (stubIter = theseStubs.
begin(); stubIter != theseStubs.
end(); ++stubIter) {
406 lowerClusterToBeReplaced = stubIter->clusterRef(0);
408 upperClusterToBeReplaced = stubIter->clusterRef(1);
410 bool lowerOK =
false;
411 bool upperOK =
false;
413 for (clusterIter = lowerClusters.
begin(); clusterIter != lowerClusters.
end() && !lowerOK; ++clusterIter) {
414 if (clusterIter->getHits() == lowerClusterToBeReplaced->getHits()) {
415 tempTTStub.addClusterRef(
edmNew::makeRefTo(ttClusterAcceptedHandle, clusterIter));
420 for (clusterIter = upperClusters.
begin(); clusterIter != upperClusters.
end() && !upperOK; ++clusterIter) {
421 if (clusterIter->getHits() == upperClusterToBeReplaced->getHits()) {
422 tempTTStub.addClusterRef(
edmNew::makeRefTo(ttClusterAcceptedHandle, clusterIter));
428 if (!lowerOK || !upperOK)
431 tempTTStub.setRawBend(2. * stubIter->rawBend());
432 tempTTStub.setBendOffset(
433 2. * stubIter->bendOffset());
434 tempTTStub.setBendBE(stubIter->bendBE());
435 tempTTStub.setModuleTypePS(stubIter->moduleTypePS());
437 acceptedOutputFiller.
push_back(tempTTStub);
441 if (acceptedOutputFiller.
empty())
442 acceptedOutputFiller.abort();
452 moduleStubs_CIC.clear();
454 moduleStubs_MPA.clear();
455 moduleStubs_CBC.clear();