CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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  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 == "ValidationCorrs") {
95  setWhatProduced (this, &HcalTextCalibrations::produceValidationCorrs);
96  findingRecord <HcalValidationCorrsRcd> ();
97  }
98  else if (objectName == "LutMetadata") {
99  setWhatProduced (this, &HcalTextCalibrations::produceLutMetadata);
100  findingRecord <HcalLutMetadataRcd> ();
101  }
102  else if (objectName == "DcsValues") {
103  setWhatProduced (this, &HcalTextCalibrations::produceDcsValues);
104  findingRecord <HcalDcsRcd> ();
105  }
106  else if (objectName == "DcsMap") {
107  setWhatProduced (this, &HcalTextCalibrations::produceDcsMap);
108  findingRecord <HcalDcsMapRcd> ();
109  }
110  else if (objectName == "CholeskyMatrices") {
111  setWhatProduced (this, &HcalTextCalibrations::produceCholeskyMatrices);
112  findingRecord <HcalCholeskyMatricesRcd> ();
113  }
114  else if (objectName == "CovarianceMatrices") {
115  setWhatProduced (this, &HcalTextCalibrations::produceCovarianceMatrices);
116  findingRecord <HcalCovarianceMatricesRcd> ();
117  }
118  else if (objectName == "RecoParams") {
119  setWhatProduced (this, &HcalTextCalibrations::produceRecoParams);
120  findingRecord <HcalRecoParamsRcd> ();
121  }
122  else if (objectName == "TimingParams") {
123  setWhatProduced (this, &HcalTextCalibrations::produceTimingParams);
124  findingRecord <HcalTimingParamsRcd> ();
125  }
126  else if (objectName == "LongRecoParams") {
127  setWhatProduced (this, &HcalTextCalibrations::produceLongRecoParams);
128  findingRecord <HcalLongRecoParamsRcd> ();
129  }
130  else if (objectName == "ZDCLowGainFractions") {
131  setWhatProduced (this, &HcalTextCalibrations::produceZDCLowGainFractions);
132  findingRecord <HcalZDCLowGainFractionsRcd> ();
133  }
134  else if (objectName == "MCParams") {
135  setWhatProduced (this, &HcalTextCalibrations::produceMCParams);
136  findingRecord <HcalMCParamsRcd> ();
137  }
138  else if (objectName == "FlagHFDigiTimeParams") {
139  setWhatProduced (this, &HcalTextCalibrations::produceFlagHFDigiTimeParams);
140  findingRecord <HcalFlagHFDigiTimeParamsRcd> ();
141  }
142  else {
143  std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName
144  << "', known names are: "
145  << "Pedestals PedestalWidths Gains GainWidths QIEData QIETypes ChannelQuality ElectronicsMap "
146  << "ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
147  << "ValidationCorrs LutMetadata DcsValues DcsMap CholeskyMatrices CovarianceMatrices "
148  << "RecoParams LongRecoParams ZDCLowGainFraction FlagHFDigiTimeParams MCParams "
149  << std::endl;
150  }
151  }
152  // setWhatProduced(this);
153 }
154 
155 
157 {
158 }
159 
160 
161 //
162 // member functions
163 //
164 void
166  std::string record = iKey.name ();
168 }
169 
170 template <class T>
171 std::auto_ptr<T> produce_impl (const HcalTopology* topo, const std::string& fFile) {
172  std::auto_ptr<T> result (new T (topo));
173  // std::auto_ptr<T> result;
174  std::ifstream inStream (fFile.c_str ());
175  if (!inStream.good ()) {
176  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
177  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
178  }
179  if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
180  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
181  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
182  }
183  return result;
184 }
185 
186 template <class T>
187 std::auto_ptr<T> produce_impl (const std::string& fFile) {
188  std::auto_ptr<T> result (new T ());
189  // std::auto_ptr<T> result;
190  std::ifstream inStream (fFile.c_str ());
191  if (!inStream.good ()) {
192  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
193  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
194  }
195  if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
196  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
197  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
198  }
199  return result;
200 }
201 
202 
203 
204 std::auto_ptr<HcalPedestals> HcalTextCalibrations::producePedestals (const HcalPedestalsRcd& rcd) {
206  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
207  const HcalTopology* topo=&(*htopo);
208 
209  return produce_impl<HcalPedestals> (topo,mInputs ["Pedestals"]);
210 }
211 
212 std::auto_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd& rcd) {
214  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
215  const HcalTopology* topo=&(*htopo);
216  return produce_impl<HcalPedestalWidths> (topo,mInputs ["PedestalWidths"]);
217 }
218 
219 std::auto_ptr<HcalGains> HcalTextCalibrations::produceGains (const HcalGainsRcd& rcd) {
221  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
222  const HcalTopology* topo=&(*htopo);
223  return produce_impl<HcalGains> (topo,mInputs ["Gains"]);
224 }
225 
226 std::auto_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths (const HcalGainWidthsRcd& rcd) {
228  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
229  const HcalTopology* topo=&(*htopo);
230  return produce_impl<HcalGainWidths> (topo,mInputs ["GainWidths"]);
231 }
232 
233 std::auto_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
235  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
236  const HcalTopology* topo=&(*htopo);
237  return produce_impl<HcalQIEData> (topo,mInputs ["QIEData"]);
238 }
239 
240 std::auto_ptr<HcalQIETypes> HcalTextCalibrations::produceQIETypes (const HcalQIETypesRcd& rcd) {
242  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
243  const HcalTopology* topo=&(*htopo);
244  return produce_impl<HcalQIETypes> (topo,mInputs ["QIETypes"]);
245 }
246 
247 std::auto_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
249  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
250  const HcalTopology* topo=&(*htopo);
251  return produce_impl<HcalChannelQuality> (topo,mInputs ["ChannelQuality"]);
252 }
253 
255  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
256  const HcalTopology* topo=&(*htopo);
257  return produce_impl<HcalZSThresholds> (topo,mInputs ["ZSThresholds"]);
258 }
259 
260 std::auto_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
262  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
263  const HcalTopology* topo=&(*htopo);
264  return produce_impl<HcalRespCorrs> (topo,mInputs ["RespCorrs"]);
265 }
266 
267 std::auto_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
269  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
270  const HcalTopology* topo=&(*htopo);
271  return produce_impl<HcalLUTCorrs> (topo,mInputs ["LUTCorrs"]);
272 }
273 
274 std::auto_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
276  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
277  const HcalTopology* topo=&(*htopo);
278  return produce_impl<HcalPFCorrs> (topo,mInputs ["PFCorrs"]);
279 }
280 
281 std::auto_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
283  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
284  const HcalTopology* topo=&(*htopo);
285  return produce_impl<HcalTimeCorrs> (topo,mInputs ["TimeCorrs"]);
286 }
287 
288 std::auto_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
290  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
291  const HcalTopology* topo=&(*htopo);
292  return produce_impl<HcalL1TriggerObjects> (topo,mInputs ["L1TriggerObjects"]);
293 }
294 
295 std::auto_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
296  return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"]);
297 }
298 
299 std::auto_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
301  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
302  const HcalTopology* topo=&(*htopo);
303  return produce_impl<HcalValidationCorrs> (topo,mInputs ["ValidationCorrs"]);
304 }
305 
306 std::auto_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
308  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
309  const HcalTopology* topo=&(*htopo);
310  return produce_impl<HcalLutMetadata> (topo,mInputs ["LutMetadata"]);
311 }
312 
313 std::auto_ptr<HcalDcsValues>
315  return produce_impl<HcalDcsValues> (mInputs ["DcsValues"]);
316 }
317 
318 std::auto_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
319  return produce_impl<HcalDcsMap> (mInputs ["DcsMap"]);
320 }
321 
322 std::auto_ptr<HcalCovarianceMatrices> HcalTextCalibrations::produceCovarianceMatrices (const HcalCovarianceMatricesRcd& rcd) {
324  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
325  const HcalTopology* topo=&(*htopo);
326  return produce_impl<HcalCovarianceMatrices> (topo,mInputs ["CovarianceMatrices"]);
327 }
328 
329 std::auto_ptr<HcalCholeskyMatrices> HcalTextCalibrations::produceCholeskyMatrices (const HcalCholeskyMatricesRcd& rcd) {
331  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
332  const HcalTopology* topo=&(*htopo);
333  return produce_impl<HcalCholeskyMatrices> (topo,mInputs ["CholeskyMatrices"]);
334 }
335 
336 std::auto_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams (const HcalRecoParamsRcd& rcd) {
338  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
339  const HcalTopology* topo=&(*htopo);
340  return produce_impl<HcalRecoParams> (topo,mInputs ["RecoParams"]);
341 }
342 
343 std::auto_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams (const HcalLongRecoParamsRcd& rcd) {
345  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
346  const HcalTopology* topo=&(*htopo);
347  return produce_impl<HcalLongRecoParams> (topo,mInputs ["LongRecoParams"]);
348 }
349 
350 std::auto_ptr<HcalZDCLowGainFractions> HcalTextCalibrations::produceZDCLowGainFractions (const HcalZDCLowGainFractionsRcd& rcd) {
352  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
353  const HcalTopology* topo=&(*htopo);
354  return produce_impl<HcalZDCLowGainFractions> (topo,mInputs ["ZDCLowGainFractions"]);
355 }
356 
357 std::auto_ptr<HcalTimingParams> HcalTextCalibrations::produceTimingParams (const HcalTimingParamsRcd& rcd) {
359  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
360  const HcalTopology* topo=&(*htopo);
361  return produce_impl<HcalTimingParams> (topo,mInputs ["TimingParams"]);
362 }
363 std::auto_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams (const HcalMCParamsRcd& rcd) {
365  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
366  const HcalTopology* topo=&(*htopo);
367  return produce_impl<HcalMCParams> (topo,mInputs ["MCParams"]);
368 }
369 
370 std::auto_ptr<HcalFlagHFDigiTimeParams> HcalTextCalibrations::produceFlagHFDigiTimeParams (const HcalFlagHFDigiTimeParamsRcd& rcd) {
372  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
373  const HcalTopology* topo=&(*htopo);
374  return produce_impl<HcalFlagHFDigiTimeParams> (topo,mInputs ["FlagHFDigiTimeParams"]);
375 }
T getParameter(std::string const &) const
std::auto_ptr< HcalDcsValues > produceDcsValues(HcalDcsRcd const &rcd)
std::auto_ptr< HcalQIEData > produceQIEData(const HcalQIEDataRcd &rcd)
std::auto_ptr< HcalLongRecoParams > produceLongRecoParams(const HcalLongRecoParamsRcd &rcd)
JetCorrectorParameters::Record record
Definition: classes.h:7
std::auto_ptr< HcalPedestals > producePedestals(const HcalPedestalsRcd &rcd)
std::auto_ptr< HcalCovarianceMatrices > produceCovarianceMatrices(const HcalCovarianceMatricesRcd &rcd)
std::auto_ptr< HcalZDCLowGainFractions > produceZDCLowGainFractions(const HcalZDCLowGainFractionsRcd &rcd)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
std::auto_ptr< HcalMCParams > produceMCParams(const HcalMCParamsRcd &rcd)
tuple result
Definition: mps_fire.py:95
std::auto_ptr< HcalGainWidths > produceGainWidths(const HcalGainWidthsRcd &rcd)
static const IOVSyncValue & beginOfTime()
std::auto_ptr< HcalZSThresholds > produceZSThresholds(const HcalZSThresholdsRcd &rcd)
std::auto_ptr< HcalValidationCorrs > produceValidationCorrs(const HcalValidationCorrsRcd &rcd)
std::auto_ptr< HcalFlagHFDigiTimeParams > produceFlagHFDigiTimeParams(const HcalFlagHFDigiTimeParamsRcd &rcd)
HcalTextCalibrations(const edm::ParameterSet &)
std::auto_ptr< HcalRespCorrs > produceRespCorrs(const HcalRespCorrsRcd &rcd)
std::auto_ptr< HcalL1TriggerObjects > produceL1TriggerObjects(const HcalL1TriggerObjectsRcd &rcd)
std::auto_ptr< HcalRecoParams > produceRecoParams(const HcalRecoParamsRcd &rcd)
std::auto_ptr< HcalTimeCorrs > produceTimeCorrs(const HcalTimeCorrsRcd &rcd)
std::auto_ptr< HcalTimingParams > produceTimingParams(const HcalTimingParamsRcd &rcd)
std::auto_ptr< HcalCholeskyMatrices > produceCholeskyMatrices(const HcalCholeskyMatricesRcd &rcd)
std::auto_ptr< HcalChannelQuality > produceChannelQuality(const HcalChannelQualityRcd &rcd)
bool getObject(std::istream &fInput, HcalPedestals *fObject)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::auto_ptr< HcalGains > produceGains(const HcalGainsRcd &rcd)
std::auto_ptr< HcalLUTCorrs > produceLUTCorrs(const HcalLUTCorrsRcd &rcd)
std::auto_ptr< HcalLutMetadata > produceLutMetadata(const HcalLutMetadataRcd &rcd)
std::auto_ptr< HcalQIETypes > produceQIETypes(const HcalQIETypesRcd &rcd)
std::string fullPath() const
Definition: FileInPath.cc:184
std::auto_ptr< T > produce_impl(const std::string &fFile)
long double T
std::auto_ptr< HcalElectronicsMap > produceElectronicsMap(const HcalElectronicsMapRcd &rcd)
std::auto_ptr< HcalPedestalWidths > producePedestalWidths(const HcalPedestalWidthsRcd &rcd)
std::auto_ptr< HcalPFCorrs > producePFCorrs(const HcalPFCorrsRcd &rcd)
std::auto_ptr< HcalDcsMap > produceDcsMap(const HcalDcsMapRcd &rcd)