File indexing completed on 2024-04-06 12:28:10
0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/stream/EDProducer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h"
0006
0007 class dso_hidden MaskedMeasurementTrackerEventProducer final : public edm::stream::EDProducer<> {
0008 public:
0009 explicit MaskedMeasurementTrackerEventProducer(const edm::ParameterSet &iConfig);
0010 ~MaskedMeasurementTrackerEventProducer() override {}
0011
0012 private:
0013 void produce(edm::Event &, const edm::EventSetup &) override;
0014
0015 typedef edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > StripMask;
0016 typedef edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > PixelMask;
0017 typedef edm::ContainerMask<edmNew::DetSetVector<Phase2TrackerCluster1D> > Phase2OTMask;
0018
0019 edm::EDGetTokenT<MeasurementTrackerEvent> src_;
0020
0021 bool skipClusters_;
0022 bool phase2skipClusters_;
0023
0024 edm::EDGetTokenT<StripMask> maskStrips_;
0025 edm::EDGetTokenT<PixelMask> maskPixels_;
0026 edm::EDGetTokenT<Phase2OTMask> maskPhase2OTs_;
0027 };
0028
0029 MaskedMeasurementTrackerEventProducer::MaskedMeasurementTrackerEventProducer(const edm::ParameterSet &iConfig)
0030 : src_(consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("src"))),
0031 skipClusters_(false),
0032 phase2skipClusters_(false) {
0033
0034 if (iConfig.existsAs<edm::InputTag>("clustersToSkip")) {
0035 skipClusters_ = true;
0036 edm::InputTag clustersToSkip = iConfig.getParameter<edm::InputTag>("clustersToSkip");
0037 maskPixels_ = consumes<PixelMask>(clustersToSkip);
0038 maskStrips_ = consumes<StripMask>(clustersToSkip);
0039 }
0040 if (iConfig.existsAs<edm::InputTag>("phase2clustersToSkip")) {
0041 phase2skipClusters_ = true;
0042 edm::InputTag phase2clustersToSkip = iConfig.getParameter<edm::InputTag>("phase2clustersToSkip");
0043 maskPixels_ = consumes<PixelMask>(phase2clustersToSkip);
0044 maskPhase2OTs_ = consumes<Phase2OTMask>(phase2clustersToSkip);
0045 }
0046 produces<MeasurementTrackerEvent>();
0047 }
0048
0049 void MaskedMeasurementTrackerEventProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
0050 edm::Handle<MeasurementTrackerEvent> mte;
0051 iEvent.getByToken(src_, mte);
0052
0053
0054 std::unique_ptr<MeasurementTrackerEvent> out;
0055
0056 if (skipClusters_) {
0057 edm::Handle<PixelMask> maskPixels;
0058 iEvent.getByToken(maskPixels_, maskPixels);
0059 edm::Handle<StripMask> maskStrips;
0060 iEvent.getByToken(maskStrips_, maskStrips);
0061
0062 out = std::make_unique<MeasurementTrackerEvent>(*mte, *maskStrips, *maskPixels);
0063
0064 } else if (phase2skipClusters_) {
0065 edm::Handle<PixelMask> maskPixels;
0066 iEvent.getByToken(maskPixels_, maskPixels);
0067 edm::Handle<Phase2OTMask> maskPhase2OTs;
0068 iEvent.getByToken(maskPhase2OTs_, maskPhase2OTs);
0069
0070 out = std::make_unique<MeasurementTrackerEvent>(*mte, *maskPixels, *maskPhase2OTs);
0071 }
0072
0073
0074 iEvent.put(std::move(out));
0075 }
0076
0077 #include "FWCore/Framework/interface/MakerMacros.h"
0078 DEFINE_FWK_MODULE(MaskedMeasurementTrackerEventProducer);