27 #include "CoralBase/Exception.h"
28 #include "CoralBase/AttributeList.h"
29 #include "CoralBase/Attribute.h"
30 #include "CoralBase/AttributeSpecification.h"
31 #include "CoralBase/Exception.h"
32 #include "RelationalAccess/ISessionProxy.h"
33 #include "RelationalAccess/ITransaction.h"
34 #include "RelationalAccess/AccessMode.h"
35 #include "RelationalAccess/ITypeConverter.h"
36 #include "RelationalAccess/IQuery.h"
37 #include "RelationalAccess/ICursor.h"
38 #include "RelationalAccess/ISchema.h"
39 #include "RelationalAccess/ITable.h"
55 #include <boost/foreach.hpp>
56 #include <boost/tokenizer.hpp>
57 #include <xercesc/dom/DOM.hpp>
58 #include <xercesc/parsers/XercesDOMParser.hpp>
59 #include <xercesc/util/PlatformUtils.hpp>
60 #include <xercesc/util/XMLString.hpp>
62 #include "boost/filesystem/path.hpp"
63 #include "boost/filesystem/operations.hpp"
68 findingRecord<DIPLuminosityRcd>();
78 if(currentls==0||currentls==4294967295){
92 std::vector<unsigned int>
v;
94 v.push_back(it->first);
110 if(currentls==0||currentls==4294967295){
111 return boost::shared_ptr<DIPLumiDetail>(
new DIPLumiDetail());
121 return boost::shared_ptr<DIPLumiDetail>(
new DIPLumiDetail());
124 std::vector<unsigned int>
v;
126 v.push_back(it->first);
133 return boost::shared_ptr<DIPLumiDetail>(
new DIPLumiDetail());
162 throw cms::Exception(
"Non existing service lumi::service::DBService");
165 coral::ITypeConverter& tconverter=session->typeConverter();
169 unsigned int lsmin=1;
170 unsigned int lsmax=currentlsnum;
172 session->transaction().start(
true);
173 coral::ISchema&
schema=session->nominalSchema();
175 if(maxavailableLS!=0 && maxavailableLS<currentlsnum){
176 lsmax=maxavailableLS;
177 }
else if(maxavailableLS==0){
179 session->transaction().commit();
187 coral::AttributeList lumisummaryBindVariables;
188 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
189 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
190 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
192 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
193 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
194 std::string conditionStr(
"RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax");
195 coral::AttributeList lumisummaryOutput;
196 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
197 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
198 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
199 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
200 lumisummaryOutput.extend(
"CMS_ACTIVE",
typeid(
unsigned short));
201 coral::IQuery* lumisummaryQuery=schema.newQuery();
202 lumisummaryQuery->addToTableList(
std::string(
"LUMI_SECTIONS"));
203 lumisummaryQuery->addToOutputList(
"LUMISECTION");
204 lumisummaryQuery->addToOutputList(
"INSTLUMI");
205 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
206 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
207 lumisummaryQuery->addToOutputList(
"CMS_ACTIVE");
208 lumisummaryQuery->setCondition(conditionStr,lumisummaryBindVariables);
209 lumisummaryQuery->defineOutput(lumisummaryOutput);
210 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
211 while( lumisummarycursor.next() ){
212 const coral::AttributeList& row=lumisummarycursor.currentRow();
213 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
215 if(!row[
"INSTLUMI"].isNull()){
216 instlumi=row[
"INSTLUMI"].data<
float>();
218 float intgdellumi=0.0;
219 if(!row[
"DELIVLUMISECTION"].isNull()){
220 intgdellumi=row[
"DELIVLUMISECTION"].data<
float>()*1000.0;
222 float intgreclumi=0.0;
223 if(!row[
"LIVELUMISECTION"].isNull()){
224 intgreclumi=row[
"LIVELUMISECTION"].data<
float>()*1000.0;
226 unsigned short cmsalive=0;
227 if(!row[
"CMS_ACTIVE"].isNull()){
228 cmsalive=row[
"CMS_ACTIVE"].data<
unsigned short>();
230 boost::shared_ptr<DIPLumiSummary> tmpls(
new DIPLumiSummary(instlumi,intgdellumi,intgreclumi,cmsalive));
235 delete lumisummaryQuery;
236 session->transaction().commit();
238 session->transaction().rollback();
250 coral::AttributeList bindVariables;
251 bindVariables.extend(
"runnumber",
typeid(
unsigned int));
252 bindVariables[
"runnumber"].data<
unsigned int>()=runnumber;
254 coral::AttributeList MyOutput;
255 MyOutput.extend(
"maxavailablels",
typeid(
unsigned int));
256 coral::IQuery*
myQuery=schema.newQuery();
257 myQuery->addToTableList(tablename);
258 myQuery->addToOutputList(
"max(LUMISECTION)",
"maxavailablels");
259 myQuery->setCondition(conditionStr,bindVariables);
260 myQuery->defineOutput(MyOutput);
261 coral::ICursor& mycursor=myQuery->execute();
262 while( mycursor.next() ){
263 const coral::AttributeList& row=mycursor.currentRow();
264 if(!row[
"maxavailablels"].isNull()){
265 result=row[
"maxavailablels"].data<
unsigned int>();
281 throw cms::Exception(
"Non existing service lumi::service::DBService");
284 coral::ITypeConverter& tconverter=session->typeConverter();
287 unsigned int lsmin=1;
288 unsigned int lsmax=currentlsnum;
290 session->transaction().start(
true);
291 coral::ISchema&
schema=session->nominalSchema();
293 if(maxavailableLS!=0 &&maxavailableLS<currentlsnum ){
294 lsmax=maxavailableLS;
295 }
else if(maxavailableLS==0){
297 session->transaction().commit();
304 coral::AttributeList lumidetailBindVariables;
305 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
306 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
307 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
309 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
310 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
311 std::string conditionStr(
"RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax AND BUNCHLUMI>0 ");
312 coral::AttributeList lumidetailOutput;
313 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
314 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
315 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
316 coral::IQuery* lumidetailQuery=schema.newQuery();
317 lumidetailQuery->addToTableList(
std::string(
"BUNCH_LUMI_SECTIONS"));
318 lumidetailQuery->addToOutputList(
"LUMISECTION");
319 lumidetailQuery->addToOutputList(
"BUNCH");
320 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
321 lumidetailQuery->setCondition(conditionStr,lumidetailBindVariables);
322 lumidetailQuery->defineOutput(lumidetailOutput);
323 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
324 while( lumidetailcursor.next() ){
325 const coral::AttributeList& row=lumidetailcursor.currentRow();
326 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
331 if(!row[
"BUNCH"].isNull()){
332 unsigned int bxidx=row[
"BUNCH"].data<
unsigned int>();
334 if(!row[
"BUNCHLUMI"].isNull()){
335 bxlumi=row[
"BUNCHLUMI"].data<
float>();
340 delete lumidetailQuery;
341 session->transaction().commit();
343 session->transaction().rollback();
void setFirst(const IOVSyncValue &iTime)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int m_detailcachedrun
boost::shared_ptr< DIPLumiSummary > m_summaryresult
const EventID & eventID() const
DIPLumiProducer(const edm::ParameterSet &)
boost::shared_ptr< DIPLumiDetail > m_detailresult
std::map< unsigned int, boost::shared_ptr< DIPLumiDetail > > m_detailcache
ReturnDetailType produceDetail(const DIPLuminosityRcd &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
std::map< unsigned int, boost::shared_ptr< DIPLumiSummary > > m_summarycache
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
LuminosityBlockNumber_t luminosityBlockNumber() const
void disconnect(coral::ISessionProxy *session)
void setLast(const IOVSyncValue &iTime)
boost::shared_ptr< DIPLumiDetail > ReturnDetailType
unsigned int m_summarycachedrun
boost::shared_ptr< DIPLumiSummary > ReturnSummaryType
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
unsigned int maxavailableLSforRun(coral::ISchema &schema, const std::string &tablename, unsigned int runnumber)
void filldetailcache(unsigned int runnumber, unsigned int startlsnum)
const edm::IOVSyncValue * m_pcurrentTime
coral::ISessionProxy * connectReadOnly(const std::string &connectstring)
void fillsummarycache(unsigned int runnumber, unsigned int startlsnum)
ReturnSummaryType produceSummary(const DIPLuminosityRcd &)