File indexing completed on 2024-04-06 12:30:45
0001
0002 #include <memory>
0003 #include <string>
0004 #include <vector>
0005 #include <iostream>
0006 #include <algorithm>
0007 #include <regex>
0008
0009
0010 #include "FWCore/Framework/interface/Frameworkfwd.h"
0011 #include "FWCore/Framework/interface/global/EDProducer.h"
0012 #include "FWCore/Framework/interface/ConsumesCollector.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Utilities/interface/ESGetToken.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019
0020 #include "DataFormats/Common/interface/DetSetVector.h"
0021 #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
0022 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0023 #include "CondFormats/RecoMuonObjects/interface/MuonSystemAging.h"
0024 #include "CondFormats/DataRecord/interface/MuonSystemAgingRcd.h"
0025
0026
0027
0028
0029
0030 class GEMChamberMasker : public edm::global::EDProducer<> {
0031 public:
0032 explicit GEMChamberMasker(const edm::ParameterSet&);
0033
0034 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0035
0036 private:
0037 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0038
0039
0040 const edm::InputTag digiTag_;
0041 const bool ge11Minus_;
0042 const bool ge11Plus_;
0043 const bool ge21Minus_;
0044 const bool ge21Plus_;
0045
0046 const edm::EDGetTokenT<GEMDigiCollection> m_digiTag;
0047 const edm::EDPutTokenT<GEMDigiCollection> m_putToken;
0048 const edm::ESGetToken<MuonSystemAging, MuonSystemAgingRcd> m_agingObj;
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 GEMChamberMasker::GEMChamberMasker(const edm::ParameterSet& iConfig)
0063 : digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")),
0064 ge11Minus_(iConfig.getParameter<bool>("ge11Minus")),
0065 ge11Plus_(iConfig.getParameter<bool>("ge11Plus")),
0066 ge21Minus_(iConfig.getParameter<bool>("ge21Minus")),
0067 ge21Plus_(iConfig.getParameter<bool>("ge21Plus")),
0068 m_digiTag(consumes(digiTag_)),
0069 m_putToken(produces()),
0070 m_agingObj(esConsumes()) {}
0071
0072
0073
0074
0075
0076
0077 void GEMChamberMasker::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0078 using namespace edm;
0079 GEMDigiCollection filteredDigis;
0080
0081 auto const& agingObj = iSetup.getData(m_agingObj);
0082
0083 auto const& maskedGEMIDs = agingObj.m_GEMChambEffs;
0084
0085 if (!digiTag_.label().empty()) {
0086 GEMDigiCollection const& gemDigis = iEvent.get(m_digiTag);
0087
0088 for (const auto& gemLayerId : gemDigis) {
0089 auto chambId = gemLayerId.first.chamberId();
0090
0091 bool keepDigi = (!ge11Minus_ && chambId.station() == 1 && chambId.region() < 0) ||
0092 (!ge11Plus_ && chambId.station() == 1 && chambId.region() > 0) ||
0093 (!ge21Minus_ && chambId.station() == 2 && chambId.region() < 0) ||
0094 (!ge21Plus_ && chambId.station() == 2 && chambId.region() > 0);
0095
0096 uint32_t rawId = chambId.rawId();
0097 if (keepDigi || maskedGEMIDs.find(rawId) == maskedGEMIDs.end()) {
0098 filteredDigis.put(gemLayerId.second, gemLayerId.first);
0099 }
0100 }
0101 }
0102
0103 iEvent.emplace(m_putToken, std::move(filteredDigis));
0104 }
0105
0106 void GEMChamberMasker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0107 edm::ParameterSetDescription desc;
0108 desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonGEMDigis"));
0109 desc.add<bool>("ge11Minus", true);
0110 desc.add<bool>("ge11Plus", true);
0111 desc.add<bool>("ge21Minus", true);
0112 desc.add<bool>("ge21Plus", true);
0113
0114 descriptions.add("gemChamberMasker", desc);
0115 }
0116
0117
0118 DEFINE_FWK_MODULE(GEMChamberMasker);