#include <CondTools/SiPixel/interface/PixelPopConCalibSourceHandler.h>
Public Member Functions | |
void | getNewObjects_coral () |
void | getNewObjects_file () |
virtual std::string | id () const |
PixelPopConCalibSourceHandler (edm::ParameterSet const &) | |
~PixelPopConCalibSourceHandler () |
Definition at line 31 of file PixelPopConCalibSourceHandler.h.
PixelPopConCalibSourceHandler::~PixelPopConCalibSourceHandler | ( | ) |
PixelPopConCalibSourceHandler::PixelPopConCalibSourceHandler | ( | edm::ParameterSet const & | pset | ) |
Definition at line 50 of file PixelPopConCalibSourceHandler.cc.
References PixelPopConSourceHandler< SiPixelCalibConfiguration >::_configKeyName, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_connectString, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_runNumber, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_schemaName, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_sinceIOV, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_viewName, and edm::ParameterSet::getParameter().
00050 { 00051 00052 // try to get a parameter 00053 _connectString = pset.getParameter<string>("connectString"); 00054 //cout << " connectString: " << _connectString << endl; 00055 00056 // get the schema and view name to use from the config file 00057 _viewName = pset.getParameter<string>("viewName"); 00058 _schemaName = pset.getParameter<string>("schemaName"); 00059 00060 // get the key name and/or run number to use 00061 _runNumber = pset.getParameter<int>("runNumber"); 00062 _configKeyName = pset.getParameter<string>("configKeyName"); 00063 00064 // get the "since" IOV parameter 00065 _sinceIOV = pset.getParameter<unsigned int>("sinceIOV"); 00066 00067 } // constructor
void PixelPopConCalibSourceHandler::getNewObjects_coral | ( | ) | [virtual] |
Reimplemented from PixelPopConSourceHandler< SiPixelCalibConfiguration >.
Definition at line 82 of file PixelPopConCalibSourceHandler.cc.
References PixelPopConSourceHandler< SiPixelCalibConfiguration >::_configKeyName, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_connectString, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_runNumber, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_schemaName, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_sinceIOV, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_viewName, TestMuL1L2Filter_cff::cerr, cols, cond::DBSession::configuration(), cond::Connection::connect(), cond::CoralTransaction::coralSessionProxy(), cond::Connection::coralTransaction(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), cond::Error, exception, SiPixelCalibConfiguration::getCalibrationMode(), SiPixelCalibConfiguration::getColumnPattern(), SiPixelCalibConfiguration::getNTriggers(), SiPixelCalibConfiguration::getRowPattern(), SiPixelCalibConfiguration::getVCalValues(), it, popcon::PopConSourceHandler< SiPixelCalibConfiguration >::m_to_transfer, cond::DBSession::open(), row, rows, cond::SessionConfiguration::setAuthenticationMethod(), SiPixelCalibConfiguration::setCalibrationMode(), SiPixelCalibConfiguration::setColumnPattern(), cond::SessionConfiguration::setMessageLevel(), SiPixelCalibConfiguration::setNTriggers(), SiPixelCalibConfiguration::setRowPattern(), SiPixelCalibConfiguration::setVCalValues(), ss, cond::CoralTransaction::start(), cms::Exception::what(), and cond::XML.
00082 { 00083 cout << "I'm sorry, the PixelPopConCalibSourceHandler::getNewObjects_coral() is not currently working." << endl; 00084 cout << "I am not able to build calibration configuration objects from the database" << endl; 00085 return; 00086 00087 // create the empty SiPixelCalibConfiguration object 00088 SiPixelCalibConfiguration* calibConfig = new SiPixelCalibConfiguration(); 00089 00090 // set up the DB session 00091 cond::DBSession* dbsession = new cond::DBSession(); 00092 dbsession->configuration().setAuthenticationMethod(cond::XML); 00093 dbsession->configuration().setMessageLevel(cond::Error); 00094 try{ 00095 dbsession->open(); 00096 }catch(cond::Exception& er){ 00097 std::cerr<< "CoralIface::initialize cond " << er.what()<<std::endl; 00098 throw; 00099 }catch(std::exception& er){ 00100 std::cerr<< "CoralIface::initialize std " << er.what()<<std::endl; 00101 throw; 00102 } 00103 00104 cond::Connection dbconn(_connectString); 00105 dbconn.connect(dbsession); 00106 cond::CoralTransaction& coraldb=dbconn.coralTransaction(); 00107 coraldb.start(true); 00108 00109 // build and execute the query 00110 coral::IQuery* query = coraldb.coralSessionProxy().schema(_schemaName).newQuery(); 00111 query->addToTableList(_viewName); 00112 query->addToOutputList("CONFG_KEY"); 00113 query->addToOutputList("VERSION"); 00114 query->addToOutputList("RUN_TYPE"); 00115 query->addToOutputList("RUN_NUMBER"); 00116 query->addToOutputList("CALIB_OBJ_DATA_FILE"); 00117 query->addToOutputList("CALIB_OBJ_DATA_CLOB"); 00118 00119 // if _runNumber is -1, query by config key name 00120 if (_runNumber == -1) 00121 query->setCondition("CONFG_KEY = '" + _configKeyName + "'", coral::AttributeList()); 00122 else // query by run number 00123 query->setCondition("RUN_NUMBER = " + _runNumber, coral::AttributeList()); 00124 coral::ICursor& cursor = query->execute(); 00125 00126 // parse the response, build the Calib object 00127 bool found_fNtriggers = false; 00128 bool found_fRowPattern = false; 00129 bool found_fColumnPattern = false; 00130 bool found_fVCalValues = false; 00131 bool found_fMode = false; 00132 while ( cursor.next() ) { 00133 cout << "Inside cursor.next() loop" << endl; 00134 //cursor.currentRow().toOutputStream( std::cout ) << std::endl; 00135 coral::AttributeList row = cursor.currentRow(); 00136 00137 string mystring = row["CALIB_OBJ_DATA_CLOB"].data<string>(); 00138 cout << "mystring: " << mystring << endl; 00139 00140 // get fMode 00141 if (!found_fMode) { 00142 calibConfig->setCalibrationMode(row["CALIB_MODE"].data<string>()); 00143 found_fMode = true; 00144 } // if (!found_fMode) 00145 00146 // fill fNTriggers 00147 if (row["PARAMETER"].data<string>() == "Number of Triggers") { 00148 if (found_fNtriggers) { 00149 cout << "Warning: found mulitple entries for fNtriggers!" << endl; 00150 } 00151 int fNtriggers = atoi(row["VALUE"].data<string>().c_str()); 00152 //cout << "Number of triggers: " << fNtriggers << endl; 00153 calibConfig->setNTriggers(static_cast<short>(fNtriggers)); 00154 found_fNtriggers = true; 00155 } // fill fNTriggers 00156 00157 /* 00158 // fill fROCIds 00159 if (row["PARAMETER"].data<string>() == "ROC") { 00160 if (found_fROCIds) { 00161 cout << "Warning: found mulitple entries for fROCIds!" << endl; 00162 } 00163 string rocidlist = row["VALUE"].data<string>(); 00164 // split the string 00165 string buff; 00166 vector<string> ROCIds; 00167 stringstream ss(rocidlist); 00168 while (ss >> buff) { 00169 ROCIds.push_back(buff); 00170 } 00171 calibConfig->setROCIds(ROCIds); 00172 found_fROCIds = true; 00173 } // fill fROCIds 00174 */ 00175 00176 // fill fRowPattern 00177 if (row["PARAMETER"].data<string>() == "RowNums") { 00178 if (found_fRowPattern) { 00179 cout << "Warning: found mulitple entries for fRowPattern!" << endl; 00180 } 00181 string rowlist = row["VALUE"].data<string>(); 00182 // split the string 00183 string buff; 00184 vector<short> rows; 00185 stringstream ss(rowlist); 00186 while (ss >> buff) { 00187 rows.push_back(static_cast<short>(atoi(buff.c_str()))); 00188 } 00189 calibConfig->setRowPattern(rows); 00190 found_fRowPattern = true; 00191 } // fill fRowPattern 00192 00193 // fill fColumnPattern 00194 if (row["PARAMETER"].data<string>() == "ColNums") { 00195 if (found_fColumnPattern) { 00196 cout << "Warning: found mulitple entries for fColumnPattern!" << endl; 00197 } 00198 string collist = row["VALUE"].data<string>(); 00199 // split the string 00200 string buff; 00201 vector<short> cols; 00202 stringstream ss(collist); 00203 while (ss >> buff) { 00204 cols.push_back(static_cast<short>(atoi(buff.c_str()))); 00205 } 00206 calibConfig->setColumnPattern(cols); 00207 found_fColumnPattern = true; 00208 } // fill fColumnPattern 00209 00210 // fill fVCalValues 00211 if (row["CALIB_OBJECT"].data<string>() == "Vcal DAC") { 00212 if (found_fVCalValues) { 00213 cout << "Warning: found mulitple entries for fVCalValues!" << endl; 00214 } 00215 string vcallist = row["VALUE"].data<string>(); 00216 // split the string 00217 string buff; 00218 vector<short> vcals; 00219 stringstream ss(vcallist); 00220 while (ss >> buff) { 00221 vcals.push_back(static_cast<short>(atoi(buff.c_str()))); 00222 } 00223 calibConfig->setVCalValues(vcals); 00224 found_fVCalValues = true; 00225 } // fill fRowPattern 00226 00227 /* 00228 for (coral::AttributeList::iterator it = row.begin(); 00229 it != row.end(); ++it) { 00230 if it->specification().name() == "PARAMETER" 00231 00232 if (it->specification().name() == "RUN_NUMBER") 00233 cout << it->specification().name() << ", " << it->data<long long>() << endl; 00234 else 00235 cout << it->specification().name() << ", " << it->data<string>() << endl; 00236 00237 } // loop over attribute list 00238 */ 00239 } // while (cursor.next()) 00240 00241 // spit out calibConfig object 00242 cout << endl << "** calibConfig: " << endl; 00243 cout << " fNtriggers: " << calibConfig->getNTriggers() << endl; 00244 /* 00245 cout << " fROCIds: "; 00246 vector<string> rocids = calibConfig->getROCIds(); 00247 for (vector<string>::const_iterator it = rocids.begin(); 00248 it != rocids.end(); ++it) 00249 cout << *it << ", "; 00250 cout << endl; 00251 */ 00252 cout << " fRowPattern: "; 00253 vector<short> rowpattern = calibConfig->getRowPattern(); 00254 for (vector<short>::const_iterator it = rowpattern.begin(); 00255 it != rowpattern.end(); ++it) 00256 cout << *it << ", "; 00257 cout << endl; 00258 cout << " fColumnPattern: "; 00259 vector<short> columnpattern = calibConfig->getColumnPattern(); 00260 for (vector<short>::const_iterator it = columnpattern.begin(); 00261 it != columnpattern.end(); ++it) 00262 cout << *it << ", "; 00263 cout << endl; 00264 cout << " fVcalValues: "; 00265 vector<short> vcalvalues = calibConfig->getVCalValues(); 00266 for (vector<short>::const_iterator it = vcalvalues.begin(); 00267 it != vcalvalues.end(); ++it) 00268 cout << *it << ", "; 00269 cout << endl; 00270 cout << " fNmode: " << calibConfig->getCalibrationMode() << endl; 00271 00272 // see what's in the db 00273 //cout << "tagInfo: " << tagInfo().name << ", " << tagInfo().lastInterval.first << endl; 00274 00275 m_to_transfer.push_back(std::make_pair(calibConfig,_sinceIOV)); 00276 00277 00278 delete dbsession; 00279 } // void PixelPopConCalibSourceHandler::getNewObjects_coral()
void PixelPopConCalibSourceHandler::getNewObjects_file | ( | ) | [virtual] |
Reimplemented from PixelPopConSourceHandler< SiPixelCalibConfiguration >.
Definition at line 282 of file PixelPopConCalibSourceHandler.cc.
References PixelPopConSourceHandler< SiPixelCalibConfiguration >::_connectString, PixelPopConSourceHandler< SiPixelCalibConfiguration >::_sinceIOV, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and popcon::PopConSourceHandler< SiPixelCalibConfiguration >::m_to_transfer.
00282 { 00283 // check to make sure the _connectString begins with "file//" 00284 if (_connectString.find("file://") != 0) { 00285 cout << "Invalid connectString: " << _connectString << endl; 00286 cout << "It should begin with \"file://\"" << endl; 00287 return; 00288 } 00289 // strip the "file://" from the connect string 00290 string inputFilename = _connectString.erase(0, 7); 00291 00292 cout << "PopCon-ing the calibration configuration file located at " << inputFilename << endl; 00293 00294 // use online code to parse the file 00295 pos::PixelCalibConfiguration fancyCalib(inputFilename); 00296 SiPixelCalibConfiguration *calibConfig = new SiPixelCalibConfiguration(fancyCalib); 00297 00298 m_to_transfer.push_back(std::make_pair(calibConfig, _sinceIOV)); 00299 00300 } // void PixelPopConCalibSourceHandler::getNewObjects_file()
string PixelPopConCalibSourceHandler::id | ( | void | ) | const [virtual] |
Reimplemented from PixelPopConSourceHandler< SiPixelCalibConfiguration >.
Definition at line 74 of file PixelPopConCalibSourceHandler.cc.
00074 { 00075 00076 return string("PixelPopConCalibSourceHandler"); 00077 00078 } // string PixelPopConCalibSourceHandler::id()