21 iEvent.getByToken(ttClusterTruthToken_, ttClusterAssociationMapHandle);
23 iEvent.getByToken(ttStubTruthToken_, ttStubAssociationMapHandle);
28 for (
const auto& iTag : ttTracksTokens_) {
30 auto associationMapForOutput = std::make_unique<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>>();
34 iEvent.getByToken(iTag, TTTrackHandle);
37 std::map<TTTrackPtr, TrackingParticlePtr> trackToTrackingParticleMap;
38 std::map<TrackingParticlePtr, std::vector<TTTrackPtr>> trackingParticleToTrackVectorMap;
42 for (
unsigned int jTrk = 0; jTrk < TTTrackHandle->size(); jTrk++) {
47 const std::vector<TTStubRef>& theseStubs = tempTrackPtr->getStubRefs();
50 std::map<const TrackingParticle*, TrackingParticlePtr> auxMap;
51 int mayCombinUnknown = 0;
56 for (
const TTStubRef& stub : theseStubs) {
57 for (
unsigned int ic = 0; ic < 2; ic++) {
58 const std::vector<TrackingParticlePtr>& tempTPs =
59 ttClusterAssociationMapHandle->findTrackingParticlePtrs(stub->clusterRef(ic));
66 if (trackingParticleToTrackVectorMap.find(testTP) == trackingParticleToTrackVectorMap.end()) {
67 std::vector<TTTrackPtr> trackVector;
68 trackingParticleToTrackVectorMap.emplace(testTP, trackVector);
70 trackingParticleToTrackVectorMap.find(testTP)->second.push_back(tempTrackPtr);
73 if (auxMap.find(testTP.get()) == auxMap.end()) {
74 auxMap.emplace(testTP.get(), testTP);
80 if (ttStubAssociationMapHandle->isUnknown(stub))
88 if (mayCombinUnknown >= 2)
96 std::vector<const TrackingParticle*> tpInAllStubs;
98 for (
const auto& auxPair : auxMap) {
100 const std::vector<TTStubRef>& tempStubs = ttStubAssociationMapHandle->findTTStubRefs(auxPair.second);
104 for (
const TTStubRef& stub : theseStubs) {
109 if (
std::find(tempStubs.begin(), tempStubs.end(), stub) == tempStubs.end()) {
122 tpInAllStubs.push_back(auxPair.first);
127 std::sort(tpInAllStubs.begin(), tpInAllStubs.end());
128 tpInAllStubs.erase(
std::unique(tpInAllStubs.begin(), tpInAllStubs.end()), tpInAllStubs.end());
129 unsigned int nTPs = tpInAllStubs.size();
143 trackToTrackingParticleMap.emplace(tempTrackPtr, auxMap.find(tpInAllStubs.at(0))->
second);
149 for (
auto&
p : trackingParticleToTrackVectorMap) {
152 std::vector<TTTrackPtr>& tempVector =
p.second;
155 std::sort(tempVector.begin(), tempVector.end());
156 tempVector.erase(
std::unique(tempVector.begin(), tempVector.end()), tempVector.end());
163 associationMapForOutput->setTTTrackToTrackingParticleMap(trackToTrackingParticleMap);
164 associationMapForOutput->setTrackingParticleToTTTracksMap(trackingParticleToTrackVectorMap);
165 associationMapForOutput->setTTStubAssociationMap(theStubAssoMap);
169 iEvent.put(
std::move(associationMapForOutput), ttTracksInputTags_.at(ncont1).instance());
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
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)
TTTrackAllowOneFalse2SStub