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 
SiPixelQualityESProducer
Definition: SiPixelQualityESProducer.cc:42
SiStripDependentRecords.h
SiPixelQualityESProducer::produce
std::unique_ptr< SiPixelQuality > produce(const SiPixelQualityRcd &iRecord)
Definition: SiPixelQualityESProducer.cc:116
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
TrackerGeometry.h
SiPixelQualityRcd
Definition: SiPixelQualityRcd.h:13
edm::ESConsumesCollector
Definition: ESConsumesCollector.h:58
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelQualityESProducer::Tokens
Definition: SiPixelQualityESProducer.cc:55
edm::LogInfo
Definition: MessageLogger.h:254
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
SiPixelQualityESProducer::SiPixelQualityESProducer
SiPixelQualityESProducer(const edm::ParameterSet &iConfig)
Definition: SiPixelQualityESProducer.cc:70
SiPixelQualityESProducer::~SiPixelQualityESProducer
~SiPixelQualityESProducer() override
Definition: SiPixelQualityESProducer.cc:89
SiPixelQualityFromDbRcd.h
infinity
const double infinity
Definition: CSCChamberFitter.cc:10
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
SiPixelQualityESProducer::get_pointer
std::unique_ptr< SiPixelQuality > get_pointer(const SiPixelQualityRcd &iRecord, const Tokens &tokens)
Definition: SiPixelQualityESProducer.cc:94
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
cc
SiPixelQualityRcd.h
SiPixelQualityESProducer::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Definition: SiPixelQualityESProducer.cc:123
edm::es::Label
Definition: es_Label.h:54
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
SiPixelQualityESProducer::Tokens::voffToken_
edm::ESGetToken< SiStripDetVOff, SiPixelDetVOffRcd > voffToken_
Definition: SiPixelQualityESProducer.cc:56
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelQualityESProducer::produceWithLabel
std::unique_ptr< SiPixelQuality > produceWithLabel(const SiPixelQualityRcd &iRecord)
Definition: SiPixelQualityESProducer.cc:119
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
TrackerDigiGeometryRecord.h
SiPixelQualityESProducer::labelTokens_
Tokens labelTokens_
Definition: SiPixelQualityESProducer.cc:63
edm::ParameterSet
Definition: ParameterSet.h:36
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
SiPixelQualityESProducer::Tokens::dbobjectToken_
edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > dbobjectToken_
Definition: SiPixelQualityESProducer.cc:57
SiPixelQualityESProducer::defaultTokens_
Tokens defaultTokens_
Definition: SiPixelQualityESProducer.cc:62
edm::ESGetToken< SiStripDetVOff, SiPixelDetVOffRcd >
SiPixelDetInfoFileReader.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ModuleFactory.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
EventSetup.h
SiPixelQuality.h
edm::ESProducer
Definition: ESProducer.h:101
ParameterSet.h
SiStripDetVOff.h
label
const char * label
Definition: PFTauDecayModeTools.cc:11