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 == "ChannelQuality") {
59  setWhatProduced (this, &HcalTextCalibrations::produceChannelQuality);
60  findingRecord <HcalChannelQualityRcd> ();
61  }
62  else if (objectName == "ZSThresholds") {
63  setWhatProduced (this, &HcalTextCalibrations::produceZSThresholds);
64  findingRecord <HcalZSThresholdsRcd> ();
65  }
66  else if (objectName == "RespCorrs") {
67  setWhatProduced (this, &HcalTextCalibrations::produceRespCorrs);
68  findingRecord <HcalRespCorrsRcd> ();
69  }
70  else if (objectName == "LUTCorrs") {
71  setWhatProduced (this, &HcalTextCalibrations::produceLUTCorrs);
72  findingRecord <HcalLUTCorrsRcd> ();
73  }
74  else if (objectName == "PFCorrs") {
75  setWhatProduced (this, &HcalTextCalibrations::producePFCorrs);
76  findingRecord <HcalPFCorrsRcd> ();
77  }
78  else if (objectName == "TimeCorrs") {
79  setWhatProduced (this, &HcalTextCalibrations::produceTimeCorrs);
80  findingRecord <HcalTimeCorrsRcd> ();
81  }
82  else if (objectName == "L1TriggerObjects") {
83  setWhatProduced (this, &HcalTextCalibrations::produceL1TriggerObjects);
84  findingRecord <HcalL1TriggerObjectsRcd> ();
85  }
86  else if (objectName == "ElectronicsMap") {
87  setWhatProduced (this, &HcalTextCalibrations::produceElectronicsMap);
88  findingRecord <HcalElectronicsMapRcd> ();
89  }
90  else if (objectName == "ValidationCorrs") {
91  setWhatProduced (this, &HcalTextCalibrations::produceValidationCorrs);
92  findingRecord <HcalValidationCorrsRcd> ();
93  }
94  else if (objectName == "LutMetadata") {
95  setWhatProduced (this, &HcalTextCalibrations::produceLutMetadata);
96  findingRecord <HcalLutMetadataRcd> ();
97  }
98  else if (objectName == "DcsValues") {
99  setWhatProduced (this, &HcalTextCalibrations::produceDcsValues);
100  findingRecord <HcalDcsRcd> ();
101  }
102  else if (objectName == "DcsMap") {
103  setWhatProduced (this, &HcalTextCalibrations::produceDcsMap);
104  findingRecord <HcalDcsMapRcd> ();
105  }
106  else if (objectName == "CholeskyMatrices") {
107  setWhatProduced (this, &HcalTextCalibrations::produceCholeskyMatrices);
108  findingRecord <HcalCholeskyMatricesRcd> ();
109  }
110  else if (objectName == "CovarianceMatrices") {
111  setWhatProduced (this, &HcalTextCalibrations::produceCovarianceMatrices);
112  findingRecord <HcalCovarianceMatricesRcd> ();
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 {
139  std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName
140  << "', known names are: "
141  << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap "
142  << "ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
143  << "ValidationCorrs LutMetadata DcsValues DcsMap CholeskyMatrices CovarianceMatrices "
144  << "RecoParams LongRecoParams ZDCLowGainFraction FlagHFDigiTimeParams MCParams "
145  << std::endl;
146  }
147  }
148  // setWhatProduced(this);
149 }
150 
151 
153 {
154 }
155 
156 
157 //
158 // member functions
159 //
160 void
162  std::string record = iKey.name ();
164 }
165 
166 template <class T>
167 std::auto_ptr<T> produce_impl (const HcalTopology* topo, const std::string& fFile) {
168  std::auto_ptr<T> result (new T (topo));
169  // std::auto_ptr<T> result;
170  std::ifstream inStream (fFile.c_str ());
171  if (!inStream.good ()) {
172  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
173  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
174  }
175  if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
176  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
177  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
178  }
179  return result;
180 }
181 
182 template <class T>
183 std::auto_ptr<T> produce_impl (const std::string& fFile) {
184  std::auto_ptr<T> result (new T ());
185  // std::auto_ptr<T> result;
186  std::ifstream inStream (fFile.c_str ());
187  if (!inStream.good ()) {
188  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
189  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
190  }
191  if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
192  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
193  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
194  }
195  return result;
196 }
197 
198 
199 
200 std::auto_ptr<HcalPedestals> HcalTextCalibrations::producePedestals (const HcalPedestalsRcd& rcd) {
202  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
203  const HcalTopology* topo=&(*htopo);
204 
205  return produce_impl<HcalPedestals> (topo,mInputs ["Pedestals"]);
206 }
207 
208 std::auto_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd& rcd) {
210  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
211  const HcalTopology* topo=&(*htopo);
212  return produce_impl<HcalPedestalWidths> (topo,mInputs ["PedestalWidths"]);
213 }
214 
215 std::auto_ptr<HcalGains> HcalTextCalibrations::produceGains (const HcalGainsRcd& rcd) {
217  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
218  const HcalTopology* topo=&(*htopo);
219  return produce_impl<HcalGains> (topo,mInputs ["Gains"]);
220 }
221 
222 std::auto_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths (const HcalGainWidthsRcd& rcd) {
224  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
225  const HcalTopology* topo=&(*htopo);
226  return produce_impl<HcalGainWidths> (topo,mInputs ["GainWidths"]);
227 }
228 
229 std::auto_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
231  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
232  const HcalTopology* topo=&(*htopo);
233  return produce_impl<HcalQIEData> (topo,mInputs ["QIEData"]);
234 }
235 
236 std::auto_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
238  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
239  const HcalTopology* topo=&(*htopo);
240  return produce_impl<HcalChannelQuality> (topo,mInputs ["ChannelQuality"]);
241 }
242 
244  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
245  const HcalTopology* topo=&(*htopo);
246  return produce_impl<HcalZSThresholds> (topo,mInputs ["ZSThresholds"]);
247 }
248 
249 std::auto_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
251  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
252  const HcalTopology* topo=&(*htopo);
253  return produce_impl<HcalRespCorrs> (topo,mInputs ["RespCorrs"]);
254 }
255 
256 std::auto_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
258  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
259  const HcalTopology* topo=&(*htopo);
260  return produce_impl<HcalLUTCorrs> (topo,mInputs ["LUTCorrs"]);
261 }
262 
263 std::auto_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
265  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
266  const HcalTopology* topo=&(*htopo);
267  return produce_impl<HcalPFCorrs> (topo,mInputs ["PFCorrs"]);
268 }
269 
270 std::auto_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
272  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
273  const HcalTopology* topo=&(*htopo);
274  return produce_impl<HcalTimeCorrs> (topo,mInputs ["TimeCorrs"]);
275 }
276 
277 std::auto_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
279  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
280  const HcalTopology* topo=&(*htopo);
281  return produce_impl<HcalL1TriggerObjects> (topo,mInputs ["L1TriggerObjects"]);
282 }
283 
284 std::auto_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
285  return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"]);
286 }
287 
288 std::auto_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
290  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
291  const HcalTopology* topo=&(*htopo);
292  return produce_impl<HcalValidationCorrs> (topo,mInputs ["ValidationCorrs"]);
293 }
294 
295 std::auto_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
297  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
298  const HcalTopology* topo=&(*htopo);
299  return produce_impl<HcalLutMetadata> (topo,mInputs ["LutMetadata"]);
300 }
301 
302 std::auto_ptr<HcalDcsValues>
304  return produce_impl<HcalDcsValues> (mInputs ["DcsValues"]);
305 }
306 
307 std::auto_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
308  return produce_impl<HcalDcsMap> (mInputs ["DcsMap"]);
309 }
310 
311 std::auto_ptr<HcalCovarianceMatrices> HcalTextCalibrations::produceCovarianceMatrices (const HcalCovarianceMatricesRcd& rcd) {
313  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
314  const HcalTopology* topo=&(*htopo);
315  return produce_impl<HcalCovarianceMatrices> (topo,mInputs ["CovarianceMatrices"]);
316 }
317 
318 std::auto_ptr<HcalCholeskyMatrices> HcalTextCalibrations::produceCholeskyMatrices (const HcalCholeskyMatricesRcd& rcd) {
320  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
321  const HcalTopology* topo=&(*htopo);
322  return produce_impl<HcalCholeskyMatrices> (topo,mInputs ["CholeskyMatrices"]);
323 }
324 
325 std::auto_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams (const HcalRecoParamsRcd& rcd) {
327  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
328  const HcalTopology* topo=&(*htopo);
329  return produce_impl<HcalRecoParams> (topo,mInputs ["RecoParams"]);
330 }
331 
332 std::auto_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams (const HcalLongRecoParamsRcd& rcd) {
334  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
335  const HcalTopology* topo=&(*htopo);
336  return produce_impl<HcalLongRecoParams> (topo,mInputs ["LongRecoParams"]);
337 }
338 
339 std::auto_ptr<HcalZDCLowGainFractions> HcalTextCalibrations::produceZDCLowGainFractions (const HcalZDCLowGainFractionsRcd& rcd) {
341  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
342  const HcalTopology* topo=&(*htopo);
343  return produce_impl<HcalZDCLowGainFractions> (topo,mInputs ["ZDCLowGainFractions"]);
344 }
345 
346 std::auto_ptr<HcalTimingParams> HcalTextCalibrations::produceTimingParams (const HcalTimingParamsRcd& rcd) {
348  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
349  const HcalTopology* topo=&(*htopo);
350  return produce_impl<HcalTimingParams> (topo,mInputs ["TimingParams"]);
351 }
352 std::auto_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams (const HcalMCParamsRcd& rcd) {
354  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
355  const HcalTopology* topo=&(*htopo);
356  return produce_impl<HcalMCParams> (topo,mInputs ["MCParams"]);
357 }
358 
359 std::auto_ptr<HcalFlagHFDigiTimeParams> HcalTextCalibrations::produceFlagHFDigiTimeParams (const HcalFlagHFDigiTimeParamsRcd& rcd) {
361  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
362  const HcalTopology* topo=&(*htopo);
363  return produce_impl<HcalFlagHFDigiTimeParams> (topo,mInputs ["FlagHFDigiTimeParams"]);
364 }
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)
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)
tuple result
Definition: query.py:137
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::string fullPath() const
Definition: FileInPath.cc:165
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)