22 iEvent.
getByToken( TTClusterTruthToken, TTClusterAssociationMapHandle );
24 iEvent.
getByToken( TTStubTruthToken, TTStubAssociationMapHandle );
30 for (
auto iTag = TTTracksTokens.begin(); iTag!= TTTracksTokens.end(); iTag++ )
33 auto associationMapForOutput = std::make_unique<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>>();
41 std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > > > trackingParticleToTrackVectorMap;
42 trackToTrackingParticleMap.clear();
43 trackingParticleToTrackVectorMap.clear();
49 typename std::vector< TTTrack< Ref_Phase2TrackerDigi_ > >::const_iterator inputIter;
50 for ( inputIter = TTTrackHandle->begin();
51 inputIter != TTTrackHandle->end();
58 std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >,
TTStub< Ref_Phase2TrackerDigi_ > > > theseStubs = tempTrackPtr->getStubRefs();
61 std::map< const TrackingParticle*, edm::Ptr< TrackingParticle > > auxMap;
63 int mayCombinUnknown = 0;
66 for (
unsigned int is = 0; is < theseStubs.size(); is++ )
69 for (
unsigned int ic = 0; ic < 2; ic++ )
71 std::vector< edm::Ptr< TrackingParticle > > tempTPs = TTClusterAssociationMapHandle->findTrackingParticlePtrs( theseStubs.at(is)->getClusterRef(ic) );
72 for (
unsigned int itp = 0; itp < tempTPs.size(); itp++ )
80 if ( trackingParticleToTrackVectorMap.find( testTP ) == trackingParticleToTrackVectorMap.end() )
82 std::vector< edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > > trackVector;
84 trackingParticleToTrackVectorMap.insert( std::make_pair( testTP, trackVector ) );
86 trackingParticleToTrackVectorMap.find( testTP )->second.push_back( tempTrackPtr );
89 if ( auxMap.find( testTP.
get() ) == auxMap.end() )
91 auxMap.insert( std::make_pair( testTP.
get(), testTP ) );
98 if ( TTStubAssociationMapHandle->isUnknown( theseStubs.at(is) ) )
105 if ( mayCombinUnknown >= 2 )
113 std::vector< const TrackingParticle* > tpInAllStubs;
115 std::map< const TrackingParticle*, edm::Ptr< TrackingParticle > >::const_iterator iterAuxMap;
116 for ( iterAuxMap = auxMap.begin();
117 iterAuxMap != auxMap.end();
121 std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >,
TTStub< Ref_Phase2TrackerDigi_ > > > tempStubs = TTStubAssociationMapHandle->findTTStubRefs( iterAuxMap->second );
127 for (
unsigned int js = 0; js < theseStubs.size(); js++ )
133 if (
std::find( tempStubs.begin(), tempStubs.end(), theseStubs.at(js) ) == tempStubs.end() )
149 tpInAllStubs.push_back( iterAuxMap->first );
153 std::sort( tpInAllStubs.begin(), tpInAllStubs.end() );
154 tpInAllStubs.erase(
std::unique( tpInAllStubs.begin(), tpInAllStubs.end() ), tpInAllStubs.end() );
155 unsigned int nTPs = tpInAllStubs.size();
159 if ( nTPs != 1 )
continue;
163 trackToTrackingParticleMap.insert( std::make_pair( tempTrackPtr, auxMap.find( tpInAllStubs.at(0) )->
second ) );
169 typename std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > > >::iterator iterMapToClean;
170 for ( iterMapToClean = trackingParticleToTrackVectorMap.begin();
171 iterMapToClean != trackingParticleToTrackVectorMap.end();
175 std::vector< edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > > tempVector = iterMapToClean->second;
178 std::sort( tempVector.begin(), tempVector.end() );
179 tempVector.erase(
std::unique( tempVector.begin(), tempVector.end() ), tempVector.end() );
181 iterMapToClean->second = tempVector;
188 associationMapForOutput->setTTTrackToTrackingParticleMap( trackToTrackingParticleMap );
189 associationMapForOutput->setTrackingParticleToTTTracksMap( trackingParticleToTrackVectorMap );
190 associationMapForOutput->setTTStubAssociationMap( theStubAssoMap );
193 iEvent.
put(
std::move(associationMapForOutput), TTTracksInputTags.at(ncont1).instance() );
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T const * get() const
Returns C++ pointer to the item.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
U second(std::pair< T, U > const &p)
def unique(seq, keepstr=True)
bool isNull() const
Checks for null.
Class to store the L1 Track Trigger stubs.
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)