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 // $Id: HcalOmdsCalibrations.cc,v 1.13 2010/08/06 20:24:13 wmtan Exp $
6 //
7 
8 #include <memory>
9 #include <iostream>
10 #include <fstream>
11 
14 
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::auto_ptr<T> produce_impl (const std::string & fTag,
144  const std::string & fVersion=default_version,
145  const int fSubversion=1,
146  const int fIOVBegin=1,
147  const std::string & fQuery = default_query,
148  const std::string& fAccessor = omds_occi_default_accessor ) {
149  std::auto_ptr<T> result (new T ());
150 
151  HCALConfigDB * db = new HCALConfigDB();
152  try {
153  db -> connect( fAccessor );
154  } catch (hcal::exception::ConfigurationDatabaseException & e) {
155  std::cerr << "Cannot connect to the database" << std::endl;
156  }
157  oracle::occi::Connection * _connection = db -> getConnection();
158  if (_connection){
159  if (!HcalDbOmds::getObject (_connection, fTag, fVersion, fSubversion, fIOVBegin, fQuery, &*result)) {
160  std::cerr << "HcalOmdsCalibrations-> Can not read tag name '" << fTag << "' from database '" << fAccessor << "'" << std::endl;
161  throw cms::Exception("ReadError") << "Can not read tag name '" << fTag << "' from database '" << fAccessor << "'" << std::endl;
162  }
163  }
164  else{
165  std::cerr << "Database connection is null. This should NEVER happen here. Something fishy is going on..." << std::endl;
166  }
167  return result;
168 }
169 
170 
171 
172 std::auto_ptr<HcalPedestals> HcalOmdsCalibrations::producePedestals (const HcalPedestalsRcd&) {
173  return produce_impl<HcalPedestals> (mInputs ["Pedestals"],
174  mVersion["Pedestals"],
175  mSubversion["Pedestals"],
176  mIOVBegin["Pedestals"],
177  mQuery["Pedestals"],
178  mAccessor["Pedestals"]);
179 }
180 
181 std::auto_ptr<HcalPedestalWidths> HcalOmdsCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd&) {
182  return produce_impl<HcalPedestalWidths> (mInputs ["PedestalWidths"],
183  mVersion["PedestalWidths"],
184  mSubversion["PedestalWidths"],
185  mIOVBegin["PedestalWidths"],
186  mQuery["PedestalWidths"],
187  mAccessor["PedestalWidths"]);
188 }
189 
190 std::auto_ptr<HcalGains> HcalOmdsCalibrations::produceGains (const HcalGainsRcd&) {
191  return produce_impl<HcalGains> (mInputs ["Gains"],
192  mVersion["Gains"],
193  mSubversion["Gains"],
194  mIOVBegin["Gains"],
195  mQuery["Gains"],
196  mAccessor["Gains"]);
197 }
198 
199 std::auto_ptr<HcalGainWidths> HcalOmdsCalibrations::produceGainWidths (const HcalGainWidthsRcd&) {
200  return produce_impl<HcalGainWidths> (mInputs ["GainWidths"],
201  mVersion["GainWidths"],
202  mSubversion["GainWidths"],
203  mIOVBegin["GainWidths"],
204  mQuery["GainWidths"],
205  mAccessor["GainWidths"]);
206 }
207 
208 std::auto_ptr<HcalQIEData> HcalOmdsCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
209  return produce_impl<HcalQIEData> (mInputs ["QIEData"],
210  mVersion["QIEData"],
211  mSubversion["QIEData"],
212  mIOVBegin["QIEData"],
213  mQuery["QIEData"],
214  mAccessor["QIEData"]);
215 }
216 
217 std::auto_ptr<HcalChannelQuality> HcalOmdsCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
218  return produce_impl<HcalChannelQuality> (mInputs ["ChannelQuality"],
219  mVersion["ChannelQuality"],
220  mSubversion["ChannelQuality"],
221  mIOVBegin["ChannelQuality"],
222  mQuery["ChannelQuality"],
223  mAccessor["ChannelQuality"]);
224 }
225 
226 std::auto_ptr<HcalZSThresholds> HcalOmdsCalibrations::produceZSThresholds (const HcalZSThresholdsRcd& rcd) {
227  return produce_impl<HcalZSThresholds> (mInputs ["ZSThresholds"],
228  mVersion["ZSThresholds"],
229  mSubversion["ZSThresholds"],
230  mIOVBegin["ZSThresholds"],
231  mQuery["ZSThresholds"],
232  mAccessor["ZSThresholds"]);
233 }
234 
235 std::auto_ptr<HcalRespCorrs> HcalOmdsCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
236  return produce_impl<HcalRespCorrs> (mInputs ["RespCorrs"],
237  mVersion["RespCorrs"],
238  mSubversion["RespCorrs"],
239  mIOVBegin["RespCorrs"],
240  mQuery["RespCorrs"],
241  mAccessor["RespCorrs"]);
242 }
243 
244 std::auto_ptr<HcalL1TriggerObjects> HcalOmdsCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
245  return produce_impl<HcalL1TriggerObjects> (mInputs ["L1TriggerObjects"],
246  mVersion["L1TriggerObjects"],
247  mSubversion["L1TriggerObjects"],
248  mIOVBegin["L1TriggerObjects"],
249  mQuery["L1TriggerObjects"],
250  mAccessor["L1TriggerObjects"]);
251 }
252 
253 std::auto_ptr<HcalElectronicsMap> HcalOmdsCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
254  return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"],
255  mVersion["ElectronicsMap"],
256  mSubversion["ElectronicsMap"],
257  mIOVBegin["ElectronicsMap"],
258  mQuery["ElectronicsMap"],
259  mAccessor["ElectronicsMap"]);
260 }
261 
262 std::auto_ptr<HcalValidationCorrs> HcalOmdsCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
263  return produce_impl<HcalValidationCorrs> (mInputs ["ValidationCorrs"],
264  mVersion["ValidationCorrs"],
265  mSubversion["ValidationCorrs"],
266  mIOVBegin["ValidationCorrs"],
267  mQuery["ValidationCorrs"],
268  mAccessor["ValidationCorrs"]);
269 }
270 
271 std::auto_ptr<HcalLutMetadata> HcalOmdsCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
272  return produce_impl<HcalLutMetadata> (mInputs ["LutMetadata"],
273  mVersion["LutMetadata"],
274  mSubversion["LutMetadata"],
275  mIOVBegin["LutMetadata"],
276  mQuery["LutMetadata"],
277  mAccessor["LutMetadata"]);
278 }
279 
280 std::auto_ptr<HcalDcsValues> HcalOmdsCalibrations::produceDcsValues (const HcalDcsRcd& rcd) {
281  return produce_impl<HcalDcsValues> (mInputs ["DcsValues"],
282  mVersion["DcsValues"],
283  mSubversion["DcsValues"],
284  mIOVBegin["DcsValues"],
285  mQuery["DcsValues"],
286  mAccessor["DcsValues"]);
287 }
288 
std::auto_ptr< HcalZSThresholds > produceZSThresholds(const HcalZSThresholdsRcd &rcd)
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::auto_ptr< HcalQIEData > produceQIEData(const HcalQIEDataRcd &rcd)
std::auto_ptr< HcalDcsValues > produceDcsValues(const HcalDcsRcd &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:11
std::auto_ptr< HcalL1TriggerObjects > produceL1TriggerObjects(const HcalL1TriggerObjectsRcd &rcd)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
tuple db
Definition: EcalCondDB.py:151
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
HcalOmdsCalibrations(const edm::ParameterSet &)
std::auto_ptr< HcalPedestalWidths > producePedestalWidths(const HcalPedestalWidthsRcd &rcd)
std::auto_ptr< HcalPedestals > producePedestals(const HcalPedestalsRcd &rcd)
std::auto_ptr< HcalGainWidths > produceGainWidths(const HcalGainWidthsRcd &rcd)
static const IOVSyncValue & beginOfTime()
tuple result
Definition: query.py:137
std::auto_ptr< HcalRespCorrs > produceRespCorrs(const HcalRespCorrsRcd &rcd)
std::auto_ptr< HcalLutMetadata > produceLutMetadata(const HcalLutMetadataRcd &rcd)
Gather config data from online DB.
Definition: HCALConfigDB.h:21
static const std::string omds_occi_default_accessor
static const std::string default_query
std::auto_ptr< HcalChannelQuality > produceChannelQuality(const HcalChannelQualityRcd &rcd)
std::auto_ptr< HcalElectronicsMap > produceElectronicsMap(const HcalElectronicsMapRcd &rcd)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::auto_ptr< HcalGains > produceGains(const HcalGainsRcd &rcd)
std::auto_ptr< HcalValidationCorrs > produceValidationCorrs(const HcalValidationCorrsRcd &rcd)
std::auto_ptr< T > produce_impl(const std::string &fFile)
long double T