select distinct name from runsession_parameter l1key: select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY'; amodetag: select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag' egev: select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' hltkey: select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.LVL0:HLT_KEY_DESCRIPTION'; fillnumber: select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.SCAL:FILLN' order by time;//take the first one sequence: select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.LVL0:SEQ_NAME' start/stop time: select time from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.LVL0:START_TIME_T'; select time from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.LVL0:STOP_TIME_T';
123 std::string runsessionParamTable(
"RUNSESSION_PARAMETER");
124 coral::ConnectionService*
svc=
new coral::ConnectionService;
134 if(cutpos!=std::string::npos){
136 csvsource=
m_source.substr(cutpos+1);
139 coral::ISessionProxy* runinfosession=svc->connect(dbsource,coral::ReadOnly);
141 coral::ITypeConverter& tpc=runinfosession->typeConverter();
142 tpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(38)");
143 runinfosession->transaction().start(
true);
144 coral::ISchema& runinfoschemaHandle=runinfosession->schema(runinfoschema);
145 if(!runinfoschemaHandle.existsTable(runsessionParamTable)){
148 coral::IQuery* amodetagQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
149 coral::AttributeList amodetagOutput;
150 amodetagOutput.extend(
"amodetag",
typeid(
std::string));
151 coral::AttributeList amodetagCondition;
152 amodetagCondition=coral::AttributeList();
153 amodetagCondition.extend(
"name",
typeid(
std::string));
154 amodetagCondition.extend(
"runnumber",
typeid(
unsigned int));
156 amodetagCondition[
"runnumber"].data<
unsigned int>()=
runnumber;
157 amodetagQuery->addToOutputList(
"distinct(STRING_VALUE)");
158 amodetagQuery->setCondition(
"NAME=:name AND RUNNUMBER=:runnumber",amodetagCondition);
160 amodetagQuery->defineOutput(amodetagOutput);
161 coral::ICursor& amodetagCursor=amodetagQuery->execute();
162 std::vector<std::string> amodes;
163 while (amodetagCursor.next()){
164 const coral::AttributeList& row=amodetagCursor.currentRow();
165 amodes.push_back(row[
"amodetag"].data<std::string>());
172 for(std::vector<std::string>::iterator it=amodes.begin();it!=amodes.end();++it){
173 if(it->find(
"PHYS")==std::string::npos)
continue;
176 if(amd.size()==0&&amodes.size()!=0){
177 amd=*(amodes.begin());
184 delete amodetagQuery;
186 coral::IQuery* egevQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
187 coral::AttributeList egevOutput;
189 coral::AttributeList egevCondition;
190 egevCondition=coral::AttributeList();
192 egevCondition.extend(
"runnumber",
typeid(
unsigned int));
194 egevCondition[
"runnumber"].data<
unsigned int>()=
runnumber;
195 egevQuery->addToOutputList(
"distinct(STRING_VALUE)");
196 egevQuery->setCondition(
"NAME=:name AND RUNNUMBER=:runnumber",egevCondition);
197 egevQuery->defineOutput(egevOutput);
198 coral::ICursor& egevCursor=egevQuery->execute();
200 while (egevCursor.next()){
201 const coral::AttributeList& row=egevCursor.currentRow();
204 if(tmpgev>result.egev){
213 coral::IQuery* seqQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
214 coral::AttributeList seqBindVariableList;
215 seqBindVariableList.extend(
"runnumber",
typeid(
unsigned int));
216 seqBindVariableList.extend(
"name",
typeid(
std::string));
218 seqBindVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
220 seqQuery->setCondition(
"RUNNUMBER =:runnumber AND NAME =:name",seqBindVariableList);
221 seqQuery->addToOutputList(
"STRING_VALUE");
222 coral::ICursor& seqCursor=seqQuery->execute();
224 while( seqCursor.next() ){
225 const coral::AttributeList& row=seqCursor.currentRow();
226 result.sequence=row[
"STRING_VALUE"].data<
std::string>();
230 coral::IQuery* hltkeyQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
231 coral::AttributeList hltkeyBindVariableList;
232 hltkeyBindVariableList.extend(
"runnumber",
typeid(
unsigned int));
233 hltkeyBindVariableList.extend(
"name",
typeid(
std::string));
235 hltkeyBindVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
237 hltkeyQuery->setCondition(
"RUNNUMBER =:runnumber AND NAME =:name",hltkeyBindVariableList);
238 hltkeyQuery->addToOutputList(
"STRING_VALUE");
239 coral::ICursor& hltkeyCursor=hltkeyQuery->execute();
241 while( hltkeyCursor.next() ){
242 const coral::AttributeList& row=hltkeyCursor.currentRow();
243 result.hltkey=row[
"STRING_VALUE"].data<
std::string>();
247 coral::IQuery* fillQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
248 coral::AttributeList fillBindVariableList;
249 fillBindVariableList.extend(
"runnumber",
typeid(
unsigned int));
250 fillBindVariableList.extend(
"name",
typeid(
std::string));
252 fillBindVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
254 fillQuery->setCondition(
"RUNNUMBER =:runnumber AND NAME =:name",fillBindVariableList);
255 fillQuery->addToOutputList(
"STRING_VALUE");
256 fillQuery->addToOrderList(
"TIME");
258 coral::ICursor& fillCursor=fillQuery->execute();
260 while( fillCursor.next() ){
261 const coral::AttributeList& row=fillCursor.currentRow();
263 result.fillnumber=row[
"STRING_VALUE"].data<
std::string>();
268 if (result.fillnumber.empty()){
269 throw nonCollisionException(
"retrieveData",
"CMSRunSummary2DB");
271 coral::IQuery* startTQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
272 coral::AttributeList startTVariableList;
273 startTVariableList.extend(
"runnumber",
typeid(
unsigned int));
274 startTVariableList.extend(
"name",
typeid(
std::string));
276 startTVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
278 startTQuery->setCondition(
"RUNNUMBER =:runnumber AND NAME =:name",startTVariableList);
279 startTQuery->addToOutputList(
"TIME");
280 coral::ICursor& startTCursor=startTQuery->execute();
282 while( startTCursor.next() ){
283 const coral::AttributeList& row=startTCursor.currentRow();
284 result.startT=row[
"TIME"].data<coral::TimeStamp>();
287 coral::IQuery* stopTQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
288 coral::AttributeList stopTVariableList;
289 stopTVariableList.extend(
"runnumber",
typeid(
unsigned int));
290 stopTVariableList.extend(
"name",
typeid(
std::string));
292 stopTVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
294 stopTQuery->setCondition(
"RUNNUMBER =:runnumber AND NAME =:name",stopTVariableList);
295 stopTQuery->addToOutputList(
"TIME");
296 coral::ICursor& stopTCursor=stopTQuery->execute();
298 while( stopTCursor.next() ){
299 const coral::AttributeList& row=stopTCursor.currentRow();
300 result.stopT=row[
"TIME"].data<coral::TimeStamp>();
303 coral::IQuery* l1keyQuery=runinfoschemaHandle.tableHandle(runsessionParamTable).newQuery();
304 coral::AttributeList l1keyOutput;
306 coral::AttributeList l1keyCondition;
307 l1keyCondition=coral::AttributeList();
309 l1keyCondition.extend(
"runnumber",
typeid(
unsigned int));
311 l1keyCondition[
"runnumber"].data<
unsigned int>()=
runnumber;
312 l1keyQuery->addToOutputList(
"STRING_VALUE");
313 l1keyQuery->setCondition(
"NAME=:name AND RUNNUMBER=:runnumber",l1keyCondition);
315 l1keyQuery->defineOutput(l1keyOutput);
316 coral::ICursor& l1keyCursor=l1keyQuery->execute();
317 while (l1keyCursor.next()){
318 const coral::AttributeList& row=l1keyCursor.currentRow();
323 runinfosession->transaction().rollback();
324 delete runinfosession;
328 runinfosession->transaction().commit();
329 delete runinfosession;
331 if(csvsource.size()!=0){
335 result.ncollidingbunches=0;
337 std::cout<<
"result for run "<<
runnumber<<
" : sequence : "<<result.sequence<<
" : hltkey : "<<result.hltkey<<
" : fillnumber : "<<result.fillnumber<<
" : l1key : "<<result.l1key<<
" : amodetag :"<<result.amodetag<<
" : egev : "<<result.egev<<
" : fillscheme "<<result.fillscheme<<
" : ncollidingbunches : "<<result.ncollidingbunches<<std::endl;
342 coral::ITypeConverter& desttpc=destsession->typeConverter();
343 desttpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)");
345 destsession->transaction().start(
false);
346 coral::ISchema& destschema=destsession->nominalSchema();
348 coral::AttributeList runData;
349 destruntable.dataEditor().rowBuffer(runData);
350 runData[
"RUNNUM"].data<
unsigned int>()=
runnumber;
351 runData[
"FILLNUM"].data<
unsigned int>()=
str2int(result.fillnumber);
352 runData[
"SEQUENCE"].data<
std::string>()=result.sequence;
353 runData[
"HLTKEY"].data<
std::string>()=result.hltkey;
354 runData[
"STARTTIME"].data<coral::TimeStamp>()=result.startT;
355 runData[
"STOPTIME"].data<coral::TimeStamp>()=result.stopT;
356 runData[
"AMODETAG"].data<
std::string>()=result.amodetag;
357 runData[
"EGEV"].data<
unsigned int>()=(
unsigned int)result.egev;
359 runData[
"FILLSCHEME"].data<
std::string>()=result.fillscheme;
360 runData[
"NCOLLIDINGBUNCHES"].data<
unsigned int>()=result.ncollidingbunches;
361 destruntable.dataEditor().insertRow(runData);
363 std::cout<<
"database problem "<<er.what()<<std::endl;
364 destsession->transaction().rollback();
369 destsession->transaction().commit();
unsigned int str2int(const std::string &s) const
void parseFillCSV(const std::string &csvsource, cmsrunsum &result)
static const std::string cmsrunsummaryTableName()