23 case TriggerPrimitive::kDT :
24 _dtAssociatedStubs.push_back( stub );
26 case TriggerPrimitive::kRPC : {
31 <<
"The RPC stub is not in a barrel layer" << std::endl;
34 if ( rpcId.
layer() == 1 ) _rpcInAssociatedStubs.push_back( stub );
35 else if ( rpcId.
layer() == 2 ) _rpcOutAssociatedStubs.push_back( stub );
37 <<
"The RPC layer is not a barrel layer" << std::endl;
42 <<
"The specified subsystem for this track stub is out of range"
52 size_t dtSize = _dtAssociatedStubs.size();
53 size_t rpcInSize = _rpcInAssociatedStubs.size();
54 size_t rpcOutSize = _rpcOutAssociatedStubs.size();
55 _dtMapAss.resize( dtSize );
63 std::vector< size_t > rpcInAss( rpcInSize, 0 );
64 std::vector< size_t > rpcOutAss( rpcOutSize, 0 );
66 for (
size_t iDt = 0; iDt < dtSize; ++iDt ) {
68 double phi = _dtAssociatedStubs.at(iDt)->getCMSGlobalPhi();
69 std::map< double, size_t > rpcInIdx;
70 std::map< double, size_t > rpcOutIdx;
72 for (
size_t iIn = 0; iIn < rpcInSize; ++iIn ) {
73 double phiIn = _rpcInAssociatedStubs.at( iIn )->getCMSGlobalPhi();
75 if ( deltaPhiIn < minRpcPhi ) {
76 rpcInIdx[ deltaPhiIn ] = iIn;
82 for (
size_t iOut = 0; iOut < rpcOutSize; ++iOut ) {
83 double phiOut = _rpcOutAssociatedStubs.at( iOut )->getCMSGlobalPhi();
85 if ( deltaPhiOut < minRpcPhi ) {
86 rpcOutIdx[ deltaPhiOut ] = iOut;
95 std::map< double, size_t >::const_iterator it = rpcInIdx.begin();
96 std::map< double, size_t >::const_iterator itend = rpcInIdx.end();
97 dtAss.
rpcIn.reserve( rpcInIdx.size() );
98 for ( ; it != itend; ++it ) dtAss.
rpcIn.push_back( it->second );
101 it = rpcOutIdx.begin();
102 itend = rpcOutIdx.end();
103 dtAss.
rpcOut.reserve( rpcOutIdx.size() );
104 for ( ; it != itend; ++it ) dtAss.
rpcOut.push_back( it->second );
109 for (
size_t iIn = 0; iIn < rpcInSize; ++iIn ) {
110 if ( !rpcInAss.at(iIn) ) _rpcMapUnass.rpcIn.push_back(iIn);
112 if ( _rpcInAssociatedStubs.size() < _rpcMapUnass.rpcIn.size() )
113 throw cms::Exception(
"More unassociated IN hits than the total rpc IN hits") << std::endl;
116 for (
size_t iOut = 0; iOut < rpcOutSize; ++iOut ) {
117 if ( !rpcOutAss.at(iOut) ) _rpcMapUnass.rpcOut.push_back(iOut);
119 if ( _rpcOutAssociatedStubs.size() < _rpcMapUnass.rpcOut.size() )
120 throw cms::Exception(
"More unassociated OUT hits than the total OUT rpc hits") << std::endl;
132 std::vector<size_t>::const_iterator it = prim.
rpcIn.begin();
133 std::vector<size_t>::const_iterator itend = prim.
rpcIn.end();
135 for ( ; it != itend; ++it ) returnList.push_back( _rpcInAssociatedStubs.at( *it ) );
137 }
catch (
const std::out_of_range &
e ) {
139 <<
"Requested DT primitive in position " << dtIndex <<
" out of " << _dtMapAss.size() <<
" total primitives"
156 std::vector<size_t>::const_iterator it = prim.
rpcOut.begin();
157 std::vector<size_t>::const_iterator itend = prim.
rpcOut.end();
159 for ( ; it != itend; ++it ) returnList.push_back( _rpcOutAssociatedStubs.at( *it ) );
160 }
catch (
const std::out_of_range &
e ) {
162 <<
"The number of dt primitives in sector are " << _dtMapAss.size()
178 std::vector<size_t>::const_iterator it = _rpcMapUnass.rpcIn.begin();
179 std::vector<size_t>::const_iterator itend = _rpcMapUnass.rpcIn.end();
181 for ( ; it != itend; ++it )
182 returnList.push_back( _rpcInAssociatedStubs.at( *it ) );
194 std::vector<size_t>::const_iterator it = _rpcMapUnass.rpcOut.begin();
195 std::vector<size_t>::const_iterator itend = _rpcMapUnass.rpcOut.end();
197 for ( ; it != itend; ++it )
198 returnList.push_back( _rpcOutAssociatedStubs.at( *it ) );
214 <<
"The two id passed refer to the same primitive"
250 if ( !prim1.
rpcIn.empty() && !prim2.
rpcIn.empty() ) {
251 if ( prim1.
rpcIn.front() == prim2.
rpcIn.front() ) {
258 ret_val = ( ret_val == INMATCH ) ? FULLMATCH : OUTMATCH;
263 }
catch (
const std::out_of_range &
e ) {
265 <<
"The number of dt primitives in sector are " << _dtMapAss.size()
278 std::vector< size_t > & cluster2,
281 double minRpcPhi )
const
284 size_t clSize1 = cluster1.size();
285 size_t clSize2 = cluster2.size();
287 for (
size_t idx1 = 0; idx1 < clSize1; ++idx1 ) {
289 size_t uidx1 = cluster1.at(idx1);
290 double phi1 = rpcList1.at( uidx1 )->getCMSGlobalPhi();
292 for (
size_t idx2 = 0; idx2 < clSize2; ++idx2 ) {
294 size_t uidx2 = cluster2.at(idx2);
295 double phi2 = rpcList2.at( uidx2 )->getCMSGlobalPhi();
297 if ( deltaPhiIn < minRpcPhi ) {
312 double minRpcPhi )
const
315 size_t clusterSize =
clusters.size();
316 if ( clusterSize < 2 )
return 0;
318 std::vector<bool> pickUpClusterMap( clusterSize,
true );
321 for (
size_t cidx1 = 0; cidx1 < clusterSize; ++cidx1 ) {
323 if ( pickUpClusterMap.at(cidx1) ) {
324 for (
size_t cidx2 = cidx1+1; cidx2 < clusterSize; ++cidx2 ) {
325 if ( pickUpClusterMap.at(cidx2) &&
327 rpcList, rpcList, minRpcPhi ) ) {
332 pickUpClusterMap[cidx2] =
false;
341 std::vector< std::vector <size_t> > tmpClusters;
342 for (
size_t cidx = 0; cidx < clusterSize; ++cidx ) {
343 if ( pickUpClusterMap.at(cidx) ) {
344 tmpClusters.push_back(
clusters.at(cidx) );
359 std::vector< std::vector <size_t> > &
clusters )
const
362 if ( rpcUnass.empty() )
return;
364 size_t rpcSizeU = rpcUnass.size();
365 std::vector<bool> pickUpMap( rpcSizeU,
true );
367 for (
size_t idx1 = 0; idx1 < rpcSizeU; ++idx1 ) {
369 if ( pickUpMap.at(idx1) ) {
372 size_t uidx1 = rpcUnass.at(idx1);
374 std::vector<size_t> subCluster = { uidx1 };
375 double phi1 = rpcList.at( uidx1 )->getCMSGlobalPhi();
377 for (
size_t idx2 = idx1+1; idx2 < rpcSizeU; ++idx2 ) {
379 if ( pickUpMap.at(idx2) ) {
382 size_t uidx2 = rpcUnass.at(idx2);
384 double phi2 = rpcList.at( uidx2 )->getCMSGlobalPhi();
386 if ( deltaPhiIn < minRpcPhi ) {
387 subCluster.push_back( uidx2 );
388 pickUpMap[idx2] =
false;
398 reduced = reduceRpcClusters(
clusters, rpcList, minRpcPhi );
407 std::vector< std::pair< L1TwinMux::TriggerPrimitiveList, L1TwinMux::TriggerPrimitiveList > >
413 std::vector< std::pair< L1TwinMux::TriggerPrimitiveList, L1TwinMux::TriggerPrimitiveList > > associated;
415 if ( _rpcMapUnass.rpcIn.empty() && _rpcMapUnass.rpcOut.empty())
420 std::vector< std::vector <size_t> > inClusters;
422 getUnassociatedRpcClusters( _rpcMapUnass.rpcIn, _rpcInAssociatedStubs,
423 minRpcPhi, inClusters );
424 }
catch (
const std::out_of_range &
e ) {
425 std::cout <<
" getUnassociatedRpcClusters " << e.what() << std::endl;
429 size_t rpcInClusterSize = inClusters.size();
430 std::vector< std::vector <size_t> > outClusters;
432 getUnassociatedRpcClusters( _rpcMapUnass.rpcOut, _rpcOutAssociatedStubs,
433 minRpcPhi, outClusters );
434 }
catch (
const std::out_of_range & e ) {
435 std::cout <<
" getUnassociatedRpcClusters " << e.what() << std::endl;
439 size_t rpcOutClusterSize = outClusters.size();
442 std::vector<bool> spareInMap( rpcInClusterSize,
true );
443 std::vector<bool> spareOutMap( rpcOutClusterSize,
true );
445 for (
size_t in = 0;
in < rpcInClusterSize; ++
in ) {
446 for (
size_t out = 0;
out < rpcOutClusterSize; ++
out ) {
447 if ( areCloseClusters( inClusters.at(
in),
449 _rpcInAssociatedStubs,
450 _rpcOutAssociatedStubs,
454 std::vector<size_t>::const_iterator itIn = inClusters.at(
in).begin();
455 std::vector<size_t>::const_iterator itInEnd = inClusters.at(
in).end();
456 for ( ; itIn != itInEnd; ++itIn )
457 primIn.push_back( _rpcInAssociatedStubs.at(*itIn) );
460 std::vector<size_t>::const_iterator itOut = outClusters.at(
out).begin();
461 std::vector<size_t>::const_iterator itOutEnd = outClusters.at(
out).end();
462 for ( ; itOut != itOutEnd; ++itOut )
463 primOut.push_back( _rpcOutAssociatedStubs.at(*itOut) );
465 associated.push_back( std::pair< L1TwinMux::TriggerPrimitiveList, L1TwinMux::TriggerPrimitiveList >(primIn, primOut) );
466 spareInMap[
in] =
false;
467 spareOutMap[
out] =
false;
472 for (
size_t in = 0;
in < rpcInClusterSize; ++
in ) {
473 if ( spareInMap[
in] ) {
476 std::vector<size_t>::const_iterator itIn = inClusters.at(in).begin();
477 std::vector<size_t>::const_iterator itInEnd = inClusters.at(in).end();
478 for ( ; itIn != itInEnd; ++itIn )
479 primIn.push_back( _rpcInAssociatedStubs.at(*itIn) );
482 associated.push_back( std::pair< L1TwinMux::TriggerPrimitiveList, L1TwinMux::TriggerPrimitiveList >(primIn, primOut) );
486 for (
size_t out = 0;
out < rpcOutClusterSize; ++
out ) {
487 if ( spareOutMap[
out] ) {
492 std::vector<size_t>::const_iterator itOut = outClusters.at(out).begin();
493 std::vector<size_t>::const_iterator itOutEnd = outClusters.at(out).end();
494 for ( ; itOut != itOutEnd; ++itOut )
495 primOut.push_back( _rpcOutAssociatedStubs.at(*itOut) );
497 associated.push_back( std::pair< L1TwinMux::TriggerPrimitiveList, L1TwinMux::TriggerPrimitiveList >(primIn, primOut) );
TriggerPrimitiveList getRpcInUnassociatedStubs() const
rpc inner layer hits associated to a given dt station
bxMatch haveCommonRpc(size_t dt1, size_t dt2) const
std::vector< std::pair< TriggerPrimitiveList, TriggerPrimitiveList > > getUnassociatedRpcClusters(double minRpcPhi) const
RPC unassociated clusters.
int _wheel
space coordinates
bool areCloseClusters(std::vector< size_t > &cluster1, std::vector< size_t > &cluster2, const TriggerPrimitiveList &rpcList1, const TriggerPrimitiveList &rpcList2, double minRpcPhi) const
TriggerPrimitiveList getRpcInAssociatedStubs(size_t dtIndex) const
rpc inner layer hits associated to a given dt station
structure for internal indexing
void addStub(const TriggerPrimitiveRef &stub)
std::vector< size_t > rpcOut
size_t reduceRpcClusters(std::vector< std::vector< size_t > > &tmpClusters, const TriggerPrimitiveList &rpcList, double minRpcPhi) const
double deltaPhi(double phi1, double phi2)
std::vector< TriggerPrimitiveRef > TriggerPrimitiveList
Geom::Phi< T > phi() const
std::vector< size_t > rpcIn
TriggerPrimitiveList getRpcOutAssociatedStubs(size_t dtIndex) const
rpc outer layer hits associated to a given dt station
int station() const
Return the station number.
int wheel() const
Return the wheel number.
MBLTCollection()
default constructor
TriggerPrimitiveList getRpcOutUnassociatedStubs() const
rpc outer layer hits associated to a given dt station
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.