CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DIPLumiProducer Class Reference

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

Inheritance diagram for DIPLumiProducer:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef std::shared_ptr< const DIPLumiDetailReturnDetailType
 
typedef std::shared_ptr< const DIPLumiSummaryReturnSummaryType
 

Public Member Functions

 DIPLumiProducer (const edm::ParameterSet &)
 
ReturnDetailType produceDetail (const DIPLuminosityRcd &)
 
ReturnSummaryType produceSummary (const DIPLuminosityRcd &)
 
 ~DIPLumiProducer () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Protected Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Private Member Functions

void filldetailcache (unsigned int runnumber, unsigned int startlsnum)
 
void fillsummarycache (unsigned int runnumber, unsigned int startlsnum)
 
unsigned int maxavailableLSforRun (coral::ISchema &schema, const std::string &tablename, unsigned int runnumber)
 

Private Attributes

unsigned int m_cachesize
 
std::string m_connectStr
 
std::map< unsigned int, std::shared_ptr< const DIPLumiDetail > > m_detailcache
 
unsigned int m_detailcachedrun
 
std::shared_ptr< const DIPLumiDetailm_detailresult
 
bool m_isNullRun
 
const edm::IOVSyncValuem_pcurrentTime
 
std::map< unsigned int, std::shared_ptr< const DIPLumiSummary > > m_summarycache
 
unsigned int m_summarycachedrun
 
std::shared_ptr< const DIPLumiSummarym_summaryresult
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 

Detailed Description

HF Luminosity numbers from DIP. Only exist if stable beam. No data available for other beam status

Description: A essource/esproducer for lumi values from DIP via runtime logger DB

Definition at line 22 of file DIPLumiProducer.h.

Member Typedef Documentation

◆ ReturnDetailType

typedef std::shared_ptr<const DIPLumiDetail> DIPLumiProducer::ReturnDetailType

Definition at line 27 of file DIPLumiProducer.h.

◆ ReturnSummaryType

typedef std::shared_ptr<const DIPLumiSummary> DIPLumiProducer::ReturnSummaryType

Definition at line 25 of file DIPLumiProducer.h.

Constructor & Destructor Documentation

◆ DIPLumiProducer()

DIPLumiProducer::DIPLumiProducer ( const edm::ParameterSet iConfig)

Definition at line 59 of file DIPLumiProducer.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_cachesize, m_connectStr, produceDetail(), produceSummary(), edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

63  findingRecord<DIPLuminosityRcd>();
64  m_connectStr = iConfig.getParameter<std::string>("connect");
65  m_cachesize = iConfig.getUntrackedParameter<unsigned int>("ncacheEntries", 3);
66 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
unsigned int m_detailcachedrun
std::string m_connectStr
ReturnDetailType produceDetail(const DIPLuminosityRcd &)
T getUntrackedParameter(std::string const &, T const &) const
unsigned int m_summarycachedrun
unsigned int m_cachesize
ReturnSummaryType produceSummary(const DIPLuminosityRcd &)

◆ ~DIPLumiProducer()

DIPLumiProducer::~DIPLumiProducer ( )
override

Definition at line 342 of file DIPLumiProducer.cc.

342 {}

Member Function Documentation

◆ filldetailcache()

void DIPLumiProducer::filldetailcache ( unsigned int  runnumber,
unsigned int  startlsnum 
)
private

Definition at line 262 of file DIPLumiProducer.cc.

References lumi::service::DBService::connectReadOnly(), Exception, edm::Service< T >::isAvailable(), B2GTnPMonitor_cfi::item, remoteMonitoring_LASER_era2018_cfg::lsmax, remoteMonitoring_LASER_era2018_cfg::lsmin, m_cachesize, m_connectStr, m_detailcache, m_detailcachedrun, m_summarycachedrun, maxavailableLSforRun(), eostools::move(), cond::runnumber, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by produceDetail().

262  {
263  m_detailcache.clear();
265 
266  std::map<unsigned int, std::unique_ptr<DIPLumiDetail> > detailcache;
267  //
268  //queries once per cache refill
269  //
270  //select lumisection,bunch,bunchlumi from cms_runtime_logger.bunch_lumi_sections where lumisection>=:lsmin and lumisection<:lsmax and runnumber=:runnumber ;
271  //
273  if (!mydbservice.isAvailable()) {
274  throw cms::Exception("Non existing service lumi::service::DBService");
275  }
276  auto session = mydbservice->connectReadOnly(m_connectStr);
277  coral::ITypeConverter& tconverter = session->typeConverter();
278  tconverter.setCppTypeForSqlType(std::string("float"), std::string("FLOAT(63)"));
279  tconverter.setCppTypeForSqlType(std::string("unsigned int"), std::string("NUMBER(10)"));
280  unsigned int lsmin = 1;
281  unsigned int lsmax = currentlsnum;
282  try {
283  session->transaction().start(true);
284  coral::ISchema& schema = session->nominalSchema();
285  unsigned int maxavailableLS = maxavailableLSforRun(schema, std::string("BUNCH_LUMI_SECTIONS"), m_summarycachedrun);
286  if (maxavailableLS != 0 && maxavailableLS < currentlsnum) {
287  lsmax = maxavailableLS;
288  } else if (maxavailableLS == 0) {
289  //this run not existing (yet)
290  session->transaction().commit();
291  return;
292  }
293  if (m_cachesize != 0) {
294  lsmin = (lsmax - m_cachesize) > 0 ? (lsmax - m_cachesize + 1) : 1;
295  }
296  coral::AttributeList lumidetailBindVariables;
297  lumidetailBindVariables.extend("lsmin", typeid(unsigned int));
298  lumidetailBindVariables.extend("lsmax", typeid(unsigned int));
299  lumidetailBindVariables.extend("runnumber", typeid(unsigned int));
300  lumidetailBindVariables["runnumber"].data<unsigned int>() = m_detailcachedrun;
301  lumidetailBindVariables["lsmin"].data<unsigned int>() = lsmin;
302  lumidetailBindVariables["lsmax"].data<unsigned int>() = lsmax;
303  std::string conditionStr("RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax AND BUNCHLUMI>0 ");
304  coral::AttributeList lumidetailOutput;
305  lumidetailOutput.extend("LUMISECTION", typeid(unsigned int));
306  lumidetailOutput.extend("BUNCH", typeid(unsigned int));
307  lumidetailOutput.extend("BUNCHLUMI", typeid(float));
308  coral::IQuery* lumidetailQuery = schema.newQuery();
309  lumidetailQuery->addToTableList(std::string("BUNCH_LUMI_SECTIONS"));
310  lumidetailQuery->addToOutputList("LUMISECTION");
311  lumidetailQuery->addToOutputList("BUNCH");
312  lumidetailQuery->addToOutputList("BUNCHLUMI");
313  lumidetailQuery->setCondition(conditionStr, lumidetailBindVariables);
314  lumidetailQuery->defineOutput(lumidetailOutput);
315  coral::ICursor& lumidetailcursor = lumidetailQuery->execute();
316  while (lumidetailcursor.next()) {
317  const coral::AttributeList& row = lumidetailcursor.currentRow();
318  unsigned int lsnum = row["LUMISECTION"].data<unsigned int>();
319  if (detailcache.find(lsnum) == detailcache.end()) {
320  detailcache.insert(std::make_pair(lsnum, std::make_unique<DIPLumiDetail>()));
321  detailcache[lsnum]->setOrigin(m_detailcachedrun, lsnum);
322  }
323  if (!row["BUNCH"].isNull()) {
324  unsigned int bxidx = row["BUNCH"].data<unsigned int>();
325  float bxlumi = 0.0;
326  if (!row["BUNCHLUMI"].isNull()) {
327  bxlumi = row["BUNCHLUMI"].data<float>(); //Hz/ub
328  }
329  detailcache[lsnum]->fillbxdata(bxidx, bxlumi);
330  }
331  }
332  for (auto& item : detailcache) {
333  m_detailcache[item.first] = std::move(item.second);
334  }
335  delete lumidetailQuery;
336  session->transaction().commit();
337  } catch (const coral::Exception& er) {
338  session->transaction().rollback();
339  throw cms::Exception("DatabaseError ") << er.what();
340  }
341 }
unsigned int m_detailcachedrun
ISessionProxyPtr connectReadOnly(const std::string &connectstring)
Definition: DBService.cc:19
std::string m_connectStr
unsigned int m_summarycachedrun
std::map< unsigned int, std::shared_ptr< const DIPLumiDetail > > m_detailcache
unsigned int m_cachesize
unsigned int maxavailableLSforRun(coral::ISchema &schema, const std::string &tablename, unsigned int runnumber)
bool isAvailable() const
Definition: Service.h:40
def move(src, dest)
Definition: eostools.py:511

◆ fillsummarycache()

void DIPLumiProducer::fillsummarycache ( unsigned int  runnumber,
unsigned int  startlsnum 
)
private

Definition at line 141 of file DIPLumiProducer.cc.

References lumi::service::DBService::connectReadOnly(), Exception, edm::Service< T >::isAvailable(), remoteMonitoring_LASER_era2018_cfg::lsmax, remoteMonitoring_LASER_era2018_cfg::lsmin, m_cachesize, m_connectStr, m_summarycache, m_summarycachedrun, maxavailableLSforRun(), eostools::move(), cond::runnumber, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by produceSummary().

141  {
142  m_summarycache.clear();
144  //
145  // queries once per cache refill
146  //
147  // select max(lumi_sections) as maxavailable from cms_runtime_logger.lumi_sections where runnumber=:runnumber;
148  //
149  // if maxavailable<currentls: get lsmax=maxavailable ; else: get lsmax=currentls
150  // lsmin=lsmax-cachesize
151  // select runnumber,lumisection,instlumi,delivlumi,livelumi from cms_runtime_logger.lumi_sections where lumisection>=:lsmin and lumisection<=:lsmax and runnumber=:runnumber;
152  //
154  if (!mydbservice.isAvailable()) {
155  throw cms::Exception("Non existing service lumi::service::DBService");
156  }
157  auto session = mydbservice->connectReadOnly(m_connectStr);
158  coral::ITypeConverter& tconverter = session->typeConverter();
159  tconverter.setCppTypeForSqlType(std::string("float"), std::string("FLOAT(63)"));
160  tconverter.setCppTypeForSqlType(std::string("unsigned int"), std::string("NUMBER(10)"));
161  tconverter.setCppTypeForSqlType(std::string("unsigned short"), std::string("NUMBER(1)"));
162  unsigned int lsmin = 1;
163  unsigned int lsmax = currentlsnum;
164  try {
165  session->transaction().start(true);
166  coral::ISchema& schema = session->nominalSchema();
167  unsigned int maxavailableLS = maxavailableLSforRun(schema, std::string("LUMI_SECTIONS"), m_summarycachedrun);
168  if (maxavailableLS != 0 && maxavailableLS < currentlsnum) {
169  lsmax = maxavailableLS;
170  } else if (maxavailableLS == 0) {
171  //this run not existing (yet)
172  session->transaction().commit();
173  return;
174  }
175  if (m_cachesize != 0) {
176  lsmin = (lsmax - m_cachesize) > 0 ? (lsmax - m_cachesize + 1) : 1;
177  }
178  //std::cout<<"lsmin "<<lsmin<<" lsmax "<<lsmax<<std::endl;
179  coral::AttributeList lumisummaryBindVariables;
180  lumisummaryBindVariables.extend("lsmin", typeid(unsigned int));
181  lumisummaryBindVariables.extend("lsmax", typeid(unsigned int));
182  lumisummaryBindVariables.extend("runnumber", typeid(unsigned int));
183  lumisummaryBindVariables["runnumber"].data<unsigned int>() = m_summarycachedrun;
184  lumisummaryBindVariables["lsmin"].data<unsigned int>() = lsmin;
185  lumisummaryBindVariables["lsmax"].data<unsigned int>() = lsmax;
186  std::string conditionStr("RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND LUMISECTION<=:lsmax");
187  coral::AttributeList lumisummaryOutput;
188  lumisummaryOutput.extend("LUMISECTION", typeid(unsigned int));
189  lumisummaryOutput.extend("INSTLUMI", typeid(float));
190  lumisummaryOutput.extend("DELIVLUMISECTION", typeid(float));
191  lumisummaryOutput.extend("LIVELUMISECTION", typeid(float));
192  lumisummaryOutput.extend("CMS_ACTIVE", typeid(unsigned short));
193  coral::IQuery* lumisummaryQuery = schema.newQuery();
194  lumisummaryQuery->addToTableList(std::string("LUMI_SECTIONS"));
195  lumisummaryQuery->addToOutputList("LUMISECTION");
196  lumisummaryQuery->addToOutputList("INSTLUMI");
197  lumisummaryQuery->addToOutputList("DELIVLUMISECTION");
198  lumisummaryQuery->addToOutputList("LIVELUMISECTION");
199  lumisummaryQuery->addToOutputList("CMS_ACTIVE");
200  lumisummaryQuery->setCondition(conditionStr, lumisummaryBindVariables);
201  lumisummaryQuery->defineOutput(lumisummaryOutput);
202  coral::ICursor& lumisummarycursor = lumisummaryQuery->execute();
203  while (lumisummarycursor.next()) {
204  const coral::AttributeList& row = lumisummarycursor.currentRow();
205  unsigned int lsnum = row["LUMISECTION"].data<unsigned int>();
206  float instlumi = 0.0;
207  if (!row["INSTLUMI"].isNull()) {
208  instlumi = row["INSTLUMI"].data<float>(); //Hz/ub
209  }
210  float intgdellumi = 0.0;
211  if (!row["DELIVLUMISECTION"].isNull()) {
212  intgdellumi = row["DELIVLUMISECTION"].data<float>() * 1000.0; //convert to /ub
213  }
214  float intgreclumi = 0.0;
215  if (!row["LIVELUMISECTION"].isNull()) {
216  intgreclumi = row["LIVELUMISECTION"].data<float>() * 1000.0; //convert to /ub
217  }
218  unsigned short cmsalive = 0;
219  if (!row["CMS_ACTIVE"].isNull()) {
220  cmsalive = row["CMS_ACTIVE"].data<unsigned short>();
221  }
222  auto tmpls = std::make_unique<DIPLumiSummary>(instlumi, intgdellumi, intgreclumi, cmsalive);
223  tmpls->setOrigin(m_summarycachedrun, lsnum);
224  //std::cout<<"filling "<<lsnum<<std::endl;
225  std::shared_ptr<const DIPLumiSummary> const_tmpls = std::move(tmpls);
226  m_summarycache.insert(std::make_pair(lsnum, const_tmpls));
227  }
228  delete lumisummaryQuery;
229  session->transaction().commit();
230  } catch (const coral::Exception& er) {
231  session->transaction().rollback();
232  throw cms::Exception("DatabaseError ") << er.what();
233  }
234 }
ISessionProxyPtr connectReadOnly(const std::string &connectstring)
Definition: DBService.cc:19
std::string m_connectStr
unsigned int m_summarycachedrun
std::map< unsigned int, std::shared_ptr< const DIPLumiSummary > > m_summarycache
unsigned int m_cachesize
unsigned int maxavailableLSforRun(coral::ISchema &schema, const std::string &tablename, unsigned int runnumber)
bool isAvailable() const
Definition: Service.h:40
def move(src, dest)
Definition: eostools.py:511

◆ maxavailableLSforRun()

unsigned int DIPLumiProducer::maxavailableLSforRun ( coral::ISchema &  schema,
const std::string &  tablename,
unsigned int  runnumber 
)
private

select max(lumisection) as maxavailable from cms_runtime_logger.lumi_sections where runnumber=:runnumber;

Definition at line 235 of file DIPLumiProducer.cc.

References inputsource_file_cfi::myQuery, mps_fire::result, cond::runnumber, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by filldetailcache(), and fillsummarycache().

237  {
241  unsigned int result = 0;
242  coral::AttributeList bindVariables;
243  bindVariables.extend("runnumber", typeid(unsigned int));
244  bindVariables["runnumber"].data<unsigned int>() = runnumber;
245  std::string conditionStr("RUNNUMBER=:runnumber");
246  coral::AttributeList MyOutput;
247  MyOutput.extend("maxavailablels", typeid(unsigned int));
248  coral::IQuery* myQuery = schema.newQuery();
249  myQuery->addToTableList(tablename);
250  myQuery->addToOutputList("max(LUMISECTION)", "maxavailablels");
251  myQuery->setCondition(conditionStr, bindVariables);
252  myQuery->defineOutput(MyOutput);
253  coral::ICursor& mycursor = myQuery->execute();
254  while (mycursor.next()) {
255  const coral::AttributeList& row = mycursor.currentRow();
256  if (!row["maxavailablels"].isNull()) {
257  result = row["maxavailablels"].data<unsigned int>();
258  }
259  }
260  return result;
261 }

◆ produceDetail()

DIPLumiProducer::ReturnDetailType DIPLumiProducer::produceDetail ( const DIPLuminosityRcd )

Definition at line 100 of file DIPLumiProducer.cc.

References dqmiodumpmetadata::currentrun, edm::IOVSyncValue::eventID(), filldetailcache(), edm::IOVSyncValue::luminosityBlockNumber(), m_detailcache, m_detailcachedrun, m_detailresult, m_pcurrentTime, genParticles_cff::map, edm::EventID::run(), and findQualityFiles::v.

Referenced by DIPLumiProducer().

100  {
101  unsigned int currentrun = m_pcurrentTime->eventID().run();
102  unsigned int currentls = m_pcurrentTime->luminosityBlockNumber();
103  if (currentls == 0 || currentls == 4294967295) {
104  return std::make_shared<const DIPLumiDetail>();
105  }
106  if (m_detailcachedrun != currentrun) { //i'm in a new run
107  filldetailcache(currentrun, currentls); //starting ls
108  } else { //i'm in an known run
109  if (m_detailcache.find(currentls) == m_detailcache.end()) { //i'm in a unknown ls
110  filldetailcache(currentrun, currentls); //cache all ls>=currentls
111  }
112  }
113  if (m_detailcache.empty()) {
114  return std::make_shared<const DIPLumiDetail>();
115  }
116  if (m_detailcache.find(currentls) == m_detailcache.end()) {
117  std::vector<unsigned int> v;
118  for (std::map<unsigned int, std::shared_ptr<const DIPLumiDetail> >::iterator it = m_detailcache.begin();
119  it != m_detailcache.end();
120  ++it) {
121  v.push_back(it->first);
122  }
123  m_detailresult = m_detailcache[v.back()];
124  } else {
125  m_detailresult = m_detailcache[currentls];
126  }
127  if (m_detailresult.get() == nullptr) {
128  return std::make_shared<const DIPLumiDetail>();
129  }
130  return m_detailresult;
131 }
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:41
unsigned int m_detailcachedrun
RunNumber_t run() const
Definition: EventID.h:38
std::map< unsigned int, std::shared_ptr< const DIPLumiDetail > > m_detailcache
const EventID & eventID() const
Definition: IOVSyncValue.h:40
void filldetailcache(unsigned int runnumber, unsigned int startlsnum)
const edm::IOVSyncValue * m_pcurrentTime
std::shared_ptr< const DIPLumiDetail > m_detailresult

◆ produceSummary()

DIPLumiProducer::ReturnSummaryType DIPLumiProducer::produceSummary ( const DIPLuminosityRcd )

Definition at line 68 of file DIPLumiProducer.cc.

References dqmiodumpmetadata::currentrun, edm::IOVSyncValue::eventID(), fillsummarycache(), edm::IOVSyncValue::luminosityBlockNumber(), m_pcurrentTime, m_summarycache, m_summarycachedrun, m_summaryresult, genParticles_cff::map, edm::EventID::run(), and findQualityFiles::v.

Referenced by DIPLumiProducer().

68  {
69  unsigned int currentrun = m_pcurrentTime->eventID().run();
70  unsigned int currentls = m_pcurrentTime->luminosityBlockNumber();
71  if (currentls == 0 || currentls == 4294967295) {
72  return std::make_shared<const DIPLumiSummary>();
73  }
74  if (m_summarycachedrun != currentrun) { //i'm in a new run
75  fillsummarycache(currentrun, currentls); //starting ls
76  } else { //i'm in an old run
77  if (m_summarycache.find(currentls) == m_summarycache.end()) { //i'm not cached
78  fillsummarycache(currentrun, currentls); //
79  }
80  }
81  if (m_summarycache.empty()) {
82  return std::make_shared<const DIPLumiSummary>();
83  }
84  if (m_summarycache.find(currentls) == m_summarycache.end()) {
85  std::vector<unsigned int> v;
86  for (std::map<unsigned int, std::shared_ptr<const DIPLumiSummary> >::iterator it = m_summarycache.begin();
87  it != m_summarycache.end();
88  ++it) {
89  v.push_back(it->first);
90  }
92  } else {
93  m_summaryresult = m_summarycache[currentls];
94  }
95  if (m_summaryresult.get() == nullptr) {
96  return std::make_shared<const DIPLumiSummary>();
97  }
98  return m_summaryresult;
99 }
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:41
std::shared_ptr< const DIPLumiSummary > m_summaryresult
unsigned int m_summarycachedrun
RunNumber_t run() const
Definition: EventID.h:38
std::map< unsigned int, std::shared_ptr< const DIPLumiSummary > > m_summarycache
const EventID & eventID() const
Definition: IOVSyncValue.h:40
const edm::IOVSyncValue * m_pcurrentTime
void fillsummarycache(unsigned int runnumber, unsigned int startlsnum)

◆ setIntervalFor()

void DIPLumiProducer::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey iKey,
const edm::IOVSyncValue iTime,
edm::ValidityInterval oValidity 
)
overrideprotectedvirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 133 of file DIPLumiProducer.cc.

References m_pcurrentTime, edm::ValidityInterval::setFirst(), and edm::ValidityInterval::setLast().

135  {
136  m_pcurrentTime = &iTime;
137  oValidity.setFirst(iTime);
138  oValidity.setLast(iTime);
139 }
void setFirst(const IOVSyncValue &iTime)
void setLast(const IOVSyncValue &iTime)
const edm::IOVSyncValue * m_pcurrentTime

Member Data Documentation

◆ m_cachesize

unsigned int DIPLumiProducer::m_cachesize
private

Definition at line 46 of file DIPLumiProducer.h.

Referenced by DIPLumiProducer(), filldetailcache(), and fillsummarycache().

◆ m_connectStr

std::string DIPLumiProducer::m_connectStr
private

Definition at line 40 of file DIPLumiProducer.h.

Referenced by DIPLumiProducer(), filldetailcache(), and fillsummarycache().

◆ m_detailcache

std::map<unsigned int, std::shared_ptr<const DIPLumiDetail> > DIPLumiProducer::m_detailcache
private

Definition at line 42 of file DIPLumiProducer.h.

Referenced by filldetailcache(), and produceDetail().

◆ m_detailcachedrun

unsigned int DIPLumiProducer::m_detailcachedrun
private

Definition at line 45 of file DIPLumiProducer.h.

Referenced by filldetailcache(), and produceDetail().

◆ m_detailresult

std::shared_ptr<const DIPLumiDetail> DIPLumiProducer::m_detailresult
private

Definition at line 48 of file DIPLumiProducer.h.

Referenced by produceDetail().

◆ m_isNullRun

bool DIPLumiProducer::m_isNullRun
private

Definition at line 43 of file DIPLumiProducer.h.

◆ m_pcurrentTime

const edm::IOVSyncValue* DIPLumiProducer::m_pcurrentTime
private

Definition at line 49 of file DIPLumiProducer.h.

Referenced by produceDetail(), produceSummary(), and setIntervalFor().

◆ m_summarycache

std::map<unsigned int, std::shared_ptr<const DIPLumiSummary> > DIPLumiProducer::m_summarycache
private

Definition at line 41 of file DIPLumiProducer.h.

Referenced by fillsummarycache(), and produceSummary().

◆ m_summarycachedrun

unsigned int DIPLumiProducer::m_summarycachedrun
private

Definition at line 44 of file DIPLumiProducer.h.

Referenced by filldetailcache(), fillsummarycache(), and produceSummary().

◆ m_summaryresult

std::shared_ptr<const DIPLumiSummary> DIPLumiProducer::m_summaryresult
private

Definition at line 47 of file DIPLumiProducer.h.

Referenced by produceSummary().