CMS 3D CMS Logo

CastorTextCalibrations.cc
Go to the documentation of this file.
1 #include <map>
2 #include <memory>
3 #include <iostream>
4 #include <fstream>
5 #include <string>
6 
12 
14 
16 
24 
34 
36 public:
38  ~CastorTextCalibrations() override;
39 
40  void produce() {}
41 
42 protected:
44  const edm::IOVSyncValue&,
45  edm::ValidityInterval&) override;
46 
47  std::unique_ptr<CastorPedestals> producePedestals(const CastorPedestalsRcd& rcd);
48  std::unique_ptr<CastorPedestalWidths> producePedestalWidths(const CastorPedestalWidthsRcd& rcd);
49  std::unique_ptr<CastorGains> produceGains(const CastorGainsRcd& rcd);
50  std::unique_ptr<CastorGainWidths> produceGainWidths(const CastorGainWidthsRcd& rcd);
51  std::unique_ptr<CastorQIEData> produceQIEData(const CastorQIEDataRcd& rcd);
52  std::unique_ptr<CastorChannelQuality> produceChannelQuality(const CastorChannelQualityRcd& rcd);
53  std::unique_ptr<CastorElectronicsMap> produceElectronicsMap(const CastorElectronicsMapRcd& rcd);
54  std::unique_ptr<CastorRecoParams> produceRecoParams(const CastorRecoParamsRcd& rcd);
55  std::unique_ptr<CastorSaturationCorrs> produceSaturationCorrs(const CastorSaturationCorrsRcd& rcd);
56 
57 private:
58  std::map<std::string, std::string> mInputs;
59 };
60 //
61 // class decleration
62 //
63 
64 using namespace cms;
65 
67 
68 {
69  //parsing parameters
70  std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
71  std::vector<edm::ParameterSet>::iterator request = data.begin();
72  for (; request != data.end(); ++request) {
73  std::string objectName = request->getParameter<std::string>("object");
74  edm::FileInPath fp = request->getParameter<edm::FileInPath>("file");
75  mInputs[objectName] = fp.fullPath();
76  if (objectName == "Pedestals") {
77  setWhatProduced(this, &CastorTextCalibrations::producePedestals);
78  findingRecord<CastorPedestalsRcd>();
79  } else if (objectName == "PedestalWidths") {
80  setWhatProduced(this, &CastorTextCalibrations::producePedestalWidths);
81  findingRecord<CastorPedestalWidthsRcd>();
82  } else if (objectName == "Gains") {
83  setWhatProduced(this, &CastorTextCalibrations::produceGains);
84  findingRecord<CastorGainsRcd>();
85  } else if (objectName == "GainWidths") {
86  setWhatProduced(this, &CastorTextCalibrations::produceGainWidths);
87  findingRecord<CastorGainWidthsRcd>();
88  } else if (objectName == "QIEData") {
89  setWhatProduced(this, &CastorTextCalibrations::produceQIEData);
90  findingRecord<CastorQIEDataRcd>();
91  } else if (objectName == "ChannelQuality") {
92  setWhatProduced(this, &CastorTextCalibrations::produceChannelQuality);
93  findingRecord<CastorChannelQualityRcd>();
94  } else if (objectName == "ElectronicsMap") {
95  setWhatProduced(this, &CastorTextCalibrations::produceElectronicsMap);
96  findingRecord<CastorElectronicsMapRcd>();
97  } else if (objectName == "RecoParams") {
98  setWhatProduced(this, &CastorTextCalibrations::produceRecoParams);
99  findingRecord<CastorRecoParamsRcd>();
100  } else if (objectName == "SaturationCorrs") {
101  setWhatProduced(this, &CastorTextCalibrations::produceSaturationCorrs);
102  findingRecord<CastorSaturationCorrsRcd>();
103  } else {
104  std::cerr << "CastorTextCalibrations-> Unknown object name '" << objectName << "', known names are: "
105  << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap RecoParams "
106  "SaturationCorrs"
107  << std::endl;
108  }
109  }
110  // setWhatProduced(this);
111 }
112 
114 
115 //
116 // member functions
117 //
119  const edm::IOVSyncValue& iTime,
120  edm::ValidityInterval& oInterval) {
121  std::string record = iKey.name();
123 }
124 
125 template <class T>
126 std::unique_ptr<T> produce_impl(const std::string& fFile) {
127  std::unique_ptr<T> result(new T());
128  std::ifstream inStream(fFile.c_str());
129  if (!inStream.good()) {
130  std::cerr << "CastorTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
131  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
132  }
133  if (!CastorDbASCIIIO::getObject(inStream, *result)) {
134  std::cerr << "CastorTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
135  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
136  }
137  return result;
138 }
139 
140 std::unique_ptr<CastorPedestals> CastorTextCalibrations::producePedestals(const CastorPedestalsRcd&) {
141  return produce_impl<CastorPedestals>(mInputs["Pedestals"]);
142 }
143 
144 std::unique_ptr<CastorPedestalWidths> CastorTextCalibrations::producePedestalWidths(const CastorPedestalWidthsRcd&) {
145  return produce_impl<CastorPedestalWidths>(mInputs["PedestalWidths"]);
146 }
147 
148 std::unique_ptr<CastorGains> CastorTextCalibrations::produceGains(const CastorGainsRcd&) {
149  return produce_impl<CastorGains>(mInputs["Gains"]);
150 }
151 
152 std::unique_ptr<CastorGainWidths> CastorTextCalibrations::produceGainWidths(const CastorGainWidthsRcd&) {
153  return produce_impl<CastorGainWidths>(mInputs["GainWidths"]);
154 }
155 
156 std::unique_ptr<CastorQIEData> CastorTextCalibrations::produceQIEData(const CastorQIEDataRcd& rcd) {
157  return produce_impl<CastorQIEData>(mInputs["QIEData"]);
158 }
159 
160 std::unique_ptr<CastorChannelQuality> CastorTextCalibrations::produceChannelQuality(const CastorChannelQualityRcd& rcd) {
161  return produce_impl<CastorChannelQuality>(mInputs["ChannelQuality"]);
162 }
163 
164 std::unique_ptr<CastorElectronicsMap> CastorTextCalibrations::produceElectronicsMap(const CastorElectronicsMapRcd& rcd) {
165  return produce_impl<CastorElectronicsMap>(mInputs["ElectronicsMap"]);
166 }
167 
168 std::unique_ptr<CastorRecoParams> CastorTextCalibrations::produceRecoParams(const CastorRecoParamsRcd& rcd) {
169  return produce_impl<CastorRecoParams>(mInputs["RecoParams"]);
170 }
171 
172 std::unique_ptr<CastorSaturationCorrs> CastorTextCalibrations::produceSaturationCorrs(
173  const CastorSaturationCorrsRcd& rcd) {
174  return produce_impl<CastorSaturationCorrs>(mInputs["SaturationCorrs"]);
175 }
176 
179 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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:17
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
std::map< std::string, std::string > mInputs
Namespace of DDCMS conversion namespace.
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
std::unique_ptr< CastorChannelQuality > produceChannelQuality(const CastorChannelQualityRcd &rcd)
bool getObject(std::istream &fInput, CastorPedestals &fObject)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
std::unique_ptr< CastorSaturationCorrs > produceSaturationCorrs(const CastorSaturationCorrsRcd &rcd)
std::unique_ptr< CastorElectronicsMap > produceElectronicsMap(const CastorElectronicsMapRcd &rcd)
CastorTextCalibrations(const edm::ParameterSet &)
long double T
std::unique_ptr< CastorQIEData > produceQIEData(const CastorQIEDataRcd &rcd)
std::unique_ptr< CastorGains > produceGains(const CastorGainsRcd &rcd)