20 iEvent.getByToken(digisimLinkToken_, thePixelDigiSimLinkHandle_);
24 iEvent.getByToken(tpToken_, trackingParticleHandle_);
31 std::map<std::pair<unsigned int, EncodedEventId>,
TrackingParticlePtr> simTrackUniqueToTPMap;
33 if (not trackingParticleHandle_->empty()) {
35 for (
unsigned int tpCnt = 0; tpCnt < trackingParticleHandle_->size(); tpCnt++) {
45 simTrackUniqueToTPMap.emplace(std::make_pair(
simTrack.trackId(), eventId), tempTPPtr);
54 for (
const auto& iTag : ttClustersTokens_) {
56 auto associationMapForOutput = std::make_unique<TTClusterAssociationMap<Ref_Phase2TrackerDigi_>>();
61 iEvent.getByToken(iTag, TTClusterHandle);
64 std::map<TTClusterRef, std::vector<TrackingParticlePtr>> clusterToTrackingParticleVectorMap;
65 std::map<TrackingParticlePtr, std::vector<TTClusterRef>> trackingParticleToClusterVectorMap;
68 for (
const auto& gd : theTrackerGeom->
dets()) {
69 DetId detid = gd->geographicalId();
73 if (TTClusterHandle->find(detid) == TTClusterHandle->end())
79 for (
auto contentIter =
clusters.begin(); contentIter !=
clusters.end(); ++contentIter) {
84 if (clusterToTrackingParticleVectorMap.find(tempCluRef) == clusterToTrackingParticleVectorMap.end()) {
85 std::vector<TrackingParticlePtr> tpVector;
86 clusterToTrackingParticleVectorMap.emplace(tempCluRef, tpVector);
91 if (thePixelDigiSimLinkHandle_->find(detid) == thePixelDigiSimLinkHandle_->end()) {
96 std::vector<Ref_Phase2TrackerDigi_> theseHits = tempCluRef->getHits();
97 for (
unsigned int i = 0;
i < theseHits.size();
i++) {
101 clusterToTrackingParticleVectorMap.find(tempCluRef)->second.push_back(tempTPPtr);
112 std::vector<Ref_Phase2TrackerDigi_> theseHits = tempCluRef->getHits();
113 for (
unsigned int i = 0;
i < theseHits.size();
i++) {
115 for (iterSimLink = thisDigiSimLink.
data.begin(); iterSimLink != thisDigiSimLink.
data.end(); iterSimLink++) {
117 if (static_cast<int>(iterSimLink->channel()) != static_cast<int>(theseHits.at(
i)->channel()))
121 unsigned int curSimTrkId = iterSimLink->SimTrackId();
125 std::pair<unsigned int, EncodedEventId> thisUniqueId = std::make_pair(curSimTrkId, curSimEvId);
128 if (simTrackUniqueToTPMap.find(thisUniqueId) != simTrackUniqueToTPMap.end()) {
129 TrackingParticlePtr thisTrackingParticle = simTrackUniqueToTPMap.find(thisUniqueId)->second;
132 clusterToTrackingParticleVectorMap.find(tempCluRef)->second.push_back(thisTrackingParticle);
135 if (trackingParticleToClusterVectorMap.find(thisTrackingParticle) ==
136 trackingParticleToClusterVectorMap.end()) {
137 std::vector<TTClusterRef> clusterVector;
138 trackingParticleToClusterVectorMap.emplace(thisTrackingParticle, clusterVector);
140 trackingParticleToClusterVectorMap.find(thisTrackingParticle)
141 ->second.push_back(tempCluRef);
146 clusterToTrackingParticleVectorMap.find(tempCluRef)->second.push_back(tempTPPtr);
152 const std::vector<TrackingParticlePtr>& theseClusterTrackingParticlePtrs =
153 clusterToTrackingParticleVectorMap.find(tempCluRef)->second;
154 bool allOfThemAreNull =
true;
155 for (
unsigned int tpi = 0; tpi < theseClusterTrackingParticlePtrs.size() && allOfThemAreNull; tpi++) {
156 if (theseClusterTrackingParticlePtrs.at(tpi).isNull() ==
false)
157 allOfThemAreNull =
false;
160 if (allOfThemAreNull) {
162 clusterToTrackingParticleVectorMap.erase(tempCluRef);
169 for (
auto&
p : trackingParticleToClusterVectorMap) {
171 std::vector<TTClusterRef>& tempVector =
p.second;
174 std::sort(tempVector.begin(), tempVector.end());
175 tempVector.erase(
std::unique(tempVector.begin(), tempVector.end()), tempVector.end());
179 associationMapForOutput->setTTClusterToTrackingParticlesMap(clusterToTrackingParticleVectorMap);
180 associationMapForOutput->setTrackingParticleToTTClustersMap(trackingParticleToClusterVectorMap);
183 iEvent.put(
std::move(associationMapForOutput), ttClustersInputTags_.at(ncont1).instance());
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)
EncodedEventId eventId() const
Signal source, crossing number.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Mandatory methods.
const std::vector< SimTrack > & g4Tracks() const
def unique(seq, keepstr=True)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
static constexpr auto TOB
collection_type::const_iterator const_iterator
static constexpr auto TID