File indexing completed on 2024-04-06 12:11:23
0001
0002 #include <memory>
0003
0004
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/stream/EDProducer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Utilities/interface/StreamID.h"
0011
0012
0013 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0014 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0015 #include "DataFormats/TrackerRecHit2D/interface/FastTrackerRecHitCollection.h"
0016 #include "FastSimulation/Tracking/interface/FastTrackerRecHitSplitter.h"
0017
0018 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0019 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0020 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0021 #include "FWCore/Framework/interface/ESHandle.h"
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023
0024 class FastTrackerRecHitCombiner : public edm::stream::EDProducer<> {
0025 public:
0026 explicit FastTrackerRecHitCombiner(const edm::ParameterSet&);
0027 ~FastTrackerRecHitCombiner() override { ; }
0028
0029 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0030
0031 private:
0032 void beginStream(edm::StreamID) override { ; }
0033 void produce(edm::Event&, const edm::EventSetup&) override;
0034 void endStream() override { ; }
0035
0036
0037 edm::EDGetTokenT<edm::PSimHitContainer> simHitsToken;
0038 edm::EDGetTokenT<FastTrackerRecHitRefCollection> simHit2RecHitMapToken;
0039 unsigned int minNHits;
0040 };
0041
0042 FastTrackerRecHitCombiner::FastTrackerRecHitCombiner(const edm::ParameterSet& iConfig)
0043 : simHitsToken(consumes<edm::PSimHitContainer>(iConfig.getParameter<edm::InputTag>("simHits"))),
0044 simHit2RecHitMapToken(
0045 consumes<FastTrackerRecHitRefCollection>(iConfig.getParameter<edm::InputTag>("simHit2RecHitMap"))),
0046 minNHits(iConfig.getParameter<unsigned int>("minNHits")) {
0047 produces<FastTrackerRecHitCombinationCollection>();
0048 }
0049
0050 void FastTrackerRecHitCombiner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0051
0052 edm::Handle<edm::PSimHitContainer> simHits;
0053 iEvent.getByToken(simHitsToken, simHits);
0054
0055 edm::Handle<FastTrackerRecHitRefCollection> simHit2RecHitMap;
0056 iEvent.getByToken(simHit2RecHitMapToken, simHit2RecHitMap);
0057
0058
0059 std::unique_ptr<FastTrackerRecHitCombinationCollection> output(new FastTrackerRecHitCombinationCollection);
0060
0061 FastTrackerRecHitCombination currentCombination;
0062 for (unsigned int simHitCounter = 0; simHitCounter < simHits->size(); simHitCounter++) {
0063
0064 const PSimHit& simHit = (*simHits)[simHitCounter];
0065 const FastTrackerRecHitRef& recHit = (*simHit2RecHitMap)[simHitCounter];
0066
0067
0068 if (!recHit.isNull())
0069 currentCombination.push_back(recHit);
0070
0071
0072 if (simHits->size() - simHitCounter == 1 || simHit.trackId() != (*simHits)[simHitCounter + 1].trackId()) {
0073
0074 if (currentCombination.size() >= minNHits) {
0075 currentCombination.shrink_to_fit();
0076 output->push_back(currentCombination);
0077 }
0078 currentCombination.clear();
0079 }
0080 }
0081
0082
0083 iEvent.put(std::move(output));
0084 }
0085
0086
0087 void FastTrackerRecHitCombiner::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0088
0089
0090 edm::ParameterSetDescription desc;
0091 desc.setUnknown();
0092 descriptions.addDefault(desc);
0093 }
0094
0095
0096 DEFINE_FWK_MODULE(FastTrackerRecHitCombiner);