CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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] =
67  setWhatProduced(this, &HcalTextCalibrations::produceChannelQuality, edm::es::Label("withTopo")).consumes();
68  findingRecord<HcalChannelQualityRcd>();
69  } else if (objectName == "ZSThresholds") {
70  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceZSThresholds).consumes();
71  findingRecord<HcalZSThresholdsRcd>();
72  } else if (objectName == "RespCorrs") {
73  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceRespCorrs).consumes();
74  findingRecord<HcalRespCorrsRcd>();
75  } else if (objectName == "LUTCorrs") {
76  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceLUTCorrs).consumes();
77  findingRecord<HcalLUTCorrsRcd>();
78  } else if (objectName == "PFCorrs") {
79  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::producePFCorrs).consumes();
80  findingRecord<HcalPFCorrsRcd>();
81  } else if (objectName == "TimeCorrs") {
82  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceTimeCorrs).consumes();
83  findingRecord<HcalTimeCorrsRcd>();
84  } else if (objectName == "L1TriggerObjects") {
85  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceL1TriggerObjects).consumes();
86  findingRecord<HcalL1TriggerObjectsRcd>();
87  } else if (objectName == "ElectronicsMap") {
88  setWhatProduced(this, &HcalTextCalibrations::produceElectronicsMap);
89  findingRecord<HcalElectronicsMapRcd>();
90  } else if (objectName == "FrontEndMap") {
91  setWhatProduced(this, &HcalTextCalibrations::produceFrontEndMap);
92  findingRecord<HcalFrontEndMapRcd>();
93  } else if (objectName == "ValidationCorrs") {
94  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceValidationCorrs).consumes();
95  findingRecord<HcalValidationCorrsRcd>();
96  } else if (objectName == "LutMetadata") {
97  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceLutMetadata).consumes();
98  findingRecord<HcalLutMetadataRcd>();
99  } else if (objectName == "DcsValues") {
100  setWhatProduced(this, &HcalTextCalibrations::produceDcsValues);
101  findingRecord<HcalDcsRcd>();
102  } else if (objectName == "DcsMap") {
103  setWhatProduced(this, &HcalTextCalibrations::produceDcsMap);
104  findingRecord<HcalDcsMapRcd>();
105  } else if (objectName == "RecoParams") {
106  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceRecoParams).consumes();
107  findingRecord<HcalRecoParamsRcd>();
108  } else if (objectName == "TimingParams") {
109  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceTimingParams).consumes();
110  findingRecord<HcalTimingParamsRcd>();
111  } else if (objectName == "LongRecoParams") {
112  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceLongRecoParams).consumes();
113  findingRecord<HcalLongRecoParamsRcd>();
114  } else if (objectName == "ZDCLowGainFractions") {
115  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceZDCLowGainFractions).consumes();
116  findingRecord<HcalZDCLowGainFractionsRcd>();
117  } else if (objectName == "MCParams") {
118  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceMCParams).consumes();
119  findingRecord<HcalMCParamsRcd>();
120  } else if (objectName == "FlagHFDigiTimeParams") {
121  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceFlagHFDigiTimeParams).consumes();
122  findingRecord<HcalFlagHFDigiTimeParamsRcd>();
123  } else if (objectName == "SiPMParameters") {
124  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceSiPMParameters).consumes();
125  findingRecord<HcalSiPMParametersRcd>();
126  } else if (objectName == "SiPMCharacteristics") {
127  setWhatProduced(this, &HcalTextCalibrations::produceSiPMCharacteristics);
128  findingRecord<HcalSiPMCharacteristicsRcd>();
129  } else if (objectName == "TPChannelParameters") {
130  mTokens[objectName] = setWhatProduced(this, &HcalTextCalibrations::produceTPChannelParameters).consumes();
131  findingRecord<HcalTPChannelParametersRcd>();
132  } else if (objectName == "TPParameters") {
133  setWhatProduced(this, &HcalTextCalibrations::produceTPParameters);
134  findingRecord<HcalTPParametersRcd>();
135  } else {
136  std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName << "', known names are: "
137  << "Pedestals PedestalWidths Gains GainWidths QIEData QIETypes ChannelQuality ElectronicsMap "
138  << "FrontEndMap ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
139  << "ValidationCorrs LutMetadata DcsValues DcsMap "
140  << "RecoParams LongRecoParams ZDCLowGainFraction FlagHFDigiTimeParams MCParams "
141  << "SiPMParameters SiPMCharacteristics TPChannelParameters TPParameters" << std::endl;
142  }
143  }
144  // setWhatProduced(this);
145 }
146 
148 
149 //
150 // member functions
151 //
153  const edm::IOVSyncValue& iTime,
154  edm::ValidityInterval& oInterval) {
155  std::string record = iKey.name();
157 }
158 namespace {
159  template <class T, template <class> class F>
160  std::unique_ptr<T> produce_impl(const std::string& fFile, const HcalTopology* topo = nullptr) {
161  std::ifstream inStream(fFile.c_str());
162  if (!inStream.good()) {
163  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
164  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
165  }
166  auto result = F<T>(topo)(inStream);
167  if (!result) {
168  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
169  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
170  }
171  return result;
172  }
173  template <class T>
174  std::unique_ptr<T> get_impl(const std::string& fFile) {
175  return produce_impl<T, HcalTextCalibrations::CheckGetObject>(fFile);
176  }
177  template <class T>
178  std::unique_ptr<T> get_impl_topo(const std::string& fFile, const HcalTopology* topo) {
179  return produce_impl<T, HcalTextCalibrations::CheckGetObjectTopo>(fFile, topo);
180  }
181  template <class T>
182  std::unique_ptr<T> create_impl(const std::string& fFile) {
183  return produce_impl<T, HcalTextCalibrations::CheckCreateObject>(fFile);
184  }
185 } // namespace
186 
187 std::unique_ptr<HcalPedestals> HcalTextCalibrations::producePedestals(const HcalPedestalsRcd& rcd) {
188  std::string const n = "Pedestals";
189  return get_impl_topo<HcalPedestals>(mInputs[n], &rcd.get(mTokens[n]));
190 }
191 
192 std::unique_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths(const HcalPedestalWidthsRcd& rcd) {
193  std::string const n = "PedestalWidths";
194  return get_impl_topo<HcalPedestalWidths>(mInputs[n], &rcd.get(mTokens[n]));
195 }
196 
197 std::unique_ptr<HcalPedestals> HcalTextCalibrations::produceEffectivePedestals(const HcalPedestalsRcd& rcd) {
198  std::string const n = "EffectivePedestals";
199  return get_impl_topo<HcalPedestals>(mInputs[n], &rcd.get(mTokens[n]));
200 }
201 
202 std::unique_ptr<HcalPedestalWidths> HcalTextCalibrations::produceEffectivePedestalWidths(
203  const HcalPedestalWidthsRcd& rcd) {
204  std::string const n = "EffectivePedestalWidths";
205  return get_impl_topo<HcalPedestalWidths>(mInputs[n], &rcd.get(mTokens[n]));
206 }
207 
208 std::unique_ptr<HcalGains> HcalTextCalibrations::produceGains(const HcalGainsRcd& rcd) {
209  std::string const n = "Gains";
210  return get_impl_topo<HcalGains>(mInputs[n], &rcd.get(mTokens[n]));
211 }
212 
213 std::unique_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths(const HcalGainWidthsRcd& rcd) {
214  std::string const n = "GainWidths";
215  return get_impl_topo<HcalGainWidths>(mInputs[n], &rcd.get(mTokens[n]));
216 }
217 
218 std::unique_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData(const HcalQIEDataRcd& rcd) {
219  std::string const n = "QIEData";
220  return get_impl_topo<HcalQIEData>(mInputs[n], &rcd.get(mTokens[n]));
221 }
222 
223 std::unique_ptr<HcalQIETypes> HcalTextCalibrations::produceQIETypes(const HcalQIETypesRcd& rcd) {
224  std::string const n = "QIETypes";
225  return get_impl_topo<HcalQIETypes>(mInputs[n], &rcd.get(mTokens[n]));
226 }
227 
228 std::unique_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality(const HcalChannelQualityRcd& rcd) {
229  std::string const n = "ChannelQuality";
230  return get_impl_topo<HcalChannelQuality>(mInputs[n], &rcd.get(mTokens[n]));
231 }
232 
233 std::unique_ptr<HcalZSThresholds> HcalTextCalibrations::produceZSThresholds(const HcalZSThresholdsRcd& rcd) {
234  std::string const n = "ZSThresholds";
235  return get_impl_topo<HcalZSThresholds>(mInputs[n], &rcd.get(mTokens[n]));
236 }
237 
238 std::unique_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs(const HcalRespCorrsRcd& rcd) {
239  std::string const n = "RespCorrs";
240  return get_impl_topo<HcalRespCorrs>(mInputs[n], &rcd.get(mTokens[n]));
241 }
242 
243 std::unique_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs(const HcalLUTCorrsRcd& rcd) {
244  std::string const n = "LUTCorrs";
245  return get_impl_topo<HcalLUTCorrs>(mInputs[n], &rcd.get(mTokens[n]));
246 }
247 
248 std::unique_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs(const HcalPFCorrsRcd& rcd) {
249  std::string const n = "PFCorrs";
250  return get_impl_topo<HcalPFCorrs>(mInputs[n], &rcd.get(mTokens[n]));
251 }
252 
253 std::unique_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs(const HcalTimeCorrsRcd& rcd) {
254  std::string const n = "TimeCorrs";
255  return get_impl_topo<HcalTimeCorrs>(mInputs[n], &rcd.get(mTokens[n]));
256 }
257 
258 std::unique_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects(const HcalL1TriggerObjectsRcd& rcd) {
259  std::string const n = "L1TriggerObjects";
260  return get_impl_topo<HcalL1TriggerObjects>(mInputs[n], &rcd.get(mTokens[n]));
261 }
262 
263 std::unique_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap(const HcalElectronicsMapRcd& rcd) {
264  return create_impl<HcalElectronicsMap>(mInputs["ElectronicsMap"]);
265 }
266 
267 std::unique_ptr<HcalFrontEndMap> HcalTextCalibrations::produceFrontEndMap(const HcalFrontEndMapRcd& rcd) {
268  return create_impl<HcalFrontEndMap>(mInputs["FrontEndMap"]);
269 }
270 
271 std::unique_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs(const HcalValidationCorrsRcd& rcd) {
272  std::string const n = "ValidationCorrs";
273  return get_impl_topo<HcalValidationCorrs>(mInputs[n], &rcd.get(mTokens[n]));
274 }
275 
276 std::unique_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata(const HcalLutMetadataRcd& rcd) {
277  std::string const n = "LutMetadata";
278  return get_impl_topo<HcalLutMetadata>(mInputs[n], &rcd.get(mTokens[n]));
279 }
280 
281 std::unique_ptr<HcalDcsValues> HcalTextCalibrations::produceDcsValues(HcalDcsRcd const& rcd) {
282  return get_impl<HcalDcsValues>(mInputs["DcsValues"]);
283 }
284 
285 std::unique_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap(const HcalDcsMapRcd& rcd) {
286  return create_impl<HcalDcsMap>(mInputs["DcsMap"]);
287 }
288 
289 std::unique_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams(const HcalRecoParamsRcd& rcd) {
290  std::string const n = "RecoParams";
291  return get_impl_topo<HcalRecoParams>(mInputs[n], &rcd.get(mTokens[n]));
292 }
293 
294 std::unique_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams(const HcalLongRecoParamsRcd& rcd) {
295  std::string const n = "LongRecoParams";
296  return get_impl_topo<HcalLongRecoParams>(mInputs[n], &rcd.get(mTokens[n]));
297 }
298 
299 std::unique_ptr<HcalZDCLowGainFractions> HcalTextCalibrations::produceZDCLowGainFractions(
300  const HcalZDCLowGainFractionsRcd& rcd) {
301  std::string const n = "ZDCLowGainFractions";
302  return get_impl_topo<HcalZDCLowGainFractions>(mInputs[n], &rcd.get(mTokens[n]));
303 }
304 
305 std::unique_ptr<HcalTimingParams> HcalTextCalibrations::produceTimingParams(const HcalTimingParamsRcd& rcd) {
306  std::string const n = "TimingParams";
307  return get_impl_topo<HcalTimingParams>(mInputs[n], &rcd.get(mTokens[n]));
308 }
309 std::unique_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams(const HcalMCParamsRcd& rcd) {
310  std::string const n = "MCParams";
311  return get_impl_topo<HcalMCParams>(mInputs[n], &rcd.get(mTokens[n]));
312 }
313 
314 std::unique_ptr<HcalFlagHFDigiTimeParams> HcalTextCalibrations::produceFlagHFDigiTimeParams(
315  const HcalFlagHFDigiTimeParamsRcd& rcd) {
316  std::string const n = "FlagHFDigiTimeParams";
317  return get_impl_topo<HcalFlagHFDigiTimeParams>(mInputs[n], &rcd.get(mTokens[n]));
318 }
319 
320 std::unique_ptr<HcalSiPMParameters> HcalTextCalibrations::produceSiPMParameters(const HcalSiPMParametersRcd& rcd) {
321  std::string const n = "SiPMParameters";
322  return get_impl_topo<HcalSiPMParameters>(mInputs[n], &rcd.get(mTokens[n]));
323 }
324 
325 std::unique_ptr<HcalSiPMCharacteristics> HcalTextCalibrations::produceSiPMCharacteristics(
326  const HcalSiPMCharacteristicsRcd& rcd) {
327  return create_impl<HcalSiPMCharacteristics>(mInputs["SiPMCharacteristics"]);
328 }
329 
330 std::unique_ptr<HcalTPChannelParameters> HcalTextCalibrations::produceTPChannelParameters(
331  const HcalTPChannelParametersRcd& rcd) {
332  std::string const n = "TPChannelParameters";
333  return get_impl_topo<HcalTPChannelParameters>(mInputs[n], &rcd.get(mTokens[n]));
334 }
335 
336 std::unique_ptr<HcalTPParameters> HcalTextCalibrations::produceTPParameters(const HcalTPParametersRcd& rcd) {
337  return get_impl<HcalTPParameters>(mInputs["TPParameters"]);
338 }
std::unique_ptr< HcalPedestals > producePedestals(const HcalPedestalsRcd &rcd)
std::unique_ptr< HcalGainWidths > produceGainWidths(const HcalGainWidthsRcd &rcd)
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)
tuple result
Definition: mps_fire.py:311
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)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
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)
std::unique_ptr< HcalTimingParams > produceTimingParams(const HcalTimingParamsRcd &rcd)
std::unique_ptr< HcalTPParameters > produceTPParameters(const HcalTPParametersRcd &rcd)
std::unique_ptr< HcalElectronicsMap > produceElectronicsMap(const HcalElectronicsMapRcd &rcd)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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)
std::string fullPath() const
Definition: FileInPath.cc:161
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
std::unique_ptr< HcalLutMetadata > produceLutMetadata(const HcalLutMetadataRcd &rcd)
std::unique_ptr< HcalTimeCorrs > produceTimeCorrs(const HcalTimeCorrsRcd &rcd)
std::unique_ptr< HcalFlagHFDigiTimeParams > produceFlagHFDigiTimeParams(const HcalFlagHFDigiTimeParamsRcd &rcd)
std::unique_ptr< HcalValidationCorrs > produceValidationCorrs(const HcalValidationCorrsRcd &rcd)