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