File indexing completed on 2024-04-06 11:59:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <memory>
0020 #include <iostream>
0021 #include <algorithm>
0022
0023
0024 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
0025 #include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 #include "FWCore/Framework/interface/stream/EDFilter.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033
0034 class FilterTrackerOn : public edm::stream::EDFilter<> {
0035 public:
0036 explicit FilterTrackerOn(const edm::ParameterSet&);
0037 static void fillDescriptions(edm::ConfigurationDescriptions&);
0038 ~FilterTrackerOn() override;
0039
0040 private:
0041 bool filter(edm::Event&, const edm::EventSetup&) override;
0042
0043 int minModulesWithHVoff_;
0044 edm::ESGetToken<SiStripDetVOff, SiStripDetVOffRcd> detVOffToken_;
0045 };
0046
0047 FilterTrackerOn::FilterTrackerOn(const edm::ParameterSet& iConfig)
0048 : minModulesWithHVoff_(iConfig.getParameter<int>("MinModulesWithHVoff")), detVOffToken_(esConsumes()) {}
0049
0050 FilterTrackerOn::~FilterTrackerOn() = default;
0051
0052 void FilterTrackerOn::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0053 edm::ParameterSetDescription desc;
0054 desc.setComment("Filters out events in which at least a fraction of Tracker is DCS ON");
0055 desc.addUntracked<int>("MinModulesWithHVoff", 0);
0056 descriptions.addWithDefaultLabel(desc);
0057 }
0058
0059 bool FilterTrackerOn::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0060 using namespace edm;
0061 const auto& detVOff = iSetup.getData(detVOffToken_);
0062
0063 LogDebug("FilterTrackerOn") << "detVOff.getHVoffCounts() = " << detVOff.getHVoffCounts() << " < "
0064 << minModulesWithHVoff_;
0065 if (detVOff.getHVoffCounts() > minModulesWithHVoff_) {
0066 LogDebug("FilterTrackerOn") << " skipping event";
0067 return false;
0068 }
0069 LogDebug("FilterTrackerOn") << " keeping event";
0070 return true;
0071 }
0072
0073
0074 DEFINE_FWK_MODULE(FilterTrackerOn);