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 
50 private:
51  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
52  const edm::IOVSyncValue&,
53  edm::ValidityInterval&) override;
54 
55  struct Tokens {
56  Tokens() = default;
58  voffToken_ = cc.consumes();
59  dbobjectToken_ = cc.consumes(edm::ESInputTag{"", label});
60  }
63  };
64 
65  std::unique_ptr<SiPixelQuality> get_pointer(const SiPixelQualityRcd& iRecord, const Tokens& tokens);
66 
69 };
70 
71 //
72 // constructors and destructor
73 //
74 
76  : defaultTokens_(setWhatProduced(this), "") {
77  edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
78 
79  auto label =
80  conf_.exists("siPixelQualityLabel") ? conf_.getParameter<std::string>("siPixelQualityLabel") : std::string{};
81 
82  if (label == "forDigitizer" || label == "forRawToDigi") {
83  labelTokens_ =
85  }
86  findingRecord<SiPixelQualityRcd>();
87 }
88 
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 }
93 
94 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::get_pointer(const SiPixelQualityRcd& iRecord,
95  const Tokens& tokens) {
97  // errortype "whole" = int 0 in DB BadRocs = 65535 //
98  // errortype "tbmA" = int 1 in DB BadRocs = 255 //
99  // errortype "tbmB" = int 2 in DB Bad Rocs = 65280 //
100  // errortype "none" = int 3 in DB //
102 
103  //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)
104  //SiPixelQuality * obj = new SiPixelQuality();
105  //SiPixelQuality::disabledModuleType BadModule;
106  //BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);
107 
108  //now the dbobject is the one copied from the db
109  auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(tokens.dbobjectToken_));
110 
111  //here is the magic line in which it switches off Bad Modules
112  dbptr->add(&(iRecord.get(tokens.voffToken_)));
113  return dbptr;
114 }
115 
116 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
117  return get_pointer(iRecord, defaultTokens_);
118 }
119 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabel(const SiPixelQualityRcd& iRecord) {
120  return get_pointer(iRecord, labelTokens_);
121 }
122 
124  const edm::IOVSyncValue& iosv,
125  edm::ValidityInterval& oValidity) {
127  oValidity = infinity;
128 }
129 
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)
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_
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
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
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)