25 #include "CoralBase/Exception.h" 26 #include "CoralBase/AttributeList.h" 27 #include "CoralBase/Attribute.h" 28 #include "CoralBase/AttributeSpecification.h" 29 #include "CoralBase/Exception.h" 30 #include "RelationalAccess/ISessionProxy.h" 31 #include "RelationalAccess/ITransaction.h" 32 #include "RelationalAccess/AccessMode.h" 33 #include "RelationalAccess/ITypeConverter.h" 34 #include "RelationalAccess/IQuery.h" 35 #include "RelationalAccess/ICursor.h" 36 #include "RelationalAccess/ISchema.h" 37 #include "RelationalAccess/ITable.h" 53 #include <boost/foreach.hpp> 54 #include <boost/tokenizer.hpp> 55 #include <xercesc/dom/DOM.hpp> 56 #include <xercesc/parsers/XercesDOMParser.hpp> 58 #include <xercesc/util/XMLString.hpp> 60 #include "boost/filesystem/path.hpp" 61 #include "boost/filesystem/operations.hpp" 66 findingRecord<DIPLuminosityRcd>();
76 if(currentls==0||currentls==4294967295){
77 return std::make_shared<DIPLumiSummary>();
87 return std::make_shared<DIPLumiSummary>();
90 std::vector<unsigned int>
v;
92 v.push_back(it->first);
99 return std::make_shared<DIPLumiSummary>();
108 if(currentls==0||currentls==4294967295){
109 return std::make_shared<DIPLumiDetail>();
119 return std::make_shared<DIPLumiDetail>();
122 std::vector<unsigned int>
v;
124 v.push_back(it->first);
131 return std::make_shared<DIPLumiDetail>();
160 throw cms::Exception(
"Non existing service lumi::service::DBService");
163 coral::ITypeConverter& tconverter=
session->typeConverter();
167 unsigned int lsmin=1;
168 unsigned int lsmax=currentlsnum;
170 session->transaction().start(
true);
173 if(maxavailableLS!=0 && maxavailableLS<currentlsnum){
174 lsmax=maxavailableLS;
175 }
else if(maxavailableLS==0){
177 session->transaction().commit();
184 coral::AttributeList lumisummaryBindVariables;
185 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
186 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
187 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
189 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
190 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
191 std::string conditionStr(
"RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax");
192 coral::AttributeList lumisummaryOutput;
193 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
194 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
195 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
196 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
197 lumisummaryOutput.extend(
"CMS_ACTIVE",
typeid(
unsigned short));
198 coral::IQuery* lumisummaryQuery=schema.newQuery();
199 lumisummaryQuery->addToTableList(
std::string(
"LUMI_SECTIONS"));
200 lumisummaryQuery->addToOutputList(
"LUMISECTION");
201 lumisummaryQuery->addToOutputList(
"INSTLUMI");
202 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
203 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
204 lumisummaryQuery->addToOutputList(
"CMS_ACTIVE");
205 lumisummaryQuery->setCondition(conditionStr,lumisummaryBindVariables);
206 lumisummaryQuery->defineOutput(lumisummaryOutput);
207 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
208 while( lumisummarycursor.next() ){
209 const coral::AttributeList& row=lumisummarycursor.currentRow();
210 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
212 if(!row[
"INSTLUMI"].isNull()){
213 instlumi=row[
"INSTLUMI"].data<
float>();
215 float intgdellumi=0.0;
216 if(!row[
"DELIVLUMISECTION"].isNull()){
217 intgdellumi=row[
"DELIVLUMISECTION"].data<
float>()*1000.0;
219 float intgreclumi=0.0;
220 if(!row[
"LIVELUMISECTION"].isNull()){
221 intgreclumi=row[
"LIVELUMISECTION"].data<
float>()*1000.0;
223 unsigned short cmsalive=0;
224 if(!row[
"CMS_ACTIVE"].isNull()){
225 cmsalive=row[
"CMS_ACTIVE"].data<
unsigned short>();
227 auto tmpls = std::make_shared<DIPLumiSummary>(instlumi,intgdellumi,intgreclumi,cmsalive);
232 delete lumisummaryQuery;
233 session->transaction().commit();
235 session->transaction().rollback();
245 coral::AttributeList bindVariables;
246 bindVariables.extend(
"runnumber",
typeid(
unsigned int));
247 bindVariables[
"runnumber"].data<
unsigned int>()=runnumber;
249 coral::AttributeList MyOutput;
250 MyOutput.extend(
"maxavailablels",
typeid(
unsigned int));
251 coral::IQuery* myQuery=schema.newQuery();
252 myQuery->addToTableList(tablename);
253 myQuery->addToOutputList(
"max(LUMISECTION)",
"maxavailablels");
254 myQuery->setCondition(conditionStr,bindVariables);
255 myQuery->defineOutput(MyOutput);
256 coral::ICursor& mycursor=myQuery->execute();
257 while( mycursor.next() ){
258 const coral::AttributeList& row=mycursor.currentRow();
259 if(!row[
"maxavailablels"].isNull()){
260 result=row[
"maxavailablels"].data<
unsigned int>();
276 throw cms::Exception(
"Non existing service lumi::service::DBService");
279 coral::ITypeConverter& tconverter=
session->typeConverter();
282 unsigned int lsmin=1;
283 unsigned int lsmax=currentlsnum;
285 session->transaction().start(
true);
288 if(maxavailableLS!=0 &&maxavailableLS<currentlsnum ){
289 lsmax=maxavailableLS;
290 }
else if(maxavailableLS==0){
292 session->transaction().commit();
298 coral::AttributeList lumidetailBindVariables;
299 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
300 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
301 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
303 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
304 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
305 std::string conditionStr(
"RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax AND BUNCHLUMI>0 ");
306 coral::AttributeList lumidetailOutput;
307 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
308 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
309 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
310 coral::IQuery* lumidetailQuery=schema.newQuery();
311 lumidetailQuery->addToTableList(
std::string(
"BUNCH_LUMI_SECTIONS"));
312 lumidetailQuery->addToOutputList(
"LUMISECTION");
313 lumidetailQuery->addToOutputList(
"BUNCH");
314 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
315 lumidetailQuery->setCondition(conditionStr,lumidetailBindVariables);
316 lumidetailQuery->defineOutput(lumidetailOutput);
317 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
318 while( lumidetailcursor.next() ){
319 const coral::AttributeList& row=lumidetailcursor.currentRow();
320 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
322 m_detailcache.insert(std::make_pair(lsnum,std::make_shared<DIPLumiDetail>()));
325 if(!row[
"BUNCH"].isNull()){
326 unsigned int bxidx=row[
"BUNCH"].data<
unsigned int>();
328 if(!row[
"BUNCHLUMI"].isNull()){
329 bxlumi=row[
"BUNCHLUMI"].data<
float>();
334 delete lumidetailQuery;
335 session->transaction().commit();
337 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
const EventID & eventID() const
DIPLumiProducer(const edm::ParameterSet &)
ISessionProxyPtr connectReadOnly(const std::string &connectstring)
std::shared_ptr< DIPLumiSummary > ReturnSummaryType
ReturnDetailType produceDetail(const DIPLuminosityRcd &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
std::shared_ptr< DIPLumiSummary > m_summaryresult
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
LuminosityBlockNumber_t luminosityBlockNumber() const
std::shared_ptr< DIPLumiDetail > m_detailresult
void setLast(const IOVSyncValue &iTime)
std::map< unsigned int, std::shared_ptr< DIPLumiSummary > > m_summarycache
unsigned int m_summarycachedrun
std::shared_ptr< DIPLumiDetail > ReturnDetailType
#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
std::map< unsigned int, std::shared_ptr< DIPLumiDetail > > m_detailcache
void fillsummarycache(unsigned int runnumber, unsigned int startlsnum)
ReturnSummaryType produceSummary(const DIPLuminosityRcd &)