CMS 3D CMS Logo

PixelPopConCalibSourceHandler.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CondTools/SiPixel
4 // Class: PixelPopConCalibSourceHandler
5 //
13 //
14 // Original Author: Michael Eads
15 // Created: 8 Feb 2008
16 // $Id: PixelPopConCalibSourceHandler.cc,v 1.3 2010/01/21 21:11:46 meads Exp $
17 //
18 //
19 
21 
22 #include <iostream>
23 #include <sstream>
24 
25 // DBCommon includes
26 // #include "CondCore/DBCommon/interface/SessionConfiguration.h"
27 // #include "CondCore/DBCommon/interface/Exception.h"
28 // #include "CondCore/DBCommon/interface/Connection.h"
29 
30 // CORAL includes
31 // #include "RelationalAccess/IView.h"
32 // #include "RelationalAccess/ISessionProxy.h"
33 // #include "RelationalAccess/ISchema.h"
34 // #include "RelationalAccess/ISessionProperties.h"
35 // #include "RelationalAccess/IQuery.h"
36 // #include "RelationalAccess/ICursor.h"
37 // #include "CoralBase/AttributeList.h"
38 // #include "CoralBase/Attribute.h"
39 
41 
42 // test poolDBOutput
45 
46 
47 using namespace std;
48 
49 // constructor
51 
52  // try to get a parameter
53  _connectString = pset.getParameter<string>("connectString");
54  //cout << " connectString: " << _connectString << endl;
55 
56  // get the schema and view name to use from the config file
57  _viewName = pset.getParameter<string>("viewName");
58  _schemaName = pset.getParameter<string>("schemaName");
59 
60  // get the key name and/or run number to use
61  _runNumber = pset.getParameter<int>("runNumber");
62  _configKeyName = pset.getParameter<string>("configKeyName");
63 
64  // get the "since" IOV parameter
65  _sinceIOV = pset.getParameter<unsigned int>("sinceIOV");
66 
67 } // constructor
68 
69 // destructor
71 
72 } // destructor
73 
75 
76  return string("PixelPopConCalibSourceHandler");
77 
78 } // string PixelPopConCalibSourceHandler::id()
79 
80 
81 // getNewObjects method using coral
83  cout << "I'm sorry, the PixelPopConCalibSourceHandler::getNewObjects_coral() is not currently working." << endl;
84  cout << "I am not able to build calibration configuration objects from the database" << endl;
85  return;
86 
87 // // create the empty SiPixelCalibConfiguration object
88 // SiPixelCalibConfiguration* calibConfig = new SiPixelCalibConfiguration();
89 
90 // // set up the DB session
91 // cond::DBSession* dbsession = new cond::DBSession();
92 // dbsession->configuration().setAuthenticationMethod(cond::XML);
93 // dbsession->configuration().setMessageLevel(cond::Error);
94 // try{
95 // dbsession->open();
96 // }catch(cond::Exception& er){
97 // std::cerr<< "CoralIface::initialize cond " << er.what()<<std::endl;
98 // throw;
99 // }catch(std::exception& er){
100 // std::cerr<< "CoralIface::initialize std " << er.what()<<std::endl;
101 // throw;
102 // }
103 
104 // cond::Connection dbconn(_connectString);
105 // dbconn.connect(dbsession);
106 // cond::CoralTransaction& coraldb=dbconn.coralTransaction();
107 // coraldb.start(true);
108 
109 // // build and execute the query
110 // coral::IQuery* query = coraldb.coralSessionProxy().schema(_schemaName).newQuery();
111 // query->addToTableList(_viewName);
112 // query->addToOutputList("CONFG_KEY");
113 // query->addToOutputList("VERSION");
114 // query->addToOutputList("RUN_TYPE");
115 // query->addToOutputList("RUN_NUMBER");
116 // query->addToOutputList("CALIB_OBJ_DATA_FILE");
117 // query->addToOutputList("CALIB_OBJ_DATA_CLOB");
118 
119 // // if _runNumber is -1, query by config key name
120 // if (_runNumber == -1)
121 // query->setCondition("CONFG_KEY = '" + _configKeyName + "'", coral::AttributeList());
122 // else // query by run number
123 // query->setCondition("RUN_NUMBER = " + _runNumber, coral::AttributeList());
124 // coral::ICursor& cursor = query->execute();
125 
126 // // parse the response, build the Calib object
127 // bool found_fNtriggers = false;
128 // bool found_fRowPattern = false;
129 // bool found_fColumnPattern = false;
130 // bool found_fVCalValues = false;
131 // bool found_fMode = false;
132 // while ( cursor.next() ) {
133 // cout << "Inside cursor.next() loop" << endl;
134 // //cursor.currentRow().toOutputStream( std::cout ) << std::endl;
135 // coral::AttributeList row = cursor.currentRow();
136 
137 // string mystring = row["CALIB_OBJ_DATA_CLOB"].data<string>();
138 // cout << "mystring: " << mystring << endl;
139 
140 // // get fMode
141 // if (!found_fMode) {
142 // calibConfig->setCalibrationMode(row["CALIB_MODE"].data<string>());
143 // found_fMode = true;
144 // } // if (!found_fMode)
145 
146 // // fill fNTriggers
147 // if (row["PARAMETER"].data<string>() == "Number of Triggers") {
148 // if (found_fNtriggers) {
149 // cout << "Warning: found mulitple entries for fNtriggers!" << endl;
150 // }
151 // int fNtriggers = atoi(row["VALUE"].data<string>().c_str());
152 // //cout << "Number of triggers: " << fNtriggers << endl;
153 // calibConfig->setNTriggers(static_cast<short>(fNtriggers));
154 // found_fNtriggers = true;
155 // } // fill fNTriggers
156 
157 // /*
158 // // fill fROCIds
159 // if (row["PARAMETER"].data<string>() == "ROC") {
160 // if (found_fROCIds) {
161 // cout << "Warning: found mulitple entries for fROCIds!" << endl;
162 // }
163 // string rocidlist = row["VALUE"].data<string>();
164 // // split the string
165 // string buff;
166 // vector<string> ROCIds;
167 // stringstream ss(rocidlist);
168 // while (ss >> buff) {
169 // ROCIds.push_back(buff);
170 // }
171 // calibConfig->setROCIds(ROCIds);
172 // found_fROCIds = true;
173 // } // fill fROCIds
174 // */
175 
176 // // fill fRowPattern
177 // if (row["PARAMETER"].data<string>() == "RowNums") {
178 // if (found_fRowPattern) {
179 // cout << "Warning: found mulitple entries for fRowPattern!" << endl;
180 // }
181 // string rowlist = row["VALUE"].data<string>();
182 // // split the string
183 // string buff;
184 // vector<short> rows;
185 // stringstream ss(rowlist);
186 // while (ss >> buff) {
187 // rows.push_back(static_cast<short>(atoi(buff.c_str())));
188 // }
189 // calibConfig->setRowPattern(rows);
190 // found_fRowPattern = true;
191 // } // fill fRowPattern
192 
193 // // fill fColumnPattern
194 // if (row["PARAMETER"].data<string>() == "ColNums") {
195 // if (found_fColumnPattern) {
196 // cout << "Warning: found mulitple entries for fColumnPattern!" << endl;
197 // }
198 // string collist = row["VALUE"].data<string>();
199 // // split the string
200 // string buff;
201 // vector<short> cols;
202 // stringstream ss(collist);
203 // while (ss >> buff) {
204 // cols.push_back(static_cast<short>(atoi(buff.c_str())));
205 // }
206 // calibConfig->setColumnPattern(cols);
207 // found_fColumnPattern = true;
208 // } // fill fColumnPattern
209 
210 // // fill fVCalValues
211 // if (row["CALIB_OBJECT"].data<string>() == "Vcal DAC") {
212 // if (found_fVCalValues) {
213 // cout << "Warning: found mulitple entries for fVCalValues!" << endl;
214 // }
215 // string vcallist = row["VALUE"].data<string>();
216 // // split the string
217 // string buff;
218 // vector<short> vcals;
219 // stringstream ss(vcallist);
220 // while (ss >> buff) {
221 // vcals.push_back(static_cast<short>(atoi(buff.c_str())));
222 // }
223 // calibConfig->setVCalValues(vcals);
224 // found_fVCalValues = true;
225 // } // fill fRowPattern
226 
227 // /*
228 // for (coral::AttributeList::iterator it = row.begin();
229 // it != row.end(); ++it) {
230 // if it->specification().name() == "PARAMETER"
231 
232 // if (it->specification().name() == "RUN_NUMBER")
233 // cout << it->specification().name() << ", " << it->data<long long>() << endl;
234 // else
235 // cout << it->specification().name() << ", " << it->data<string>() << endl;
236 
237 // } // loop over attribute list
238 // */
239 // } // while (cursor.next())
240 
241 // // spit out calibConfig object
242 // cout << endl << "** calibConfig: " << endl;
243 // cout << " fNtriggers: " << calibConfig->getNTriggers() << endl;
244 // /*
245 // cout << " fROCIds: ";
246 // vector<string> rocids = calibConfig->getROCIds();
247 // for (vector<string>::const_iterator it = rocids.begin();
248 // it != rocids.end(); ++it)
249 // cout << *it << ", ";
250 // cout << endl;
251 // */
252 // cout << " fRowPattern: ";
253 // vector<short> rowpattern = calibConfig->getRowPattern();
254 // for (vector<short>::const_iterator it = rowpattern.begin();
255 // it != rowpattern.end(); ++it)
256 // cout << *it << ", ";
257 // cout << endl;
258 // cout << " fColumnPattern: ";
259 // vector<short> columnpattern = calibConfig->getColumnPattern();
260 // for (vector<short>::const_iterator it = columnpattern.begin();
261 // it != columnpattern.end(); ++it)
262 // cout << *it << ", ";
263 // cout << endl;
264 // cout << " fVcalValues: ";
265 // vector<short> vcalvalues = calibConfig->getVCalValues();
266 // for (vector<short>::const_iterator it = vcalvalues.begin();
267 // it != vcalvalues.end(); ++it)
268 // cout << *it << ", ";
269 // cout << endl;
270 // cout << " fNmode: " << calibConfig->getCalibrationMode() << endl;
271 
272 // // see what's in the db
273 // //cout << "tagInfo: " << tagInfo().name << ", " << tagInfo().lastInterval.first << endl;
274 
275 // m_to_transfer.push_back(std::make_pair(calibConfig,_sinceIOV));
276 
277 
278 // delete dbsession;
279 } // void PixelPopConCalibSourceHandler::getNewObjects_coral()
280 
281 // getNewObjects method using a text file
283  // check to make sure the _connectString begins with "file//"
284  if (_connectString.find("file://") != 0) {
285  cout << "Invalid connectString: " << _connectString << endl;
286  cout << "It should begin with \"file://\"" << endl;
287  return;
288  }
289  // strip the "file://" from the connect string
290  string inputFilename = _connectString.erase(0, 7);
291 
292  cout << "PopCon-ing the calibration configuration file located at " << inputFilename << endl;
293 
294  // use online code to parse the file
295  pos::PixelCalibConfiguration fancyCalib(inputFilename);
296  SiPixelCalibConfiguration *calibConfig = new SiPixelCalibConfiguration(fancyCalib);
297 
298  m_to_transfer.push_back(std::make_pair(calibConfig, _sinceIOV));
299 
300 } // void PixelPopConCalibSourceHandler::getNewObjects_file()
301 
T getParameter(std::string const &) const
This class implements the steps that are used in a scan over Threshold and CalDelay.
PixelPopConCalibSourceHandler(edm::ParameterSet const &)
This class implements the steps that are used in a scan over Threshold and CalDelay.