202 algo->beginEvent(event,eventSetup);
210 output_recHits->reserve(simHits->size());
215 std::map<unsigned int,std::vector<std::pair<unsigned int,const PSimHit*>>> simHitsIdPairPerDetId;
216 for (
unsigned int ihit = 0; ihit < simHits->size(); ++ihit)
219 simHitsIdPairPerDetId[simHit->
detUnitId()].push_back(std::make_pair(ihit,simHit));
222 for (
auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end(); ++simHitsIdPairIt)
224 const DetId& detId = simHitsIdPairIt->first;
225 std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt =
_detIdPipes.find(detId);
228 auto& simHitIdPairList = simHitsIdPairIt->second;
233 product = pipe.
produce(product);
235 const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList = product->getRecHitToSimHitIdPairs();
238 for (
unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit)
240 output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].
first);
241 const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList = recHitToSimHitIdPairsList[irecHit].second;
242 double energyLoss_tot = 0;
243 for (
unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit){
244 unsigned int simHitId = simHitIdPairList[isimHit].first;
245 const PSimHit * simHit = simHitIdPairList[isimHit].second;
247 if (not (*output_recHitRefs)[simHitId].isNull())
249 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit cannot lead to multiple FastTrackerRecHits");
259 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit carries a DetId which does not belong to the TrackerGeometry: "+std::to_string(detId));
266 algo->endEvent(event,eventSetup);
271 for(
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex)
277 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
float energyLoss() const
The energy deposit in the PSimHit, in ???.
TrackingRecHitProductPtr produce(TrackingRecHitProductPtr product) const
unsigned int detUnitId() const