171 algo->beginEvent(event,eventSetup);
179 output_recHits->reserve(simHits->size());
184 std::map<unsigned int,std::vector<std::pair<unsigned int,const PSimHit*>>> simHitsIdPairPerDetId;
185 for (
unsigned int ihit = 0; ihit < simHits->size(); ++ihit)
188 simHitsIdPairPerDetId[simHit->
detUnitId()].push_back(std::make_pair(ihit,simHit));
191 for (
auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end(); ++simHitsIdPairIt)
193 const DetId& detId = simHitsIdPairIt->first;
194 std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt =
_detIdPipes.find(detId);
197 auto& simHitIdPairList = simHitsIdPairIt->second;
202 product = pipe.
produce(product);
204 const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList = product->getRecHitToSimHitIdPairs();
207 for (
unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit)
209 output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].
first);
210 const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList = recHitToSimHitIdPairsList[irecHit].second;
211 for (
unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit)
213 unsigned int simHitId = simHitIdPairList[isimHit].first;
214 if (not (*output_recHitRefs)[simHitId].isNull())
216 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit cannot lead to multiple FastTrackerRecHits");
225 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit carries a DetId which does not belong to the TrackerGeometry: "+std::to_string(detId));
232 algo->endEvent(event,eventSetup);
237 for(
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex)
243 event.put(
std::move(output_recHitRefs),
"simHit2RecHitMap");
void setupDetIdPipes(const edm::EventSetup &eventSetup)
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
edm::Ref< FastTrackerRecHitCollection > FastTrackerRecHitRef
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
std::vector< FastTrackerRecHitRef > FastTrackerRecHitRefCollection
TrackingRecHitProductPtr produce(TrackingRecHitProductPtr product) const
unsigned int detUnitId() const