CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalOmdsCalibrations.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Original Author: Gena Kukartsev Mar 11, 2009
4 // Adapted from HcalAsciiCalibrations
5 //
6 
7 #include <memory>
8 #include <iostream>
9 #include <fstream>
10 
13 
16 
18 
32 
34 
36 //
37 // class decleration
38 //
39 
40 using namespace cms;
41 
43 
44 {
45  //parsing parameters
46  std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
47  std::vector<edm::ParameterSet>::iterator request = data.begin ();
48  for (; request != data.end (); request++) {
49  std::string objectName = request->getParameter<std::string> ("object");
50 
51  if (request->exists("version")) mVersion[objectName] = request->getParameter<std::string>("version");
52  if (request->exists("subversion")) mSubversion[objectName] = request->getParameter<int>("subversion");
53  if (request->exists("iov_begin")) mIOVBegin[objectName] = request->getParameter<int>("iov_begin");
54  if (request->exists("accessor")) mAccessor[objectName] = request->getParameter<std::string>("accessor");
55  if (request->exists("query")) mQuery[objectName] = request->getParameter<std::string>("query");
56 
57  mInputs [objectName] = request->getParameter<std::string>("tag");
58  if (objectName == "Pedestals") {
59  setWhatProduced (this, &HcalOmdsCalibrations::producePedestals);
60  findingRecord <HcalPedestalsRcd> ();
61  }
62  else if (objectName == "PedestalWidths") {
63  setWhatProduced (this, &HcalOmdsCalibrations::producePedestalWidths);
64  findingRecord <HcalPedestalWidthsRcd> ();
65  }
66  else if (objectName == "Gains") {
67  setWhatProduced (this, &HcalOmdsCalibrations::produceGains);
68  findingRecord <HcalGainsRcd> ();
69  }
70  else if (objectName == "GainWidths") {
71  setWhatProduced (this, &HcalOmdsCalibrations::produceGainWidths);
72  findingRecord <HcalGainWidthsRcd> ();
73  }
74  else if (objectName == "QIEData") {
75  setWhatProduced (this, &HcalOmdsCalibrations::produceQIEData);
76  findingRecord <HcalQIEDataRcd> ();
77  }
78  else if (objectName == "ChannelQuality") {
79  setWhatProduced (this, &HcalOmdsCalibrations::produceChannelQuality);
80  findingRecord <HcalChannelQualityRcd> ();
81  }
82  else if (objectName == "ZSThresholds") {
83  setWhatProduced (this, &HcalOmdsCalibrations::produceZSThresholds);
84  findingRecord <HcalZSThresholdsRcd> ();
85  }
86  else if (objectName == "RespCorrs") {
87  setWhatProduced (this, &HcalOmdsCalibrations::produceRespCorrs);
88  findingRecord <HcalRespCorrsRcd> ();
89  }
90  else if (objectName == "L1TriggerObjects") {
91  setWhatProduced (this, &HcalOmdsCalibrations::produceL1TriggerObjects);
92  findingRecord <HcalL1TriggerObjectsRcd> ();
93  }
94  else if (objectName == "ElectronicsMap") {
95  setWhatProduced (this, &HcalOmdsCalibrations::produceElectronicsMap);
96  findingRecord <HcalElectronicsMapRcd> ();
97  }
98  else if (objectName == "ValidationCorrs") {
99  setWhatProduced (this, &HcalOmdsCalibrations::produceValidationCorrs);
100  findingRecord <HcalValidationCorrsRcd> ();
101  }
102  else if (objectName == "LutMetadata") {
103  setWhatProduced (this, &HcalOmdsCalibrations::produceLutMetadata);
104  findingRecord <HcalLutMetadataRcd> ();
105  }
106  else if (objectName == "DcsValues") {
107  setWhatProduced (this, &HcalOmdsCalibrations::produceDcsValues);
108  findingRecord <HcalDcsRcd> ();
109  }
110  else {
111  std::cerr << "HcalOmdsCalibrations-> Unknown object name '" << objectName
112  << "', known names are: "
113  << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap "
114  << "ZSThresholds RespCorrs L1TriggerObjects ValidationCorrs LutMetadata DcsValues "
115  << std::endl;
116  }
117  }
118  // setWhatProduced(this);
119 }
120 
121 
123 {
124 }
125 
126 
127 //
128 // member functions
129 //
130 void
132  std::string record = iKey.name ();
134 }
135 
136 // FIXME: put this into the HcalDbOmds namespace
137 //const static std::string omds_occi_default_accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22";
138 const static std::string omds_occi_default_accessor = "occi://CMS_HCL_APPUSER_R@anyhost/cms_omds_lb?PASSWORD=HCAL_Reader_44,LHWM_VERSION=22";
139 const static std::string default_version = "";
140 const static std::string default_query = "";
141 
142 template <class T>
143 std::unique_ptr<T> produce_impl (const HcalTopology* topo,
144  const std::string & fTag,
145  const std::string & fVersion=default_version,
146  const int fSubversion=1,
147  const int fIOVBegin=1,
148  const std::string & fQuery = default_query,
149  const std::string& fAccessor = omds_occi_default_accessor ) {
150  std::unique_ptr<T> result (new T (topo));
151 
152  HCALConfigDB * db = new HCALConfigDB();
153  try {
154  db -> connect( fAccessor );
155  } catch (hcal::exception::ConfigurationDatabaseException & e) {
156  std::cerr << "Cannot connect to the database" << std::endl;
157  }
158  oracle::occi::Connection * _connection = db -> getConnection();
159  if (_connection){
160  if (!HcalDbOmds::getObject (_connection, fTag, fVersion, fSubversion, fIOVBegin, fQuery, &*result)) {
161  std::cerr << "HcalOmdsCalibrations-> Can not read tag name '" << fTag << "' from database '" << fAccessor << "'" << std::endl;
162  throw cms::Exception("ReadError") << "Can not read tag name '" << fTag << "' from database '" << fAccessor << "'" << std::endl;
163  }
164  }
165  else{
166  std::cerr << "Database connection is null. This should NEVER happen here. Something fishy is going on..." << std::endl;
167  }
168  return result;
169 }
170 template <class T>
171 std::unique_ptr<T> produce_impl (const std::string & fTag,
172  const std::string & fVersion=default_version,
173  const int fSubversion=1,
174  const int fIOVBegin=1,
175  const std::string & fQuery = default_query,
176  const std::string& fAccessor = omds_occi_default_accessor ) {
177  std::unique_ptr<T> result (new T ());
178 
179  HCALConfigDB * db = new HCALConfigDB();
180  try {
181  db -> connect( fAccessor );
182  } catch (hcal::exception::ConfigurationDatabaseException & e) {
183  std::cerr << "Cannot connect to the database" << std::endl;
184  }
185  oracle::occi::Connection * _connection = db -> getConnection();
186  if (_connection){
187  if (!HcalDbOmds::getObject (_connection, fTag, fVersion, fSubversion, fIOVBegin, fQuery, &*result)) {
188  std::cerr << "HcalOmdsCalibrations-> Can not read tag name '" << fTag << "' from database '" << fAccessor << "'" << std::endl;
189  throw cms::Exception("ReadError") << "Can not read tag name '" << fTag << "' from database '" << fAccessor << "'" << std::endl;
190  }
191  }
192  else{
193  std::cerr << "Database connection is null. This should NEVER happen here. Something fishy is going on..." << std::endl;
194  }
195  return result;
196 }
197 
198 
199 
200 std::unique_ptr<HcalPedestals> HcalOmdsCalibrations::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  mVersion["Pedestals"],
207  mSubversion["Pedestals"],
208  mIOVBegin["Pedestals"],
209  mQuery["Pedestals"],
210  mAccessor["Pedestals"]);
211 }
212 
213 std::unique_ptr<HcalPedestalWidths> HcalOmdsCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd& rcd) {
215  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
216  const HcalTopology* topo=&(*htopo);
217  return produce_impl<HcalPedestalWidths> (topo, mInputs ["PedestalWidths"],
218  mVersion["PedestalWidths"],
219  mSubversion["PedestalWidths"],
220  mIOVBegin["PedestalWidths"],
221  mQuery["PedestalWidths"],
222  mAccessor["PedestalWidths"]);
223 }
224 
225 std::unique_ptr<HcalGains> HcalOmdsCalibrations::produceGains (const HcalGainsRcd& rcd) {
227  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
228  const HcalTopology* topo=&(*htopo);
229  return produce_impl<HcalGains> (topo, mInputs ["Gains"],
230  mVersion["Gains"],
231  mSubversion["Gains"],
232  mIOVBegin["Gains"],
233  mQuery["Gains"],
234  mAccessor["Gains"]);
235 }
236 
237 std::unique_ptr<HcalGainWidths> HcalOmdsCalibrations::produceGainWidths (const HcalGainWidthsRcd& rcd) {
239  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
240  const HcalTopology* topo=&(*htopo);
241  return produce_impl<HcalGainWidths> (topo, mInputs ["GainWidths"],
242  mVersion["GainWidths"],
243  mSubversion["GainWidths"],
244  mIOVBegin["GainWidths"],
245  mQuery["GainWidths"],
246  mAccessor["GainWidths"]);
247 }
248 
249 std::unique_ptr<HcalQIEData> HcalOmdsCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
251  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
252  const HcalTopology* topo=&(*htopo);
253  return produce_impl<HcalQIEData> (topo, mInputs ["QIEData"],
254  mVersion["QIEData"],
255  mSubversion["QIEData"],
256  mIOVBegin["QIEData"],
257  mQuery["QIEData"],
258  mAccessor["QIEData"]);
259 }
260 
261 std::unique_ptr<HcalChannelQuality> HcalOmdsCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
263  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
264  const HcalTopology* topo=&(*htopo);
265  return produce_impl<HcalChannelQuality> (topo, mInputs ["ChannelQuality"],
266  mVersion["ChannelQuality"],
267  mSubversion["ChannelQuality"],
268  mIOVBegin["ChannelQuality"],
269  mQuery["ChannelQuality"],
270  mAccessor["ChannelQuality"]);
271 }
272 
273 std::unique_ptr<HcalZSThresholds> HcalOmdsCalibrations::produceZSThresholds (const HcalZSThresholdsRcd& rcd) {
275  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
276  const HcalTopology* topo=&(*htopo);
277  return produce_impl<HcalZSThresholds> (topo, mInputs ["ZSThresholds"],
278  mVersion["ZSThresholds"],
279  mSubversion["ZSThresholds"],
280  mIOVBegin["ZSThresholds"],
281  mQuery["ZSThresholds"],
282  mAccessor["ZSThresholds"]);
283 }
284 
285 std::unique_ptr<HcalRespCorrs> HcalOmdsCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
287  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
288  const HcalTopology* topo=&(*htopo);
289  return produce_impl<HcalRespCorrs> (topo, mInputs ["RespCorrs"],
290  mVersion["RespCorrs"],
291  mSubversion["RespCorrs"],
292  mIOVBegin["RespCorrs"],
293  mQuery["RespCorrs"],
294  mAccessor["RespCorrs"]);
295 }
296 
297 std::unique_ptr<HcalL1TriggerObjects> HcalOmdsCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
299  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
300  const HcalTopology* topo=&(*htopo);
301  return produce_impl<HcalL1TriggerObjects> (topo, mInputs ["L1TriggerObjects"],
302  mVersion["L1TriggerObjects"],
303  mSubversion["L1TriggerObjects"],
304  mIOVBegin["L1TriggerObjects"],
305  mQuery["L1TriggerObjects"],
306  mAccessor["L1TriggerObjects"]);
307 }
308 
309 std::unique_ptr<HcalElectronicsMap> HcalOmdsCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
310  return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"],
311  mVersion["ElectronicsMap"],
312  mSubversion["ElectronicsMap"],
313  mIOVBegin["ElectronicsMap"],
314  mQuery["ElectronicsMap"],
315  mAccessor["ElectronicsMap"]);
316 }
317 
318 std::unique_ptr<HcalValidationCorrs> HcalOmdsCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
320  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
321  const HcalTopology* topo=&(*htopo);
322  return produce_impl<HcalValidationCorrs> (topo, mInputs ["ValidationCorrs"],
323  mVersion["ValidationCorrs"],
324  mSubversion["ValidationCorrs"],
325  mIOVBegin["ValidationCorrs"],
326  mQuery["ValidationCorrs"],
327  mAccessor["ValidationCorrs"]);
328 }
329 
330 std::unique_ptr<HcalLutMetadata> HcalOmdsCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
332  rcd.getRecord<HcalRecNumberingRecord>().get(htopo);
333  const HcalTopology* topo=&(*htopo);
334  return produce_impl<HcalLutMetadata> (topo, mInputs ["LutMetadata"],
335  mVersion["LutMetadata"],
336  mSubversion["LutMetadata"],
337  mIOVBegin["LutMetadata"],
338  mQuery["LutMetadata"],
339  mAccessor["LutMetadata"]);
340 }
341 
342 std::unique_ptr<HcalDcsValues> HcalOmdsCalibrations::produceDcsValues (const HcalDcsRcd& rcd) {
343  return produce_impl<HcalDcsValues> (mInputs ["DcsValues"],
344  mVersion["DcsValues"],
345  mSubversion["DcsValues"],
346  mIOVBegin["DcsValues"],
347  mQuery["DcsValues"],
348  mAccessor["DcsValues"]);
349 }
350 
T getParameter(std::string const &) const
static const std::string default_version
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
std::unique_ptr< HcalQIEData > produceQIEData(const HcalQIEDataRcd &rcd)
bool getObject(oracle::occi::Connection *connection, const std::string &fTag, const std::string &fVersion, const int fSubversion, const int fIOVBegin, const std::string &fQuery, HcalPedestals *fObject)
JetCorrectorParameters::Record record
Definition: classes.h:7
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
tuple db
Definition: EcalCondDB.py:151
std::unique_ptr< HcalChannelQuality > produceChannelQuality(const HcalChannelQualityRcd &rcd)
std::unique_ptr< HcalRespCorrs > produceRespCorrs(const HcalRespCorrsRcd &rcd)
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
std::unique_ptr< HcalGainWidths > produceGainWidths(const HcalGainWidthsRcd &rcd)
HcalOmdsCalibrations(const edm::ParameterSet &)
tuple result
Definition: mps_fire.py:84
std::unique_ptr< HcalValidationCorrs > produceValidationCorrs(const HcalValidationCorrsRcd &rcd)
std::unique_ptr< HcalElectronicsMap > produceElectronicsMap(const HcalElectronicsMapRcd &rcd)
std::unique_ptr< HcalZSThresholds > produceZSThresholds(const HcalZSThresholdsRcd &rcd)
std::unique_ptr< T > produce_impl(const std::string &fFile)
static const IOVSyncValue & beginOfTime()
std::unique_ptr< HcalDcsValues > produceDcsValues(const HcalDcsRcd &rcd)
Gather config data from online DB.
Definition: HCALConfigDB.h:21
static const std::string omds_occi_default_accessor
std::unique_ptr< HcalGains > produceGains(const HcalGainsRcd &rcd)
std::unique_ptr< HcalPedestals > producePedestals(const HcalPedestalsRcd &rcd)
static const std::string default_query
std::unique_ptr< HcalL1TriggerObjects > produceL1TriggerObjects(const HcalL1TriggerObjectsRcd &rcd)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::unique_ptr< HcalPedestalWidths > producePedestalWidths(const HcalPedestalWidthsRcd &rcd)
std::unique_ptr< HcalLutMetadata > produceLutMetadata(const HcalLutMetadataRcd &rcd)
long double T