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 #include <memory>
20 
33 
35 public:
37  ~SiPixelQualityESProducer() override = default;
38 
39  std::unique_ptr<SiPixelQuality> produce(const SiPixelQualityRcd& iRecord);
40 
42 
43 private:
45  const edm::IOVSyncValue&,
46  edm::ValidityInterval&) override;
47 
50 };
51 
53  // setWhatProduced internally uses "appendToDataLabel" to name the output product of this ESProducer
54  auto const& appendToDataLabel = iConfig.getParameter<std::string>("appendToDataLabel");
55  auto esCC = setWhatProduced(this);
56 
57  // "siPixelQualityFromDbLabel" corresponds to the Label of a tag with Record
58  // "SiPixelQualityFromDbRcd" in the EventSetup (normally provided by the GlobalTag)
59  auto const& siPixelQualityFromDbLabel = iConfig.getParameter<std::string>("siPixelQualityFromDbLabel");
60  siPixelQualityFromDbToken_ = esCC.consumes(edm::ESInputTag{"", siPixelQualityFromDbLabel});
61  voffToken_ = esCC.consumes();
62 
63  findingRecord<SiPixelQualityRcd>();
64 
65  edm::LogInfo("SiPixelQualityESProducer")
66  << "Module = \"" << description().label_ << "\" (appendToDataLabel = \"" << appendToDataLabel
67  << "\", siPixelQualityFromDbLabel = \"" << siPixelQualityFromDbLabel << "\")";
68 }
69 
70 std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
72  // errortype "whole" = int 0 in DB BadRocs = 65535 //
73  // errortype "tbmA" = int 1 in DB BadRocs = 255 //
74  // errortype "tbmB" = int 2 in DB Bad Rocs = 65280 //
75  // errortype "none" = int 3 in DB //
77 
78  //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)
79  //SiPixelQuality * obj = new SiPixelQuality();
80  //SiPixelQuality::disabledModuleType BadModule;
81  //BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);
82 
83  //now the dbobject is the one copied from the db
84  auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(siPixelQualityFromDbToken_));
85 
86  //here is the magic line in which it switches off Bad Modules
87  dbptr->add(&(iRecord.get(voffToken_)));
88  return dbptr;
89 }
90 
92  const edm::IOVSyncValue& iosv,
93  edm::ValidityInterval& oValidity) {
95  oValidity = infinity;
96 }
97 
100  desc.add<std::string>("siPixelQualityFromDbLabel", "");
101  {
103  desc_ps.add<std::string>("record", "SiPixelQualityFromDbRcd");
104  desc_ps.add<std::string>("tag", "");
105  std::vector<edm::ParameterSet> default_ps;
106  default_ps.reserve(2);
107  {
109  temp.addParameter<std::string>("record", "SiPixelQualityFromDbRcd");
110  temp.addParameter<std::string>("tag", "");
111  default_ps.push_back(temp);
112  }
113  {
115  temp.addParameter<std::string>("record", "SiPixelDetVOffRcd");
116  temp.addParameter<std::string>("tag", "");
117  default_ps.push_back(temp);
118  }
119  desc.addVPSet("ListOfRecordToMerge", desc_ps, default_ps);
120  }
121  descriptions.addWithDefaultLabel(desc);
122 }
123 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const ComponentDescription & description() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::ESGetToken< SiStripDetVOff, SiPixelDetVOffRcd > voffToken_
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
const double infinity
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
static void fillDescriptions(edm::ConfigurationDescriptions &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Log< level::Info, false > LogInfo
~SiPixelQualityESProducer() override=default
std::unique_ptr< SiPixelQuality > produce(const SiPixelQualityRcd &iRecord)
edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > siPixelQualityFromDbToken_
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
SiPixelQualityESProducer(const edm::ParameterSet &iConfig)