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 );
39 unsigned maxStubs = 0;
41 for (
auto gd=theTrackerGeom->
dets().begin(); gd != theTrackerGeom->
dets().end(); gd++) {
42 DetId detid = (*gd)->geographicalId();
44 if(!tTopo->
isLower(detid) )
continue;
45 DetId lowerDetid = detid;
50 if ( clusterHandle->find( lowerDetid ) == clusterHandle->end() ||
51 clusterHandle->find( upperDetid ) == clusterHandle->end() )
61 if ( lowerClusters.
empty() || upperClusters.
empty() )
65 std::vector< TTCluster< Ref_Phase2TrackerDigi_ > > tempInner;
66 std::vector< TTCluster< Ref_Phase2TrackerDigi_ > > tempOuter;
67 std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempAccepted;
78 std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > moduleStubs;
81 for (
auto lowerClusterIter = lowerClusters.
begin();
82 lowerClusterIter != lowerClusters.
end();
83 ++lowerClusterIter ) {
87 std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempOutput;
90 for (
auto upperClusterIter = upperClusters.
begin();
91 upperClusterIter != upperClusters.
end();
92 ++upperClusterIter ) {
100 bool thisConfirmation =
false;
101 int thisDisplacement = 999999;
104 theStubFindingAlgoHandle->PatternHitCorrelation( thisConfirmation, thisDisplacement, thisOffset, tempTTStub );
107 if ( thisConfirmation )
111 tempOutput.push_back( tempTTStub );
117 if ( ForbidMultipleStubs && tempOutput.size() > 1 )
123 typename std::vector< TTStub< Ref_Phase2TrackerDigi_ > >::iterator tempIter = tempOutput.begin();
129 tempOutput.erase( tempIter, tempOutput.end() );
136 for (
unsigned int iTempStub = 0; iTempStub < tempOutput.size(); ++iTempStub )
147 tempAccepted.push_back( tempTTStub );
154 if ( moduleStubs.find( chip ) == moduleStubs.end() )
157 std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempStubs(1,tempTTStub);
165 moduleStubs[chip].push_back( tempTTStub );
173 if ( moduleStubs.empty() ==
false )
177 for (
auto const & is : moduleStubs )
180 if ( is.second.size() <= maxStubs )
182 for (
auto const & ts: is.second )
184 tempInner.push_back( *(ts.getClusterRef(0)) );
185 tempOuter.push_back( *(ts.getClusterRef(1)) );
186 tempAccepted.push_back( ts );
192 std::vector< std::pair< unsigned int, double > > bendMap;
193 bendMap.reserve(is.second.size());
194 for (
unsigned int i = 0;
i < is.second.size(); ++
i )
196 bendMap.push_back( std::pair< unsigned int, double >(
i, is.second[
i].getTriggerBend() ) );
200 for (
unsigned int i = 0;
i < maxStubs; ++
i )
203 tempInner.push_back( *(is.second[bendMap[
i].first].getClusterRef(0)) );
204 tempOuter.push_back( *(is.second[bendMap[
i].first].getClusterRef(1)) );
205 tempAccepted.push_back( is.second[bendMap[
i].first] );
210 if ( !tempInner.empty() )
214 for (
unsigned int m = 0;
m < tempInner.size();
m++ )
216 lowerOutputFiller.
push_back( tempInner.at(
m) );
218 if ( lowerOutputFiller.
empty() )
219 lowerOutputFiller.abort();
222 if ( !tempOuter.empty() )
225 for (
unsigned int m = 0;
m < tempOuter.size();
m++ )
227 upperOutputFiller.
push_back( tempOuter.at(
m) );
229 if ( upperOutputFiller.
empty() )
230 upperOutputFiller.abort();
233 if ( !tempAccepted.empty() )
236 for (
unsigned int m = 0;
m < tempAccepted.size();
m++ )
238 tempAcceptedFiller.
push_back( tempAccepted.at(
m) );
240 if ( tempAcceptedFiller.
empty() )
241 tempAcceptedFiller.abort();
253 for ( stubDetIter = ttStubDSVForOutputTemp->
begin();
254 stubDetIter != ttStubDSVForOutputTemp->
end();
257 DetId thisStackedDetId = stubDetIter->
id();
262 DetId lowerDetid = thisStackedDetId+1;
263 DetId upperDetid = thisStackedDetId+2;
276 for ( stubIter = theseStubs.
begin();
277 stubIter != theseStubs.
end();
286 bool lowerOK =
false;
287 bool upperOK =
false;
289 for ( clusterIter = lowerClusters.
begin();
290 clusterIter != lowerClusters.
end() && !lowerOK;
292 if ( clusterIter->getHits() == lowerClusterToBeReplaced->getHits() ) {
293 tempTTStub.addClusterRef(
edmNew::makeRefTo( ttClusterAcceptedHandle, clusterIter ) );
298 for ( clusterIter = upperClusters.
begin();
299 clusterIter != upperClusters.
end() && !upperOK;
301 if ( clusterIter->getHits() == upperClusterToBeReplaced->getHits() ) {
302 tempTTStub.addClusterRef(
edmNew::makeRefTo( ttClusterAcceptedHandle, clusterIter ) );
308 if ( !lowerOK || !upperOK )
continue;
310 tempTTStub.setTriggerDisplacement( 2.*stubIter->getTriggerDisplacement() );
311 tempTTStub.setTriggerOffset( 2.*stubIter->getTriggerOffset() );
313 acceptedOutputFiller.
push_back( tempTTStub );
317 if ( acceptedOutputFiller.
empty() )
318 acceptedOutputFiller.abort();
323 iEvent.
put(
std::move(ttStubDSVForOutputAccepted),
"StubAccepted" );
324 iEvent.
put(
std::move(ttStubDSVForOutputRejected),
"StubRejected" );
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.
virtual int rowsperroc() const =0
Item & push_back(id_type iid)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
id_type id(size_t cell) const
DetId partnerDetId(const DetId &id) const
bool isLower(const DetId &id) const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void setTriggerDisplacement(int aDisplacement)
In FULL-STRIP units! (hence, not implemented herein)
Class to store the L1 Track Trigger stubs.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
void addClusterRef(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aTTCluster)
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 ...