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  }
51  else if (objectName == "PedestalWidths") {
52  setWhatProduced (this, &CastorTextCalibrations::producePedestalWidths);
53  findingRecord <CastorPedestalWidthsRcd> ();
54  }
55  else if (objectName == "Gains") {
56  setWhatProduced (this, &CastorTextCalibrations::produceGains);
57  findingRecord <CastorGainsRcd> ();
58  }
59  else if (objectName == "GainWidths") {
60  setWhatProduced (this, &CastorTextCalibrations::produceGainWidths);
61  findingRecord <CastorGainWidthsRcd> ();
62  }
63  else if (objectName == "QIEData") {
64  setWhatProduced (this, &CastorTextCalibrations::produceQIEData);
65  findingRecord <CastorQIEDataRcd> ();
66  }
67  else if (objectName == "ChannelQuality") {
68  setWhatProduced (this, &CastorTextCalibrations::produceChannelQuality);
69  findingRecord <CastorChannelQualityRcd> ();
70  }
71  else if (objectName == "ElectronicsMap") {
72  setWhatProduced (this, &CastorTextCalibrations::produceElectronicsMap);
73  findingRecord <CastorElectronicsMapRcd> ();
74  }
75  else if (objectName == "RecoParams") {
76  setWhatProduced (this, &CastorTextCalibrations::produceRecoParams);
77  findingRecord <CastorRecoParamsRcd> ();
78  }
79  else if (objectName == "SaturationCorrs") {
80  setWhatProduced (this, &CastorTextCalibrations::produceSaturationCorrs);
81  findingRecord <CastorSaturationCorrsRcd> ();
82  }
83  else {
84  std::cerr << "CastorTextCalibrations-> Unknown object name '" << objectName
85  << "', known names are: "
86  << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap RecoParams SaturationCorrs"
87  << std::endl;
88  }
89  }
90  // setWhatProduced(this);
91 }
92 
93 
95 {
96 }
97 
98 
99 //
100 // member functions
101 //
102 void
104  std::string record = iKey.name ();
106 }
107 
108 template <class T>
109 std::unique_ptr<T> produce_impl (const std::string& fFile) {
110  std::unique_ptr<T> result (new T ());
111  std::ifstream inStream (fFile.c_str ());
112  if (!inStream.good ()) {
113  std::cerr << "CastorTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
114  throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
115  }
116  if (!CastorDbASCIIIO::getObject (inStream, &*result)) {
117  std::cerr << "CastorTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
118  throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
119  }
120  return result;
121 }
122 
123 
124 std::unique_ptr<CastorPedestals> CastorTextCalibrations::producePedestals (const CastorPedestalsRcd&) {
125  return produce_impl<CastorPedestals> (mInputs ["Pedestals"]);
126 }
127 
128 std::unique_ptr<CastorPedestalWidths> CastorTextCalibrations::producePedestalWidths (const CastorPedestalWidthsRcd&) {
129  return produce_impl<CastorPedestalWidths> (mInputs ["PedestalWidths"]);
130 }
131 
132 std::unique_ptr<CastorGains> CastorTextCalibrations::produceGains (const CastorGainsRcd&) {
133  return produce_impl<CastorGains> (mInputs ["Gains"]);
134 }
135 
136 std::unique_ptr<CastorGainWidths> CastorTextCalibrations::produceGainWidths (const CastorGainWidthsRcd&) {
137  return produce_impl<CastorGainWidths> (mInputs ["GainWidths"]);
138 }
139 
140 std::unique_ptr<CastorQIEData> CastorTextCalibrations::produceQIEData (const CastorQIEDataRcd& rcd) {
141  return produce_impl<CastorQIEData> (mInputs ["QIEData"]);
142 }
143 
144 std::unique_ptr<CastorChannelQuality> CastorTextCalibrations::produceChannelQuality (const CastorChannelQualityRcd& rcd) {
145  return produce_impl<CastorChannelQuality> (mInputs ["ChannelQuality"]);
146 }
147 
148 std::unique_ptr<CastorElectronicsMap> CastorTextCalibrations::produceElectronicsMap (const CastorElectronicsMapRcd& rcd) {
149  return produce_impl<CastorElectronicsMap> (mInputs ["ElectronicsMap"]);
150 }
151 
152 std::unique_ptr<CastorRecoParams> CastorTextCalibrations::produceRecoParams (const CastorRecoParamsRcd& rcd) {
153  return produce_impl<CastorRecoParams> (mInputs ["RecoParams"]);
154 }
155 
156 std::unique_ptr<CastorSaturationCorrs> CastorTextCalibrations::produceSaturationCorrs (const CastorSaturationCorrsRcd& rcd) {
157  return produce_impl<CastorSaturationCorrs> (mInputs ["SaturationCorrs"]);
158 }
T getParameter(std::string const &) const
JetCorrectorParameters::Record record
Definition: classes.h:7
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
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()
bool getObject(std::istream &fInput, CastorPedestals *fObject)
std::unique_ptr< CastorChannelQuality > produceChannelQuality(const CastorChannelQualityRcd &rcd)
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:197
CastorTextCalibrations(const edm::ParameterSet &)
long double T
std::unique_ptr< CastorQIEData > produceQIEData(const CastorQIEDataRcd &rcd)
std::unique_ptr< CastorGains > produceGains(const CastorGainsRcd &rcd)