CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
LumiProducer Class Reference

#include <RecoLuminosity/LumiProducer/src/LumiProducer.cc>

Inheritance diagram for LumiProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  HLTData
 
struct  L1Data
 
struct  PerLSData
 
struct  PerRunData
 

Public Member Functions

 LumiProducer (const edm::ParameterSet &)
 
 ~LumiProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock &iLBlock, edm::EventSetup const &iSetup)
 
virtual void beginRun (edm::Run &, edm::EventSetup const &)
 
virtual void endLuminosityBlock (edm::LuminosityBlock &lumiBlock, edm::EventSetup const &c)
 
void fillLSCache (unsigned int luminum)
 
bool fillLumi (edm::LuminosityBlock &iLBlock)
 
void fillRunCache (unsigned int runnumber)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
XMLCh * s2x (const std::string &input) const
 
const std::string servletTranslation (const std::string &servlet) const
 
std::string toParentString (const xercesc::DOMNode &nodeToConvert) const
 
void writeProductsForEntry (edm::LuminosityBlock &iLBlock, unsigned int runnumber, unsigned int luminum)
 
std::string x2s (const XMLCh *input) const
 

Private Attributes

unsigned int m_cachedrun
 
unsigned int m_cachesize
 
std::string m_connectStr
 
bool m_isNullRun
 
std::map< unsigned int, PerLSDatam_lscache
 
std::string m_lumiversion
 
PerRunData m_runcache
 
std::string m_siteconfpath
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: This class would load the luminosity object into a Luminosity Block

Implementation: The are two main steps, the first one retrieve the record of the luminosity data from the DB and the second loads the Luminosity Obj into the Lumi Block. (Actually in the initial implementation it is retrieving from the ParameterSet from the configuration file, the DB is not implemented yet)

Definition at line 75 of file LumiProducer.cc.

Constructor & Destructor Documentation

LumiProducer::LumiProducer ( const edm::ParameterSet )
explicit
LumiProducer::~LumiProducer ( )

Definition at line 271 of file LumiProducer.cc.

271  {
272 }

Member Function Documentation

void LumiProducer::beginLuminosityBlock ( edm::LuminosityBlock iLBlock,
edm::EventSetup const &  iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 283 of file LumiProducer.cc.

283  {
284 }
void LumiProducer::beginRun ( edm::Run run,
edm::EventSetup const &  iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 278 of file LumiProducer.cc.

References fillRunCache(), m_cachedrun, edm::RunBase::run(), and cond::runnumber.

278  {
279  unsigned int runnumber=run.run();
281  fillRunCache(runnumber);
282 }
RunNumber_t run() const
Definition: RunBase.h:44
unsigned int m_cachedrun
void fillRunCache(unsigned int runnumber)
void LumiProducer::endLuminosityBlock ( edm::LuminosityBlock lumiBlock,
edm::EventSetup const &  c 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 285 of file LumiProducer.cc.

References fillLSCache(), edm::LuminosityBlockBase::luminosityBlock(), m_isNullRun, m_lscache, edm::LuminosityBlock::put(), edm::LuminosityBlockBase::run(), cond::runnumber, and writeProductsForEntry().

285  {
286  unsigned int runnumber=iLBlock.run();
287  unsigned int luminum=iLBlock.luminosityBlock();
288  //if is null run, fill empty values and return
289  if(m_isNullRun){
290  std::auto_ptr<LumiSummary> pOut1;
291  std::auto_ptr<LumiDetails> pOut2;
292  LumiSummary* pIn1=new LumiSummary;
293  LumiDetails* pIn2=new LumiDetails;
294  pOut1.reset(pIn1);
295  iLBlock.put(pOut1);
296  pOut2.reset(pIn2);
297  iLBlock.put(pOut2);
298  return;
299  }
300  if(m_lscache.find(luminum)==m_lscache.end()){
301  //if runnumber is cached but LS is not, this is the first LS, fill LS cache to full capacity
302  fillLSCache(luminum);
303  }
304  //here the presence of ls is guaranteed
305  writeProductsForEntry(iLBlock,runnumber,luminum);
306 }
void writeProductsForEntry(edm::LuminosityBlock &iLBlock, unsigned int runnumber, unsigned int luminum)
void fillLSCache(unsigned int luminum)
std::map< unsigned int, PerLSData > m_lscache
void LumiProducer::fillLSCache ( unsigned int  luminum)
private

Definition at line 393 of file LumiProducer.cc.

References LumiProducer::HLTData::acceptcount, LumiProducer::PerLSData::beam1intensity, LumiProducer::PerLSData::beam2intensity, LumiProducer::L1Data::bitnum, LumiProducer::PerLSData::bunchlumierror, LumiProducer::PerLSData::bunchlumiquality, LumiProducer::PerLSData::bunchlumivalue, lumi::service::DBService::connectReadOnly(), lumi::service::DBService::disconnect(), edm::hlt::Exception, LumiProducer::PerLSData::hltdata, LumiProducer::PerRunData::HLTPathNames, lumi::LumiNames::hltTableName(), i, edm::Service< T >::isAvailable(), prof2calltree::l, LumiProducer::PerLSData::l1data, LumiProducer::HLTData::l1passcount, lumiCalc::lsdata, lumi::LumiNames::lumidetailTableName(), lumi::LumiNames::lumisummaryTableName(), m_cachedrun, m_cachesize, m_connectStr, m_isNullRun, m_lscache, m_runcache, n, LumiProducer::HLTData::pathnum, LumiProducer::HLTData::prescale, python.IdGenerator::schema, python.CommonUtils::session, and lumi::LumiNames::trgTableName().

Referenced by endLuminosityBlock().

393  {
394  //std::cout<<"in fillLSCache "<<luminum<<std::endl;
395  //initialize cache
396  if(m_isNullRun) return;
397  m_lscache.clear();
398  for(unsigned int n=luminum;n<luminum+m_cachesize;++n){
399  PerLSData l;
400  l.hltdata.reserve(250);
401  l.l1data.reserve(192);
402  l.bunchlumivalue.reserve(5);
403  l.bunchlumierror.reserve(5);
404  l.bunchlumiquality.reserve(5);
405  l.beam1intensity.resize(3564,0.0);
406  l.beam2intensity.resize(3564,0.0);
407  m_lscache.insert(std::make_pair(n,l));
408  }
409  //queries once per cache refill
410  //
411  //select cmslsnum,instlumi,instlumierror,lumiquality,startorbit,numorbit,bxindex,beam1intensity,beam2intensity from lumisummary where cmslsnum>=:lsmin and cmslsnum<:lsmax and runnum=:runnumber ;
412  //
414  if( !mydbservice.isAvailable() ){
415  throw cms::Exception("Non existing service lumi::service::DBService");
416  }
417  coral::ISessionProxy* session=mydbservice->connectReadOnly(m_connectStr);
418  try{
419  session->transaction().start(true);
420  coral::ISchema& schema=session->nominalSchema();
421  coral::AttributeList lumisummaryBindVariables;
422  lumisummaryBindVariables.extend("runnum",typeid(unsigned int));
423  lumisummaryBindVariables.extend("lsmin",typeid(unsigned int));
424  lumisummaryBindVariables.extend("lsmax",typeid(unsigned int));
425 
426  lumisummaryBindVariables["runnum"].data<unsigned int>()=m_cachedrun;
427  lumisummaryBindVariables["lsmin"].data<unsigned int>()=luminum;
428  lumisummaryBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize;
429  coral::AttributeList lumisummaryOutput;
430  lumisummaryOutput.extend("cmslsnum",typeid(unsigned int));
431  lumisummaryOutput.extend("instlumi",typeid(float));
432  lumisummaryOutput.extend("instlumierror",typeid(float));
433  lumisummaryOutput.extend("instlumiquality",typeid(short));
434  lumisummaryOutput.extend("startorbit",typeid(unsigned int));
435  lumisummaryOutput.extend("numorbit",typeid(unsigned int));
436  lumisummaryOutput.extend("bxindexBlob",typeid(coral::Blob));
437  lumisummaryOutput.extend("beam1intensityBlob",typeid(coral::Blob));
438  lumisummaryOutput.extend("beam2intensityBlob",typeid(coral::Blob));
439 
440  coral::IQuery* lumisummaryQuery=schema.newQuery();
441  lumisummaryQuery->addToTableList(lumi::LumiNames::lumisummaryTableName());
442  lumisummaryQuery->addToOutputList("CMSLSNUM","cmslsnum");
443  lumisummaryQuery->addToOutputList("INSTLUMI","instlumi");
444  lumisummaryQuery->addToOutputList("INSTLUMIERROR","instlumierror");
445  lumisummaryQuery->addToOutputList("INSTLUMIQUALITY","instlumiquality");
446  lumisummaryQuery->addToOutputList("STARTORBIT","startorbit");
447  lumisummaryQuery->addToOutputList("NUMORBIT","numorbit");
448  lumisummaryQuery->addToOutputList("CMSBXINDEXBLOB","bxindexBlob");
449  lumisummaryQuery->addToOutputList("BEAMINTENSITYBLOB_1","beam1intensityBlob");
450  lumisummaryQuery->addToOutputList("BEAMINTENSITYBLOB_2","beam2intensityBlob");
451  lumisummaryQuery->setCondition("RUNNUM=:runnum AND CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax",lumisummaryBindVariables);
452  lumisummaryQuery->defineOutput(lumisummaryOutput);
453  coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
454  unsigned int rowcounter=0;
455  while( lumisummarycursor.next() ){
456  const coral::AttributeList& row=lumisummarycursor.currentRow();
457  unsigned int cmslsnum=row["cmslsnum"].data<unsigned int>();
458  //std::cout<<"cmslsnum "<<cmslsnum<<std::endl;
459  PerLSData& lsdata=m_lscache[cmslsnum];
460  lsdata.lumivalue=row["instlumi"].data<float>();
461  lsdata.lumierror=row["instlumierror"].data<float>();
462  lsdata.lumiquality=row["instlumiquality"].data<short>();
463  lsdata.startorbit=row["startorbit"].data<unsigned int>();
464  lsdata.numorbit=row["numorbit"].data<unsigned int>();
465 
466  if(!row["bxindexBlob"].isNull()){
467  const coral::Blob& bxindexBlob=row["bxindexBlob"].data<coral::Blob>();
468  const void* bxindex_StartAddress=bxindexBlob.startingAddress();
469  short* bxindex=(short*)::malloc(bxindexBlob.size());
470  const coral::Blob& beam1intensityBlob=row["beam1intensityBlob"].data<coral::Blob>();
471  const void* beam1intensityBlob_StartAddress=beam1intensityBlob.startingAddress();
472  float* beam1intensity=(float*)::malloc(beam1intensityBlob.size());
473  const coral::Blob& beam2intensityBlob=row["beam2intensityBlob"].data<coral::Blob>();
474  const void* beam2intensityBlob_StartAddress=beam2intensityBlob.startingAddress();
475  float* beam2intensity=(float*)::malloc(beam2intensityBlob.size());
476  std::memmove(bxindex,bxindex_StartAddress,bxindexBlob.size());
477  std::memmove(beam1intensity,beam1intensityBlob_StartAddress,beam1intensityBlob.size());
478  std::memmove(beam2intensity,beam2intensityBlob_StartAddress,beam2intensityBlob.size());
479  //std::cout<<"lsnum,pos,bxidx,beam1intensity,beam2intensity "<<std::endl;
480  for(unsigned int i=0;i<bxindexBlob.size()/sizeof(short);++i){
481  unsigned int idx=bxindex[i];
482  lsdata.beam1intensity.at(idx)=beam1intensity[i];
483  lsdata.beam2intensity.at(idx)=beam2intensity[i];
484  //std::cout<<cmslsnum<<","<<i<<","<<idx<<","<<beam1intensity[i]<<","<<beam2intensity[i]<<std::endl;
485  }
486  ::free(bxindex);
487  ::free(beam1intensity);
488  ::free(beam2intensity);
489  }
490  ++rowcounter;
491  }
492  if (rowcounter==0){
493  m_isNullRun=true;
494  return;
495  }
496  delete lumisummaryQuery;
497 
498  //
499  //select lumisummary.cmslsnum,lumidetail.bxlumivalue,lumidetail.bxlumierror,lumidetail.bxlumiquality,lumidetail.algoname from lumisummary,lumidetail where lumisummary.lumisummary_id=lumidetail.lumisummary_id and lumisummary.runnum=:runnum and lumisummary.cmslsnum>=:luminum and lumisummary.cmslsnum<:luminum+cachesize order by lumidetail.algoname,lumisummary.cmslsnum
500  //
501  coral::AttributeList lumidetailBindVariables;
502  lumidetailBindVariables.extend("runnum",typeid(unsigned int));
503  lumidetailBindVariables.extend("lsmin",typeid(unsigned int));
504  lumidetailBindVariables.extend("lsmax",typeid(unsigned int));
505 
506  lumidetailBindVariables["runnum"].data<unsigned int>()=m_cachedrun;
507  lumidetailBindVariables["lsmin"].data<unsigned int>()=luminum;
508  lumidetailBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize;
509  coral::AttributeList lumidetailOutput;
510 
511  lumidetailOutput.extend("cmslsnum",typeid(unsigned int));
512  lumidetailOutput.extend("bxlumivalue",typeid(coral::Blob));
513  lumidetailOutput.extend("bxlumierror",typeid(coral::Blob));
514  lumidetailOutput.extend("bxlumiquality",typeid(coral::Blob));
515  lumidetailOutput.extend("algoname",typeid(std::string));
516 
517  coral::IQuery* lumidetailQuery=schema.newQuery();
518  lumidetailQuery->addToTableList(lumi::LumiNames::lumisummaryTableName());
519  lumidetailQuery->addToTableList(lumi::LumiNames::lumidetailTableName());
520  lumidetailQuery->addToOutputList(lumi::LumiNames::lumisummaryTableName()+".CMSLSNUM","cmslsnum");
521  lumidetailQuery->addToOutputList(lumi::LumiNames::lumidetailTableName()+".BXLUMIVALUE","bxlumivalue");
522  lumidetailQuery->addToOutputList(lumi::LumiNames::lumidetailTableName()+".BXLUMIERROR","bxlumierror");
523  lumidetailQuery->addToOutputList(lumi::LumiNames::lumidetailTableName()+".BXLUMIQUALITY","instlumiquality");
524  lumidetailQuery->addToOutputList(lumi::LumiNames::lumidetailTableName()+".ALGONAME","algoname");
525  lumidetailQuery->setCondition(lumi::LumiNames::lumisummaryTableName()+".LUMISUMMARY_ID="+lumi::LumiNames::lumidetailTableName()+".LUMISUMMARY_ID AND "+lumi::LumiNames::lumisummaryTableName()+".RUNNUM=:runnum AND "+lumi::LumiNames::lumisummaryTableName()+".CMSLSNUM>=:lsmin AND "+lumi::LumiNames::lumisummaryTableName()+".CMSLSNUM<:lsmax",lumidetailBindVariables);
526  lumidetailQuery->addToOrderList(lumi::LumiNames::lumidetailTableName()+".ALGONAME");
527  lumidetailQuery->addToOrderList(lumi::LumiNames::lumisummaryTableName()+".CMSLSNUM");
528  lumidetailQuery->defineOutput(lumidetailOutput);
529  coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
530  while( lumidetailcursor.next() ){
531  const coral::AttributeList& row=lumidetailcursor.currentRow();
532  unsigned int cmslsnum=row["cmslsnum"].data<unsigned int>();
533  std::string algoname=row["algoname"].data<std::string>();
534  //std::cout<<"cmslsnum "<<cmslsnum<<" "<<algoname<<std::endl;
535  PerLSData& lsdata=m_lscache[cmslsnum];
536  if( !row["bxlumivalue"].isNull() && !row["bxlumierror"].isNull() && !row["bxlumiquality"].isNull() ){
537  const coral::Blob& bxlumivalueBlob=row["bxlumivalue"].data<coral::Blob>();
538  const coral::Blob& bxlumierrorBlob=row["bxlumierror"].data<coral::Blob>();
539  const coral::Blob& bxlumiqualityBlob=row["bxlumiquality"].data<coral::Blob>();
540  const void* bxlumivalueBlob_StartAddress=bxlumivalueBlob.startingAddress();
541  const void* bxlumierrorBlob_StartAddress=bxlumierrorBlob.startingAddress();
542  const void* bxlumiqualityBlob_StartAddress=bxlumiqualityBlob.startingAddress();
543  float* bxlumivalue=(float*)::malloc(bxlumivalueBlob.size());
544  float* bxlumierror=(float*)::malloc(bxlumierrorBlob.size());
545  short* bxlumiquality=(short*)::malloc(bxlumiqualityBlob.size());
546  std::memmove(bxlumivalue,bxlumivalueBlob_StartAddress,bxlumivalueBlob.size());
547  std::memmove(bxlumierror,bxlumierrorBlob_StartAddress,bxlumierrorBlob.size());
548  std::memmove(bxlumiquality,bxlumiqualityBlob_StartAddress,bxlumiqualityBlob.size());
549  std::vector<float> bxlumivalueVec(bxlumivalue,bxlumivalue+bxlumivalueBlob.size()/sizeof(float));
550  ::free(bxlumivalue);
551  lsdata.bunchlumivalue.push_back(std::make_pair(algoname,bxlumivalueVec));
552  std::vector<float> bxlumierrorVec(bxlumierror,bxlumierror+bxlumierrorBlob.size()/sizeof(float));
553  ::free(bxlumierror);
554  lsdata.bunchlumierror.push_back(std::make_pair(algoname,bxlumierrorVec));
555  std::vector<short> bxlumiqualityVec(bxlumiquality,bxlumiquality+bxlumiqualityBlob.size()/sizeof(short));
556  lsdata.bunchlumiquality.push_back(std::make_pair(algoname,bxlumiqualityVec));
557  ::free(bxlumiquality);
558  }
559  }
560  delete lumidetailQuery;
561  //
562  //select cmslsnum,bitnum,deadtime,prescale,trgcount from trg where cmslsnum >=:luminum and cmslsnum<:luminum+cachesize AND runnum=:runnum order by cmslsnum,bitnum
563  //
564  coral::AttributeList trgBindVariables;
565  trgBindVariables.extend("runnum",typeid(unsigned int));
566  trgBindVariables.extend("lsmin",typeid(unsigned int));
567  trgBindVariables.extend("lsmax",typeid(unsigned int));
568  trgBindVariables["runnum"].data<unsigned int>()=m_cachedrun;
569  trgBindVariables["lsmin"].data<unsigned int>()=luminum;
570  trgBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize;
571  coral::AttributeList trgOutput;
572  trgOutput.extend("cmslsnum",typeid(unsigned int));
573  trgOutput.extend("bitnum",typeid(unsigned int));
574  trgOutput.extend("deadtime",typeid(unsigned long long));
575  trgOutput.extend("prescale",typeid(unsigned int));
576  trgOutput.extend("trgcount",typeid(unsigned int));
577 
578  coral::IQuery* trgQuery=schema.newQuery();
579  trgQuery->addToTableList(lumi::LumiNames::trgTableName());
580  trgQuery->addToOutputList("CMSLSNUM","cmslsnum");
581  trgQuery->addToOutputList("BITNUM","bitnum");
582  trgQuery->addToOutputList("DEADTIME","deadtime");
583  trgQuery->addToOutputList("PRESCALE","prescale");
584  trgQuery->addToOutputList("TRGCOUNT","trgcount");
585  trgQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND RUNNUM=:runnum ",trgBindVariables);
586  trgQuery->addToOrderList("CMSLSNUM");
587  trgQuery->addToOrderList("BITNUM");
588  trgQuery->defineOutput(trgOutput);
589  coral::ICursor& trgcursor=trgQuery->execute();
590  while( trgcursor.next() ){
591  const coral::AttributeList& row=trgcursor.currentRow();
592  unsigned int cmslsnum=row["cmslsnum"].data<unsigned int>();
593  PerLSData& lsdata=m_lscache[cmslsnum];
594  lsdata.deadcount=row["deadtime"].data<unsigned long long>();
595  L1Data l1tmp;
596  l1tmp.bitnum=row["bitnum"].data<unsigned int>();
597  l1tmp.prescale=row["prescale"].data<unsigned int>();
598  l1tmp.ratecount=row["trgcount"].data<unsigned int>();
599  lsdata.l1data.push_back(l1tmp);
600  }
601  delete trgQuery;
602  //
603  //select cmslsnum,inputcount,acceptcount,prescale from hlt where cmslsnum >=:luminum and cmslsnum<=:luminum+cachesize and runnum=:runnumber order by cmslsum,pathname
604  //
605  coral::AttributeList hltBindVariables;
606  hltBindVariables.extend("runnum",typeid(unsigned int));
607  hltBindVariables.extend("lsmin",typeid(unsigned int));
608  hltBindVariables.extend("lsmax",typeid(unsigned int));
609  hltBindVariables["runnum"].data<unsigned int>()=m_cachedrun;
610  hltBindVariables["lsmin"].data<unsigned int>()=luminum;
611  hltBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize;
612  coral::AttributeList hltOutput;
613  hltOutput.extend("cmslsnum",typeid(unsigned int));
614  hltOutput.extend("inputcount",typeid(unsigned int));
615  hltOutput.extend("acceptcount",typeid(unsigned int));
616  hltOutput.extend("prescale",typeid(unsigned int));
617  coral::IQuery* hltQuery=schema.newQuery();
618  hltQuery->addToTableList(lumi::LumiNames::hltTableName());
619  hltQuery->addToOutputList("CMSLSNUM","cmslsnum");
620  hltQuery->addToOutputList("INPUTCOUNT","inputcount");
621  hltQuery->addToOutputList("ACCEPTCOUNT","acceptcount");
622  hltQuery->addToOutputList("PRESCALE","prescale");
623  hltQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND RUNNUM=:runnum",hltBindVariables);
624  hltQuery->addToOrderList("CMSLSNUM");
625  hltQuery->addToOrderList("PATHNAME");
626  hltQuery->defineOutput(hltOutput);
627  coral::ICursor& hltcursor=hltQuery->execute();
628  unsigned int npaths=m_runcache.HLTPathNames.size();
629  unsigned int pathcount=0;
630  while( hltcursor.next() ){
631  const coral::AttributeList& row=hltcursor.currentRow();
632  unsigned int cmslsnum=row["cmslsnum"].data<unsigned int>();
633  PerLSData& lsdata=m_lscache[cmslsnum];
634  HLTData hlttmp;
635  hlttmp.pathnum=pathcount;
636  hlttmp.prescale=row["prescale"].data<unsigned int>();
637  hlttmp.l1passcount=row["inputcount"].data<unsigned int>();
638  hlttmp.acceptcount=row["acceptcount"].data<unsigned int>();
639  lsdata.hltdata.push_back(hlttmp);
640  if(pathcount!=npaths){
641  ++pathcount;
642  }else{
643  pathcount=0;
644  }
645  }
646  delete hltQuery;
647  session->transaction().commit();
648  }catch(const coral::Exception& er){
649  session->transaction().rollback();
650  mydbservice->disconnect(session);
651  throw cms::Exception("DatabaseError ")<<er.what();
652  }
653  mydbservice->disconnect(session);
654 }
int i
Definition: DBlmapReader.cc:9
static const std::string trgTableName()
Definition: LumiNames.cc:14
std::map< unsigned int, std::string > HLTPathNames
Definition: LumiProducer.cc:92
std::string m_connectStr
bool isAvailable() const
Definition: Service.h:47
static const std::string lumisummaryTableName()
Definition: LumiNames.cc:8
unsigned int m_cachedrun
void disconnect(coral::ISessionProxy *session)
Definition: DBService.cc:46
static const std::string hltTableName()
Definition: LumiNames.cc:17
std::map< unsigned int, PerLSData > m_lscache
static const std::string lumidetailTableName()
Definition: LumiNames.cc:11
unsigned int m_cachesize
coral::ISessionProxy * connectReadOnly(const std::string &connectstring)
Definition: DBService.cc:42
PerRunData m_runcache
tuple lsdata
Definition: lumiCalc.py:197
bool LumiProducer::fillLumi ( edm::LuminosityBlock iLBlock)
private
void LumiProducer::fillRunCache ( unsigned int  runnumber)
private

Definition at line 308 of file LumiProducer.cc.

References lumi::service::DBService::connectReadOnly(), lumi::service::DBService::disconnect(), edm::hlt::Exception, LumiProducer::PerRunData::HLTPathNames, lumi::LumiNames::hltTableName(), edm::Service< T >::isAvailable(), m_cachedrun, m_connectStr, m_isNullRun, m_runcache, cond::runnumber, python.IdGenerator::schema, python.CommonUtils::session, LumiProducer::PerRunData::TRGBitNames, and lumi::LumiNames::trgTableName().

Referenced by beginRun().

308  {
309  //queries once per run
311  if( !mydbservice.isAvailable() ){
312  throw cms::Exception("Non existing service lumi::service::DBService");
313  }
314  //std::cout<<"in fillRunCache "<<runnumber<<std::endl;
315  coral::ISessionProxy* session=mydbservice->connectReadOnly(m_connectStr);
316  try{
317  session->transaction().start(true);
318  coral::ISchema& schema=session->nominalSchema();
319  //
320  //select bitnum,bitname from trg where runnum=:runnum and cmslsnum=:1 order by bitnum;
321  //
322  //std::cout<<"got schema handle "<<std::endl;
324  coral::AttributeList trgBindVariables;
325  trgBindVariables.extend("runnum",typeid(unsigned int));
326  trgBindVariables.extend("cmslsnum",typeid(unsigned int));
327  trgBindVariables["runnum"].data<unsigned int>()=runnumber;
328  trgBindVariables["cmslsnum"].data<unsigned int>()=1;
329  coral::AttributeList trgOutput;
330  trgOutput.extend("bitnum",typeid(unsigned int));
331  trgOutput.extend("bitname",typeid(std::string));
332  coral::IQuery* trgQuery=schema.newQuery();
333  trgQuery->addToTableList(lumi::LumiNames::trgTableName());
334  trgQuery->addToOutputList("BITNUM");
335  trgQuery->addToOutputList("BITNAME");
336  trgQuery->setCondition("RUNNUM=:runnum AND CMSLSNUM=:cmslsnum",trgBindVariables);
337  trgQuery->defineOutput(trgOutput);
338  coral::ICursor& trgcursor=trgQuery->execute();
339  unsigned int rowcounter=0;
340  while( trgcursor.next() ){
341  const coral::AttributeList& row=trgcursor.currentRow();
342  m_runcache.TRGBitNames.insert(std::make_pair(row["bitnum"].data<unsigned int>(),row["bitname"].data<std::string>()));
343  ++rowcounter;
344  }
345  delete trgQuery;
346  if (rowcounter==0){
347  m_isNullRun=true;
348  session->transaction().commit();
349  mydbservice->disconnect(session);
350  return;
351  }
352  //
353  //select pathname from from hlt where runnum=:runnum and cmslsnum=:1 order by pathname;
354  //
355  coral::AttributeList hltBindVariables;
356  hltBindVariables.extend("runnum",typeid(unsigned int));
357  hltBindVariables.extend("cmslsnum",typeid(unsigned int));
358  hltBindVariables["runnum"].data<unsigned int>()=runnumber;
359  hltBindVariables["cmslsnum"].data<unsigned int>()=1;
360  coral::AttributeList hltOutput;
361  hltOutput.extend("pathname",typeid(std::string));
362  coral::IQuery* hltQuery=schema.newQuery();
363  hltQuery->addToTableList(lumi::LumiNames::hltTableName());
364  hltQuery->addToOutputList("PATHNAME");
365  hltQuery->setCondition("RUNNUM=:runnum AND CMSLSNUM=:cmslsnum",hltBindVariables);
366  hltQuery->addToOrderList("PATHNAME");
367  hltQuery->defineOutput(hltOutput);
368  coral::ICursor& hltcursor=hltQuery->execute();
369  rowcounter=0;
370  unsigned int pathcount=0;
371  while( hltcursor.next() ){
372  const coral::AttributeList& row=hltcursor.currentRow();
373  m_runcache.HLTPathNames.insert(std::make_pair(pathcount,row["pathname"].data<std::string>()));
374  ++pathcount;
375  ++rowcounter;
376  }
377  delete hltQuery;
378  if (rowcounter==0){
379  m_isNullRun=true;
380  session->transaction().commit();
381  mydbservice->disconnect(session);
382  return;
383  }
384  session->transaction().commit();
385  }catch(const coral::Exception& er){
386  session->transaction().rollback();
387  mydbservice->disconnect(session);
388  throw cms::Exception("DatabaseError ")<<er.what();
389  }
390  mydbservice->disconnect(session);
391 }
static const std::string trgTableName()
Definition: LumiNames.cc:14
std::map< unsigned int, std::string > HLTPathNames
Definition: LumiProducer.cc:92
std::string m_connectStr
std::map< unsigned int, std::string > TRGBitNames
Definition: LumiProducer.cc:91
bool isAvailable() const
Definition: Service.h:47
unsigned int m_cachedrun
void disconnect(coral::ISessionProxy *session)
Definition: DBService.cc:46
static const std::string hltTableName()
Definition: LumiNames.cc:17
coral::ISessionProxy * connectReadOnly(const std::string &connectstring)
Definition: DBService.cc:42
PerRunData m_runcache
void LumiProducer::produce ( edm::Event e,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 276 of file LumiProducer.cc.

276  {
277 }
XMLCh * LumiProducer::s2x ( const std::string &  input) const
private

Definition at line 155 of file LumiProducer.cc.

Referenced by servletTranslation().

155  {
156  XMLCh* buff = xercesc::XMLString::transcode(temp.c_str());
157  return buff;
158 }
const std::string LumiProducer::servletTranslation ( const std::string &  servlet) const
private

Definition at line 188 of file LumiProducer.cc.

References asciidump::doc, ExpressReco_HICollisions_FallBack::e, m_siteconfpath, geometryXMLtoCSV::parser, s2x(), and toParentString().

188  {
189  std::string frontierConnect;
190  std::string realconnect;
191  xercesc::XMLPlatformUtils::Initialize();
192  std::auto_ptr< xercesc::XercesDOMParser > parser(new xercesc::XercesDOMParser);
193  try{
194  parser->setValidationScheme(xercesc::XercesDOMParser::Val_Auto);
195  parser->setDoNamespaces(false);
196  parser->parse(m_siteconfpath.c_str());
197  xercesc::DOMDocument* doc=parser->getDocument();
198  if(!doc){
199  return "";
200  }
201 
202  xercesc::DOMNodeList *frontierConnectList=doc->getElementsByTagName(s2x("frontier-connect"));
203  if (frontierConnectList->getLength()>0){
204  xercesc::DOMElement *frontierConnectElement=static_cast < xercesc::DOMElement *> (frontierConnectList->item (0));
205  frontierConnect = toParentString(*frontierConnectElement);
206  }
207  // Replace the last component of every "serverurl=" piece (up to the
208  // next close-paren) with the servlet
209  std::string::size_type nextparen = 0;
210  std::string::size_type serverurl, lastslash;
211  std::string complexstr = "";
212  while ((serverurl=frontierConnect.find("(serverurl=", nextparen)) != std::string::npos){
213  realconnect.append(frontierConnect, nextparen, serverurl - nextparen);
214  nextparen=frontierConnect.find(')', serverurl);
215  lastslash=frontierConnect.rfind('/', nextparen);
216  realconnect.append(frontierConnect,serverurl,lastslash-serverurl+1);
217  realconnect.append(servlet);
218  }
219  realconnect.append(frontierConnect, nextparen,frontierConnect.length()-nextparen);
220  }catch(xercesc::DOMException &e){
221  }
222  return realconnect;
223 }
XMLCh * s2x(const std::string &input) const
uint16_t size_type
std::string toParentString(const xercesc::DOMNode &nodeToConvert) const
tuple doc
Definition: asciidump.py:381
std::string m_siteconfpath
std::string LumiProducer::toParentString ( const xercesc::DOMNode &  nodeToConvert) const
private

Definition at line 161 of file LumiProducer.cc.

References asciidump::attributes, i, j, and x2s().

Referenced by servletTranslation().

161  {
162  std::ostringstream oss;
163  xercesc::DOMNodeList *childList = nodeToConvert.getChildNodes();
164 
165  unsigned int numNodes = childList->getLength ();
166  for (unsigned int i = 0; i < numNodes; ++i){
167  xercesc::DOMNode *childNode = childList->item(i);
168  if (childNode->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
169  continue;
170  xercesc::DOMElement *child = static_cast < xercesc::DOMElement *> (childNode);
171  xercesc::DOMNamedNodeMap *attributes = child->getAttributes();
172  unsigned int numAttributes = attributes->getLength ();
173  for (unsigned int j = 0; j < numAttributes; ++j){
174  xercesc::DOMNode *attributeNode = attributes->item(j);
175  if (attributeNode->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
176  continue;
177  xercesc::DOMAttr *attribute = static_cast <xercesc::DOMAttr *> (attributeNode);
178 
179  oss << "(" << x2s(child->getTagName()) <<
180  x2s(attribute->getName()) << "=" <<
181  x2s(attribute->getValue()) << ")";
182  }
183  }
184  return oss.str();
185 }
int i
Definition: DBlmapReader.cc:9
std::string x2s(const XMLCh *input) const
list attributes
Definition: asciidump.py:415
int j
Definition: DBlmapReader.cc:9
void LumiProducer::writeProductsForEntry ( edm::LuminosityBlock iLBlock,
unsigned int  runnumber,
unsigned int  luminum 
)
private

Definition at line 656 of file LumiProducer.cc.

References LumiProducer::PerLSData::beam1intensity, LumiProducer::PerLSData::beam2intensity, LumiProducer::PerLSData::bunchlumierror, LumiProducer::PerLSData::bunchlumiquality, LumiProducer::PerLSData::bunchlumivalue, LumiProducer::PerLSData::deadcount, LumiDetails::fill(), LumiDetails::fillBeamIntensities(), LumiProducer::PerLSData::hltdata, LumiProducer::PerRunData::HLTPathNames, i, LumiSummary::HLT::inputcount, LumiDetails::kET, LumiDetails::kOCC1, LumiDetails::kOCC2, LumiDetails::kPLT, LumiProducer::PerLSData::l1data, lumiCalc::lsdata, LumiProducer::PerLSData::lumierror, LumiProducer::PerLSData::lumiquality, LumiProducer::PerLSData::lumivalue, m_isNullRun, m_lscache, m_runcache, LumiProducer::PerLSData::numorbit, LumiSummary::HLT::pathname, LumiSummary::L1::prescale, LumiSummary::HLT::prescale, edm::LuminosityBlock::put(), LumiSummary::L1::ratecount, LumiSummary::HLT::ratecount, LumiSummary::setDeadtime(), LumiSummary::setlsnumber(), LumiSummary::setLumiData(), LumiDetails::setLumiVersion(), LumiSummary::setLumiVersion(), LumiSummary::setOrbitData(), LumiProducer::PerLSData::startorbit, LumiSummary::swapHLTData(), LumiSummary::swapL1Data(), LumiProducer::PerRunData::TRGBitNames, and LumiSummary::L1::triggername.

Referenced by endLuminosityBlock().

656  {
657  std::auto_ptr<LumiSummary> pOut1;
658  std::auto_ptr<LumiDetails> pOut2;
659  LumiSummary* pIn1=new LumiSummary;
660  LumiDetails* pIn2=new LumiDetails;
661  if(m_isNullRun){
662  pIn1->setLumiVersion("-1");
663  pIn2->setLumiVersion("-1");
664  pOut1.reset(pIn1);
665  iLBlock.put(pOut1);
666  pOut2.reset(pIn2);
667  iLBlock.put(pOut2);
668  return;
669  }
670  PerLSData& lsdata=m_lscache[luminum];
671  pIn1->setLumiData(lsdata.lumivalue,lsdata.lumierror,lsdata.lumiquality);
672  pIn1->setDeadtime(lsdata.deadcount);
673  pIn1->setlsnumber(luminum);
674  pIn1->setOrbitData(lsdata.startorbit,lsdata.numorbit);
675  std::vector<LumiSummary::L1> l1temp;
676  for(std::vector< L1Data >::iterator it=lsdata.l1data.begin();it!=lsdata.l1data.end();++it){
677  LumiSummary::L1 trgtmp;
678  trgtmp.prescale=it->prescale;
679  trgtmp.ratecount=it->ratecount;
680  trgtmp.triggername=m_runcache.TRGBitNames[it->bitnum];
681  l1temp.push_back(trgtmp);
682  }
683  std::vector<LumiSummary::HLT> hlttemp;
684  for(std::vector< HLTData >::iterator it=lsdata.hltdata.begin();it!=lsdata.hltdata.end();++it){
685  LumiSummary::HLT hlttmp;
686  hlttmp.prescale=it->prescale;
687  hlttmp.ratecount=it->acceptcount;
688  hlttmp.inputcount=it->l1passcount;
689  hlttmp.pathname=m_runcache.HLTPathNames[it->pathnum];
690  hlttemp.push_back(hlttmp);
691  }
692  pIn1->swapL1Data(l1temp);
693  pIn1->swapHLTData(hlttemp);
695  pIn2->fillBeamIntensities(lsdata.beam1intensity,lsdata.beam2intensity);
696  for(unsigned int i=0;i<lsdata.bunchlumivalue.size();++i){
697  std::string algoname=lsdata.bunchlumivalue[i].first;
698  if(algoname=="OCC1"){
699  pIn2->fill(LumiDetails::kOCC1,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second);
700  }else if(algoname=="OCC2"){
701  pIn2->fill(LumiDetails::kOCC2,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second);
702  }else if(algoname=="ET"){
703  pIn2->fill(LumiDetails::kET,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second);
704  }else if(algoname=="PLT"){
705  pIn2->fill(LumiDetails::kPLT,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second);
706  }
707  }
709  pOut1.reset(pIn1);
710  iLBlock.put(pOut1);
711  pOut2.reset(pIn2);
712  iLBlock.put(pOut2);
713 }
int i
Definition: DBlmapReader.cc:9
std::string triggername
Definition: LumiSummary.h:26
void swapHLTData(std::vector< HLT > &hltdata)
Definition: LumiSummary.cc:162
std::map< unsigned int, std::string > HLTPathNames
Definition: LumiProducer.cc:92
void setLumiVersion(std::string const &lumiVersion)
Definition: LumiDetails.cc:36
unsigned int ratecount
Definition: LumiSummary.h:34
void setlsnumber(unsigned int lsnumber)
Definition: LumiSummary.cc:149
std::map< unsigned int, std::string > TRGBitNames
Definition: LumiProducer.cc:91
unsigned int inputcount
Definition: LumiSummary.h:35
unsigned int prescale
Definition: LumiSummary.h:28
void setOrbitData(unsigned int startorbit, unsigned int numorbit)
Definition: LumiSummary.cc:153
void fill(AlgoType algo, std::vector< float > const &values, std::vector< float > const &errors, std::vector< short > const &qualities)
Definition: LumiDetails.cc:51
std::string pathname
Definition: LumiSummary.h:33
void setLumiVersion(const std::string &lumiversion)
Definition: LumiSummary.cc:135
void setLumiData(float instlumi, float instlumierr, short lumiquality)
Definition: LumiSummary.cc:139
std::map< unsigned int, PerLSData > m_lscache
unsigned int ratecount
Definition: LumiSummary.h:27
void swapL1Data(std::vector< L1 > &l1data)
Definition: LumiSummary.cc:158
void fillBeamIntensities(std::vector< float > const &beam1Intensities, std::vector< float > const &beam2Intensities)
Definition: LumiDetails.cc:74
std::string m_lumiversion
void setDeadtime(unsigned long long deadcount)
Definition: LumiSummary.cc:145
PerRunData m_runcache
unsigned int prescale
Definition: LumiSummary.h:36
tuple lsdata
Definition: lumiCalc.py:197
void put(std::auto_ptr< PROD > product)
Put a new product.
std::string LumiProducer::x2s ( const XMLCh *  input) const
private

Definition at line 149 of file LumiProducer.cc.

References tmp.

Referenced by toParentString().

149  {
150  std::string tmp(xercesc::XMLString::transcode(toTranscode));
151  return tmp;
152 }
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100

Member Data Documentation

unsigned int LumiProducer::m_cachedrun
private

Definition at line 137 of file LumiProducer.cc.

Referenced by beginRun(), fillLSCache(), and fillRunCache().

unsigned int LumiProducer::m_cachesize
private

Definition at line 141 of file LumiProducer.cc.

Referenced by fillLSCache().

std::string LumiProducer::m_connectStr
private

Definition at line 134 of file LumiProducer.cc.

Referenced by fillLSCache(), and fillRunCache().

bool LumiProducer::m_isNullRun
private
std::map< unsigned int,PerLSData > LumiProducer::m_lscache
private

Definition at line 139 of file LumiProducer.cc.

Referenced by endLuminosityBlock(), fillLSCache(), and writeProductsForEntry().

std::string LumiProducer::m_lumiversion
private

Definition at line 135 of file LumiProducer.cc.

PerRunData LumiProducer::m_runcache
private

Definition at line 138 of file LumiProducer.cc.

Referenced by fillLSCache(), fillRunCache(), and writeProductsForEntry().

std::string LumiProducer::m_siteconfpath
private

Definition at line 136 of file LumiProducer.cc.

Referenced by servletTranslation().