75 const std::vector<edm::ParameterSet>& pluginConfigs = config.
getParameter<std::vector<edm::ParameterSet>>(
"plugins");
77 for (
unsigned int iplugin = 0; iplugin < pluginConfigs.size(); ++iplugin) {
82 std::unique_ptr<TrackingRecHitAlgorithm> recHitAlgorithm{
84 if (recHitAlgorithm) {
86 <<
"adding plugin type '" << pluginType <<
"' as '" << pluginName <<
"'" << std::endl;
90 <<
"plugin type = " << pluginType <<
"\nconfiguration=\n"
91 << pluginConfig.
dump();
96 _simHitToken = consumes<std::vector<PSimHit>>(simHitTag);
98 produces<FastTrackerRecHitCollection>();
99 produces<FastTrackerRecHitRefCollection>(
"simHit2RecHitMap");
106 algo->beginStream(
id);
124 <<
"SiPixel Templates not loaded correctly from the DB object!" << std::endl;
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) +
")");
174 algo->beginEvent(event, eventSetup);
181 auto output_recHits = std::make_unique<FastTrackerRecHitCollection>();
182 output_recHits->reserve(simHits->size());
186 auto output_recHitRefs = std::make_unique<FastTrackerRecHitRefCollection>(simHits->size(),
FastTrackerRecHitRef());
188 std::map<unsigned int, std::vector<std::pair<unsigned int, const PSimHit*>>> simHitsIdPairPerDetId;
189 for (
unsigned int ihit = 0; ihit < simHits->size(); ++ihit) {
190 const PSimHit* simHit = &(*simHits)[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;
216 const PSimHit* simHit = simHitIdPairList[isimHit].second;
220 if (not(*output_recHitRefs)[simHitId].isNull()) {
222 "A PSimHit cannot lead to multiple FastTrackerRecHits");
224 (*output_recHitRefs)[simHitId] =
FastTrackerRecHitRef(output_recHits_refProd, output_recHits->size() - 1);
231 "FastSimulation/TrackingRecHitProducer",
232 "A PSimHit carries a DetId which does not belong to the TrackerGeometry: " + std::to_string(detId));
237 for (
auto&
algo : _recHitAlgorithms) {
238 algo->endEvent(event, eventSetup);
243 for (
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex) {
248 event.put(
std::move(output_recHitRefs),
"simHit2RecHitMap");
unsigned long long cacheIdentifier() const
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::string dump(unsigned int indent=0) const
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
#define DEFINE_FWK_MODULE(type)
void setupDetIdPipes(const edm::EventSetup &eventSetup)
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
void beginStream(edm::StreamID id) override
~TrackingRecHitProducer() override
void addAlgorithm(TrackingRecHitAlgorithm *algorithm)
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
std::string print(DetId detid) const
unsigned long long _trackerGeometryCacheID
edm::Ref< FastTrackerRecHitCollection > FastTrackerRecHitRef
std::vector< SiPixelTemplateStore > _pixelTempStore
bool getData(T &iHolder) const
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_
unsigned int size() const
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
Log< level::Info, false > LogInfo
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateDBObjectESToken_
T getParameter(std::string const &) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
bool passSelection(const std::string &selectionStr) const
tuple config
parse the configuration file
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
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms
void endStream() override
unsigned long long _trackerTopologyCacheID
TrackingRecHitProductPtr produce(TrackingRecHitProductPtr product) const
unsigned int detUnitId() const