CMS 3D CMS Logo

SiStripQualityESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripQualityESProducer
4 // Class: SiStripQualityESProducer
5 //
13 //
14 // Original Author: Domenico GIORDANO
15 // Created: Wed Oct 3 12:11:10 CEST 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
26 
29 
34 
35 namespace {
36  class ProductAdder {
37  public:
38  virtual ~ProductAdder() = default;
39  virtual void add(const SiStripQualityRcd& iRecord, SiStripQuality& quality) const = 0;
40  };
41 
42  template <typename Product, typename RealRecord>
43  class ProductAdderT : public ProductAdder {
44  public:
45  ProductAdderT(edm::ESConsumesCollector& cc, const std::string& label)
46  : token_{cc.consumesFrom<Product, RealRecord>(edm::ESInputTag{"", label})} {}
47  void add(const SiStripQualityRcd& iRecord, SiStripQuality& quality) const override {
48  quality.add(&iRecord.get(token_));
49  }
50 
51  private:
53  };
54 
55  template <typename Product, typename RealRecord>
56  auto make_ProductAdder(edm::ESConsumesCollector& cc, const std::string& label) {
57  return std::make_unique<ProductAdderT<Product, RealRecord>>(cc, label);
58  }
59 } // namespace
60 
62 public:
65 
66  std::unique_ptr<SiStripQuality> produce(const SiStripQualityRcd&);
67 
68 private:
69  std::vector<std::unique_ptr<const ProductAdder>> productAdders_;
71 
73  const bool printDebugOutput_;
74  const bool useEmptyRunInfo_;
75  const bool reduceGranularity_;
76 };
77 
79  : thresholdForReducedGranularity_{iConfig.getParameter<double>("ThresholdForReducedGranularity")},
80  printDebugOutput_{iConfig.getParameter<bool>("PrintDebugOutput")},
81  useEmptyRunInfo_{iConfig.getParameter<bool>("UseEmptyRunInfo")},
82  reduceGranularity_{iConfig.getParameter<bool>("ReduceGranularity")} {
83  auto cc = setWhatProduced(this);
84 
85  edm::LogInfo("SiStripQualityESProducer") << "ctor";
86 
87  bool doRunInfo = false;
88  std::string runInfoTagName = "";
89 
90  auto toGet = iConfig.getParameter<std::vector<edm::ParameterSet>>("ListOfRecordToMerge");
91 
92  for (const auto& toGetPSet : toGet) {
93  auto tagName = toGetPSet.getParameter<std::string>("tag");
94  auto recordName = toGetPSet.getParameter<std::string>("record");
95 
96  edm::LogInfo("SiStripQualityESProducer")
97  << "[SiStripQualityESProducer::ctor] Going to get data from record " << recordName << " with tag " << tagName;
98 
99  if (recordName == "SiStripBadModuleRcd") {
100  productAdders_.emplace_back(make_ProductAdder<SiStripBadStrip, SiStripBadModuleRcd>(cc, tagName));
101  } else if (recordName == "SiStripBadModuleFedErrRcd") {
102  productAdders_.emplace_back(make_ProductAdder<SiStripBadStrip, SiStripBadModuleFedErrRcd>(cc, tagName));
103  } else if (recordName == "SiStripBadFiberRcd") {
104  productAdders_.emplace_back(make_ProductAdder<SiStripBadStrip, SiStripBadFiberRcd>(cc, tagName));
105  } else if (recordName == "SiStripBadChannelRcd") {
106  productAdders_.emplace_back(make_ProductAdder<SiStripBadStrip, SiStripBadChannelRcd>(cc, tagName));
107  } else if (recordName == "SiStripBadStripRcd") {
108  productAdders_.emplace_back(make_ProductAdder<SiStripBadStrip, SiStripBadStripRcd>(cc, tagName));
109  } else if (recordName == "SiStripDetCablingRcd") {
110  productAdders_.emplace_back(make_ProductAdder<SiStripDetCabling, SiStripDetCablingRcd>(cc, tagName));
111  } else if (recordName == "SiStripDetVOffRcd") {
112  productAdders_.emplace_back(make_ProductAdder<SiStripDetVOff, SiStripDetVOffRcd>(cc, tagName));
113  } else if (recordName == "RunInfoRcd") {
114  runInfoTagName = tagName;
115  doRunInfo = true;
116  } else {
117  // Would it make sense to elevate this to an exception?
118  edm::LogError("SiStripQualityESProducer")
119  << "[SiStripQualityESProducer::ctor] Skipping the requested data for unexisting record " << recordName
120  << " with tag " << tagName << std::endl;
121  continue;
122  }
123  }
124 
125  if (doRunInfo) {
126  runInfoToken_ = cc.consumes(edm::ESInputTag{"", runInfoTagName});
127  }
128 }
129 
130 std::unique_ptr<SiStripQuality> SiStripQualityESProducer::produce(const SiStripQualityRcd& iRecord) {
131  auto quality = std::make_unique<SiStripQuality>();
132  edm::LogInfo("SiStripQualityESProducer") << "produce called";
133 
134  // Set the debug output level
135  quality->setPrintDebugOutput(printDebugOutput_);
136  // Set the protection against empty RunInfo objects
137  quality->setUseEmptyRunInfo(useEmptyRunInfo_);
138 
139  for (const auto& adder : productAdders_) {
140  adder->add(iRecord, *quality);
141  }
142 
143  // We do this after all the others so we know it is done after the DetCabling (if any)
145  quality->add(&iRecord.get(runInfoToken_));
146  }
147 
148  quality->cleanUp();
149 
150  if (reduceGranularity_) {
151  quality->ReduceGranularity(thresholdForReducedGranularity_);
152  quality->cleanUp(true);
153  }
154 
155  quality->fillBadComponents();
156 
157  return quality;
158 }
159 
SiStripQualityESProducer
Definition: SiStripQualityESProducer.cc:61
DBConfiguration_cff.toGet
toGet
Definition: DBConfiguration_cff.py:10
SiStripDependentRecords.h
SiStripQualityESProducer::produce
std::unique_ptr< SiStripQuality > produce(const SiStripQualityRcd &)
Definition: SiStripQualityESProducer.cc:130
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
edm::ESConsumesCollector
Definition: ESConsumesCollector.h:61
SiStripQualityESProducer::runInfoToken_
edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
Definition: SiStripQualityESProducer.cc:70
align_cfg.recordName
recordName
Definition: align_cfg.py:66
ESProducer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripQualityESProducer::reduceGranularity_
const bool reduceGranularity_
Definition: SiStripQualityESProducer.cc:75
edm::ESGetToken::isInitialized
constexpr bool isInitialized() const noexcept
Definition: ESGetToken.h:72
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
SiStripQualityESProducer::useEmptyRunInfo_
const bool useEmptyRunInfo_
Definition: SiStripQualityESProducer.cc:74
SiStripQualityRcd
Definition: SiStripDependentRecords.h:55
SiStripQualityESProducer::SiStripQualityESProducer
SiStripQualityESProducer(const edm::ParameterSet &)
Definition: SiStripQualityESProducer.cc:78
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripConstants.h
edm::ParameterSet
Definition: ParameterSet.h:47
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
cc
edm::ESGetToken
Definition: EventSetup.h:48
SiStripQualityESProducer::printDebugOutput_
const bool printDebugOutput_
Definition: SiStripQualityESProducer.cc:73
RunInfo.h
ModuleFactory.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
SiStripQuality.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripQualityESProducer::thresholdForReducedGranularity_
const double thresholdForReducedGranularity_
Definition: SiStripQualityESProducer.cc:72
edm::ESProducer
Definition: ESProducer.h:104
ParameterSet.h
JetPartonCorrections_cff.tagName
tagName
Definition: JetPartonCorrections_cff.py:12
label
const char * label
Definition: PFTauDecayModeTools.cc:11
SiStripQualityESProducer::productAdders_
std::vector< std::unique_ptr< const ProductAdder > > productAdders_
Definition: SiStripQualityESProducer.cc:69
SiStripQualityESProducer::~SiStripQualityESProducer
~SiStripQualityESProducer() override
Definition: SiStripQualityESProducer.cc:64
SiStripQuality
Definition: SiStripQuality.h:32