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
41 
42 using namespace edm;
43 
45 public:
47  ~SiPixelQualityESProducer() override;
48 
49  std::unique_ptr<SiPixelQuality> produce(const SiPixelQualityRcd& iRecord);
50  std::unique_ptr<SiPixelQuality> produceWithLabel(const SiPixelQualityRcd& iRecord);
51  std::unique_ptr<SiPixelQuality> produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord);
52 
54 
55 private:
56  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
57  const edm::IOVSyncValue&,
58  edm::ValidityInterval&) override;
59 
60  struct Tokens {
61  Tokens() = default;
63  voffToken_ = cc.consumes();
64  dbobjectToken_ = cc.consumes(edm::ESInputTag{"", label});
65  }
68  };
69 
70  std::unique_ptr<SiPixelQuality> get_pointer(const SiPixelQualityRcd& iRecord, const Tokens& tokens);
71 
75 };
76 
77 //
78 // constructors and destructor
79 //
80 
82  : defaultTokens_(setWhatProduced(this), "") {
83  edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
84 
85  auto label = conf_.getParameter<std::string>("siPixelQualityLabel");
86 
87  if (label == "forDigitizer") {
88  labelTokens_ =
90  }
91 
92  label = conf_.getParameter<std::string>("siPixelQualityLabel_RawToDigi");
93 
94  if (label == "forRawToDigi") {
97  }
98  findingRecord<SiPixelQualityRcd>();
99 }
100 
102  // do anything here that needs to be done at desctruction time
103  // (e.g. close files, deallocate resources etc.)
104 }
105 
106 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::get_pointer(const SiPixelQualityRcd& iRecord,
107  const Tokens& tokens) {
109  // errortype "whole" = int 0 in DB BadRocs = 65535 //
110  // errortype "tbmA" = int 1 in DB BadRocs = 255 //
111  // errortype "tbmB" = int 2 in DB Bad Rocs = 65280 //
112  // errortype "none" = int 3 in DB //
114 
115  //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)
116  //SiPixelQuality * obj = new SiPixelQuality();
117  //SiPixelQuality::disabledModuleType BadModule;
118  //BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);
119 
120  //now the dbobject is the one copied from the db
121  auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(tokens.dbobjectToken_));
122 
123  //here is the magic line in which it switches off Bad Modules
124  dbptr->add(&(iRecord.get(tokens.voffToken_)));
125  return dbptr;
126 }
127 
128 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
129  return get_pointer(iRecord, defaultTokens_);
130 }
131 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabel(const SiPixelQualityRcd& iRecord) {
132  return get_pointer(iRecord, labelTokens_);
133 }
134 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord) {
135  return get_pointer(iRecord, labelTokens_RawToDigi_);
136 }
137 
139  const edm::IOVSyncValue& iosv,
140  edm::ValidityInterval& oValidity) {
142  oValidity = infinity;
143 }
144 
147  desc.add<std::string>("siPixelQualityLabel", "");
148  desc.add<std::string>("siPixelQualityLabel_RawToDigi", "");
149  {
151  desc_ps.add<std::string>("record", "SiPixelQualityFromDbRcd");
152  desc_ps.add<std::string>("tag", "");
153  std::vector<edm::ParameterSet> default_ps;
154  default_ps.reserve(2);
155  {
157  temp.addParameter<std::string>("record", "SiPixelQualityFromDbRcd");
158  temp.addParameter<std::string>("tag", "");
159  default_ps.push_back(temp);
160  }
161  {
163  temp.addParameter<std::string>("record", "SiPixelDetVOffRcd");
164  temp.addParameter<std::string>("tag", "");
165  default_ps.push_back(temp);
166  }
167  desc.addVPSet("ListOfRecordToMerge", desc_ps, default_ps);
168  }
169  descriptions.addWithDefaultLabel(desc);
170 }
171 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
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_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
Tokens(edm::ESConsumesCollector cc, const std::string &label)
static void fillDescriptions(edm::ConfigurationDescriptions &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Log< level::Info, false > LogInfo
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
std::unique_ptr< SiPixelQuality > produce(const SiPixelQualityRcd &iRecord)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
SiPixelQualityESProducer(const edm::ParameterSet &iConfig)