27 auto ttClusterDSVForOutput = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
28 auto ttStubDSVForOutputTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
29 auto ttStubDSVForOutputAccepted = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
30 auto ttStubDSVForOutputRejected = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
34 iEvent.
getByToken( clustersToken, clusterHandle );
41 for (
const auto& gd : theTrackerGeom->
dets())
43 DetId detid = (*gd).geographicalId();
45 if(!tTopo->
isLower(detid) )
continue;
46 DetId lowerDetid = detid;
51 bool is10G_PS =
false;
61 if (tTopo->
layer(detid)==1) is10G_PS =
true;
65 if (tTopo->
tidRing(detid)<=high_rate_max_ring[tTopo->
tidWheel(detid)-1]) is10G_PS =
true;
71 unsigned int maxStubs;
72 std::vector< std::pair< unsigned int, double > > bendMap;
75 if ( clusterHandle->find( lowerDetid ) == clusterHandle->end() ||
76 clusterHandle->find( upperDetid ) == clusterHandle->end() )
86 if ( lowerClusters.
empty() || upperClusters.
empty() )
90 std::vector< TTCluster< Ref_Phase2TrackerDigi_ > > tempInner;
91 std::vector< TTCluster< Ref_Phase2TrackerDigi_ > > tempOuter;
92 std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempAccepted;
99 if (isPS) chipSize = 120;
102 for (
auto lowerClusterIter = lowerClusters.
begin();
103 lowerClusterIter != lowerClusters.
end();
104 ++lowerClusterIter ) {
108 std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempOutput;
110 for (
auto upperClusterIter = upperClusters.
begin();
111 upperClusterIter != upperClusters.
end();
112 ++upperClusterIter ) {
120 bool thisConfirmation =
false;
121 int thisDisplacement = 999999;
123 float thisROffset = 0;
124 float thisHardBend = 0;
126 theStubFindingAlgoHandle->PatternHitCorrelation( thisConfirmation, thisDisplacement, thisOffset, thisROffset, thisHardBend, tempTTStub );
129 if ( thisConfirmation )
135 tempOutput.push_back( tempTTStub );
141 if ( ForbidMultipleStubs && tempOutput.size() > 1 )
147 typename std::vector< TTStub< Ref_Phase2TrackerDigi_ > >::iterator tempIter = tempOutput.begin();
153 tempOutput.erase( tempIter, tempOutput.end() );
160 for (
unsigned int iTempStub = 0; iTempStub < tempOutput.size(); ++iTempStub )
182 tempAccepted.push_back( tempTTStub );
186 bool FEreject =
false;
190 int seg =
static_cast<int>(mp0.
y());
191 if (isPS) seg = seg/16;
193 int CIC_chip = 10*nmod+seg;
197 ? maxStubs = maxStubs_PS
198 : maxStubs = maxStubs_2S;
202 if ( moduleStubs_MPA.find( chip ) == moduleStubs_MPA.end() )
205 moduleStubs_MPA.emplace(chip,1);
209 if ( moduleStubs_MPA[chip] <
int(maxStubs) )
211 ++moduleStubs_MPA[chip];
221 if ( moduleStubs_CBC.find( chip ) == moduleStubs_CBC.end() )
224 moduleStubs_CBC.emplace(chip,1);
228 if ( moduleStubs_CBC[chip] <
int(maxStubs) )
230 ++moduleStubs_CBC[chip];
250 tempInner.push_back( *(tempTTStub2.getClusterRef(0)) );
251 tempOuter.push_back( *(tempTTStub2.getClusterRef(1)) );
252 tempAccepted.push_back( tempTTStub2 );
257 ? maxStubs = maxStubs_PS_CIC_5
258 : maxStubs = maxStubs_2S_CIC_5;
260 if (is10G_PS) maxStubs = maxStubs_PS_CIC_10;
262 if ( moduleStubs_CIC.find( CIC_chip ) == moduleStubs_CIC.end() )
265 std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempStubs(1,tempTTStub);
266 moduleStubs_CIC.emplace(CIC_chip,tempStubs);
269 tempAccepted.push_back( tempTTStub );
273 bool CIC_reject=
true;
275 if ( moduleStubs_CIC[CIC_chip].
size() < maxStubs )
277 moduleStubs_CIC[CIC_chip].push_back( tempTTStub );
280 tempAccepted.push_back( tempTTStub );
284 moduleStubs_CIC[CIC_chip].push_back( tempTTStub );
288 bendMap.reserve(moduleStubs_CIC[CIC_chip].
size());
290 for (
unsigned int i = 0;
i < moduleStubs_CIC[CIC_chip].size(); ++
i )
292 bendMap.emplace_back(
i,moduleStubs_CIC[CIC_chip].at(
i).getTriggerBend());
299 for (
unsigned int i = 0;
i < maxStubs; ++
i )
302 if (bendMap[
i].
first==moduleStubs_CIC[CIC_chip].
size()-1)
314 tempInner.push_back( *(tempTTStub2.getClusterRef(0)) );
315 tempOuter.push_back( *(tempTTStub2.getClusterRef(1)) );
316 tempAccepted.push_back( tempTTStub2 );
322 tempAccepted.push_back( tempTTStub );
331 if ( !tempInner.empty() )
334 for (
unsigned int m = 0;
m < tempInner.size();
m++ )
336 lowerOutputFiller.
push_back( tempInner.at(
m) );
338 if ( lowerOutputFiller.
empty() )
339 lowerOutputFiller.abort();
342 if ( !tempOuter.empty() )
345 for (
unsigned int m = 0;
m < tempOuter.size();
m++ )
347 upperOutputFiller.
push_back( tempOuter.at(
m) );
349 if ( upperOutputFiller.
empty() )
350 upperOutputFiller.abort();
353 if ( !tempAccepted.empty() )
356 for (
unsigned int m = 0;
m < tempAccepted.size();
m++ )
358 tempAcceptedFiller.
push_back( tempAccepted.at(
m) );
360 if ( tempAcceptedFiller.
empty() )
361 tempAcceptedFiller.abort();
373 for ( stubDetIter = ttStubDSVForOutputTemp->
begin();
374 stubDetIter != ttStubDSVForOutputTemp->
end();
377 DetId thisStackedDetId = stubDetIter->
id();
382 DetId lowerDetid = thisStackedDetId+1;
383 DetId upperDetid = thisStackedDetId+2;
396 for ( stubIter = theseStubs.
begin();
397 stubIter != theseStubs.
end();
406 bool lowerOK =
false;
407 bool upperOK =
false;
409 for ( clusterIter = lowerClusters.
begin();
410 clusterIter != lowerClusters.
end() && !lowerOK;
412 if ( clusterIter->getHits() == lowerClusterToBeReplaced->getHits() ) {
413 tempTTStub.addClusterRef(
edmNew::makeRefTo( ttClusterAcceptedHandle, clusterIter ) );
418 for ( clusterIter = upperClusters.
begin();
419 clusterIter != upperClusters.
end() && !upperOK;
421 if ( clusterIter->getHits() == upperClusterToBeReplaced->getHits() ) {
422 tempTTStub.addClusterRef(
edmNew::makeRefTo( ttClusterAcceptedHandle, clusterIter ) );
428 if ( !lowerOK || !upperOK )
continue;
430 tempTTStub.setTriggerDisplacement( 2.*stubIter->getTriggerDisplacement() );
431 tempTTStub.setTriggerOffset( 2.*stubIter->getTriggerOffset() );
432 tempTTStub.setRealTriggerOffset( 2.*stubIter->getRealTriggerOffset() );
433 tempTTStub.setHardwareBend( stubIter->getHardwareBend() );
435 acceptedOutputFiller.
push_back( tempTTStub );
439 if ( acceptedOutputFiller.
empty() )
440 acceptedOutputFiller.abort();
445 iEvent.
put(
std::move(ttStubDSVForOutputAccepted),
"StubAccepted" );
446 iEvent.
put(
std::move(ttStubDSVForOutputRejected),
"StubRejected" );
449 if (ievt%8==0) moduleStubs_CIC.clear();
450 if (ievt%2==0) moduleStubs_MPA.clear();
451 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)
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
unsigned int tidRing(const DetId &id) const
Item & push_back(id_type iid)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
unsigned int tidWheel(const DetId &id) const
DetId getDetId() const
Detector element.
id_type id(size_t cell) const
DetId partnerDetId(const DetId &id) const
double getHardwareBend() const
In FULL-STRIP units!
bool isLower(const DetId &id) const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
void setHardwareBend(float aBend)
In FULL-STRIP units!
void setTriggerDisplacement(int aDisplacement)
In FULL-STRIP units! (hence, not implemented herein)
double getTriggerOffset() const
In HALF-STRIP units!
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
ModuleType getDetectorType(DetId) const
Class to store the L1 Track Trigger stubs.
double getTriggerDisplacement() const
Trigger information.
void setTriggerOffset(int anOffset)
In FULL-STRIP units! (hence, not implemented herein)
NOTE: this is needed even if it seems not.
uint32_t stack(const DetId &id) const
void addClusterRef(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aTTCluster)
unsigned int layer(const DetId &id) const
void setRealTriggerOffset(float anOffset)
In FULL-STRIP units! (hence, not implemented herein)
double getRealTriggerOffset() const
In HALF-STRIP units!
double getTriggerPosition() const
In HALF-STRIP units!
const edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > & getClusterRef(unsigned int hitIdentifier) const
Clusters composing the Stub.
T const * product() const
const_iterator begin(bool update=false) const
Plugin to load the Stub finding algorithm and produce the collection of Stubs that goes in the event ...