CMS 3D CMS Logo

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::one::EDProducer< edm::one::WatchRuns, edm::BeginLuminosityBlockProducer, edm::EndRunProducer > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  HLTData
 
struct  L1Data
 
struct  PerLSData
 
struct  PerRunData
 

Public Member Functions

 LumiProducer (const edm::ParameterSet &)
 
 ~LumiProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns, edm::BeginLuminosityBlockProducer, edm::EndRunProducer >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginLuminosityBlockProduce (edm::LuminosityBlock &iLBlock, edm::EventSetup const &iSetup) final
 
void beginRun (edm::Run const &, edm::EventSetup const &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) final
 
void endRunProduce (edm::Run &, edm::EventSetup const &) final
 
void fillLSCache (unsigned int luminum)
 
bool fillLumi (edm::LuminosityBlock &iLBlock)
 
void fillRunCache (const coral::ISchema &schema, unsigned int runnumber)
 
std::string getCurrentDataTag (const coral::ISchema &schema)
 
unsigned long long getHltDataId (const coral::ISchema &schema, unsigned int runnumber)
 
unsigned long long getLumiDataId (const coral::ISchema &schema, unsigned int runnumber)
 
unsigned long long getTrgDataId (const coral::ISchema &schema, unsigned int runnumber)
 
void produce (edm::Event &, const edm::EventSetup &) final
 
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 long long m_cachedhltdataid
 
unsigned long long m_cachedlumidataid
 
unsigned int m_cachedrun
 
unsigned long long m_cachedtrgdataid
 
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::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

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 79 of file LumiProducer.cc.

Constructor & Destructor Documentation

◆ LumiProducer()

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

◆ ~LumiProducer()

LumiProducer::~LumiProducer ( )
override

Definition at line 282 of file LumiProducer.cc.

282 {}

Member Function Documentation

◆ beginLuminosityBlockProduce()

void LumiProducer::beginLuminosityBlockProduce ( edm::LuminosityBlock iLBlock,
edm::EventSetup const &  iSetup 
)
finalprivate

Definition at line 424 of file LumiProducer.cc.

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

424  {
425  unsigned int runnumber = iLBlock.run();
426  unsigned int luminum = iLBlock.luminosityBlock();
427  //std::cout<<"beg of beginLuminosityBlock "<<luminum<<std::endl;
428  //if is null run, fill empty values and return
429  if (m_isNullRun) {
430  iLBlock.put(std::make_unique<LumiSummary>());
431  iLBlock.put(std::make_unique<LumiDetails>());
432  return;
433  }
434  if (m_lscache.find(luminum) == m_lscache.end()) {
435  //if runnumber is cached but LS is not, this is the first LS, fill LS cache to full capacity
436  fillLSCache(luminum);
437  }
438  //here the presence of ls is guaranteed
439  writeProductsForEntry(iLBlock, runnumber, luminum);
440 }
void writeProductsForEntry(edm::LuminosityBlock &iLBlock, unsigned int runnumber, unsigned int luminum)
void put(std::unique_ptr< PROD > product)
Put a new product.
void fillLSCache(unsigned int luminum)
std::map< unsigned int, PerLSData > m_lscache
LuminosityBlockNumber_t luminosityBlock() const

◆ beginRun()

void LumiProducer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
finalprivate

Definition at line 395 of file LumiProducer.cc.

References lumi::service::DBService::connectReadOnly(), Exception, fillRunCache(), getHltDataId(), getLumiDataId(), getTrgDataId(), edm::Service< T >::isAvailable(), m_cachedhltdataid, m_cachedlumidataid, m_cachedrun, m_cachedtrgdataid, m_connectStr, m_isNullRun, writedatasetfile::run, and cond::runnumber.

395  {
396  unsigned int runnumber = run.run();
397  if (m_cachedrun != runnumber) {
398  //queries once per run
401  if (!mydbservice.isAvailable()) {
402  throw cms::Exception("Non existing service lumi::service::DBService");
403  }
404  auto session = mydbservice->connectReadOnly(m_connectStr);
405  try {
406  session->transaction().start(true);
407  m_cachedlumidataid = getLumiDataId(session->nominalSchema(), runnumber);
408  if (m_cachedlumidataid != 0) { //if no lumi, do not bother other info
409  m_cachedtrgdataid = getTrgDataId(session->nominalSchema(), runnumber);
410  m_cachedhltdataid = getHltDataId(session->nominalSchema(), runnumber);
411  fillRunCache(session->nominalSchema(), runnumber);
412  } else {
413  m_isNullRun = true;
414  }
415  session->transaction().commit();
416  } catch (const coral::Exception& er) {
417  session->transaction().rollback();
418  throw cms::Exception("DatabaseError ") << er.what();
419  }
420  }
421  //std::cout<<"end of beginRun "<<runnumber<<std::endl;
422 }
unsigned long long m_cachedhltdataid
unsigned long long getLumiDataId(const coral::ISchema &schema, unsigned int runnumber)
ISessionProxyPtr connectReadOnly(const std::string &connectstring)
Definition: DBService.cc:19
std::string m_connectStr
unsigned long long getHltDataId(const coral::ISchema &schema, unsigned int runnumber)
unsigned int m_cachedrun
unsigned long long m_cachedtrgdataid
unsigned long long m_cachedlumidataid
unsigned long long getTrgDataId(const coral::ISchema &schema, unsigned int runnumber)
bool isAvailable() const
Definition: Service.h:40
void fillRunCache(const coral::ISchema &schema, unsigned int runnumber)

◆ endRun()

void LumiProducer::endRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
finalprivate

Definition at line 441 of file LumiProducer.cc.

441 {}

◆ endRunProduce()

void LumiProducer::endRunProduce ( edm::Run run,
edm::EventSetup const &  iSetup 
)
finalprivate

Definition at line 442 of file LumiProducer.cc.

References LumiProducer::PerRunData::HLTPathNames, LumiProducer::PerRunData::HLTPathNameToIndex, m_runcache, eostools::move(), writedatasetfile::run, LumiProducer::PerRunData::TRGBitNames, and LumiProducer::PerRunData::TRGBitNameToIndex.

442  {
443  auto lsrh = std::make_unique<LumiSummaryRunHeader>();
444  lsrh->swapL1Names(m_runcache.TRGBitNames);
445  lsrh->swapHLTNames(m_runcache.HLTPathNames);
446  run.put(std::move(lsrh));
449 }
std::map< std::string, unsigned int > HLTPathNameToIndex
Definition: LumiProducer.cc:96
std::vector< std::string > TRGBitNames
Definition: LumiProducer.cc:97
std::vector< std::string > HLTPathNames
Definition: LumiProducer.cc:98
def move(src, dest)
Definition: eostools.py:511
std::map< std::string, unsigned int > TRGBitNameToIndex
Definition: LumiProducer.cc:95
PerRunData m_runcache

◆ fillLSCache()

void LumiProducer::fillLSCache ( unsigned int  luminum)
private

Definition at line 518 of file LumiProducer.cc.

References LumiProducer::HLTData::acceptcount, LumiProducer::L1Data::bitname, lumi::service::DBService::connectReadOnly(), Exception, dqmMemoryStats::float, LumiProducer::PerRunData::HLTPathNames, mps_fire::i, heavyIonCSV_trainingSettings::idx, createfilelist::int, edm::Service< T >::isAvailable(), cmsLHEtoEOSManager::l, LumiProducer::HLTData::l1passcount, lumi::LumiNames::lshltTableName(), lumi::LumiNames::lstrgTableName(), lumi::LumiNames::lumisummaryv2TableName(), m_cachedhltdataid, m_cachedlumidataid, m_cachedtrgdataid, m_cachesize, m_connectStr, m_isNullRun, m_lscache, m_runcache, dqmiodumpmetadata::n, LumiProducer::HLTData::pathname, LumiProducer::HLTData::prescale, LumiProducer::L1Data::prescale, hltrates_dqm_sourceclient-live_cfg::prescales, LumiProducer::L1Data::ratecount, AlCaHLTBitMon_QueryRunRegistry::string, and LumiProducer::PerRunData::TRGBitNames.

Referenced by beginLuminosityBlockProduce().

518  {
519  //initialize cache
520  if (m_isNullRun)
521  return;
522  m_lscache.clear();
523  for (unsigned int n = luminum; n < luminum + m_cachesize; ++n) {
524  PerLSData l;
525  l.hltdata.reserve(250);
526  l.l1data.reserve(192);
527  l.bunchlumivalue.reserve(5);
528  l.bunchlumierror.reserve(5);
529  l.bunchlumiquality.reserve(5);
530  l.beam1intensity.resize(3564, 0.0);
531  l.beam2intensity.resize(3564, 0.0);
532  m_lscache.insert(std::make_pair(n, l));
533  }
534  //queries once per cache refill
535  //
536  //select cmslsnum,instlumi,startorbit,numorbit,bxindex,beam1intensity,beam2intensity,bxlumivalue_occ1,bxlumivalue_occ2,bxlumivalue_et from lumisummaryv2 where cmslsnum>=:lsmin and cmslsnum<:lsmax and data_id=:lumidataid;
537  //
539  if (!mydbservice.isAvailable()) {
540  throw cms::Exception("Non existing service lumi::service::DBService");
541  }
542  auto session = mydbservice->connectReadOnly(m_connectStr);
543  try {
544  session->transaction().start(true);
545  coral::ISchema& schema = session->nominalSchema();
546  coral::AttributeList lumisummaryBindVariables;
547  lumisummaryBindVariables.extend("lsmin", typeid(unsigned int));
548  lumisummaryBindVariables.extend("lsmax", typeid(unsigned int));
549  lumisummaryBindVariables.extend("lumidataid", typeid(unsigned long long));
550  lumisummaryBindVariables["lumidataid"].data<unsigned long long>() = m_cachedlumidataid;
551  lumisummaryBindVariables["lsmin"].data<unsigned int>() = luminum;
552  lumisummaryBindVariables["lsmax"].data<unsigned int>() = luminum + m_cachesize;
553  coral::AttributeList lumisummaryOutput;
554  lumisummaryOutput.extend("CMSLSNUM", typeid(unsigned int));
555  lumisummaryOutput.extend("INSTLUMI", typeid(float));
556  lumisummaryOutput.extend("STARTORBIT", typeid(unsigned int));
557  lumisummaryOutput.extend("NUMORBIT", typeid(unsigned int));
558  lumisummaryOutput.extend("CMSBXINDEXBLOB", typeid(coral::Blob));
559  lumisummaryOutput.extend("BEAMINTENSITYBLOB_1", typeid(coral::Blob));
560  lumisummaryOutput.extend("BEAMINTENSITYBLOB_2", typeid(coral::Blob));
561  lumisummaryOutput.extend("BXLUMIVALUE_OCC1", typeid(coral::Blob));
562  lumisummaryOutput.extend("BXLUMIVALUE_OCC2", typeid(coral::Blob));
563  lumisummaryOutput.extend("BXLUMIVALUE_ET", typeid(coral::Blob));
564  coral::IQuery* lumisummaryQuery = schema.newQuery();
565  lumisummaryQuery->addToTableList(lumi::LumiNames::lumisummaryv2TableName());
566  lumisummaryQuery->addToOutputList("CMSLSNUM");
567  lumisummaryQuery->addToOutputList("INSTLUMI");
568  lumisummaryQuery->addToOutputList("STARTORBIT");
569  lumisummaryQuery->addToOutputList("NUMORBIT");
570  lumisummaryQuery->addToOutputList("CMSBXINDEXBLOB");
571  lumisummaryQuery->addToOutputList("BEAMINTENSITYBLOB_1");
572  lumisummaryQuery->addToOutputList("BEAMINTENSITYBLOB_2");
573  lumisummaryQuery->addToOutputList("BXLUMIVALUE_OCC1");
574  lumisummaryQuery->addToOutputList("BXLUMIVALUE_OCC2");
575  lumisummaryQuery->addToOutputList("BXLUMIVALUE_ET");
576  lumisummaryQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:lumidataid",
577  lumisummaryBindVariables);
578  lumisummaryQuery->defineOutput(lumisummaryOutput);
579  coral::ICursor& lumisummarycursor = lumisummaryQuery->execute();
580  unsigned int rowcounter = 0;
581  while (lumisummarycursor.next()) {
582  const coral::AttributeList& row = lumisummarycursor.currentRow();
583  unsigned int cmslsnum = row["CMSLSNUM"].data<unsigned int>();
584  //std::cout<<"cmslsnum "<<cmslsnum<<std::endl;
585  PerLSData& lsdata = m_lscache[cmslsnum];
586  lsdata.lumivalue = row["INSTLUMI"].data<float>();
587  lsdata.lumierror = 0.0;
588  lsdata.lumiquality = 0;
589  lsdata.startorbit = row["STARTORBIT"].data<unsigned int>();
590  lsdata.numorbit = row["NUMORBIT"].data<unsigned int>();
591 
592  if (!row["CMSBXINDEXBLOB"].isNull() && !row["BXLUMIVALUE_OCC1"].isNull()) {
593  const coral::Blob& bxindexBlob = row["CMSBXINDEXBLOB"].data<coral::Blob>();
594  const void* bxindex_StartAddress = bxindexBlob.startingAddress();
595  short* bxindex = (short*)::malloc(bxindexBlob.size());
596  const coral::Blob& beam1intensityBlob = row["BEAMINTENSITYBLOB_1"].data<coral::Blob>();
597  const void* beam1intensityBlob_StartAddress = beam1intensityBlob.startingAddress();
598  float* beam1intensity = (float*)::malloc(beam1intensityBlob.size());
599  const coral::Blob& beam2intensityBlob = row["BEAMINTENSITYBLOB_2"].data<coral::Blob>();
600  const void* beam2intensityBlob_StartAddress = beam2intensityBlob.startingAddress();
601  float* beam2intensity = (float*)::malloc(beam2intensityBlob.size());
602  std::memmove(bxindex, bxindex_StartAddress, bxindexBlob.size());
603  std::memmove(beam1intensity, beam1intensityBlob_StartAddress, beam1intensityBlob.size());
604  std::memmove(beam2intensity, beam2intensityBlob_StartAddress, beam2intensityBlob.size());
605 
606  unsigned int iMax = bxindexBlob.size() / sizeof(short);
607  unsigned int lsb1Max = lsdata.beam1intensity.size();
608  unsigned int lsb2Max = lsdata.beam2intensity.size();
609  unsigned int ib1Max = beam1intensityBlob.size() / sizeof(float);
610  unsigned int ib2Max = beam2intensityBlob.size() / sizeof(float);
611  for (unsigned int i = 0; i < iMax; ++i) {
612  unsigned int idx = bxindex[i];
613  if (ib1Max > i && lsb1Max > idx) {
614  lsdata.beam1intensity.at(idx) = beam1intensity[i];
615  }
616  if (ib2Max > i && lsb2Max > idx) {
617  lsdata.beam2intensity.at(idx) = beam2intensity[i];
618  }
619  }
620  ::free(bxindex);
621  ::free(beam1intensity);
622  ::free(beam2intensity);
623 
624  const coral::Blob& bxlumivalBlob_occ1 = row["BXLUMIVALUE_OCC1"].data<coral::Blob>();
625  const void* bxlumival_occ1_StartAddress = bxlumivalBlob_occ1.startingAddress();
626  float* bxlumival_occ1 = (float*)::malloc(bxlumivalBlob_occ1.size());
627  std::memmove(bxlumival_occ1, bxlumival_occ1_StartAddress, bxlumivalBlob_occ1.size());
628  std::vector<float> bxlumivalVec_occ1(bxlumival_occ1,
629  bxlumival_occ1 + bxlumivalBlob_occ1.size() / sizeof(float));
630  ::free(bxlumival_occ1);
631  lsdata.bunchlumivalue.push_back(std::make_pair(std::string("OCC1"), bxlumivalVec_occ1));
632  lsdata.bunchlumierror.push_back(std::make_pair(std::string("OCC1"), std::vector<float>(3564)));
633  lsdata.bunchlumiquality.push_back(std::make_pair(std::string("OCC1"), std::vector<short>(3564)));
634  const coral::Blob& bxlumivalBlob_occ2 = row["BXLUMIVALUE_OCC2"].data<coral::Blob>();
635  const void* bxlumival_occ2_StartAddress = bxlumivalBlob_occ2.startingAddress();
636  float* bxlumival_occ2 = (float*)::malloc(bxlumivalBlob_occ2.size());
637  std::memmove(bxlumival_occ2, bxlumival_occ2_StartAddress, bxlumivalBlob_occ2.size());
638  std::vector<float> bxlumivalVec_occ2(bxlumival_occ2,
639  bxlumival_occ2 + bxlumivalBlob_occ1.size() / sizeof(float));
640  ::free(bxlumival_occ2);
641  lsdata.bunchlumivalue.push_back(std::make_pair(std::string("OCC2"), bxlumivalVec_occ2));
642  lsdata.bunchlumierror.push_back(std::make_pair(std::string("OCC2"), std::vector<float>(3564)));
643  lsdata.bunchlumiquality.push_back(std::make_pair(std::string("OCC2"), std::vector<short>(3564)));
644 
645  const coral::Blob& bxlumivalBlob_et = row["BXLUMIVALUE_ET"].data<coral::Blob>();
646  const void* bxlumival_et_StartAddress = bxlumivalBlob_et.startingAddress();
647  float* bxlumival_et = (float*)::malloc(bxlumivalBlob_et.size());
648  std::memmove(bxlumival_et, bxlumival_et_StartAddress, bxlumivalBlob_et.size());
649  std::vector<float> bxlumivalVec_et(bxlumival_et, bxlumival_et + bxlumivalBlob_et.size() / sizeof(float));
650  ::free(bxlumival_et);
651  lsdata.bunchlumivalue.push_back(std::make_pair(std::string("ET"), bxlumivalVec_et));
652  lsdata.bunchlumierror.push_back(std::make_pair(std::string("ET"), std::vector<float>(3564)));
653  lsdata.bunchlumiquality.push_back(std::make_pair(std::string("ET"), std::vector<short>(3564)));
654  }
655  ++rowcounter;
656  }
657  if (rowcounter == 0) {
658  m_isNullRun = true;
659  return;
660  }
661  delete lumisummaryQuery;
662 
663  //
664  //select cmslsnum,deadtimecount,bitzerocount,bitzeroprescale,prescaleblob,trgcountblob from lstrg where cmslsnum >=:luminum and cmslsnum<:luminum+cachesize AND data_id=:trgdataid;
665  //
666  coral::AttributeList trgBindVariables;
667  trgBindVariables.extend("lsmin", typeid(unsigned int));
668  trgBindVariables.extend("lsmax", typeid(unsigned int));
669  trgBindVariables.extend("trgdataid", typeid(unsigned long long));
670  trgBindVariables["lsmin"].data<unsigned int>() = luminum;
671  trgBindVariables["lsmax"].data<unsigned int>() = luminum + m_cachesize;
672  trgBindVariables["trgdataid"].data<unsigned long long>() = m_cachedtrgdataid;
673  coral::AttributeList trgOutput;
674  trgOutput.extend("CMSLSNUM", typeid(unsigned int));
675  trgOutput.extend("DEADTIMECOUNT", typeid(unsigned long long));
676  trgOutput.extend("BITZEROCOUNT", typeid(unsigned int));
677  trgOutput.extend("BITZEROPRESCALE", typeid(unsigned int));
678  trgOutput.extend("PRESCALEBLOB", typeid(coral::Blob));
679  trgOutput.extend("TRGCOUNTBLOB", typeid(coral::Blob));
680 
681  coral::IQuery* trgQuery = schema.newQuery();
682  trgQuery->addToTableList(lumi::LumiNames::lstrgTableName());
683  trgQuery->addToOutputList("CMSLSNUM");
684  trgQuery->addToOutputList("DEADTIMECOUNT");
685  trgQuery->addToOutputList("BITZEROCOUNT");
686  trgQuery->addToOutputList("BITZEROPRESCALE");
687  trgQuery->addToOutputList("PRESCALEBLOB");
688  trgQuery->addToOutputList("TRGCOUNTBLOB");
689  trgQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:trgdataid", trgBindVariables);
690  trgQuery->defineOutput(trgOutput);
691  coral::ICursor& trgcursor = trgQuery->execute();
692  while (trgcursor.next()) {
693  const coral::AttributeList& row = trgcursor.currentRow();
694  unsigned int cmslsnum = row["CMSLSNUM"].data<unsigned int>();
695  PerLSData& lsdata = m_lscache[cmslsnum];
696  lsdata.deadcount = row["DEADTIMECOUNT"].data<unsigned long long>();
697  lsdata.bitzerocount = row["BITZEROCOUNT"].data<unsigned int>();
698  lsdata.bitzeroprescale = row["BITZEROPRESCALE"].data<unsigned int>();
699  if (!row["PRESCALEBLOB"].isNull()) {
700  const coral::Blob& prescaleblob = row["PRESCALEBLOB"].data<coral::Blob>();
701  const void* prescaleblob_StartAddress = prescaleblob.startingAddress();
702  unsigned int* prescales = (unsigned int*)::malloc(prescaleblob.size());
703  std::memmove(prescales, prescaleblob_StartAddress, prescaleblob.size());
704  const coral::Blob& trgcountblob = row["TRGCOUNTBLOB"].data<coral::Blob>();
705  const void* trgcountblob_StartAddress = trgcountblob.startingAddress();
706  unsigned int* trgcounts = (unsigned int*)::malloc(trgcountblob.size());
707  std::memmove(trgcounts, trgcountblob_StartAddress, trgcountblob.size());
708  for (unsigned int i = 0; i < trgcountblob.size() / sizeof(unsigned int); ++i) {
709  L1Data l1tmp;
710  l1tmp.bitname = m_runcache.TRGBitNames[i];
711  l1tmp.prescale = prescales[i];
712  l1tmp.ratecount = trgcounts[i];
713  lsdata.l1data.push_back(l1tmp);
714  }
715  ::free(prescales);
716  ::free(trgcounts);
717  }
718  }
719  delete trgQuery;
720  //
721  //select cmslsnum,hltcountblob,hltacceptblob,prescaleblob from hlt where cmslsnum >=:luminum and cmslsnum<=:luminum+cachesize and data_id=:hltdataid
722  //
723  coral::AttributeList hltBindVariables;
724  hltBindVariables.extend("lsmin", typeid(unsigned int));
725  hltBindVariables.extend("lsmax", typeid(unsigned int));
726  hltBindVariables.extend("hltdataid", typeid(unsigned long long));
727  hltBindVariables["lsmin"].data<unsigned int>() = luminum;
728  hltBindVariables["lsmax"].data<unsigned int>() = luminum + m_cachesize;
729  hltBindVariables["hltdataid"].data<unsigned long long>() = m_cachedhltdataid;
730  coral::AttributeList hltOutput;
731  hltOutput.extend("CMSLSNUM", typeid(unsigned int));
732  hltOutput.extend("HLTCOUNTBLOB", typeid(coral::Blob));
733  hltOutput.extend("HLTACCEPTBLOB", typeid(coral::Blob));
734  hltOutput.extend("PRESCALEBLOB", typeid(coral::Blob));
735  coral::IQuery* hltQuery = schema.newQuery();
736  hltQuery->addToTableList(lumi::LumiNames::lshltTableName());
737  hltQuery->addToOutputList("CMSLSNUM");
738  hltQuery->addToOutputList("HLTCOUNTBLOB");
739  hltQuery->addToOutputList("HLTACCEPTBLOB");
740  hltQuery->addToOutputList("PRESCALEBLOB");
741  hltQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:hltdataid", hltBindVariables);
742  hltQuery->defineOutput(hltOutput);
743  coral::ICursor& hltcursor = hltQuery->execute();
744  while (hltcursor.next()) {
745  const coral::AttributeList& row = hltcursor.currentRow();
746  unsigned int cmslsnum = row["CMSLSNUM"].data<unsigned int>();
747  PerLSData& lsdata = m_lscache[cmslsnum];
748  if (!row["PRESCALEBLOB"].isNull()) {
749  const coral::Blob& hltprescaleblob = row["PRESCALEBLOB"].data<coral::Blob>();
750  const void* hltprescaleblob_StartAddress = hltprescaleblob.startingAddress();
751  unsigned int* hltprescales = (unsigned int*)::malloc(hltprescaleblob.size());
752  std::memmove(hltprescales, hltprescaleblob_StartAddress, hltprescaleblob.size());
753  const coral::Blob& hltcountblob = row["HLTCOUNTBLOB"].data<coral::Blob>();
754  const void* hltcountblob_StartAddress = hltcountblob.startingAddress();
755  unsigned int* hltcounts = (unsigned int*)::malloc(hltcountblob.size());
756  std::memmove(hltcounts, hltcountblob_StartAddress, hltcountblob.size());
757  const coral::Blob& hltacceptblob = row["HLTACCEPTBLOB"].data<coral::Blob>();
758  const void* hltacceptblob_StartAddress = hltacceptblob.startingAddress();
759  unsigned int* hltaccepts = (unsigned int*)::malloc(hltacceptblob.size());
760  std::memmove(hltaccepts, hltacceptblob_StartAddress, hltacceptblob.size());
761  unsigned int nhltaccepts = hltacceptblob.size() / sizeof(unsigned int);
762  if (nhltaccepts > 0 && m_runcache.HLTPathNames.empty()) {
763  edm::LogWarning("CorruptOrMissingHLTData")
764  << "Got " << nhltaccepts << " hltaccepts, but the run chache is empty. hltdata will not be written";
765  break;
766  }
767 
768  for (unsigned int i = 0; i < hltacceptblob.size() / sizeof(unsigned int); ++i) {
769  HLTData hlttmp;
770  hlttmp.pathname = m_runcache.HLTPathNames[i];
771  hlttmp.prescale = hltprescales[i];
772  hlttmp.l1passcount = hltcounts[i];
773  hlttmp.acceptcount = hltaccepts[i];
774  lsdata.hltdata.push_back(hlttmp);
775  }
776  ::free(hltprescales);
777  ::free(hltcounts);
778  ::free(hltaccepts);
779  }
780  }
781  delete hltQuery;
782  session->transaction().commit();
783  } catch (const coral::Exception& er) {
784  session->transaction().rollback();
785  throw cms::Exception("DatabaseError ") << er.what();
786  }
787 }
static const std::string lshltTableName()
Definition: LumiNames.cc:16
unsigned long long m_cachedhltdataid
ISessionProxyPtr connectReadOnly(const std::string &connectstring)
Definition: DBService.cc:19
static const std::string lstrgTableName()
Definition: LumiNames.cc:12
std::string m_connectStr
unsigned long long m_cachedtrgdataid
unsigned long long m_cachedlumidataid
std::vector< std::string > TRGBitNames
Definition: LumiProducer.cc:97
static const std::string lumisummaryv2TableName()
Definition: LumiNames.cc:6
unsigned int m_cachesize
bool isAvailable() const
Definition: Service.h:40
std::map< unsigned int, PerLSData > m_lscache
Log< level::Warning, false > LogWarning
std::vector< std::string > HLTPathNames
Definition: LumiProducer.cc:98
PerRunData m_runcache

◆ fillLumi()

bool LumiProducer::fillLumi ( edm::LuminosityBlock iLBlock)
private

◆ fillRunCache()

void LumiProducer::fillRunCache ( const coral::ISchema &  schema,
unsigned int  runnumber 
)
private

Definition at line 450 of file LumiProducer.cc.

References LumiProducer::PerRunData::bitzeroname, gather_cfg::cout, getCurrentDataTag(), lumi::LumiNames::hltdataTableName(), LumiProducer::PerRunData::HLTPathNames, LumiProducer::PerRunData::HLTPathNameToIndex, mps_fire::i, m_cachedhltdataid, m_cachedtrgdataid, m_lumiversion, m_runcache, AlCaHLTBitMon_QueryRunRegistry::string, LumiProducer::PerRunData::TRGBitNames, LumiProducer::PerRunData::TRGBitNameToIndex, and lumi::LumiNames::trgdataTableName().

Referenced by beginRun().

450  {
451  if (m_lumiversion.empty()) {
453  }
454  std::cout << "lumi tag version 2 " << m_lumiversion << std::endl;
455  if (m_cachedtrgdataid != 0) {
456  coral::AttributeList trgBindVariables;
457  trgBindVariables.extend("trgdataid", typeid(unsigned long long));
458  trgBindVariables["trgdataid"].data<unsigned long long>() = m_cachedtrgdataid;
459  //std::cout<<"cached trgdataid "<<m_cachedtrgdataid<<std::endl;
460  coral::AttributeList trgOutput;
461  trgOutput.extend("bitzeroname", typeid(std::string));
462  trgOutput.extend("bitnameclob", typeid(std::string));
463  coral::IQuery* trgQuery = schema.newQuery();
464  trgQuery->addToTableList(lumi::LumiNames::trgdataTableName());
465  trgQuery->addToOutputList("BITZERONAME");
466  trgQuery->addToOutputList("BITNAMECLOB");
467  trgQuery->setCondition("DATA_ID=:trgdataid", trgBindVariables);
468  trgQuery->defineOutput(trgOutput);
469  coral::ICursor& trgcursor = trgQuery->execute();
470  while (trgcursor.next()) {
471  const coral::AttributeList& row = trgcursor.currentRow();
472  m_runcache.bitzeroname = row["bitzeroname"].data<std::string>();
473  //std::cout<<"bitzeroname "<<m_runcache.bitzeroname<<std::endl;
474  std::string bitnames = row["bitnameclob"].data<std::string>();
475  boost::char_separator<char> sep(",");
476  boost::tokenizer<boost::char_separator<char> > tokens(bitnames, sep);
477  for (boost::tokenizer<boost::char_separator<char> >::iterator tok_it = tokens.begin(); tok_it != tokens.end();
478  ++tok_it) {
479  m_runcache.TRGBitNames.push_back(*tok_it);
480  }
481  for (unsigned int i = 0; i < m_runcache.TRGBitNames.size(); ++i) {
482  m_runcache.TRGBitNameToIndex.insert(std::make_pair(m_runcache.TRGBitNames.at(i), i));
483  }
484  }
485  delete trgQuery;
486  }
487  if (m_cachedhltdataid != 0) {
488  //
489  //select pathnameclob from hltdata where data_id=:hltdataid
490  //
491  coral::AttributeList hltBindVariables;
492  hltBindVariables.extend("hltdataid", typeid(unsigned long long));
493  hltBindVariables["hltdataid"].data<unsigned long long>() = m_cachedhltdataid;
494  coral::AttributeList hltOutput;
495  hltOutput.extend("PATHNAMECLOB", typeid(std::string));
496  coral::IQuery* hltQuery = schema.newQuery();
497  hltQuery->addToTableList(lumi::LumiNames::hltdataTableName());
498  hltQuery->addToOutputList("PATHNAMECLOB");
499  hltQuery->setCondition("DATA_ID=:hltdataid", hltBindVariables);
500  hltQuery->defineOutput(hltOutput);
501  coral::ICursor& hltcursor = hltQuery->execute();
502  while (hltcursor.next()) {
503  const coral::AttributeList& row = hltcursor.currentRow();
504  std::string pathnames = row["PATHNAMECLOB"].data<std::string>();
505  boost::char_separator<char> sep(",");
506  boost::tokenizer<boost::char_separator<char> > tokens(pathnames, sep);
507  for (boost::tokenizer<boost::char_separator<char> >::iterator tok_it = tokens.begin(); tok_it != tokens.end();
508  ++tok_it) {
509  m_runcache.HLTPathNames.push_back(*tok_it);
510  }
511  for (unsigned int i = 0; i < m_runcache.HLTPathNames.size(); ++i) {
512  m_runcache.HLTPathNameToIndex.insert(std::make_pair(m_runcache.HLTPathNames.at(i), i));
513  }
514  }
515  delete hltQuery;
516  }
517 }
static const std::string trgdataTableName()
Definition: LumiNames.cc:11
unsigned long long m_cachedhltdataid
static const std::string hltdataTableName()
Definition: LumiNames.cc:15
std::map< std::string, unsigned int > HLTPathNameToIndex
Definition: LumiProducer.cc:96
unsigned long long m_cachedtrgdataid
std::vector< std::string > TRGBitNames
Definition: LumiProducer.cc:97
std::string m_lumiversion
std::string getCurrentDataTag(const coral::ISchema &schema)
std::vector< std::string > HLTPathNames
Definition: LumiProducer.cc:98
std::map< std::string, unsigned int > TRGBitNameToIndex
Definition: LumiProducer.cc:95
PerRunData m_runcache

◆ getCurrentDataTag()

std::string LumiProducer::getCurrentDataTag ( const coral::ISchema &  schema)
private

Definition at line 365 of file LumiProducer.cc.

References mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, createPayload::tagname, and lumi::LumiNames::tagsTableName().

Referenced by fillRunCache().

365  {
366  //select tagid,tagname from tags
368  std::map<unsigned long long, std::string> alltags;
369  coral::IQuery* tagQuery = schema.newQuery();
370  tagQuery->addToTableList(lumi::LumiNames::tagsTableName());
371  tagQuery->addToOutputList("TAGID");
372  tagQuery->addToOutputList("TAGNAME");
373  coral::AttributeList tagoutput;
374  tagoutput.extend("TAGID", typeid(unsigned long long));
375  tagoutput.extend("TAGNAME", typeid(std::string));
376  tagQuery->defineOutput(tagoutput);
377  coral::ICursor& tagcursor = tagQuery->execute();
378  while (tagcursor.next()) {
379  const coral::AttributeList& row = tagcursor.currentRow();
380  unsigned long long tagid = row["TAGID"].data<unsigned long long>();
381  const std::string tagname = row["TAGNAME"].data<std::string>();
382  alltags.insert(std::make_pair(tagid, tagname));
383  }
384  delete tagQuery;
385  unsigned long long maxid = 0;
386  for (std::map<unsigned long long, std::string>::iterator it = alltags.begin(); it != alltags.end(); ++it) {
387  if (it->first > maxid) {
388  maxid = it->first;
389  }
390  }
391  result = alltags[maxid];
392  return result;
393 }
static const std::string tagsTableName()
Definition: LumiNames.cc:18

◆ getHltDataId()

unsigned long long LumiProducer::getHltDataId ( const coral::ISchema &  schema,
unsigned int  runnumber 
)
private

Definition at line 339 of file LumiProducer.cc.

References lumi::LumiNames::hltdataTableName(), and cond::runnumber.

Referenced by beginRun().

339  {
340  //
341  //select max(data_id) from hltdata where runnum=:runnum
342  //
343  unsigned long long hltdataid = 0;
344  coral::AttributeList bindVariables;
345  bindVariables.extend("runnum", typeid(unsigned int));
346  bindVariables["runnum"].data<unsigned int>() = runnumber;
347  coral::AttributeList hltidOutput;
348  hltidOutput.extend("hltdataid", typeid(unsigned long long));
349  coral::IQuery* hltQuery = schema.newQuery();
350  hltQuery->addToTableList(lumi::LumiNames::hltdataTableName());
351  hltQuery->addToOutputList("MAX(DATA_ID)", "hltdataid");
352  hltQuery->setCondition("RUNNUM=:runnum", bindVariables);
353  hltQuery->defineOutput(hltidOutput);
354  coral::ICursor& hltcursor = hltQuery->execute();
355  while (hltcursor.next()) {
356  const coral::AttributeList& row = hltcursor.currentRow();
357  if (!row["hltdataid"].isNull()) {
358  hltdataid = row["hltdataid"].data<unsigned long long>();
359  }
360  }
361  delete hltQuery;
362  return hltdataid;
363 }
static const std::string hltdataTableName()
Definition: LumiNames.cc:15

◆ getLumiDataId()

unsigned long long LumiProducer::getLumiDataId ( const coral::ISchema &  schema,
unsigned int  runnumber 
)
private

Definition at line 288 of file LumiProducer.cc.

References lumi::LumiNames::lumidataTableName(), and cond::runnumber.

Referenced by beginRun().

288  {
289  //
290  //select max(data_id) from lumidata where runnum=:runnum
291  //
292  //std::count<<"entering getLumiDataId "<<std::endl;
293  unsigned long long lumidataid = 0;
294  coral::AttributeList bindVariables;
295  bindVariables.extend("runnum", typeid(unsigned int));
296  bindVariables["runnum"].data<unsigned int>() = runnumber;
297  coral::AttributeList lumiidOutput;
298  lumiidOutput.extend("lumidataid", typeid(unsigned long long));
299  coral::IQuery* lumiQuery = schema.newQuery();
300  lumiQuery->addToTableList(lumi::LumiNames::lumidataTableName());
301  lumiQuery->addToOutputList("MAX(DATA_ID)", "lumidataid");
302  lumiQuery->setCondition("RUNNUM=:runnum", bindVariables);
303  lumiQuery->defineOutput(lumiidOutput);
304  coral::ICursor& lumicursor = lumiQuery->execute();
305  while (lumicursor.next()) {
306  const coral::AttributeList& row = lumicursor.currentRow();
307  if (!row["lumidataid"].isNull()) {
308  lumidataid = row["lumidataid"].data<unsigned long long>();
309  }
310  }
311  delete lumiQuery;
312  return lumidataid;
313 }
static const std::string lumidataTableName()
Definition: LumiNames.cc:3

◆ getTrgDataId()

unsigned long long LumiProducer::getTrgDataId ( const coral::ISchema &  schema,
unsigned int  runnumber 
)
private

Definition at line 314 of file LumiProducer.cc.

References cond::runnumber, and lumi::LumiNames::trgdataTableName().

Referenced by beginRun().

314  {
315  //
316  //select max(data_id) from trgdata where runnum=:runnum
317  //
318  unsigned long long trgdataid = 0;
319  coral::AttributeList bindVariables;
320  bindVariables.extend("runnum", typeid(unsigned int));
321  bindVariables["runnum"].data<unsigned int>() = runnumber;
322  coral::AttributeList trgidOutput;
323  trgidOutput.extend("trgdataid", typeid(unsigned long long));
324  coral::IQuery* trgQuery = schema.newQuery();
325  trgQuery->addToTableList(lumi::LumiNames::trgdataTableName());
326  trgQuery->addToOutputList("MAX(DATA_ID)", "trgdataid");
327  trgQuery->setCondition("RUNNUM=:runnum", bindVariables);
328  trgQuery->defineOutput(trgidOutput);
329  coral::ICursor& trgcursor = trgQuery->execute();
330  while (trgcursor.next()) {
331  const coral::AttributeList& row = trgcursor.currentRow();
332  if (!row["trgdataid"].isNull()) {
333  trgdataid = row["trgdataid"].data<unsigned long long>();
334  }
335  }
336  delete trgQuery;
337  return trgdataid;
338 }
static const std::string trgdataTableName()
Definition: LumiNames.cc:11

◆ produce()

void LumiProducer::produce ( edm::Event e,
const edm::EventSetup iSetup 
)
finalprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 287 of file LumiProducer.cc.

287 {}

◆ s2x()

XMLCh * LumiProducer::s2x ( const std::string &  input) const
private

Definition at line 166 of file LumiProducer.cc.

References groupFilesInBlocks::temp.

Referenced by servletTranslation().

166  {
167  XMLCh* buff = xercesc::XMLString::transcode(temp.c_str());
168  return buff;
169 }

◆ servletTranslation()

const std::string LumiProducer::servletTranslation ( const std::string &  servlet) const
private

Definition at line 195 of file LumiProducer.cc.

References boostedTaus_cff::doc, MillePedeFileConverter_cfg::e, m_siteconfpath, writedatasetfile::parser, s2x(), AlCaHLTBitMon_QueryRunRegistry::string, toParentString(), and cms::concurrency::xercesInitialize().

195  {
196  std::string frontierConnect;
197  std::string realconnect;
199  std::unique_ptr<xercesc::XercesDOMParser> parser(new xercesc::XercesDOMParser);
200  try {
201  parser->setValidationScheme(xercesc::XercesDOMParser::Val_Auto);
202  parser->setDoNamespaces(false);
203  parser->parse(m_siteconfpath.c_str());
204  xercesc::DOMDocument* doc = parser->getDocument();
205  if (!doc) {
206  return "";
207  }
208 
209  xercesc::DOMNodeList* frontierConnectList = doc->getElementsByTagName(s2x("frontier-connect"));
210  if (frontierConnectList->getLength() > 0) {
211  xercesc::DOMElement* frontierConnectElement = static_cast<xercesc::DOMElement*>(frontierConnectList->item(0));
212  frontierConnect = toParentString(*frontierConnectElement);
213  }
214  // Replace the last component of every "serverurl=" piece (up to the
215  // next close-paren) with the servlet
216  std::string::size_type nextparen = 0;
217  std::string::size_type serverurl, lastslash;
218  std::string complexstr = "";
219  while ((serverurl = frontierConnect.find("(serverurl=", nextparen)) != std::string::npos) {
220  realconnect.append(frontierConnect, nextparen, serverurl - nextparen);
221  nextparen = frontierConnect.find(')', serverurl);
222  lastslash = frontierConnect.rfind('/', nextparen);
223  realconnect.append(frontierConnect, serverurl, lastslash - serverurl + 1);
224  realconnect.append(servlet);
225  }
226  realconnect.append(frontierConnect, nextparen, frontierConnect.length() - nextparen);
227  } catch (xercesc::DOMException& e) {
228  }
229  return realconnect;
230 }
void xercesInitialize()
Definition: Xerces.cc:18
uint16_t size_type
std::string m_siteconfpath
std::string toParentString(const xercesc::DOMNode &nodeToConvert) const
XMLCh * s2x(const std::string &input) const

◆ toParentString()

std::string LumiProducer::toParentString ( const xercesc::DOMNode &  nodeToConvert) const
private

Definition at line 171 of file LumiProducer.cc.

References mps_fire::i, dqmiolumiharvest::j, and x2s().

Referenced by servletTranslation().

171  {
172  std::ostringstream oss;
173  xercesc::DOMNodeList* childList = nodeToConvert.getChildNodes();
174 
175  unsigned int numNodes = childList->getLength();
176  for (unsigned int i = 0; i < numNodes; ++i) {
177  xercesc::DOMNode* childNode = childList->item(i);
178  if (childNode->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
179  continue;
180  xercesc::DOMElement* child = static_cast<xercesc::DOMElement*>(childNode);
181  xercesc::DOMNamedNodeMap* attributes = child->getAttributes();
182  unsigned int numAttributes = attributes->getLength();
183  for (unsigned int j = 0; j < numAttributes; ++j) {
184  xercesc::DOMNode* attributeNode = attributes->item(j);
185  if (attributeNode->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
186  continue;
187  xercesc::DOMAttr* attribute = static_cast<xercesc::DOMAttr*>(attributeNode);
188 
189  oss << "(" << x2s(child->getTagName()) << x2s(attribute->getName()) << "=" << x2s(attribute->getValue()) << ")";
190  }
191  }
192  return oss.str();
193 }
std::string x2s(const XMLCh *input) const

◆ writeProductsForEntry()

void LumiProducer::writeProductsForEntry ( edm::LuminosityBlock iLBlock,
unsigned int  runnumber,
unsigned int  luminum 
)
private

Definition at line 788 of file LumiProducer.cc.

References LumiProducer::PerLSData::beam1intensity, LumiProducer::PerLSData::beam2intensity, LumiProducer::PerLSData::bitzerocount, LumiProducer::PerLSData::bitzeroprescale, LumiProducer::PerLSData::bunchlumierror, LumiProducer::PerLSData::bunchlumiquality, LumiProducer::PerLSData::bunchlumivalue, LumiProducer::PerLSData::deadcount, LumiProducer::PerLSData::hltdata, LumiProducer::PerRunData::HLTPathNameToIndex, mps_fire::i, LumiDetails::kET, LumiDetails::kOCC1, LumiDetails::kOCC2, LumiDetails::kPLT, LumiProducer::PerLSData::l1data, LumiProducer::PerLSData::lumierror, LumiProducer::PerLSData::lumiquality, LumiProducer::PerLSData::lumivalue, m_isNullRun, m_lscache, m_lumiversion, m_runcache, eostools::move(), LumiProducer::PerLSData::numorbit, LumiSummary::HLT::pathnameidx, LumiSummary::L1::prescale, LumiSummary::HLT::prescale, edm::LuminosityBlock::put(), LumiProducer::PerLSData::startorbit, AlCaHLTBitMon_QueryRunRegistry::string, LumiProducer::PerRunData::TRGBitNameToIndex, and LumiSummary::L1::triggernameidx.

Referenced by beginLuminosityBlockProduce().

788  {
789  //std::cout<<"writing runnumber,luminum "<<runnumber<<" "<<luminum<<std::endl;
790  auto pIn1 = std::make_unique<LumiSummary>();
791  auto pIn2 = std::make_unique<LumiDetails>();
792  if (m_isNullRun) {
793  pIn1->setLumiVersion("-1");
794  pIn2->setLumiVersion("-1");
795  iLBlock.put(std::move(pIn1));
796  iLBlock.put(std::move(pIn2));
797  return;
798  }
799  PerLSData& lsdata = m_lscache[luminum];
800  pIn1->setLumiData(lsdata.lumivalue, lsdata.lumierror, lsdata.lumiquality);
801  pIn1->setDeadCount(lsdata.deadcount);
802  if (!lsdata.l1data.empty()) {
803  //std::cout<<"bitzerocount "<<lsdata.bitzerocount<<std::endl;
804  //std::cout<<"bitzeroprescale "<<lsdata.bitzeroprescale<<std::endl;
805  //std::cout<<"product "<<lsdata.bitzerocount*lsdata.bitzeroprescale<<std::endl;
806  pIn1->setBitZeroCount(lsdata.bitzerocount * lsdata.bitzeroprescale);
807  }
808  pIn1->setlsnumber(luminum);
809  pIn1->setOrbitData(lsdata.startorbit, lsdata.numorbit);
810  std::vector<LumiSummary::L1> l1temp;
811  for (std::vector<L1Data>::iterator it = lsdata.l1data.begin(); it != lsdata.l1data.end(); ++it) {
812  LumiSummary::L1 trgtmp;
813  trgtmp.triggernameidx = m_runcache.TRGBitNameToIndex[it->bitname];
814  trgtmp.prescale = it->prescale;
815  l1temp.push_back(trgtmp);
816  }
817  std::vector<LumiSummary::HLT> hlttemp;
818  for (std::vector<HLTData>::iterator it = lsdata.hltdata.begin(); it != lsdata.hltdata.end(); ++it) {
819  LumiSummary::HLT hlttmp;
820  hlttmp.pathnameidx = m_runcache.HLTPathNameToIndex[it->pathname];
821  ;
822  hlttmp.prescale = it->prescale;
823  hlttemp.push_back(hlttmp);
824  }
825  pIn1->swapL1Data(l1temp);
826  pIn1->swapHLTData(hlttemp);
827  pIn1->setLumiVersion(m_lumiversion);
828  pIn2->fillBeamIntensities(lsdata.beam1intensity, lsdata.beam2intensity);
829  for (unsigned int i = 0; i < lsdata.bunchlumivalue.size(); ++i) {
830  std::string algoname = lsdata.bunchlumivalue[i].first;
831  if (algoname == "OCC1") {
832  pIn2->fill(LumiDetails::kOCC1,
833  lsdata.bunchlumivalue[i].second,
834  lsdata.bunchlumierror[i].second,
835  lsdata.bunchlumiquality[i].second);
836  } else if (algoname == "OCC2") {
837  pIn2->fill(LumiDetails::kOCC2,
838  lsdata.bunchlumivalue[i].second,
839  lsdata.bunchlumierror[i].second,
840  lsdata.bunchlumiquality[i].second);
841  } else if (algoname == "ET") {
842  pIn2->fill(LumiDetails::kET,
843  lsdata.bunchlumivalue[i].second,
844  lsdata.bunchlumierror[i].second,
845  lsdata.bunchlumiquality[i].second);
846  } else if (algoname == "PLT") {
847  pIn2->fill(LumiDetails::kPLT,
848  lsdata.bunchlumivalue[i].second,
849  lsdata.bunchlumierror[i].second,
850  lsdata.bunchlumiquality[i].second);
851  }
852  }
853  pIn2->setLumiVersion(m_lumiversion);
854  iLBlock.put(std::move(pIn1));
855  iLBlock.put(std::move(pIn2));
856 }
std::map< std::string, unsigned int > HLTPathNameToIndex
Definition: LumiProducer.cc:96
unsigned int prescale
Definition: LumiSummary.h:26
void put(std::unique_ptr< PROD > product)
Put a new product.
std::string m_lumiversion
std::map< unsigned int, PerLSData > m_lscache
def move(src, dest)
Definition: eostools.py:511
std::map< std::string, unsigned int > TRGBitNameToIndex
Definition: LumiProducer.cc:95
PerRunData m_runcache
unsigned int prescale
Definition: LumiSummary.h:32

◆ x2s()

std::string LumiProducer::x2s ( const XMLCh *  input) const
private

Definition at line 161 of file LumiProducer.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

Referenced by toParentString().

161  {
162  std::string tmp(xercesc::XMLString::transcode(toTranscode));
163  return tmp;
164 }
tmp
align.sh
Definition: createJobs.py:716

Member Data Documentation

◆ m_cachedhltdataid

unsigned long long LumiProducer::m_cachedhltdataid
private

Definition at line 150 of file LumiProducer.cc.

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

◆ m_cachedlumidataid

unsigned long long LumiProducer::m_cachedlumidataid
private

Definition at line 148 of file LumiProducer.cc.

Referenced by beginRun(), and fillLSCache().

◆ m_cachedrun

unsigned int LumiProducer::m_cachedrun
private

Definition at line 147 of file LumiProducer.cc.

Referenced by beginRun().

◆ m_cachedtrgdataid

unsigned long long LumiProducer::m_cachedtrgdataid
private

Definition at line 149 of file LumiProducer.cc.

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

◆ m_cachesize

unsigned int LumiProducer::m_cachesize
private

Definition at line 154 of file LumiProducer.cc.

Referenced by fillLSCache().

◆ m_connectStr

std::string LumiProducer::m_connectStr
private

Definition at line 144 of file LumiProducer.cc.

Referenced by beginRun(), and fillLSCache().

◆ m_isNullRun

bool LumiProducer::m_isNullRun
private

◆ m_lscache

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

◆ m_lumiversion

std::string LumiProducer::m_lumiversion
private

Definition at line 145 of file LumiProducer.cc.

Referenced by fillRunCache(), and writeProductsForEntry().

◆ m_runcache

PerRunData LumiProducer::m_runcache
private

Definition at line 151 of file LumiProducer.cc.

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

◆ m_siteconfpath

std::string LumiProducer::m_siteconfpath
private

Definition at line 146 of file LumiProducer.cc.

Referenced by servletTranslation().