70 const std::vector<edm::ParameterSet>& pluginConfigs =
config.getParameter<std::vector<edm::ParameterSet>>(
"plugins");
72 for (
unsigned int iplugin = 0; iplugin < pluginConfigs.size(); ++iplugin) {
77 std::unique_ptr<TrackingRecHitAlgorithm> recHitAlgorithm{
79 if (recHitAlgorithm) {
81 <<
"adding plugin type '" << pluginType <<
"' as '" << pluginName <<
"'" << std::endl;
85 <<
"plugin type = " << pluginType <<
"\nconfiguration=\n"
93 produces<FastTrackerRecHitCollection>();
94 produces<FastTrackerRecHitRefCollection>(
"simHit2RecHitMap");
105 algo->beginStream(
id);
125 <<
"SiPixel Templates not loaded correctly from the DB object!" << std::endl;
142 trackerGeomRec.get(trackerGeometryHandle);
143 trackerTopoRec.
get(trackerTopologyHandle);
150 const std::vector<DetId>& detIds = trackerGeometry->
detIds();
151 std::vector<unsigned int> numberOfDetIdsPerAlgorithm(
_recHitAlgorithms.size(), 0);
153 for (
const DetId& detId : detIds) {
160 numberOfDetIdsPerAlgorithm[ialgo] += 1;
164 if (
pipe.size() == 0) {
165 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer: DetId not configured! (" +
166 trackerTopology->
print(detId) +
")");
185 auto output_recHits = std::make_unique<FastTrackerRecHitCollection>();
186 output_recHits->reserve(
simHits->size());
192 std::map<unsigned int, std::vector<std::pair<unsigned int, const PSimHit*>>> simHitsIdPairPerDetId;
193 for (
unsigned int ihit = 0; ihit <
simHits->size(); ++ihit) {
195 simHitsIdPairPerDetId[
simHit->detUnitId()].push_back(std::make_pair(ihit,
simHit));
198 for (
auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end();
200 const DetId& detId = simHitsIdPairIt->first;
201 std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt =
_detIdPipes.find(detId);
203 auto& simHitIdPairList = simHitsIdPairIt->second;
208 product =
pipe.produce(product);
210 const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList =
211 product->getRecHitToSimHitIdPairs();
213 for (
unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit) {
214 output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].
first);
215 const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList =
216 recHitToSimHitIdPairsList[irecHit].second;
217 double energyLoss_tot = 0;
218 for (
unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit) {
219 unsigned int simHitId = simHitIdPairList[isimHit].first;
224 if (not(*output_recHitRefs)[simHitId].isNull()) {
226 "A PSimHit cannot lead to multiple FastTrackerRecHits");
230 static_cast<FastSingleTrackerRecHit&>(output_recHits->back()).setEnergyLoss(energyLoss_tot);
235 "FastSimulation/TrackingRecHitProducer",
236 "A PSimHit carries a DetId which does not belong to the TrackerGeometry: " + std::to_string(detId));
247 for (
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex) {
252 event.put(
std::move(output_recHitRefs),
"simHit2RecHitMap");