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 {
58  };
59 
60  std::unique_ptr<SiPixelQuality> get_pointer(const SiPixelQualityRcd& iRecord, const Tokens& tokens);
61 
64 };
65 
66 //
67 // constructors and destructor
68 //
69 
71  edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
72 
73  auto label =
74  conf_.exists("siPixelQualityLabel") ? conf_.getParameter<std::string>("siPixelQualityLabel") : std::string{};
75  auto setConsumes = [](edm::ESConsumesCollector&& cc, Tokens& tokens, const std::string& label) {
76  cc.setConsumes(tokens.voffToken_).setConsumes(tokens.dbobjectToken_, edm::ESInputTag{"", label});
77  };
78 
79  //the following line is needed to tell the framework what
80  // data is being produced
81  setConsumes(setWhatProduced(this), defaultTokens_, "");
82  if (label == "forDigitizer") {
83  setConsumes(
84  setWhatProduced(this, &SiPixelQualityESProducer::produceWithLabel, edm::es::Label(label)), labelTokens_, label);
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 
T getParameter(std::string const &) const
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::unique_ptr< SiPixelQuality > produceWithLabel(const SiPixelQualityRcd &iRecord)
char const * label
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
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_
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
HLT enums.
std::unique_ptr< SiPixelQuality > produce(const SiPixelQualityRcd &iRecord)
ESConsumesCollector & setConsumes(ESGetToken< Product, Record > &token, ESInputTag const &tag)
SiPixelQualityESProducer(const edm::ParameterSet &iConfig)