CMS 3D CMS Logo

CastorHardcodeCalibrations.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Original Author: Fedor Ratnikov
3 // Adapted for CASTOR by L. Mundim
4 //
5 
6 #include <memory>
7 #include <iostream>
8 
14 
24 
28 
30 
31 // class declaration
32 //
33 
34 using namespace cms;
35 
36 namespace {
37 
38  std::vector<HcalGenericDetId> allCells(bool h2_mode) {
39  static std::vector<HcalGenericDetId> result;
40  if (result.empty()) {
41  CastorTopology castortopology;
42  HcalCastorDetId cell;
44 
45  for (int sector = 1; sector < 17; sector++) {
46  for (int module = 1; module < 3; module++) {
47  cell = HcalCastorDetId(section, true, sector, module);
48  if (castortopology.valid(cell))
49  result.push_back(cell);
50  cell = HcalCastorDetId(section, false, sector, module);
51  if (castortopology.valid(cell))
52  result.push_back(cell);
53  }
54  }
55 
56  section = HcalCastorDetId::HAD;
57  for (int sector = 1; sector < 17; sector++) {
58  for (int module = 3; module < 15; module++) {
59  cell = HcalCastorDetId(section, true, sector, module);
60  if (castortopology.valid(cell))
61  result.push_back(cell);
62  cell = HcalCastorDetId(section, false, sector, module);
63  if (castortopology.valid(cell))
64  result.push_back(cell);
65  }
66  }
67  }
68  return result;
69  }
70 } // namespace
71 
73 
74 {
75  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::CastorHardcodeCalibrations->...";
76  //parsing record parameters
77  h2mode_ = iConfig.getUntrackedParameter<bool>("H2Mode", false);
78  std::vector<std::string> toGet = iConfig.getUntrackedParameter<std::vector<std::string> >("toGet");
79  for (std::vector<std::string>::iterator objectName = toGet.begin(); objectName != toGet.end(); ++objectName) {
80  bool all = *objectName == "all";
81  if ((*objectName == "Pedestals") || all) {
82  setWhatProduced(this, &CastorHardcodeCalibrations::producePedestals);
83  findingRecord<CastorPedestalsRcd>();
84  }
85  if ((*objectName == "PedestalWidths") || all) {
87  findingRecord<CastorPedestalWidthsRcd>();
88  }
89  if ((*objectName == "Gains") || all) {
90  setWhatProduced(this, &CastorHardcodeCalibrations::produceGains);
91  findingRecord<CastorGainsRcd>();
92  }
93  if ((*objectName == "GainWidths") || all) {
94  setWhatProduced(this, &CastorHardcodeCalibrations::produceGainWidths);
95  findingRecord<CastorGainWidthsRcd>();
96  }
97  if ((*objectName == "QIEData") || all) {
98  setWhatProduced(this, &CastorHardcodeCalibrations::produceQIEData);
99  findingRecord<CastorQIEDataRcd>();
100  }
101  if ((*objectName == "ChannelQuality") || (*objectName == "channelQuality") || all) {
103  findingRecord<CastorChannelQualityRcd>();
104  }
105  if ((*objectName == "ElectronicsMap") || (*objectName == "electronicsMap") || all) {
107  findingRecord<CastorElectronicsMapRcd>();
108  }
109  if ((*objectName == "RecoParams") || all) {
110  setWhatProduced(this, &CastorHardcodeCalibrations::produceRecoParams);
111  findingRecord<CastorRecoParamsRcd>();
112  }
113  if ((*objectName == "SaturationCorrs") || all) {
115  findingRecord<CastorSaturationCorrsRcd>();
116  }
117  }
118 }
119 
121 
122 //
123 // member functions
124 //
126  const edm::IOVSyncValue& iTime,
127  edm::ValidityInterval& oInterval) {
128  std::string record = iKey.name();
129  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID()
130  << '/' << iTime.time().value();
132 }
133 
134 std::unique_ptr<CastorPedestals> CastorHardcodeCalibrations::producePedestals(const CastorPedestalsRcd&) {
135  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestals-> ...";
136  auto result = std::make_unique<CastorPedestals>(false);
137  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
138  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
140  result->addValues(item);
141  }
142  return result;
143 }
144 
145 std::unique_ptr<CastorPedestalWidths> CastorHardcodeCalibrations::producePedestalWidths(const CastorPedestalWidthsRcd&) {
146  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestalWidths-> ...";
147  auto result = std::make_unique<CastorPedestalWidths>(false);
148  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
149  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
151  result->addValues(item);
152  }
153  return result;
154 }
155 
156 std::unique_ptr<CastorGains> CastorHardcodeCalibrations::produceGains(const CastorGainsRcd&) {
157  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGains-> ...";
158  auto result = std::make_unique<CastorGains>();
159  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
160  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
162  result->addValues(item);
163  }
164  return result;
165 }
166 
167 std::unique_ptr<CastorGainWidths> CastorHardcodeCalibrations::produceGainWidths(const CastorGainWidthsRcd&) {
168  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGainWidths-> ...";
169  auto result = std::make_unique<CastorGainWidths>();
170  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
171  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
173  result->addValues(item);
174  }
175  return result;
176 }
177 
178 std::unique_ptr<CastorQIEData> CastorHardcodeCalibrations::produceQIEData(const CastorQIEDataRcd& rcd) {
179  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceQIEData-> ...";
180  auto result = std::make_unique<CastorQIEData>();
181  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
182  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
184  result->addCoder(coder);
185  }
186  return result;
187 }
188 
189 std::unique_ptr<CastorChannelQuality> CastorHardcodeCalibrations::produceChannelQuality(
190  const CastorChannelQualityRcd& rcd) {
191  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceChannelQuality-> ...";
192  auto result = std::make_unique<CastorChannelQuality>();
193  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
194  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
196  result->addValues(item);
197  }
198  return result;
199 }
200 
201 std::unique_ptr<CastorElectronicsMap> CastorHardcodeCalibrations::produceElectronicsMap(
202  const CastorElectronicsMapRcd& rcd) {
203  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceElectronicsMap-> ...";
204 
205  auto result = std::make_unique<CastorElectronicsMap>();
207  return result;
208 }
209 
210 std::unique_ptr<CastorRecoParams> CastorHardcodeCalibrations::produceRecoParams(const CastorRecoParamsRcd& rcd) {
211  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceRecoParams-> ...";
212  auto result = std::make_unique<CastorRecoParams>();
213  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
214  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
216  result->addValues(item);
217  }
218  return result;
219 }
220 
221 std::unique_ptr<CastorSaturationCorrs> CastorHardcodeCalibrations::produceSaturationCorrs(
222  const CastorSaturationCorrsRcd& rcd) {
223  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceSaturationCorrs-> ...";
224  auto result = std::make_unique<CastorSaturationCorrs>();
225  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
226  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
228  result->addValues(item);
229  }
230  return result;
231 }
CastorPedestalWidth makePedestalWidth(HcalGenericDetId fId)
T getUntrackedParameter(std::string const &, T const &) const
CastorQIECoder makeQIECoder(HcalGenericDetId fId)
const EventID & eventID() const
Definition: IOVSyncValue.h:40
std::unique_ptr< CastorQIEData > produceQIEData(const CastorQIEDataRcd &rcd)
JetCorrectorParameters::Record record
Definition: classes.h:7
void makeHardcodeMap(CastorElectronicsMap &emap)
std::unique_ptr< CastorRecoParams > produceRecoParams(const CastorRecoParamsRcd &rcd)
std::unique_ptr< CastorChannelQuality > produceChannelQuality(const CastorChannelQualityRcd &rcd)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
std::unique_ptr< CastorPedestalWidths > producePedestalWidths(const CastorPedestalWidthsRcd &rcd)
CastorHardcodeCalibrations(const edm::ParameterSet &)
std::unique_ptr< CastorPedestals > producePedestals(const CastorPedestalsRcd &rcd)
std::unique_ptr< CastorSaturationCorrs > produceSaturationCorrs(const CastorSaturationCorrsRcd &rcd)
std::unique_ptr< CastorGainWidths > produceGainWidths(const CastorGainWidthsRcd &rcd)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
CastorRecoParam makeRecoParam(HcalGenericDetId fId)
std::unique_ptr< CastorElectronicsMap > produceElectronicsMap(const CastorElectronicsMapRcd &rcd)
CastorSaturationCorr makeSaturationCorr(HcalGenericDetId fId)
Namespace of DDCMS conversion namespace.
virtual bool valid(const HcalCastorDetId &id) const
CastorGainWidth makeGainWidth(HcalGenericDetId fId)
CastorPedestal makePedestal(HcalGenericDetId fId, bool fSmear=false)
CastorGain makeGain(HcalGenericDetId fId, bool fSmear=false)
std::unique_ptr< CastorGains > produceGains(const CastorGainsRcd &rcd)
const Timestamp & time() const
Definition: IOVSyncValue.h:42
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Definition: vlib.h:208
TimeValue_t value() const
Definition: Timestamp.h:56