CMS 3D CMS Logo

SiPixelQualityESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelQualityESProducer
4 // Class: SiPixelQualityESProducer
5 //
13 //
14 // Original Author: Gemma Tinti
15 // Created: Jan 13 2011
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <cassert>
22 
23 // user include files
39 
40 using namespace edm;
41 
43 public:
45  ~SiPixelQualityESProducer() override;
46 
47  std::unique_ptr<SiPixelQuality> produce(const SiPixelQualityRcd& iRecord);
48  std::unique_ptr<SiPixelQuality> produceWithLabel(const SiPixelQualityRcd& iRecord);
49  std::unique_ptr<SiPixelQuality> produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord);
50 
51 private:
52  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
53  const edm::IOVSyncValue&,
54  edm::ValidityInterval&) override;
55 
56  struct Tokens {
57  Tokens() = default;
59  voffToken_ = cc.consumes();
60  dbobjectToken_ = cc.consumes(edm::ESInputTag{"", label});
61  }
64  };
65 
66  std::unique_ptr<SiPixelQuality> get_pointer(const SiPixelQualityRcd& iRecord, const Tokens& tokens);
67 
71 };
72 
73 //
74 // constructors and destructor
75 //
76 
78  : defaultTokens_(setWhatProduced(this), "") {
79  edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
80 
81  auto label =
82  conf_.exists("siPixelQualityLabel") ? conf_.getParameter<std::string>("siPixelQualityLabel") : std::string{};
83 
84  if (label == "forDigitizer") {
85  labelTokens_ =
87  }
88 
89  label = conf_.exists("siPixelQualityLabel_RawToDigi")
90  ? conf_.getParameter<std::string>("siPixelQualityLabel_RawToDigi")
91  : std::string{};
92 
93  if (label == "forRawToDigi") {
96  }
97  findingRecord<SiPixelQualityRcd>();
98 }
99 
101  // do anything here that needs to be done at desctruction time
102  // (e.g. close files, deallocate resources etc.)
103 }
104 
105 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::get_pointer(const SiPixelQualityRcd& iRecord,
106  const Tokens& tokens) {
108  // errortype "whole" = int 0 in DB BadRocs = 65535 //
109  // errortype "tbmA" = int 1 in DB BadRocs = 255 //
110  // errortype "tbmB" = int 2 in DB Bad Rocs = 65280 //
111  // errortype "none" = int 3 in DB //
113 
114  //if I have understood this is the one got from the DB or file, but in any case the ORIGINAL(maybe i need to get the record for it)
115  //SiPixelQuality * obj = new SiPixelQuality();
116  //SiPixelQuality::disabledModuleType BadModule;
117  //BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);
118 
119  //now the dbobject is the one copied from the db
120  auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(tokens.dbobjectToken_));
121 
122  //here is the magic line in which it switches off Bad Modules
123  dbptr->add(&(iRecord.get(tokens.voffToken_)));
124  return dbptr;
125 }
126 
127 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
128  return get_pointer(iRecord, defaultTokens_);
129 }
130 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabel(const SiPixelQualityRcd& iRecord) {
131  return get_pointer(iRecord, labelTokens_);
132 }
133 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord) {
134  return get_pointer(iRecord, labelTokens_RawToDigi_);
135 }
136 
138  const edm::IOVSyncValue& iosv,
139  edm::ValidityInterval& oValidity) {
141  oValidity = infinity;
142 }
143 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool exists(std::string const &parameterName) const
checks if a parameter exists
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::unique_ptr< SiPixelQuality > produceWithLabel(const SiPixelQualityRcd &iRecord)
std::unique_ptr< SiPixelQuality > produceWithLabelRawToDigi(const SiPixelQualityRcd &iRecord)
char const * label
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
std::unique_ptr< SiPixelQuality > get_pointer(const SiPixelQualityRcd &iRecord, const Tokens &tokens)
const double infinity
edm::ESGetToken< SiStripDetVOff, SiPixelDetVOffRcd > voffToken_
edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > dbobjectToken_
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
Tokens(edm::ESConsumesCollector cc, const std::string &label)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Log< level::Info, false > LogInfo
HLT enums.
std::unique_ptr< SiPixelQuality > produce(const SiPixelQualityRcd &iRecord)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
ESConsumesCollectorAdaptor consumes()
SiPixelQualityESProducer(const edm::ParameterSet &iConfig)