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;
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();
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
void setBendOffset(int anOffset)
void setModuleTypePS(bool isPSModule)
set whether this is a PS module or not;
Item & push_back(id_type iid)
unsigned int tidWheel(const DetId &id) const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void setBendBE(float aBend)
setBendBE(): In HALF-STRIP units! Reduced resolution in BE boards. Rename of setHardwareBend() ...
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
unsigned int layer(const DetId &id) const
T const * product() const
void setRawBend(int aDisplacement)
ModuleType getDetectorType(DetId) const
uint32_t stack(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
DetId partnerDetId(const DetId &id) const
static constexpr auto TOB
Class to store the L1 Track Trigger stubs.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
bool isLower(const DetId &id) const
void updateStubs(const edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ >>> &clusterHandle, const edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &inputEDstubs, edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &outputEDstubs) const
Update output stubs with Refs to cluster collection that is associated to stubs.
NOTE: this is needed even if it seems not.
void addClusterRef(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aTTCluster)
Add a cluster reference, depending on which stack member it is on (inner = 0, outer = 1) ...
unsigned int tidRing(const DetId &id) const
static constexpr auto TID
Plugin to load the Stub finding algorithm and produce the collection of Stubs that goes in the event ...