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
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename Record >
void updateFromMayConsumes (unsigned int iIndex, const Record &iRecord)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(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={})
 
- 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

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

Definition at line 27 of file DIPLumiProducer.h.

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

Definition at line 25 of file DIPLumiProducer.h.

Constructor & Destructor Documentation

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

Definition at line 62 of file DIPLumiProducer.cc.

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

66  findingRecord<DIPLuminosityRcd>();
67  m_connectStr = iConfig.getParameter<std::string>("connect");
68  m_cachesize = iConfig.getUntrackedParameter<unsigned int>("ncacheEntries", 3);
69 }
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
T getUntrackedParameter(std::string const &, T const &) const
unsigned int m_detailcachedrun
std::string m_connectStr
ReturnDetailType produceDetail(const DIPLuminosityRcd &)
unsigned int m_summarycachedrun
unsigned int m_cachesize
ReturnSummaryType produceSummary(const DIPLuminosityRcd &)
DIPLumiProducer::~DIPLumiProducer ( )
override

Definition at line 345 of file DIPLumiProducer.cc.

References DEFINE_FWK_EVENTSETUP_SOURCE.

345 {}

Member Function Documentation

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

Definition at line 265 of file DIPLumiProducer.cc.

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

Referenced by produceDetail().

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

Definition at line 144 of file DIPLumiProducer.cc.

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

Referenced by produceSummary().

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

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

Referenced by filldetailcache(), and fillsummarycache().

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

Definition at line 103 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().

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

Definition at line 71 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().

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 136 of file DIPLumiProducer.cc.

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

138  {
139  m_pcurrentTime = &iTime;
140  oValidity.setFirst(iTime);
141  oValidity.setLast(iTime);
142 }
void setFirst(const IOVSyncValue &iTime)
void setLast(const IOVSyncValue &iTime)
const edm::IOVSyncValue * m_pcurrentTime

Member Data Documentation

unsigned int DIPLumiProducer::m_cachesize
private

Definition at line 46 of file DIPLumiProducer.h.

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

std::string DIPLumiProducer::m_connectStr
private

Definition at line 40 of file DIPLumiProducer.h.

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

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().

unsigned int DIPLumiProducer::m_detailcachedrun
private

Definition at line 45 of file DIPLumiProducer.h.

Referenced by filldetailcache(), and produceDetail().

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

Definition at line 48 of file DIPLumiProducer.h.

Referenced by produceDetail().

bool DIPLumiProducer::m_isNullRun
private

Definition at line 43 of file DIPLumiProducer.h.

const edm::IOVSyncValue* DIPLumiProducer::m_pcurrentTime
private

Definition at line 49 of file DIPLumiProducer.h.

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

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().

unsigned int DIPLumiProducer::m_summarycachedrun
private

Definition at line 44 of file DIPLumiProducer.h.

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

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

Definition at line 47 of file DIPLumiProducer.h.

Referenced by produceSummary().