26 #include "CoralBase/Exception.h"
27 #include "CoralBase/AttributeList.h"
28 #include "CoralBase/Attribute.h"
29 #include "CoralBase/AttributeSpecification.h"
30 #include "CoralBase/Exception.h"
31 #include "RelationalAccess/ISessionProxy.h"
32 #include "RelationalAccess/ITransaction.h"
33 #include "RelationalAccess/AccessMode.h"
34 #include "RelationalAccess/ITypeConverter.h"
35 #include "RelationalAccess/IQuery.h"
36 #include "RelationalAccess/ICursor.h"
37 #include "RelationalAccess/ISchema.h"
38 #include "RelationalAccess/ITable.h"
54 #include <boost/foreach.hpp>
55 #include <boost/tokenizer.hpp>
56 #include <xercesc/dom/DOM.hpp>
57 #include <xercesc/parsers/XercesDOMParser.hpp>
59 #include <xercesc/util/XMLString.hpp>
61 #include "boost/filesystem/path.hpp"
62 #include "boost/filesystem/operations.hpp"
67 findingRecord<DIPLuminosityRcd>();
77 if(currentls==0||currentls==4294967295){
91 std::vector<unsigned int>
v;
93 v.push_back(it->first);
109 if(currentls==0||currentls==4294967295){
110 return boost::shared_ptr<DIPLumiDetail>(
new DIPLumiDetail());
120 return boost::shared_ptr<DIPLumiDetail>(
new DIPLumiDetail());
123 std::vector<unsigned int>
v;
124 for(std::map<
unsigned int,boost::shared_ptr<DIPLumiDetail> >::iterator it=
m_detailcache.begin();it!=
m_detailcache.end();++it){
125 v.push_back(it->first);
132 return boost::shared_ptr<DIPLumiDetail>(
new DIPLumiDetail());
161 throw cms::Exception(
"Non existing service lumi::service::DBService");
164 coral::ITypeConverter& tconverter=session->typeConverter();
168 unsigned int lsmin=1;
169 unsigned int lsmax=currentlsnum;
171 session->transaction().start(
true);
172 coral::ISchema&
schema=session->nominalSchema();
174 if(maxavailableLS!=0 && maxavailableLS<currentlsnum){
175 lsmax=maxavailableLS;
176 }
else if(maxavailableLS==0){
178 session->transaction().commit();
186 coral::AttributeList lumisummaryBindVariables;
187 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
188 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
189 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
191 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
192 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
193 std::string conditionStr(
"RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax");
194 coral::AttributeList lumisummaryOutput;
195 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
196 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
197 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
198 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
199 lumisummaryOutput.extend(
"CMS_ACTIVE",
typeid(
unsigned short));
200 coral::IQuery* lumisummaryQuery=schema.newQuery();
201 lumisummaryQuery->addToTableList(
std::string(
"LUMI_SECTIONS"));
202 lumisummaryQuery->addToOutputList(
"LUMISECTION");
203 lumisummaryQuery->addToOutputList(
"INSTLUMI");
204 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
205 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
206 lumisummaryQuery->addToOutputList(
"CMS_ACTIVE");
207 lumisummaryQuery->setCondition(conditionStr,lumisummaryBindVariables);
208 lumisummaryQuery->defineOutput(lumisummaryOutput);
209 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
210 while( lumisummarycursor.next() ){
211 const coral::AttributeList& row=lumisummarycursor.currentRow();
212 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
214 if(!row[
"INSTLUMI"].isNull()){
215 instlumi=row[
"INSTLUMI"].data<
float>();
217 float intgdellumi=0.0;
218 if(!row[
"DELIVLUMISECTION"].isNull()){
219 intgdellumi=row[
"DELIVLUMISECTION"].data<
float>()*1000.0;
221 float intgreclumi=0.0;
222 if(!row[
"LIVELUMISECTION"].isNull()){
223 intgreclumi=row[
"LIVELUMISECTION"].data<
float>()*1000.0;
225 unsigned short cmsalive=0;
226 if(!row[
"CMS_ACTIVE"].isNull()){
227 cmsalive=row[
"CMS_ACTIVE"].data<
unsigned short>();
229 boost::shared_ptr<DIPLumiSummary> tmpls(
new DIPLumiSummary(instlumi,intgdellumi,intgreclumi,cmsalive));
234 delete lumisummaryQuery;
235 session->transaction().commit();
237 session->transaction().rollback();
249 coral::AttributeList bindVariables;
250 bindVariables.extend(
"runnumber",
typeid(
unsigned int));
251 bindVariables[
"runnumber"].data<
unsigned int>()=runnumber;
253 coral::AttributeList MyOutput;
254 MyOutput.extend(
"maxavailablels",
typeid(
unsigned int));
255 coral::IQuery*
myQuery=schema.newQuery();
256 myQuery->addToTableList(tablename);
257 myQuery->addToOutputList(
"max(LUMISECTION)",
"maxavailablels");
258 myQuery->setCondition(conditionStr,bindVariables);
259 myQuery->defineOutput(MyOutput);
260 coral::ICursor& mycursor=myQuery->execute();
261 while( mycursor.next() ){
262 const coral::AttributeList& row=mycursor.currentRow();
263 if(!row[
"maxavailablels"].isNull()){
264 result=row[
"maxavailablels"].data<
unsigned int>();
280 throw cms::Exception(
"Non existing service lumi::service::DBService");
283 coral::ITypeConverter& tconverter=session->typeConverter();
286 unsigned int lsmin=1;
287 unsigned int lsmax=currentlsnum;
289 session->transaction().start(
true);
290 coral::ISchema&
schema=session->nominalSchema();
292 if(maxavailableLS!=0 &&maxavailableLS<currentlsnum ){
293 lsmax=maxavailableLS;
294 }
else if(maxavailableLS==0){
296 session->transaction().commit();
303 coral::AttributeList lumidetailBindVariables;
304 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
305 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
306 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
308 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
309 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
310 std::string conditionStr(
"RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax AND BUNCHLUMI>0 ");
311 coral::AttributeList lumidetailOutput;
312 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
313 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
314 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
315 coral::IQuery* lumidetailQuery=schema.newQuery();
316 lumidetailQuery->addToTableList(
std::string(
"BUNCH_LUMI_SECTIONS"));
317 lumidetailQuery->addToOutputList(
"LUMISECTION");
318 lumidetailQuery->addToOutputList(
"BUNCH");
319 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
320 lumidetailQuery->setCondition(conditionStr,lumidetailBindVariables);
321 lumidetailQuery->defineOutput(lumidetailOutput);
322 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
323 while( lumidetailcursor.next() ){
324 const coral::AttributeList& row=lumidetailcursor.currentRow();
325 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
330 if(!row[
"BUNCH"].isNull()){
331 unsigned int bxidx=row[
"BUNCH"].data<
unsigned int>();
333 if(!row[
"BUNCHLUMI"].isNull()){
334 bxlumi=row[
"BUNCHLUMI"].data<
float>();
339 delete lumidetailQuery;
340 session->transaction().commit();
342 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 &)