File indexing completed on 2024-04-06 12:00:00
0001 #ifndef CALIBTRACKER_SISTRIPESPRODUCERS_INTERFACE_SISTRIPQUALITYHELPERS_H
0002 #define CALIBTRACKER_SISTRIPESPRODUCERS_INTERFACE_SISTRIPQUALITYHELPERS_H
0003
0004 #include <memory>
0005 #include "DQMServices/Core/interface/DQMStore.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/Framework/interface/ESWatcher.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0011 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
0012 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
0013
0014 class SiStripFedCablingRcd;
0015
0016 namespace sistrip {
0017
0018
0019
0020
0021 std::unique_ptr<SiStripQuality> badStripFromFedErr(dqm::harvesting::DQMStore::IGetter& dqmStore,
0022 const SiStripFedCabling& fedCabling,
0023 float cutoff);
0024
0025
0026
0027
0028
0029
0030 std::unique_ptr<SiStripQuality> badStripFromFedErrLegacyDQMFile(const std::string& fileName,
0031 unsigned int runNumber,
0032 const SiStripFedCabling& fedCabling,
0033 float cutoff);
0034
0035
0036
0037
0038
0039
0040 }
0041
0042 class SiStripQualityWithFromFedErrorsHelper {
0043 public:
0044 SiStripQualityWithFromFedErrorsHelper(const edm::ParameterSet& iConfig,
0045 edm::ConsumesCollector iC,
0046 bool keepCopy = false) {
0047 const auto& fedErrConfig = iConfig.getParameter<edm::ParameterSet>("BadComponentsFromFedErrors");
0048 addBadCompFromFedErr_ = fedErrConfig.getParameter<bool>("Add");
0049 fedErrCutoff_ = float(fedErrConfig.getParameter<double>("Cutoff"));
0050 fedErrLegacyFile_ = fedErrConfig.getParameter<std::string>("LegacyDQMFile");
0051 fedErrFileRunNumber_ = fedErrConfig.getParameter<unsigned int>("FileRunNumber");
0052 stripQualityToken_ = iC.esConsumes<edm::Transition::EndRun>(
0053 edm::ESInputTag{"", iConfig.getParameter<std::string>("StripQualityLabel")});
0054 if (addBadCompFromFedErr_) {
0055 fedCablingToken_ = iC.esConsumes<edm::Transition::EndRun>();
0056 }
0057
0058
0059 keepCopy_ = keepCopy || addBadCompFromFedErr_;
0060 }
0061
0062 static void fillDescription(edm::ParameterSetDescription& desc) {
0063 desc.add<std::string>("StripQualityLabel", "");
0064 edm::ParameterSetDescription descFedErr;
0065 descFedErr.add<bool>("Add", false);
0066 descFedErr.add<double>("Cutoff", 0.8);
0067 descFedErr.add<std::string>("LegacyDQMFile", "");
0068 descFedErr.add<unsigned int>("FileRunNumber", -1);
0069 desc.add<edm::ParameterSetDescription>("BadComponentsFromFedErrors", descFedErr);
0070 }
0071
0072 bool endRun(const edm::EventSetup&);
0073 const SiStripQuality& getMergedQuality(dqm::harvesting::DQMStore::IGetter& getter);
0074
0075 bool addBadCompFromFedErr() const { return addBadCompFromFedErr_; }
0076 const edm::ESGetToken<SiStripQuality, SiStripQualityRcd>& qualityToken() const { return stripQualityToken_; }
0077
0078 private:
0079 bool addBadCompFromFedErr_ = false;
0080 float fedErrCutoff_;
0081 std::string fedErrLegacyFile_;
0082 unsigned int fedErrFileRunNumber_;
0083 edm::ESGetToken<SiStripQuality, SiStripQualityRcd> stripQualityToken_;
0084 edm::ESGetToken<SiStripFedCabling, SiStripFedCablingRcd> fedCablingToken_;
0085 edm::ESWatcher<SiStripQualityRcd> stripQualityWatcher_;
0086 std::unique_ptr<SiStripFedCabling> fedCabling_;
0087 std::unique_ptr<SiStripQuality> mergedQuality_;
0088 bool merged_ = false;
0089 bool keepCopy_;
0090 };
0091
0092 #endif