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 // $Id: HcalTextCalibrations.cc,v 1.22 2012/11/12 20:42:39 dlange Exp $
4 //
5 //
6 
7 #include <memory>
8 #include <iostream>
9 #include <fstream>
10 
14 
16 
19 
21 
22 #include "HcalTextCalibrations.h"
23 //
24 // class declaration
25 //
26 
27 using namespace cms;
28 
30 
31 {
32  //parsing parameters
33  std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
34  std::vector<edm::ParameterSet>::iterator request = data.begin ();
35  for (; request != data.end (); request++) {
36  std::string objectName = request->getParameter<std::string> ("object");
37  edm::FileInPath fp = request->getParameter<edm::FileInPath>("file");
38  mInputs [objectName] = fp.fullPath();
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 == "ChannelQuality") {
60  setWhatProduced (this, &HcalTextCalibrations::produceChannelQuality);
61  findingRecord <HcalChannelQualityRcd> ();
62  }
63  else if (objectName == "ZSThresholds") {
64  setWhatProduced (this, &HcalTextCalibrations::produceZSThresholds);
65  findingRecord <HcalZSThresholdsRcd> ();
66  }
67  else if (objectName == "RespCorrs") {
68  setWhatProduced (this, &HcalTextCalibrations::produceRespCorrs);
69  findingRecord <HcalRespCorrsRcd> ();
70  }
71  else if (objectName == "LUTCorrs") {
72  setWhatProduced (this, &HcalTextCalibrations::produceLUTCorrs);
73  findingRecord <HcalLUTCorrsRcd> ();
74  }
75  else if (objectName == "PFCorrs") {
76  setWhatProduced (this, &HcalTextCalibrations::producePFCorrs);
77  findingRecord <HcalPFCorrsRcd> ();
78  }
79  else if (objectName == "TimeCorrs") {
80  setWhatProduced (this, &HcalTextCalibrations::produceTimeCorrs);
81  findingRecord <HcalTimeCorrsRcd> ();
82  }
83  else if (objectName == "L1TriggerObjects") {
84  setWhatProduced (this, &HcalTextCalibrations::produceL1TriggerObjects);
85  findingRecord <HcalL1TriggerObjectsRcd> ();
86  }
87  else if (objectName == "ElectronicsMap") {
88  setWhatProduced (this, &HcalTextCalibrations::produceElectronicsMap);
89  findingRecord <HcalElectronicsMapRcd> ();
90  }
91  else if (objectName == "ValidationCorrs") {
92  setWhatProduced (this, &HcalTextCalibrations::produceValidationCorrs);
93  findingRecord <HcalValidationCorrsRcd> ();
94  }
95  else if (objectName == "LutMetadata") {
96  setWhatProduced (this, &HcalTextCalibrations::produceLutMetadata);
97  findingRecord <HcalLutMetadataRcd> ();
98  }
99  else if (objectName == "DcsValues") {
100  setWhatProduced (this, &HcalTextCalibrations::produceDcsValues);
101  findingRecord <HcalDcsRcd> ();
102  }
103  else if (objectName == "DcsMap") {
104  setWhatProduced (this, &HcalTextCalibrations::produceDcsMap);
105  findingRecord <HcalDcsMapRcd> ();
106  }
107  else if (objectName == "CholeskyMatrices") {
108  setWhatProduced (this, &HcalTextCalibrations::produceCholeskyMatrices);
109  findingRecord <HcalCholeskyMatricesRcd> ();
110  }
111  else if (objectName == "CovarianceMatrices") {
112  setWhatProduced (this, &HcalTextCalibrations::produceCovarianceMatrices);
113  findingRecord <HcalCovarianceMatricesRcd> ();
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 == "MCParams") {
128  setWhatProduced (this, &HcalTextCalibrations::produceMCParams);
129  findingRecord <HcalMCParamsRcd> ();
130  }
131  else if (objectName == "FlagHFDigiTimeParams") {
132  setWhatProduced (this, &HcalTextCalibrations::produceFlagHFDigiTimeParams);
133  findingRecord <HcalFlagHFDigiTimeParamsRcd> ();
134  }
135  else {
136  std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName
137  << "', known names are: "
138  << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap "
139  << "ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
140  << "ValidationCorrs LutMetadata DcsValues DcsMap CholeskyMatrices CovarianceMatrices "
141  << "RecoParams LongRecoParams FlagHFDigiTimeParams MCParams "
142  << std::endl;
143  }
144  }
145  // setWhatProduced(this);
146 }
147 
148 
150 {
151 }
152 
153 
154 //
155 // member functions
156 //
157 void
159  std::string record = iKey.name ();
161 }
162 
163 template <class T>
164 std::auto_ptr<T> produce_impl (const HcalTopology* topo, const std::string& fFile) {
165  std::auto_ptr<T> result (new T (topo));
166  // std::auto_ptr<T> result;
167  std::ifstream inStream (fFile.c_str ());
168  if (!inStream.good ()) {
169  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
170  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
171  }
172  if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
173  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
174  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
175  }
176  return result;
177 }
178 
179 template <class T>
180 std::auto_ptr<T> produce_impl (const std::string& fFile) {
181  std::auto_ptr<T> result (new T ());
182  // std::auto_ptr<T> result;
183  std::ifstream inStream (fFile.c_str ());
184  if (!inStream.good ()) {
185  std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
186  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
187  }
188  if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
189  std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
190  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
191  }
192  return result;
193 }
194 
195 
196 
197 std::auto_ptr<HcalPedestals> HcalTextCalibrations::producePedestals (const HcalPedestalsRcd& rcd) {
199  rcd.getRecord<IdealGeometryRecord>().get(htopo);
200  const HcalTopology* topo=&(*htopo);
201 
202  return produce_impl<HcalPedestals> (topo,mInputs ["Pedestals"]);
203 }
204 
205 std::auto_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd& rcd) {
207  rcd.getRecord<IdealGeometryRecord>().get(htopo);
208  const HcalTopology* topo=&(*htopo);
209  return produce_impl<HcalPedestalWidths> (topo,mInputs ["PedestalWidths"]);
210 }
211 
212 std::auto_ptr<HcalGains> HcalTextCalibrations::produceGains (const HcalGainsRcd& rcd) {
214  rcd.getRecord<IdealGeometryRecord>().get(htopo);
215  const HcalTopology* topo=&(*htopo);
216  return produce_impl<HcalGains> (topo,mInputs ["Gains"]);
217 }
218 
219 std::auto_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths (const HcalGainWidthsRcd& rcd) {
221  rcd.getRecord<IdealGeometryRecord>().get(htopo);
222  const HcalTopology* topo=&(*htopo);
223  return produce_impl<HcalGainWidths> (topo,mInputs ["GainWidths"]);
224 }
225 
226 std::auto_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
228  rcd.getRecord<IdealGeometryRecord>().get(htopo);
229  const HcalTopology* topo=&(*htopo);
230  return produce_impl<HcalQIEData> (topo,mInputs ["QIEData"]);
231 }
232 
233 std::auto_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
235  rcd.getRecord<IdealGeometryRecord>().get(htopo);
236  const HcalTopology* topo=&(*htopo);
237  return produce_impl<HcalChannelQuality> (topo,mInputs ["ChannelQuality"]);
238 }
239 
241  rcd.getRecord<IdealGeometryRecord>().get(htopo);
242  const HcalTopology* topo=&(*htopo);
243  return produce_impl<HcalZSThresholds> (topo,mInputs ["ZSThresholds"]);
244 }
245 
246 std::auto_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
248  rcd.getRecord<IdealGeometryRecord>().get(htopo);
249  const HcalTopology* topo=&(*htopo);
250  return produce_impl<HcalRespCorrs> (topo,mInputs ["RespCorrs"]);
251 }
252 
253 std::auto_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
255  rcd.getRecord<IdealGeometryRecord>().get(htopo);
256  const HcalTopology* topo=&(*htopo);
257  return produce_impl<HcalLUTCorrs> (topo,mInputs ["LUTCorrs"]);
258 }
259 
260 std::auto_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
262  rcd.getRecord<IdealGeometryRecord>().get(htopo);
263  const HcalTopology* topo=&(*htopo);
264  return produce_impl<HcalPFCorrs> (topo,mInputs ["PFCorrs"]);
265 }
266 
267 std::auto_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
269  rcd.getRecord<IdealGeometryRecord>().get(htopo);
270  const HcalTopology* topo=&(*htopo);
271  return produce_impl<HcalTimeCorrs> (topo,mInputs ["TimeCorrs"]);
272 }
273 
274 std::auto_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
276  rcd.getRecord<IdealGeometryRecord>().get(htopo);
277  const HcalTopology* topo=&(*htopo);
278  return produce_impl<HcalL1TriggerObjects> (topo,mInputs ["L1TriggerObjects"]);
279 }
280 
281 std::auto_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
282  return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"]);
283 }
284 
285 std::auto_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
287  rcd.getRecord<IdealGeometryRecord>().get(htopo);
288  const HcalTopology* topo=&(*htopo);
289  return produce_impl<HcalValidationCorrs> (topo,mInputs ["ValidationCorrs"]);
290 }
291 
292 std::auto_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
294  rcd.getRecord<IdealGeometryRecord>().get(htopo);
295  const HcalTopology* topo=&(*htopo);
296  return produce_impl<HcalLutMetadata> (topo,mInputs ["LutMetadata"]);
297 }
298 
299 std::auto_ptr<HcalDcsValues>
301  return produce_impl<HcalDcsValues> (mInputs ["DcsValues"]);
302 }
303 
304 std::auto_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
305  return produce_impl<HcalDcsMap> (mInputs ["DcsMap"]);
306 }
307 
308 std::auto_ptr<HcalCovarianceMatrices> HcalTextCalibrations::produceCovarianceMatrices (const HcalCovarianceMatricesRcd& rcd) {
310  rcd.getRecord<IdealGeometryRecord>().get(htopo);
311  const HcalTopology* topo=&(*htopo);
312  return produce_impl<HcalCovarianceMatrices> (topo,mInputs ["CovarianceMatrices"]);
313 }
314 
315 std::auto_ptr<HcalCholeskyMatrices> HcalTextCalibrations::produceCholeskyMatrices (const HcalCholeskyMatricesRcd& rcd) {
317  rcd.getRecord<IdealGeometryRecord>().get(htopo);
318  const HcalTopology* topo=&(*htopo);
319  return produce_impl<HcalCholeskyMatrices> (topo,mInputs ["CholeskyMatrices"]);
320 }
321 
322 std::auto_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams (const HcalRecoParamsRcd& rcd) {
324  rcd.getRecord<IdealGeometryRecord>().get(htopo);
325  const HcalTopology* topo=&(*htopo);
326  return produce_impl<HcalRecoParams> (topo,mInputs ["RecoParams"]);
327 }
328 
329 std::auto_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams (const HcalLongRecoParamsRcd& rcd) {
331  rcd.getRecord<IdealGeometryRecord>().get(htopo);
332  const HcalTopology* topo=&(*htopo);
333  return produce_impl<HcalLongRecoParams> (topo,mInputs ["LongRecoParams"]);
334 }
335 std::auto_ptr<HcalTimingParams> HcalTextCalibrations::produceTimingParams (const HcalTimingParamsRcd& rcd) {
337  rcd.getRecord<IdealGeometryRecord>().get(htopo);
338  const HcalTopology* topo=&(*htopo);
339  return produce_impl<HcalTimingParams> (topo,mInputs ["TimingParams"]);
340 }
341 std::auto_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams (const HcalMCParamsRcd& rcd) {
343  rcd.getRecord<IdealGeometryRecord>().get(htopo);
344  const HcalTopology* topo=&(*htopo);
345  return produce_impl<HcalMCParams> (topo,mInputs ["MCParams"]);
346 }
347 
348 std::auto_ptr<HcalFlagHFDigiTimeParams> HcalTextCalibrations::produceFlagHFDigiTimeParams (const HcalFlagHFDigiTimeParamsRcd& rcd) {
350  rcd.getRecord<IdealGeometryRecord>().get(htopo);
351  const HcalTopology* topo=&(*htopo);
352  return produce_impl<HcalFlagHFDigiTimeParams> (topo,mInputs ["FlagHFDigiTimeParams"]);
353 }
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:13
std::auto_ptr< HcalPedestals > producePedestals(const HcalPedestalsRcd &rcd)
std::auto_ptr< HcalCovarianceMatrices > produceCovarianceMatrices(const HcalCovarianceMatricesRcd &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:171
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)