CMS 3D CMS Logo

CastorTextCalibrations.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <iostream>
3 #include <fstream>
4 
7 
9 
11 
19 
29 
30 #include "CastorTextCalibrations.h"
31 //
32 // class decleration
33 //
34 
35 using namespace cms;
36 
38 
39 {
40  //parsing parameters
41  std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
42  std::vector<edm::ParameterSet>::iterator request = data.begin();
43  for (; request != data.end(); ++request) {
44  std::string objectName = request->getParameter<std::string>("object");
45  edm::FileInPath fp = request->getParameter<edm::FileInPath>("file");
46  mInputs[objectName] = fp.fullPath();
47  if (objectName == "Pedestals") {
48  setWhatProduced(this, &CastorTextCalibrations::producePedestals);
49  findingRecord<CastorPedestalsRcd>();
50  } else if (objectName == "PedestalWidths") {
51  setWhatProduced(this, &CastorTextCalibrations::producePedestalWidths);
52  findingRecord<CastorPedestalWidthsRcd>();
53  } else if (objectName == "Gains") {
54  setWhatProduced(this, &CastorTextCalibrations::produceGains);
55  findingRecord<CastorGainsRcd>();
56  } else if (objectName == "GainWidths") {
57  setWhatProduced(this, &CastorTextCalibrations::produceGainWidths);
58  findingRecord<CastorGainWidthsRcd>();
59  } else if (objectName == "QIEData") {
60  setWhatProduced(this, &CastorTextCalibrations::produceQIEData);
61  findingRecord<CastorQIEDataRcd>();
62  } else if (objectName == "ChannelQuality") {
63  setWhatProduced(this, &CastorTextCalibrations::produceChannelQuality);
64  findingRecord<CastorChannelQualityRcd>();
65  } else if (objectName == "ElectronicsMap") {
66  setWhatProduced(this, &CastorTextCalibrations::produceElectronicsMap);
67  findingRecord<CastorElectronicsMapRcd>();
68  } else if (objectName == "RecoParams") {
69  setWhatProduced(this, &CastorTextCalibrations::produceRecoParams);
70  findingRecord<CastorRecoParamsRcd>();
71  } else if (objectName == "SaturationCorrs") {
72  setWhatProduced(this, &CastorTextCalibrations::produceSaturationCorrs);
73  findingRecord<CastorSaturationCorrsRcd>();
74  } else {
75  std::cerr << "CastorTextCalibrations-> Unknown object name '" << objectName << "', known names are: "
76  << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap RecoParams "
77  "SaturationCorrs"
78  << std::endl;
79  }
80  }
81  // setWhatProduced(this);
82 }
83 
85 
86 //
87 // member functions
88 //
90  const edm::IOVSyncValue& iTime,
91  edm::ValidityInterval& oInterval) {
92  std::string record = iKey.name();
94 }
95 
96 template <class T>
97 std::unique_ptr<T> produce_impl(const std::string& fFile) {
98  std::unique_ptr<T> result(new T());
99  std::ifstream inStream(fFile.c_str());
100  if (!inStream.good()) {
101  std::cerr << "CastorTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
102  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
103  }
104  if (!CastorDbASCIIIO::getObject(inStream, *result)) {
105  std::cerr << "CastorTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
106  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
107  }
108  return result;
109 }
110 
111 std::unique_ptr<CastorPedestals> CastorTextCalibrations::producePedestals(const CastorPedestalsRcd&) {
112  return produce_impl<CastorPedestals>(mInputs["Pedestals"]);
113 }
114 
115 std::unique_ptr<CastorPedestalWidths> CastorTextCalibrations::producePedestalWidths(const CastorPedestalWidthsRcd&) {
116  return produce_impl<CastorPedestalWidths>(mInputs["PedestalWidths"]);
117 }
118 
119 std::unique_ptr<CastorGains> CastorTextCalibrations::produceGains(const CastorGainsRcd&) {
120  return produce_impl<CastorGains>(mInputs["Gains"]);
121 }
122 
123 std::unique_ptr<CastorGainWidths> CastorTextCalibrations::produceGainWidths(const CastorGainWidthsRcd&) {
124  return produce_impl<CastorGainWidths>(mInputs["GainWidths"]);
125 }
126 
127 std::unique_ptr<CastorQIEData> CastorTextCalibrations::produceQIEData(const CastorQIEDataRcd& rcd) {
128  return produce_impl<CastorQIEData>(mInputs["QIEData"]);
129 }
130 
131 std::unique_ptr<CastorChannelQuality> CastorTextCalibrations::produceChannelQuality(const CastorChannelQualityRcd& rcd) {
132  return produce_impl<CastorChannelQuality>(mInputs["ChannelQuality"]);
133 }
134 
135 std::unique_ptr<CastorElectronicsMap> CastorTextCalibrations::produceElectronicsMap(const CastorElectronicsMapRcd& rcd) {
136  return produce_impl<CastorElectronicsMap>(mInputs["ElectronicsMap"]);
137 }
138 
139 std::unique_ptr<CastorRecoParams> CastorTextCalibrations::produceRecoParams(const CastorRecoParamsRcd& rcd) {
140  return produce_impl<CastorRecoParams>(mInputs["RecoParams"]);
141 }
142 
143 std::unique_ptr<CastorSaturationCorrs> CastorTextCalibrations::produceSaturationCorrs(
144  const CastorSaturationCorrsRcd& rcd) {
145  return produce_impl<CastorSaturationCorrs>(mInputs["SaturationCorrs"]);
146 }
T getParameter(std::string const &) const
JetCorrectorParameters::Record record
Definition: classes.h:7
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::unique_ptr< CastorPedestals > producePedestals(const CastorPedestalsRcd &rcd)
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::unique_ptr< CastorGainWidths > produceGainWidths(const CastorGainWidthsRcd &rcd)
std::unique_ptr< CastorPedestalWidths > producePedestalWidths(const CastorPedestalWidthsRcd &rcd)
std::unique_ptr< T > produce_impl(const std::string &fFile)
std::unique_ptr< CastorRecoParams > produceRecoParams(const CastorRecoParamsRcd &rcd)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
Namespace of DDCMS conversion namespace.
std::unique_ptr< CastorChannelQuality > produceChannelQuality(const CastorChannelQualityRcd &rcd)
bool getObject(std::istream &fInput, CastorPedestals &fObject)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::unique_ptr< CastorSaturationCorrs > produceSaturationCorrs(const CastorSaturationCorrsRcd &rcd)
std::unique_ptr< CastorElectronicsMap > produceElectronicsMap(const CastorElectronicsMapRcd &rcd)
std::string fullPath() const
Definition: FileInPath.cc:163
CastorTextCalibrations(const edm::ParameterSet &)
long double T
std::unique_ptr< CastorQIEData > produceQIEData(const CastorQIEDataRcd &rcd)
std::unique_ptr< CastorGains > produceGains(const CastorGainsRcd &rcd)