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