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");
101 algo->beginStream(
id);
121 <<
"SiPixel Templates not loaded correctly from the DB object!" << std::endl;
138 trackerGeomRec.get(trackerGeometryHandle);
139 trackerTopoRec.
get(trackerTopologyHandle);
146 const std::vector<DetId>& detIds = trackerGeometry->
detIds();
147 std::vector<unsigned int> numberOfDetIdsPerAlgorithm(
_recHitAlgorithms.size(), 0);
149 for (
const DetId& detId : detIds) {
156 numberOfDetIdsPerAlgorithm[ialgo] += 1;
160 if (
pipe.size() == 0) {
161 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer: DetId not configured! (" +
162 trackerTopology->
print(detId) +
")");
181 auto output_recHits = std::make_unique<FastTrackerRecHitCollection>();
182 output_recHits->reserve(
simHits->size());
188 std::map<unsigned int, std::vector<std::pair<unsigned int, const PSimHit*>>> simHitsIdPairPerDetId;
189 for (
unsigned int ihit = 0; ihit <
simHits->size(); ++ihit) {
191 simHitsIdPairPerDetId[
simHit->detUnitId()].push_back(std::make_pair(ihit,
simHit));
194 for (
auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end();
196 const DetId& detId = simHitsIdPairIt->first;
197 std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt =
_detIdPipes.find(detId);
199 auto& simHitIdPairList = simHitsIdPairIt->second;
204 product =
pipe.produce(product);
206 const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList =
207 product->getRecHitToSimHitIdPairs();
209 for (
unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit) {
210 output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].
first);
211 const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList =
212 recHitToSimHitIdPairsList[irecHit].second;
213 double energyLoss_tot = 0;
214 for (
unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit) {
215 unsigned int simHitId = simHitIdPairList[isimHit].first;
220 if (not(*output_recHitRefs)[simHitId].isNull()) {
222 "A PSimHit cannot lead to multiple FastTrackerRecHits");
226 static_cast<FastSingleTrackerRecHit&>(output_recHits->back()).setEnergyLoss(energyLoss_tot);
231 "FastSimulation/TrackingRecHitProducer",
232 "A PSimHit carries a DetId which does not belong to the TrackerGeometry: " + std::to_string(detId));
243 for (
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex) {
248 event.put(
std::move(output_recHitRefs),
"simHit2RecHitMap");