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 "CoralBase/Blob.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"
51 #include <boost/foreach.hpp>
52 #include <boost/tokenizer.hpp>
53 #include "boost/filesystem/path.hpp"
54 #include "boost/filesystem/operations.hpp"
107 ExpressLumiProducer::
108 ExpressLumiProducer::ExpressLumiProducer(
const edm::ParameterSet& iConfig):m_cachedrun(0),m_isNullRun(
false),m_cachesize(0)
111 produces<LumiSummary, edm::InLumi>();
112 produces<LumiDetails, edm::InLumi>();
135 std::auto_ptr<LumiSummary> pOut1;
136 std::auto_ptr<LumiDetails> pOut2;
147 unsigned int currentrun=iLBlock.
run();
166 unsigned int lstowriteout=0;
168 std::vector<unsigned int>
v;
169 for(std::map<unsigned int,ExpressLumiProducer::PerLSData >::iterator it=
m_lscache.begin();it!=
m_lscache.end();++it){
170 v.push_back(it->first);
172 lstowriteout=v.back();
174 lstowriteout=currentls;
199 coral::AttributeList bindVariables;
200 bindVariables.extend(
"runnumber",
typeid(
unsigned int));
201 bindVariables[
"runnumber"].data<
unsigned int>()=runnumber;
202 std::string conditionStr(
"RUNNUMBER=:runnumber");
203 coral::AttributeList MyOutput;
204 MyOutput.extend(
"maxavailablels",
typeid(
unsigned int));
205 coral::IQuery*
myQuery=schema.newQuery();
206 myQuery->addToTableList(tablename);
207 myQuery->addToOutputList(
"max(LUMISECTION)",
"maxavailablels");
208 myQuery->setCondition(conditionStr,bindVariables);
209 myQuery->defineOutput(MyOutput);
210 coral::ICursor& mycursor=myQuery->execute();
211 while( mycursor.next() ){
212 const coral::AttributeList& row=mycursor.currentRow();
213 if(!row[
"maxavailablels"].isNull()){
214 result=row[
"maxavailablels"].data<
unsigned int>();
230 throw cms::Exception(
"Non existing service lumi::service::DBService");
233 coral::ITypeConverter& tconverter=session->typeConverter();
234 tconverter.setCppTypeForSqlType(std::string(
"float"),std::string(
"FLOAT(63)"));
235 tconverter.setCppTypeForSqlType(std::string(
"unsigned int"),std::string(
"NUMBER(10)"));
236 tconverter.setCppTypeForSqlType(std::string(
"unsigned short"),std::string(
"NUMBER(1)"));
237 unsigned int lsmin=1;
238 unsigned int lsmax=currentlsnum;
240 session->transaction().start(
true);
241 coral::ISchema&
schema=session->nominalSchema();
243 if(maxavailableLS!=0 && maxavailableLS<currentlsnum){
244 lsmax=maxavailableLS;
245 }
else if(maxavailableLS==0){
247 session->transaction().commit();
254 for(
unsigned int n=lsmin;
n<=lsmax;++
n){
256 std::vector<float> mytmp(3564,0.0);
258 std::vector<float> myerrtmp(3564,0.0);
260 std::vector<short> myqtmp(3564,0);
265 coral::AttributeList lumisummaryBindVariables;
266 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
267 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
268 lumisummaryBindVariables[
"runnumber"].data<
unsigned int>()=
m_cachedrun;
269 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
270 std::string conditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin ");
271 coral::AttributeList lumisummaryOutput;
272 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
273 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
274 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
275 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
276 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned long long));
278 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
279 conditionStr=conditionStr+
"AND LUMISECTION<=:lsmax";
280 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
282 coral::IQuery* lumisummaryQuery=schema.newQuery();
283 lumisummaryQuery->addToTableList(std::string(
"LUMI_SECTIONS"));
284 lumisummaryQuery->addToOutputList(
"LUMISECTION");
285 lumisummaryQuery->addToOutputList(
"INSTLUMI");
286 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
287 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
288 lumisummaryQuery->addToOutputList(
"STARTORBIT");
289 lumisummaryQuery->setCondition(conditionStr,lumisummaryBindVariables);
290 lumisummaryQuery->defineOutput(lumisummaryOutput);
291 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
292 unsigned int rowcounter=0;
293 while( lumisummarycursor.next() ){
294 const coral::AttributeList& row=lumisummarycursor.currentRow();
295 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
297 if(!row[
"INSTLUMI"].isNull()){
298 instlumi=row[
"INSTLUMI"].data<
float>();
301 float intgdellumi=0.0;
302 float intgreclumi=0.0;
303 unsigned long long startorbit=0;
304 if(!row[
"DELIVLUMISECTION"].isNull()){
305 intgdellumi=row[
"DELIVLUMISECTION"].data<
float>()*1000.0;
307 if(!row[
"LIVELUMISECTION"].isNull()){
308 intgreclumi=row[
"LIVELUMISECTION"].data<
float>()*1000.0;
311 deadfrac=1.0-intgreclumi/intgdellumi;
313 if(!row[
"STARTORBIT"].isNull()){
314 startorbit=row[
"STARTORBIT"].data<
unsigned long long>();
316 unsigned long long deadcount=deadfrac*10000.0;
317 unsigned long long bitzerocount=10000.0;
330 delete lumisummaryQuery;
337 coral::AttributeList lumidetailBindVariables;
338 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
339 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
340 lumidetailBindVariables[
"runnumber"].data<
unsigned int>()=
m_cachedrun;
341 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
342 std::string detailconditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND BUNCHLUMI>0 ");
343 coral::AttributeList lumidetailOutput;
344 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
345 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
346 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
348 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
349 detailconditionStr=detailconditionStr+
"AND LUMISECTION<=:lsmax";
350 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
352 coral::IQuery* lumidetailQuery=schema.newQuery();
353 lumidetailQuery->addToTableList(std::string(
"BUNCH_LUMI_SECTIONS"));
354 lumidetailQuery->addToOutputList(
"LUMISECTION");
355 lumidetailQuery->addToOutputList(
"BUNCH");
356 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
357 lumidetailQuery->setCondition(detailconditionStr,lumidetailBindVariables);
358 lumidetailQuery->defineOutput(lumidetailOutput);
359 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
360 while( lumidetailcursor.next() ){
361 const coral::AttributeList& row=lumidetailcursor.currentRow();
362 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
363 unsigned int bxidx=row[
"BUNCH"].data<
unsigned int>();
364 float bxlumi=row[
"BUNCHLUMI"].data<
float>();
365 m_lscache[lsnum].bunchlumivalue[bxidx]=bxlumi;
367 delete lumidetailQuery;
368 session->transaction().commit();
370 session->transaction().rollback();
379 std::auto_ptr<LumiSummary> pOut1;
380 std::auto_ptr<LumiDetails> pOut2;
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
T getUntrackedParameter(std::string const &, T const &) const
unsigned long long deadcount
#define DEFINE_FWK_MODULE(type)
virtual void endRun(edm::Run &, edm::EventSetup const &)
virtual void beginRun(edm::Run &, edm::EventSetup const &)
std::vector< short > bunchlumiquality
LuminosityBlockNumber_t luminosityBlock() const
void setLumiVersion(std::string const &lumiVersion)
std::map< unsigned int, PerLSData > m_lscache
void setlsnumber(unsigned int lsnumber)
virtual void endLuminosityBlock(edm::LuminosityBlock &lumiBlock, edm::EventSetup const &c)
void setOrbitData(unsigned int startorbit, unsigned int numorbit)
void fill(AlgoType algo, std::vector< float > const &values, std::vector< float > const &errors, std::vector< short > const &qualities)
void fillLSCache(unsigned int runnum, unsigned int luminum)
void writeProductsForEntry(edm::LuminosityBlock &iLBlock, unsigned int luminum)
void disconnect(coral::ISessionProxy *session)
void writeEmptyProductForEntry(edm::LuminosityBlock &iLBlock)
void setLumiVersion(const std::string &lumiversion)
std::vector< float > bunchlumivalue
void setLumiData(float instlumi, float instlumierr, short lumiquality)
void setBitZeroCount(unsigned long long bitzerocount)
unsigned int bitzerocount
unsigned int maxavailableLSforRun(coral::ISchema &schema, const std::string &tablename, unsigned int runnumber)
void setDeadCount(unsigned long long deadcount)
virtual void beginLuminosityBlock(edm::LuminosityBlock &iLBlock, edm::EventSetup const &iSetup)
std::vector< float > bunchlumierror
coral::ISessionProxy * connectReadOnly(const std::string &connectstring)
ExpressLumiProducer(const edm::ParameterSet &)
bool fillLumi(edm::LuminosityBlock &iLBlock)
void put(std::auto_ptr< PROD > product)
Put a new product.