68 const std::vector<edm::ParameterSet>& pluginConfigs = config.
getParameter<std::vector<edm::ParameterSet>>(
"plugins");
70 for (
unsigned int iplugin = 0; iplugin<pluginConfigs.size(); ++iplugin)
79 edm::LogInfo(
"TrackingRecHitProducer: ")<<
"adding plugin type '"<<pluginType<<
"' as '"<<pluginName<<
"'"<<std::endl;
84 throw cms::Exception(
"TrackingRecHitAlgorithm plugin not found: ") <<
"plugin type = "<<pluginType<<
"\nconfiguration=\n"<<pluginConfig.
dump();
89 _simHitToken = consumes<std::vector<PSimHit>>(simHitTag);
91 produces<FastTrackerRecHitCollection>();
92 produces<FastTrackerRecHitRefCollection>(
"simHit2RecHitMap");
101 _recHitAlgorithms.clear();
108 algo->beginStream(
id);
132 const std::vector<DetId>& detIds = trackerGeometry->
detIds();
133 std::vector<unsigned int> numberOfDetIdsPerAlgorithm(
_recHitAlgorithms.size(),0);
135 for (
const DetId& detId: detIds)
145 numberOfDetIdsPerAlgorithm[ialgo]+=1;
151 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer: DetId not configured! ("+trackerTopology->
print(detId)+
")");
167 algo->beginEvent(event,eventSetup);
175 output_recHits->reserve(simHits->size());
180 std::map<unsigned int,std::vector<std::pair<unsigned int,const PSimHit*>>> simHitsIdPairPerDetId;
181 for (
unsigned int ihit = 0; ihit < simHits->size(); ++ihit)
183 const PSimHit* simHit = &(*simHits)[ihit];
184 simHitsIdPairPerDetId[simHit->
detUnitId()].push_back(std::make_pair(ihit,simHit));
187 for (
auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end(); ++simHitsIdPairIt)
189 const DetId& detId = simHitsIdPairIt->first;
190 std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt =
_detIdPipes.find(detId);
193 auto& simHitIdPairList = simHitsIdPairIt->second;
198 product = pipe.
produce(product);
200 const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList = product->getRecHitToSimHitIdPairs();
203 for (
unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit)
205 output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].
first);
206 const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList = recHitToSimHitIdPairsList[irecHit].second;
207 for (
unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit)
209 unsigned int simHitId = simHitIdPairList[isimHit].first;
210 if (not (*output_recHitRefs)[simHitId].isNull())
212 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit cannot lead to multiple FastTrackerRecHits");
214 (*output_recHitRefs)[simHitId] =
FastTrackerRecHitRef(output_recHits_refProd,output_recHits->size()-1);
221 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer",
"A PSimHit carries a DetId which does not belong to the TrackerGeometry: "+std::to_string(detId));
228 algo->endEvent(event,eventSetup);
233 for(
unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex)
239 event.put(
std::move(output_recHitRefs),
"simHit2RecHitMap");
T getParameter(std::string const &) const
virtual void beginRun(edm::Run const &, const edm::EventSetup &eventSetup)
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
virtual void beginStream(edm::StreamID id)
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup)
T const * product() const
const IOVSyncValue & iovSyncValue() const
std::vector< FastTrackerRecHitRef > FastTrackerRecHitRefCollection
TrackingRecHitProducer(const edm::ParameterSet &config)
const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
TrackingRecHitProductPtr produce(TrackingRecHitProductPtr product) const
T get(const Candidate &c)
unsigned int detUnitId() const
virtual ~TrackingRecHitProducer()