74 const std::vector<edm::ParameterSet>& pluginConfigs = config.
getParameter<std::vector<edm::ParameterSet>>(
"plugins");
76 for (
unsigned int iplugin = 0; iplugin<pluginConfigs.size(); ++iplugin)
85 edm::LogInfo(
"TrackingRecHitProducer: ")<<
"adding plugin type '"<<pluginType<<
"' as '"<<pluginName<<
"'"<<std::endl;
90 throw cms::Exception(
"TrackingRecHitAlgorithm plugin not found: ") <<
"plugin type = "<<pluginType<<
"\nconfiguration=\n"<<pluginConfig.
dump();
97 produces<FastTrackerRecHitCollection>();
98 produces<FastTrackerRecHitRefCollection>(
"simHit2RecHitMap");
107 _recHitAlgorithms.clear();
118 algo->beginStream(
id);
139 <<
"SiPixel Templates not loaded correctly from the DB object!" << std::endl;
163 const std::vector<DetId>& detIds = trackerGeometry->
detIds();
164 std::vector<unsigned int> numberOfDetIdsPerAlgorithm(
_recHitAlgorithms.size(),0);
166 for (
const DetId& detId: detIds)
176 numberOfDetIdsPerAlgorithm[ialgo]+=1;
182 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer: DetId not configured! ("+trackerTopology->
print(detId)+
")");
198 algo->beginEvent(event,eventSetup);
206 output_recHits->reserve(simHits->size());
211 std::map<unsigned int,std::vector<std::pair<unsigned int,const PSimHit*>>> simHitsIdPairPerDetId;
212 for (
unsigned int ihit = 0; ihit < simHits->size(); ++ihit)
215 simHitsIdPairPerDetId[simHit->
detUnitId()].push_back(std::make_pair(ihit,simHit));
218 for (
auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end(); ++simHitsIdPairIt)
220 const DetId& detId = simHitsIdPairIt->first;
221 std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt =
_detIdPipes.find(detId);
224 auto& simHitIdPairList = simHitsIdPairIt->second;
229 product = pipe.
produce(product);
231 const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList = product->getRecHitToSimHitIdPairs();
234 for (
unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit)
236 output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].
first);
237 const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList = recHitToSimHitIdPairsList[irecHit].second;
238 double energyLoss_tot = 0;
239 for (
unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit){
240 unsigned int simHitId = simHitIdPairList[isimHit].first;
243 if (not (*output_recHitRefs)[simHitId].isNull())
245 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit cannot lead to multiple FastTrackerRecHits");
255 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit carries a DetId which does not belong to the TrackerGeometry: "+std::to_string(detId));
262 algo->endEvent(event,eventSetup);
267 for(
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex)
273 event.put(
std::move(output_recHitRefs),
"simHit2RecHitMap");
T getParameter(std::string const &) const
std::string dump(unsigned int indent=0) const
edm::IOVSyncValue _iovSyncValue
#define DEFINE_FWK_MODULE(type)
void setupDetIdPipes(const edm::EventSetup &eventSetup)
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
void beginStream(edm::StreamID id) override
~TrackingRecHitProducer() override
void addAlgorithm(TrackingRecHitAlgorithm *algorithm)
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
std::string print(DetId detid) const
edm::Ref< FastTrackerRecHitCollection > FastTrackerRecHitRef
bool passSelection(std::string selectionStr) const
const std::string & getSelectionString() const
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
unsigned int size() const
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
def pipe(cmdline, input=None)
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
const IOVSyncValue & iovSyncValue() const
std::vector< FastTrackerRecHitRef > FastTrackerRecHitRefCollection
TrackingRecHitProducer(const edm::ParameterSet &config)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
void beginRun(edm::Run const &, const edm::EventSetup &eventSetup) override
void endStream() override
std::vector< SiPixelTemplateStore > _pixelTempStore
T const * product() const
TrackingRecHitProductPtr produce(TrackingRecHitProductPtr product) const
T get(const Candidate &c)
unsigned int detUnitId() const