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