21 iEvent.getByToken(TTClusterTruthToken, TTClusterAssociationMapHandle);
23 iEvent.getByToken(TTStubTruthToken, TTStubAssociationMapHandle);
28 for (
auto iTag = TTTracksTokens.begin(); iTag != TTTracksTokens.end(); iTag++) {
30 auto associationMapForOutput = std::make_unique<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>>();
34 iEvent.getByToken(*iTag, TTTrackHandle);
38 std::map<edm::Ptr<TrackingParticle>, std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>>>
39 trackingParticleToTrackVectorMap;
40 trackToTrackingParticleMap.clear();
41 trackingParticleToTrackVectorMap.clear();
46 typename std::vector<TTTrack<Ref_Phase2TrackerDigi_>>::const_iterator inputIter;
47 for (inputIter = TTTrackHandle->begin(); inputIter != TTTrackHandle->end(); ++inputIter) {
53 theseStubs = tempTrackPtr->getStubRefs();
56 std::map<const TrackingParticle*, edm::Ptr<TrackingParticle>> auxMap;
58 int mayCombinUnknown = 0;
61 for (
unsigned int is = 0; is < theseStubs.size(); is++) {
63 for (
unsigned int ic = 0; ic < 2; ic++) {
64 std::vector<edm::Ptr<TrackingParticle>> tempTPs =
65 TTClusterAssociationMapHandle->findTrackingParticlePtrs(theseStubs.at(is)->clusterRef(ic));
66 for (
unsigned int itp = 0; itp < tempTPs.size(); itp++)
74 if (trackingParticleToTrackVectorMap.find(testTP) == trackingParticleToTrackVectorMap.end()) {
75 std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>> trackVector;
77 trackingParticleToTrackVectorMap.insert(std::make_pair(testTP, trackVector));
79 trackingParticleToTrackVectorMap.find(testTP)->second.push_back(tempTrackPtr);
82 if (auxMap.find(testTP.
get()) == auxMap.end()) {
83 auxMap.insert(std::make_pair(testTP.
get(), testTP));
89 if (TTStubAssociationMapHandle->isUnknown(theseStubs.at(is)))
96 if (mayCombinUnknown >= 2)
104 std::vector<const TrackingParticle*> tpInAllStubs;
106 std::map<const TrackingParticle*, edm::Ptr<TrackingParticle>>::const_iterator iterAuxMap;
107 for (iterAuxMap = auxMap.begin(); iterAuxMap != auxMap.end(); ++iterAuxMap) {
110 tempStubs = TTStubAssociationMapHandle->findTTStubRefs(iterAuxMap->second);
116 for (
unsigned int js = 0; js < theseStubs.size(); js++) {
121 if (
std::find(tempStubs.begin(), tempStubs.end(), theseStubs.at(js)) == tempStubs.end()) {
136 tpInAllStubs.push_back(iterAuxMap->first);
140 std::sort(tpInAllStubs.begin(), tpInAllStubs.end());
141 tpInAllStubs.erase(
std::unique(tpInAllStubs.begin(), tpInAllStubs.end()), tpInAllStubs.end());
142 unsigned int nTPs = tpInAllStubs.size();
151 trackToTrackingParticleMap.insert(std::make_pair(tempTrackPtr, auxMap.find(tpInAllStubs.at(0))->
second));
157 typename std::map<edm::Ptr<TrackingParticle>, std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>>>::iterator
159 for (iterMapToClean = trackingParticleToTrackVectorMap.begin();
160 iterMapToClean != trackingParticleToTrackVectorMap.end();
163 std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>> tempVector = iterMapToClean->second;
166 std::sort(tempVector.begin(), tempVector.end());
167 tempVector.erase(
std::unique(tempVector.begin(), tempVector.end()), tempVector.end());
169 iterMapToClean->second = tempVector;
176 associationMapForOutput->setTTTrackToTrackingParticleMap(trackToTrackingParticleMap);
177 associationMapForOutput->setTrackingParticleToTTTracksMap(trackingParticleToTrackVectorMap);
178 associationMapForOutput->setTTStubAssociationMap(theStubAssoMap);
182 iEvent.put(
std::move(associationMapForOutput), TTTracksInputTags.at(ncont1).instance());