CMS 3D CMS Logo

HcalTextCalibrations.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Original Author: Fedor Ratnikov
3 //
4 //
5 
6 #include <memory>
7 #include <iostream>
8 #include <fstream>
9 
12 
14 
16 
18 
19 #include "HcalTextCalibrations.h"
20 //
21 // class declaration
22 //
23 
24 using namespace cms;
25 
27 
28 {
29  //parsing parameters
30  std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
31  std::vector<edm::ParameterSet>::iterator request = data.begin();
32  for (; request != data.end(); ++request) {
33  std::string objectName = request->getParameter<std::string>("object");
34  edm::FileInPath fp = request->getParameter<edm::FileInPath>("file");
35  mInputs[objectName] = fp.fullPath();
36  // std::cout << objectName << " with file " << fp.fullPath() << std::endl;
37  if (objectName == "Pedestals") {
38  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::producePedestals).consumes();
39  findingRecord<HcalPedestalsRcd>();
40  } else if (objectName == "PedestalWidths") {
41  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::producePedestalWidths).consumes();
42  findingRecord<HcalPedestalWidthsRcd>();
43  } else if (objectName == "EffectivePedestals") {
44  mTokens[objectName] =
45  setWhatProduced(this, &HcalTextCalibrations::produceEffectivePedestals, edm::es::Label("effective"))
46  .consumes();
47  findingRecord<HcalPedestalsRcd>();
48  } else if (objectName == "EffectivePedestalWidths") {
49  mTokens[objectName] =
50  setWhatProduced(this, &HcalTextCalibrations::produceEffectivePedestalWidths, edm::es::Label("effective"))
51  .consumes();
52  findingRecord<HcalPedestalWidthsRcd>();
53  } else if (objectName == "Gains") {
54  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceGains).consumes();
55  findingRecord<HcalGainsRcd>();
56  } else if (objectName == "GainWidths") {
57  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceGainWidths).consumes();
58  findingRecord<HcalGainWidthsRcd>();
59  } else if (objectName == "QIEData") {
60  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceQIEData).consumes();
61  findingRecord<HcalQIEDataRcd>();
62  } else if (objectName == "QIETypes") {
63  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceQIETypes).consumes();
64  findingRecord<HcalQIETypesRcd>();
65  } else if (objectName == "ChannelQuality") {
66  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceChannelQuality).consumes();
67  findingRecord<HcalChannelQualityRcd>();
68  } else if (objectName == "ZSThresholds") {
69  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceZSThresholds).consumes();
70  findingRecord<HcalZSThresholdsRcd>();
71  } else if (objectName == "RespCorrs") {
72  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceRespCorrs).consumes();
73  findingRecord<HcalRespCorrsRcd>();
74  } else if (objectName == "LUTCorrs") {
75  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceLUTCorrs).consumes();
76  findingRecord<HcalLUTCorrsRcd>();
77  } else if (objectName == "PFCorrs") {
78  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::producePFCorrs).consumes();
79  findingRecord<HcalPFCorrsRcd>();
80  } else if (objectName == "TimeCorrs") {
81  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceTimeCorrs).consumes();
82  findingRecord<HcalTimeCorrsRcd>();
83  } else if (objectName == "L1TriggerObjects") {
84  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceL1TriggerObjects).consumes();
85  findingRecord<HcalL1TriggerObjectsRcd>();
86  } else if (objectName == "ElectronicsMap") {
87  setWhatProduced(this, &HcalTextCalibrations::produceElectronicsMap);
88  findingRecord<HcalElectronicsMapRcd>();
89  } else if (objectName == "FrontEndMap") {
90  setWhatProduced(this, &HcalTextCalibrations::produceFrontEndMap);
91  findingRecord<HcalFrontEndMapRcd>();
92  } else if (objectName == "ValidationCorrs") {
93  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceValidationCorrs).consumes();
94  findingRecord<HcalValidationCorrsRcd>();
95  } else if (objectName == "LutMetadata") {
96  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceLutMetadata).consumes();
97  findingRecord<HcalLutMetadataRcd>();
98  } else if (objectName == "DcsValues") {
99  setWhatProduced(this, &HcalTextCalibrations::produceDcsValues);
100  findingRecord<HcalDcsRcd>();
101  } else if (objectName == "DcsMap") {
102  setWhatProduced(this, &HcalTextCalibrations::produceDcsMap);
103  findingRecord<HcalDcsMapRcd>();
104  } else if (objectName == "RecoParams") {
105  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceRecoParams).consumes();
106  findingRecord<HcalRecoParamsRcd>();
107  } else if (objectName == "TimingParams") {
108  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceTimingParams).consumes();
109  findingRecord<HcalTimingParamsRcd>();
110  } else if (objectName == "LongRecoParams") {
111  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceLongRecoParams).consumes();
112  findingRecord<HcalLongRecoParamsRcd>();
113  } else if (objectName == "ZDCLowGainFractions") {
114  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceZDCLowGainFractions).consumes();
115  findingRecord<HcalZDCLowGainFractionsRcd>();
116  } else if (objectName == "MCParams") {
117  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceMCParams).consumes();
118  findingRecord<HcalMCParamsRcd>();
119  } else if (objectName == "FlagHFDigiTimeParams") {
120  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceFlagHFDigiTimeParams).consumes();
121  findingRecord<HcalFlagHFDigiTimeParamsRcd>();
122  } else if (objectName == "SiPMParameters") {
123  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceSiPMParameters).consumes();
124  findingRecord<HcalSiPMParametersRcd>();
125  } else if (objectName == "SiPMCharacteristics") {
126  setWhatProduced(this, &HcalTextCalibrations::produceSiPMCharacteristics);
127  findingRecord<HcalSiPMCharacteristicsRcd>();
128  } else if (objectName == "TPChannelParameters") {
129  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceTPChannelParameters).consumes();
130  findingRecord<HcalTPChannelParametersRcd>();
131  } else if (objectName == "TPParameters") {
132  setWhatProduced(this, &HcalTextCalibrations::produceTPParameters);
133  findingRecord<HcalTPParametersRcd>();
134  } else {
135  std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName << "', known names are: "
136  << "Pedestals PedestalWidths Gains GainWidths QIEData QIETypes ChannelQuality ElectronicsMap "
137  << "FrontEndMap ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
138  << "ValidationCorrs LutMetadata DcsValues DcsMap "
139  << "RecoParams LongRecoParams ZDCLowGainFraction FlagHFDigiTimeParams MCParams "
140  << "SiPMParameters SiPMCharacteristics TPChannelParameters TPParameters" << std::endl;
141  }
142  }
143  // setWhatProduced(this);
144 }
145 
147 
148 //
149 // member functions
150 //
152  const edm::IOVSyncValue& iTime,
153  edm::ValidityInterval& oInterval) {
154  std::string record = iKey.name();
156 }
157 namespace {
158  template <class T, template <class> class F>
159  std::unique_ptr<T> produce_impl(const std::string& fFile, const HcalTopology* topo = nullptr) {
160  std::ifstream inStream(fFile.c_str());
161  if (!inStream.good()) {
162  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
163  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
164  }
165  auto result = F<T>(topo)(inStream);
166  if (!result) {
167  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
168  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
169  }
170  return result;
171  }
172  template <class T>
173  std::unique_ptr<T> get_impl(const std::string& fFile) {
174  return produce_impl<T, HcalTextCalibrations::CheckGetObject>(fFile);
175  }
176  template <class T>
177  std::unique_ptr<T> get_impl_topo(const std::string& fFile, const HcalTopology* topo) {
178  return produce_impl<T, HcalTextCalibrations::CheckGetObjectTopo>(fFile, topo);
179  }
180  template <class T>
181  std::unique_ptr<T> create_impl(const std::string& fFile) {
182  return produce_impl<T, HcalTextCalibrations::CheckCreateObject>(fFile);
183  }
184 } // namespace
185 
186 std::unique_ptr<HcalPedestals> HcalTextCalibrations::producePedestals(const HcalPedestalsRcd& rcd) {
187  std::string const n = "Pedestals";
188  return get_impl_topo<HcalPedestals>(mInputs[n], &rcd.get(mTokens[n]));
189 }
190 
191 std::unique_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths(const HcalPedestalWidthsRcd& rcd) {
192  std::string const n = "PedestalWidths";
193  return get_impl_topo<HcalPedestalWidths>(mInputs[n], &rcd.get(mTokens[n]));
194 }
195 
196 std::unique_ptr<HcalPedestals> HcalTextCalibrations::produceEffectivePedestals(const HcalPedestalsRcd& rcd) {
197  std::string const n = "EffectivePedestals";
198  return get_impl_topo<HcalPedestals>(mInputs[n], &rcd.get(mTokens[n]));
199 }
200 
201 std::unique_ptr<HcalPedestalWidths> HcalTextCalibrations::produceEffectivePedestalWidths(
202  const HcalPedestalWidthsRcd& rcd) {
203  std::string const n = "EffectivePedestalWidths";
204  return get_impl_topo<HcalPedestalWidths>(mInputs[n], &rcd.get(mTokens[n]));
205 }
206 
207 std::unique_ptr<HcalGains> HcalTextCalibrations::produceGains(const HcalGainsRcd& rcd) {
208  std::string const n = "Gains";
209  return get_impl_topo<HcalGains>(mInputs[n], &rcd.get(mTokens[n]));
210 }
211 
212 std::unique_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths(const HcalGainWidthsRcd& rcd) {
213  std::string const n = "GainWidths";
214  return get_impl_topo<HcalGainWidths>(mInputs[n], &rcd.get(mTokens[n]));
215 }
216 
217 std::unique_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData(const HcalQIEDataRcd& rcd) {
218  std::string const n = "QIEData";
219  return get_impl_topo<HcalQIEData>(mInputs[n], &rcd.get(mTokens[n]));
220 }
221 
222 std::unique_ptr<HcalQIETypes> HcalTextCalibrations::produceQIETypes(const HcalQIETypesRcd& rcd) {
223  std::string const n = "QIETypes";
224  return get_impl_topo<HcalQIETypes>(mInputs[n], &rcd.get(mTokens[n]));
225 }
226 
227 std::unique_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality(const HcalChannelQualityRcd& rcd) {
228  std::string const n = "ChannelQuality";
229  return get_impl_topo<HcalChannelQuality>(mInputs[n], &rcd.get(mTokens[n]));
230 }
231 
232 std::unique_ptr<HcalZSThresholds> HcalTextCalibrations::produceZSThresholds(const HcalZSThresholdsRcd& rcd) {
233  std::string const n = "ZSThresholds";
234  return get_impl_topo<HcalZSThresholds>(mInputs[n], &rcd.get(mTokens[n]));
235 }
236 
237 std::unique_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs(const HcalRespCorrsRcd& rcd) {
238  std::string const n = "RespCorrs";
239  return get_impl_topo<HcalRespCorrs>(mInputs[n], &rcd.get(mTokens[n]));
240 }
241 
242 std::unique_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs(const HcalLUTCorrsRcd& rcd) {
243  std::string const n = "LUTCorrs";
244  return get_impl_topo<HcalLUTCorrs>(mInputs[n], &rcd.get(mTokens[n]));
245 }
246 
247 std::unique_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs(const HcalPFCorrsRcd& rcd) {
248  std::string const n = "PFCorrs";
249  return get_impl_topo<HcalPFCorrs>(mInputs[n], &rcd.get(mTokens[n]));
250 }
251 
252 std::unique_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs(const HcalTimeCorrsRcd& rcd) {
253  std::string const n = "TimeCorrs";
254  return get_impl_topo<HcalTimeCorrs>(mInputs[n], &rcd.get(mTokens[n]));
255 }
256 
257 std::unique_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects(const HcalL1TriggerObjectsRcd& rcd) {
258  std::string const n = "L1TriggerObjects";
259  return get_impl_topo<HcalL1TriggerObjects>(mInputs[n], &rcd.get(mTokens[n]));
260 }
261 
262 std::unique_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap(const HcalElectronicsMapRcd& rcd) {
263  return create_impl<HcalElectronicsMap>(mInputs["ElectronicsMap"]);
264 }
265 
266 std::unique_ptr<HcalFrontEndMap> HcalTextCalibrations::produceFrontEndMap(const HcalFrontEndMapRcd& rcd) {
267  return create_impl<HcalFrontEndMap>(mInputs["FrontEndMap"]);
268 }
269 
270 std::unique_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs(const HcalValidationCorrsRcd& rcd) {
271  std::string const n = "ValidationCorrs";
272  return get_impl_topo<HcalValidationCorrs>(mInputs[n], &rcd.get(mTokens[n]));
273 }
274 
275 std::unique_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata(const HcalLutMetadataRcd& rcd) {
276  std::string const n = "LutMetadata";
277  return get_impl_topo<HcalLutMetadata>(mInputs[n], &rcd.get(mTokens[n]));
278 }
279 
280 std::unique_ptr<HcalDcsValues> HcalTextCalibrations::produceDcsValues(HcalDcsRcd const& rcd) {
281  return get_impl<HcalDcsValues>(mInputs["DcsValues"]);
282 }
283 
284 std::unique_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap(const HcalDcsMapRcd& rcd) {
285  return create_impl<HcalDcsMap>(mInputs["DcsMap"]);
286 }
287 
288 std::unique_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams(const HcalRecoParamsRcd& rcd) {
289  std::string const n = "RecoParams";
290  return get_impl_topo<HcalRecoParams>(mInputs[n], &rcd.get(mTokens[n]));
291 }
292 
293 std::unique_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams(const HcalLongRecoParamsRcd& rcd) {
294  std::string const n = "LongRecoParams";
295  return get_impl_topo<HcalLongRecoParams>(mInputs[n], &rcd.get(mTokens[n]));
296 }
297 
298 std::unique_ptr<HcalZDCLowGainFractions> HcalTextCalibrations::produceZDCLowGainFractions(
299  const HcalZDCLowGainFractionsRcd& rcd) {
300  std::string const n = "ZDCLowGainFractions";
301  return get_impl_topo<HcalZDCLowGainFractions>(mInputs[n], &rcd.get(mTokens[n]));
302 }
303 
304 std::unique_ptr<HcalTimingParams> HcalTextCalibrations::produceTimingParams(const HcalTimingParamsRcd& rcd) {
305  std::string const n = "TimingParams";
306  return get_impl_topo<HcalTimingParams>(mInputs[n], &rcd.get(mTokens[n]));
307 }
308 std::unique_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams(const HcalMCParamsRcd& rcd) {
309  std::string const n = "MCParams";
310  return get_impl_topo<HcalMCParams>(mInputs[n], &rcd.get(mTokens[n]));
311 }
312 
313 std::unique_ptr<HcalFlagHFDigiTimeParams> HcalTextCalibrations::produceFlagHFDigiTimeParams(
314  const HcalFlagHFDigiTimeParamsRcd& rcd) {
315  std::string const n = "FlagHFDigiTimeParams";
316  return get_impl_topo<HcalFlagHFDigiTimeParams>(mInputs[n], &rcd.get(mTokens[n]));
317 }
318 
319 std::unique_ptr<HcalSiPMParameters> HcalTextCalibrations::produceSiPMParameters(const HcalSiPMParametersRcd& rcd) {
320  std::string const n = "SiPMParameters";
321  return get_impl_topo<HcalSiPMParameters>(mInputs[n], &rcd.get(mTokens[n]));
322 }
323 
324 std::unique_ptr<HcalSiPMCharacteristics> HcalTextCalibrations::produceSiPMCharacteristics(
325  const HcalSiPMCharacteristicsRcd& rcd) {
326  return create_impl<HcalSiPMCharacteristics>(mInputs["SiPMCharacteristics"]);
327 }
328 
329 std::unique_ptr<HcalTPChannelParameters> HcalTextCalibrations::produceTPChannelParameters(
330  const HcalTPChannelParametersRcd& rcd) {
331  std::string const n = "TPChannelParameters";
332  return get_impl_topo<HcalTPChannelParameters>(mInputs[n], &rcd.get(mTokens[n]));
333 }
334 
335 std::unique_ptr<HcalTPParameters> HcalTextCalibrations::produceTPParameters(const HcalTPParametersRcd& rcd) {
336  return get_impl<HcalTPParameters>(mInputs["TPParameters"]);
337 }
std::unique_ptr< HcalPedestals > producePedestals(const HcalPedestalsRcd &rcd)
std::unique_ptr< HcalGainWidths > produceGainWidths(const HcalGainWidthsRcd &rcd)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< HcalZDCLowGainFractions > produceZDCLowGainFractions(const HcalZDCLowGainFractionsRcd &rcd)
std::unique_ptr< HcalPedestals > produceEffectivePedestals(const HcalPedestalsRcd &rcd)
std::unique_ptr< HcalL1TriggerObjects > produceL1TriggerObjects(const HcalL1TriggerObjectsRcd &rcd)
std::unique_ptr< HcalPedestalWidths > producePedestalWidths(const HcalPedestalWidthsRcd &rcd)
std::unique_ptr< HcalLongRecoParams > produceLongRecoParams(const HcalLongRecoParamsRcd &rcd)
std::unique_ptr< HcalMCParams > produceMCParams(const HcalMCParamsRcd &rcd)
std::unique_ptr< HcalLUTCorrs > produceLUTCorrs(const HcalLUTCorrsRcd &rcd)
std::unique_ptr< HcalPFCorrs > producePFCorrs(const HcalPFCorrsRcd &rcd)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::unique_ptr< HcalDcsValues > produceDcsValues(HcalDcsRcd const &rcd)
std::unique_ptr< HcalQIEData > produceQIEData(const HcalQIEDataRcd &rcd)
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::unique_ptr< HcalSiPMCharacteristics > produceSiPMCharacteristics(const HcalSiPMCharacteristicsRcd &rcd)
std::unique_ptr< T > produce_impl(const std::string &fFile)
std::unique_ptr< HcalZSThresholds > produceZSThresholds(const HcalZSThresholdsRcd &rcd)
std::unique_ptr< HcalSiPMParameters > produceSiPMParameters(const HcalSiPMParametersRcd &rcd)
std::unique_ptr< HcalDcsMap > produceDcsMap(const HcalDcsMapRcd &rcd)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
std::unique_ptr< HcalRecoParams > produceRecoParams(const HcalRecoParamsRcd &rcd)
std::unique_ptr< HcalChannelQuality > produceChannelQuality(const HcalChannelQualityRcd &rcd)
std::unique_ptr< HcalPedestalWidths > produceEffectivePedestalWidths(const HcalPedestalWidthsRcd &rcd)
HcalTextCalibrations(const edm::ParameterSet &)
std::unique_ptr< HcalTPChannelParameters > produceTPChannelParameters(const HcalTPChannelParametersRcd &rcd)
std::unique_ptr< HcalQIETypes > produceQIETypes(const HcalQIETypesRcd &rcd)
Namespace of DDCMS conversion namespace.
std::unique_ptr< HcalTimingParams > produceTimingParams(const HcalTimingParamsRcd &rcd)
std::unique_ptr< HcalTPParameters > produceTPParameters(const HcalTPParametersRcd &rcd)
std::unique_ptr< HcalElectronicsMap > produceElectronicsMap(const HcalElectronicsMapRcd &rcd)
std::unique_ptr< HcalGains > produceGains(const HcalGainsRcd &rcd)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::unique_ptr< HcalRespCorrs > produceRespCorrs(const HcalRespCorrsRcd &rcd)
std::unique_ptr< HcalFrontEndMap > produceFrontEndMap(const HcalFrontEndMapRcd &rcd)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
std::unique_ptr< HcalLutMetadata > produceLutMetadata(const HcalLutMetadataRcd &rcd)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::unique_ptr< HcalTimeCorrs > produceTimeCorrs(const HcalTimeCorrsRcd &rcd)
std::unique_ptr< HcalFlagHFDigiTimeParams > produceFlagHFDigiTimeParams(const HcalFlagHFDigiTimeParamsRcd &rcd)
std::unique_ptr< HcalValidationCorrs > produceValidationCorrs(const HcalValidationCorrsRcd &rcd)