CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HLTScalersClient Class Reference

#include <HLTScalersClient.h>

Inheritance diagram for HLTScalersClient:
edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

class  CountLS_t
 
class  CountLSFifo_t
 

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob (void) override
 BeginJob. More...
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void beginRun (const edm::Run &run, const edm::EventSetup &c) override
 BeginRun. More...
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void endRun (const edm::Run &run, const edm::EventSetup &c) override
 EndRun. More...
 
 HLTScalersClient (const edm::ParameterSet &ps)
 Constructors. More...
 
 ~HLTScalersClient () override
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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

std::pair< double, double > getSlope_ (const CountLSFifo_t &points)
 

Private Attributes

std::vector< MonitorElement * > countHistories_
 
int currentLumiBlockNumber_
 
MonitorElementcurrentNormRate_
 
MonitorElementcurrentRate_
 
int currentRun_
 
DQMStoredbe_
 
bool debug_
 
bool first_
 
std::string folderName_
 
MonitorElementhltCount_
 
std::vector< MonitorElement * > hltCurrentNormRate_
 
std::vector< MonitorElement * > hltCurrentRate_
 
MonitorElementhltNormRate_
 
MonitorElementhltRate_
 
std::deque< int > ignores_
 
unsigned int kRateIntegWindow_
 
int maxFU_
 
MonitorElementmergeCount_
 
bool missingPathNames_
 
int nev_
 
int nLumi_
 
std::string processName_
 
std::vector< MonitorElement * > rateHistories_
 
std::vector< MonitorElement * > rateNormHistories_
 
CountLSFifo_t recentNormedOverallCountsPerLS_
 
std::vector< CountLSFifo_trecentNormedPathCountsPerLS_
 
CountLSFifo_t recentOverallCountsPerLS_
 
std::vector< CountLSFifo_trecentPathCountsPerLS_
 
std::ofstream textfile_
 
MonitorElementupdates_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Definition at line 56 of file HLTScalersClient.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 63 of file HLTScalersClient.h.

◆ MonitorElement

Definition at line 62 of file HLTScalersClient.h.

Constructor & Destructor Documentation

◆ HLTScalersClient()

HLTScalersClient::HLTScalersClient ( const edm::ParameterSet ps)

Constructors.

Definition at line 61 of file HLTScalersClient.cc.

References dqm::implementation::IBooker::book1D(), gather_cfg::cout, dbe_, debug_, folderName_, hltCount_, hltNormRate_, hltRate_, LogDebug, MAX_LUMI_SEG_HLT, mergeCount_, Utilities::operator, dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, textfile_, and updates_.

62  : dbe_(nullptr),
63  nLumi_(0),
64  currentRate_(nullptr),
66  first_(true),
67  missingPathNames_(true),
68  folderName_(ps.getUntrackedParameter<std::string>("dqmFolder", "HLT/HLScalers_EvF")),
69  kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>("rateIntegWindow", 3)),
70  processName_(ps.getParameter<std::string>("processName")),
71  ignores_(),
72  debug_(ps.getUntrackedParameter<bool>("debugDump", false)),
73  maxFU_(ps.getUntrackedParameter<unsigned int>("maxFU", false)),
76  LogDebug("HLTScalersClient") << "constructor";
77  if (debug_) {
78  textfile_.open("debug.txt");
79  if (!textfile_) {
80  std::cout << "constructor: can't open text file" << std::endl;
81  }
82  }
83  // get back-end interface
84  usesResource("DQMStore");
87 
88  std::string rawdir(folderName_ + "/raw");
89  dbe_->setCurrentFolder(rawdir);
90  hltRate_ = dbe_->book1D("hltRate", "Overall HLT Accept rate vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
93  "hltRateNorm", "Overall HLT Accept rate vs LS, scaled", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
94  hltCount_ = dbe_->book1D("hltCount", "Overall HLT Counts vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
95  // hltCountN_= dbe_->book1D("hltCountN", "Overall HLT Counts per LS vs LS",
96  // MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT-0.5);
97  mergeCount_ =
98  dbe_->book1D("mergeCount", "Number of merge counts vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
99 
100  updates_ = dbe_->book1D("updates", "Status of Updates", 2, 0, 2);
101  updates_->setBinLabel(1, "Good Updates");
102  updates_->setBinLabel(2, "Incomplete Updates");
103 
104 } // end constructor
std::ofstream textfile_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement * updates_
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:646
T getUntrackedParameter(std::string const &, T const &) const
std::string folderName_
std::string processName_
MonitorElement * hltRate_
std::deque< int > ignores_
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
MonitorElement * hltCount_
CountLSFifo_t recentNormedOverallCountsPerLS_
#define MAX_LUMI_SEG_HLT
MonitorElement * hltNormRate_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
#define LogDebug(id)

◆ ~HLTScalersClient()

HLTScalersClient::~HLTScalersClient ( )
inlineoverride

Destructor.

Definition at line 120 of file HLTScalersClient.h.

References debug_, and textfile_.

120  {
121  if (debug_) {
122  textfile_.close();
123  }
124  };
std::ofstream textfile_

Member Function Documentation

◆ analyze()

void HLTScalersClient::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 519 of file HLTScalersClient.cc.

519  {
520  // nothing to do here
521 }

◆ beginJob()

void HLTScalersClient::beginJob ( void  )
overridevirtual

BeginJob.

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 107 of file HLTScalersClient.cc.

References dbe_, first_, folderName_, LogDebug, missingPathNames_, and dqm::implementation::DQMStore::setCurrentFolder().

107  {
108  LogDebug("HLTScalersClient") << "beingJob";
109  if (dbe_) {
111  }
112  first_ = true;
113  missingPathNames_ = true;
114 }
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:646
std::string folderName_
#define LogDebug(id)

◆ beginLuminosityBlock()

void HLTScalersClient::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
inlineoverride

End LumiBlock DQM Client Diagnostic should be performed here

Definition at line 137 of file HLTScalersClient.h.

137 {}

◆ beginRun()

void HLTScalersClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
override

BeginRun.

beginRun

Definition at line 117 of file HLTScalersClient.cc.

References first_, LogDebug, missingPathNames_, and writedatasetfile::run.

117  {
118  missingPathNames_ = true;
119  first_ = true;
120  LogDebug("HLTScalersClient") << "beginRun, run " << run.id();
121 
122 } // beginRun
#define LogDebug(id)

◆ endLuminosityBlock()

void HLTScalersClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
override

End LumiBlock DQM Client Diagnostic should be performed here

Definition at line 132 of file HLTScalersClient.cc.

References newFWLiteAna::bin, dqm::implementation::IBooker::book1D(), countHistories_, gather_cfg::cout, currentNormRate_, currentRate_, dbe_, debug_, relativeConstraints::empty, dqm::impl::MonitorElement::Fill(), first_, SiStripCommissioningSource_FromRAW_cfg::fnames, folderName_, dqm::implementation::IGetter::get(), dqm::impl::MonitorElement::getBinContent(), HLTScalersClient::CountLSFifo_t::getCount(), dqm::impl::MonitorElement::getIntValue(), getSlope_(), hltCount_, hltCurrentNormRate_, hltCurrentRate_, hltNormRate_, hltRate_, mps_fire::i, edm::LuminosityBlockBase::id(), createfilelist::int, edm::isNotFinite(), dqmdumpme::k, kPerHisto, kRateIntegWindow_, label, mps_splice::line, LogDebug, edm::LuminosityBlockID::luminosityBlock(), MAX_LUMI_SEG_HLT, MAX_PATHS, maxFU_, mergeCount_, missingPathNames_, mps_check::msg, Skims_PA_cff::name, names, nLumi_, unpackData-CaloStage2::pname, rateHistories_, rateNormHistories_, recentNormedOverallCountsPerLS_, recentNormedPathCountsPerLS_, recentOverallCountsPerLS_, recentPathCountsPerLS_, DQMOffline_LumiMonitoring_cff::scalers, SECS_PER_LUMI_SECTION, dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::DQMStore::setCurrentFolder(), slope, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, textfile_, HLTScalersClient::CountLSFifo_t::update(), and updates_.

132  {
133  nLumi_ = lumiSeg.id().luminosityBlock();
134 
135  // get raw data
136  std::string scalHisto = folderName_ + "/raw/hltScalers";
137  MonitorElement *scalers = dbe_->get(scalHisto);
138  if (scalers == nullptr) {
139  LogDebug("HLTScalersClient") << "cannot get hlt scalers histogram, "
140  << "bailing out.";
141  if (debug_)
142  std::cout << "No scalers ? Looking for " << scalHisto << std::endl;
143  return;
144  }
145 
146  int npaths = scalers->getNbinsX();
147  if (npaths > MAX_PATHS)
148  npaths = MAX_PATHS; // HARD CODE FOR NOW
149  LogDebug("HLTScalersClient") << "I see " << npaths << " paths. ";
150 
151  // set the bin labels on the first go-through
152  // I need to do this here because we don't have the paths yet
153  // on begin-run. I should do this in a less ugly way (see FV?)
154  if (first_) {
155  std::string rawdir(folderName_ + "/raw");
156 
157  LogDebug("HLTScalersClient") << "Setting up paths on first endLumiBlock " << npaths;
158  dbe_->setCurrentFolder(rawdir);
159  currentRate_ = dbe_->book1D("cur_rate", "current lumi section rate per path", npaths, -0.5, npaths - 0.5);
161  dbe_->book1D("cur_rate_norm", "current norm. lumi section rate per path", npaths, -0.5, npaths - 0.5);
162  recentPathCountsPerLS_.reserve(npaths);
163  recentNormedPathCountsPerLS_.reserve(npaths);
164  char rates_subfolder[256];
165  snprintf(rates_subfolder, 256, "%s/RateHistory", folderName_.c_str());
166  char counts_subfolder[256];
167  snprintf(counts_subfolder, 256, "%s/CountHistory", folderName_.c_str());
168 
169  hltCurrentRate_.reserve(npaths);
170  rateHistories_.reserve(npaths);
171  countHistories_.reserve(npaths);
172  hltCurrentNormRate_.reserve(npaths);
173  rateNormHistories_.reserve(npaths);
174 
175  dbe_->setCurrentFolder(folderName_); // these belong in top-level
176  for (int i = 0; i < npaths; ++i) {
177  dbe_->setCurrentFolder(std::string(rates_subfolder) + "/raw");
178 
179  char name[256];
180  snprintf(name, 256, "raw_rate_p%03d", i);
181  // LogDebug("HLTScalersClient") << "name " << i << " is " << name ;
183  snprintf(name, 256, "norm_rate_p%03d", i);
184  dbe_->setCurrentFolder(rates_subfolder);
186  dbe_->setCurrentFolder(counts_subfolder);
187  snprintf(name, 256, "counts_p%03d", i);
189  // prefill the data structures
190  recentPathCountsPerLS_.push_back(CountLSFifo_t(kRateIntegWindow_));
191  recentNormedPathCountsPerLS_.push_back(CountLSFifo_t(2));
192  }
194 
195  // split hlt scalers up into groups of 20
196  const int maxlen = 64;
197  char metitle[maxlen]; // histo name
198  char mename[maxlen]; // ME name
199  int numHistos = int(npaths / kPerHisto); // this hasta be w/o remainders
200 
201  int remainder = npaths % kPerHisto;
202  if (remainder)
203  numHistos += 1;
204 
205  for (int k = 0; k < numHistos; k++) {
206  int npath_low = kPerHisto * k;
207  int npath_high = kPerHisto * (k + 1) - 1;
208  snprintf(mename, maxlen, "hltScalers_%0d", k);
209  snprintf(metitle, maxlen, "HLT scalers - Paths %d to %d", npath_low, npath_high);
210  dbe_->setCurrentFolder(rawdir);
211  hltCurrentRate_.push_back(dbe_->book1D(mename, metitle, kPerHisto, -0.5 + npath_low, npath_high + 0.5));
212  dbe_->setCurrentFolder(folderName_); // these belong in top-level
213  snprintf(mename, maxlen, "hltScalersNorm_%0d", k);
214  snprintf(metitle, maxlen, "HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
215  hltCurrentNormRate_.push_back(dbe_->book1D(mename, metitle, kPerHisto, -0.5 + npath_low, npath_high + 0.5));
216  }
217 
218  first_ = false;
219  }
220 
221  if (missingPathNames_) {
222  // first try the scalers histogram and see if the bin names are set
223  for (int i = 0; i < npaths; ++i) {
224  // needs to be i+1 since root bins start at 1
225  const char *name = scalers->getTH1()->GetXaxis()->GetBinLabel(i + 1);
226  if (name && (strlen(name) > 0)) {
227  if (debug_) {
228  std::cout << "path " << i << " name is " << name << std::endl;
229  }
230  int whichHisto = i / kPerHisto;
231  int whichBin = i % kPerHisto + 1;
232  char pname[256];
233  hltCurrentRate_[whichHisto]->setBinLabel(whichBin, name);
234  hltCurrentNormRate_[whichHisto]->setBinLabel(whichBin, name);
235  snprintf(pname, 256, "Rate - path %s (Path # %03d)", name, i);
236  rateHistories_[i]->setTitle(pname);
237  rateNormHistories_[i]->setTitle(pname);
238  snprintf(pname, 256, "Counts - path %s (Path # %03d)", name, i);
239  countHistories_[i]->setTitle(pname);
240 
243 
244  missingPathNames_ = false;
245  }
246  }
247  }
248  // MEGA-HACK
249  if (missingPathNames_) {
250  // if that didn't work we load 'em from a text file. damn straight.
251  int ipath = 1;
252  std::ifstream names("names.dat");
253  if (!names) {
254  if (debug_) {
255  std::ostringstream msg;
256  msg << "open of "
257  << "names.dat";
258  perror(msg.str().c_str());
259  }
260  } else { // open succeeded
261  missingPathNames_ = false;
263  while (!names.eof()) {
264  getline(names, line);
265  std::istringstream fnames(line);
267  int bin;
268  if (fnames.str().find('#') == 0) // skip comment lines
269  continue;
270  if (fnames >> bin >> label) {
271  if (debug_) {
272  std::cout << bin << "--" << label << "(" << ipath << ")" << std::endl;
273  }
274  currentRate_->setBinLabel(ipath, label);
276  countHistories_[ipath - 1]->setTitle(label);
277  rateHistories_[ipath - 1]->setTitle(label);
278  rateNormHistories_[ipath - 1]->setTitle(label);
279  int whichHisto = (ipath - 1) / kPerHisto;
280  int whichBin = (ipath - 1) % kPerHisto + 1;
281  hltCurrentRate_[whichHisto]->setBinLabel(whichBin, label);
282  hltCurrentNormRate_[whichHisto]->setBinLabel(whichBin, label);
283  ++ipath;
284  if (ipath > npaths)
285  break;
286  } //
287  } // loop lines
288  } // open ok
289  }
290 
291  // END SETUP
292 
293  std::string nLumiHisto(folderName_ + "/nLumiBlock");
294  MonitorElement *nLumi = dbe_->get(nLumiHisto);
295  if (nLumi == nullptr) {
296  nLumiHisto = folderName_ + "/raw/nLumiBlock";
297  nLumi = dbe_->get(nLumiHisto);
298  }
299  int testval = (nLumi != nullptr ? nLumi->getIntValue() : -1);
300  LogDebug("HLTScalersClient") << "Lumi Block from DQM: " << testval << ", local is " << nLumi_;
301  int nL = (nLumi != nullptr ? nLumi->getIntValue() : nLumi_);
302  if (nL > MAX_LUMI_SEG_HLT) {
303  LogDebug("HLTScalersClient") << "Too many Lumi segments, " << nL << " is greater than MAX_LUMI_SEG_HLT,"
304  << " wrapping to " << (nL % MAX_LUMI_SEG_HLT);
305  // nL = MAX_LUMI_SEG_HLT;
306  nL = nL % MAX_LUMI_SEG_HLT;
307  }
308 
309  // merging counts
310  double num_fu = -1.0;
311  std::string mergeName(folderName_ + "/raw/hltMerge");
312  MonitorElement *merge = dbe_->get(mergeName);
313  if (merge != nullptr) {
314  num_fu = merge->getBinContent(1);
315  if (debug_) {
316  std::cout << "Number of received entries: " << num_fu << std::endl;
317  }
318  mergeCount_->Fill(nL, num_fu);
319  }
320  // end
321 
322  // evaluate the data
323  // loop over current counts
324 
325  // this gets filled for all times. Mainly for debugging.
326  for (int i = 1; i <= npaths; ++i) { // bins start at 1
327  double current_count = scalers->getBinContent(i);
328  // nb that this will now _overwrite_ some settings
329  countHistories_[i - 1]->setBinContent(nL, current_count); // good or bad
330  }
331 
332  std::string overallScalerName(folderName_ + "/raw/hltOverallScaler");
333  MonitorElement *hltScaler = dbe_->get(overallScalerName);
334  if (hltScaler != nullptr) {
335  double current_count = hltScaler->getBinContent(1);
336  hltCount_->setBinContent(nL, current_count);
337  recentOverallCountsPerLS_.update(CountLS_t(nL, current_count));
338  std::pair<double, double> sl = getSlope_(recentOverallCountsPerLS_);
339  double slope = sl.first;
340  double slope_err = sl.second;
341  if (slope > 0) {
343  if (!edm::isNotFinite(slope_err) && (slope_err >= 0))
344  hltRate_->setBinError(nL, slope_err);
345  }
346  } // found histo
347 
348  if (num_fu >= 0.95 * maxFU_) {
349  if (num_fu > maxFU_) {
350  maxFU_ = num_fu;
351  if (debug_)
352  std::cout << "maxFU is now " << maxFU_ << std::endl;
353  }
354  // good data
355  for (int i = 1; i <= npaths; ++i) { // bins start at 1
356  double current_count = scalers->getBinContent(i);
357  // DEBUG
358  if (!recentPathCountsPerLS_[i - 1].empty() && debug_)
359  std::cout << i << "\t-> good one: new => cnt, ls = " << current_count << ", " << nL
360  << ", old = " << recentPathCountsPerLS_[i - 1].back().second << "\t"
361  << recentPathCountsPerLS_[i - 1].back().first << std::endl;
362  // END DEBUG
363  recentPathCountsPerLS_[i - 1].update(CountLS_t(nL, current_count));
364 
365  // NB: we do not fill a new entry in the rate histo if we can't
366  // calculate it
367  std::pair<double, double> sl = getSlope_(recentPathCountsPerLS_[i - 1]);
368  double slope = sl.first;
369  double slope_err = sl.second;
370  // rateHistories_[i-1]->Fill(nL,slope);
371  if (slope > 0) {
372  rateHistories_[i - 1]->setBinContent(nL, slope);
373  // set the current rate(s)
374  hltCurrentRate_[(i - 1) / kPerHisto]->setBinContent(i % kPerHisto, slope);
376  if (!edm::isNotFinite(slope_err) && (slope_err >= 0)) {
377  currentRate_->setBinError(i, slope_err);
378  hltCurrentRate_[(i - 1) / kPerHisto]->setBinError(i % kPerHisto, slope_err);
379  rateHistories_[i - 1]->setBinError(nL, slope_err);
380  }
381  }
384 
385  } // loop over paths
386 
387  // ---------------------------- overall rate, absolute counts
388  std::string overallScalerName(folderName_ + "/raw/hltOverallScaler");
389  MonitorElement *hltScaler = dbe_->get(overallScalerName);
390  if (hltScaler != nullptr) {
391  double current_count = hltScaler->getBinContent(1);
392  hltCount_->setBinContent(nL, current_count);
393  recentOverallCountsPerLS_.update(CountLS_t(nL, current_count));
394  std::pair<double, double> sl = getSlope_(recentOverallCountsPerLS_);
395  double slope = sl.first;
396  double slope_err = sl.second;
397  if (slope >= 0) {
399  if (!edm::isNotFinite(slope_err) && (slope_err >= 0))
400  hltRate_->setBinError(nL, slope_err);
401  }
402  } // found histo
403  updates_->Fill(0); // good
404  } // check on number of FU's - good data
405  else {
406  updates_->Fill(1); // missing updates
407  }
408 
409  // PW DEBUG
410  if (debug_) {
411  textfile_ << nL << "\t" << npaths << "\t";
412  for (int i = 0; i < npaths; ++i) {
413  textfile_ << scalers->getBinContent(i) << " ";
414  }
415  textfile_ << std::endl;
416  }
417  // end DEBUG
418 
419 #ifdef LATER
420  // ------ overall rate normalized - all data
421  overallScalerName = std::string(folderName_ + "/raw/hltOverallScalerN");
422  hltScaler = dbe_->get(overallScalerName);
423  if (hltScaler != 0) {
424  double cnt = hltScaler->getBinContent(1);
425  // hltCountN_->setBinContent(nL,cnt);
426  if (debug_) {
427  std::cout << "Overall Norm: new => cnt, ls = " << cnt << ", " << nL << ", num_fu = " << num_fu << std::endl;
428  }
429  recentNormedOverallCountsPerLS_.update(CountLS_t(nL, cnt / num_fu));
430  cnt = recentNormedOverallCountsPerLS_.getCount(nL); // for dupes/partials
431  double slope = cnt / num_fu / SECS_PER_LUMI_SECTION;
432  if (debug_) {
433  std::cout << "Normalized slope = " << slope << std::endl;
434  }
435  if (slope > 0)
437  }
438  //
439  std::string scalHistoNorm = folderName_ + "/raw/hltScalersN";
440  MonitorElement *scalersN = dbe_->get(scalHistoNorm);
441  if (scalersN) {
442  for (int i = 0; i < npaths; ++i) {
443  double cnt = scalersN->getBinContent(i);
444  double slope = cnt / num_fu / SECS_PER_LUMI_SECTION;
445  if (slope > 0) {
446  rateNormHistories_[i - 1]->setBinContent(nL, slope);
447  // set the current rate(s)
448  hltCurrentNormRate_[(i - 1) / kPerHisto]->setBinContent(i % kPerHisto, slope);
450  }
451  }
452  }
453 #else // NOT LATER
454  // ------ overall rate normalized - all data
455  overallScalerName = std::string(folderName_ + "/raw/hltOverallScaler");
456  hltScaler = dbe_->get(overallScalerName);
457  if (hltScaler != nullptr) {
458  double cnt = hltScaler->getBinContent(1);
459  // hltCountN_->setBinContent(nL,cnt);
460  float sf = num_fu / maxFU_;
461  if (debug_) {
462  std::cout << "Overall Norm: new => cnt, ls = " << cnt << ", " << nL << ", num_fu = " << num_fu << ", sf = " << sf
463  << std::endl;
464  }
465  recentNormedOverallCountsPerLS_.update(CountLS_t(nL, cnt / sf));
466  cnt = recentNormedOverallCountsPerLS_.getCount(nL); // for dupes/partials
467  std::pair<double, double> sl = getSlope_(recentNormedOverallCountsPerLS_);
468  double slope = sl.first;
469  double slope_err = sl.second;
470  if (debug_) {
471  std::cout << "Normalized slope = " << slope << std::endl;
472  }
473  if (slope > 0) {
475  if (cnt > 0)
476  slope_err = slope * sqrt(2. / num_fu + 2. / cnt);
477  if (!edm::isNotFinite(slope_err) && (slope_err >= 0))
478  hltNormRate_->setBinError(nL, slope_err);
479  }
480  }
481  //
482  std::string scalHistoNorm = folderName_ + "/raw/hltScalers";
483  MonitorElement *scalersN = dbe_->get(scalHistoNorm);
484  if (scalersN) {
485  double sf = num_fu / maxFU_;
486  for (int i = 1; i <= npaths; ++i) {
487  double cnt = scalersN->getBinContent(i);
488  recentNormedPathCountsPerLS_[i - 1].update(CountLS_t(nL, cnt / sf));
489  std::pair<double, double> sl = getSlope_(recentNormedPathCountsPerLS_[i - 1]);
490  double slope = sl.first;
491  double slope_err = sl.second;
492  if (slope >= 0) {
493  rateNormHistories_[i - 1]->setBinContent(nL, slope);
494  // set the current rate(s)
495  hltCurrentNormRate_[(i - 1) / kPerHisto]->setBinContent(i % kPerHisto, slope);
497  if (slope_err <= 0 && cnt > 0) {
498  // ignores error on prev point, so scale by sqrt(2)
499  slope_err = slope * sqrt(2. / num_fu + 2. / cnt);
500  if (debug_) {
501  std::cout << "Slope err " << i << " = " << slope_err << std::endl;
502  }
503  }
504  if (!edm::isNotFinite(slope_err) && (slope_err >= 0)) {
505  rateNormHistories_[i - 1]->setBinError(nL, slope_err);
506  // set the current rate(s)
507  hltCurrentNormRate_[(i - 1) / kPerHisto]->setBinError(i % kPerHisto, slope_err);
508  currentNormRate_->setBinError(i, slope_err);
509  }
510  }
511  }
512  }
513 
514 #endif // LATER
515  //
516 }
std::ofstream textfile_
Definition: merge.py:1
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * updates_
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
static const double slope[3]
MonitorElement * currentNormRate_
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:646
std::vector< CountLSFifo_t > recentNormedPathCountsPerLS_
const std::string names[nVars_]
std::vector< MonitorElement * > hltCurrentNormRate_
void Fill(long long x)
char const * label
std::string folderName_
#define SECS_PER_LUMI_SECTION
MonitorElement * hltRate_
T sqrt(T t)
Definition: SSEVec.h:19
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
std::vector< MonitorElement * > countHistories_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
std::vector< MonitorElement * > hltCurrentRate_
void update(const CountLS_t &T)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
LuminosityBlockID id() const
std::vector< CountLSFifo_t > recentPathCountsPerLS_
std::vector< MonitorElement * > rateHistories_
tuple msg
Definition: mps_check.py:286
MonitorElement * hltCount_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
CountLSFifo_t recentNormedOverallCountsPerLS_
#define MAX_LUMI_SEG_HLT
const int kPerHisto
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * hltNormRate_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
#define MAX_PATHS
#define LogDebug(id)
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual int64_t getIntValue() const

◆ endRun()

void HLTScalersClient::endRun ( const edm::Run run,
const edm::EventSetup c 
)
override

EndRun.

Definition at line 125 of file HLTScalersClient.cc.

References first_, and missingPathNames_.

125  {
126  missingPathNames_ = true;
127  first_ = true;
128 }

◆ getSlope_()

std::pair< double, double > HLTScalersClient::getSlope_ ( const CountLSFifo_t points)
private

Definition at line 526 of file HLTScalersClient.cc.

References gather_cfg::cout, debug_, mps_fire::i, dqmiodumpmetadata::n, hiPixelPairStep_cff::points, funct::pow(), SECS_PER_LUMI_SECTION, slope, mathSSE::sqrt(), x, geometryCSVtoXML::xy, and y.

Referenced by endLuminosityBlock().

526  {
527  double slope, sigma_m;
528  if (points.size() < points.targetSize()) {
529  return std::pair<double, double>(-1, -1);
530  }
531  // just do a delta if we just want two bins
532  else if (points.size() == 2) {
533  // just do diff and be done with it
534  double delta_ls = points.front().first - points.back().first;
535  double delta_cnt = points.front().second - points.back().second;
536  slope = delta_cnt / delta_ls;
537  sigma_m = -1;
538  } else { // do a fit
539  double xy = 0;
540  double x = 0;
541  double xsq = 0;
542  double y = 0;
543  double n = double(points.size());
544  for (auto i(points.begin()); i != points.end(); ++i) {
545  if (debug_)
546  std::cout << "x = " << i->first << ", y = " << i->second << std::endl;
547  xy += i->first * i->second;
548  x += i->first;
549  xsq += i->first * i->first;
550  y += i->second;
551  }
552  slope = (n * xy - x * y) / (n * xsq - x * x);
553 
554  // now get the uncertainty on the slope. Need intercept for this.
555  double intercept = (xsq * y - xy * x) / (n * xsq - x * x);
556  double sigma_ysq = 0;
557  for (auto i(points.begin()); i != points.end(); ++i) {
558  sigma_ysq += pow((i->second - slope * i->first - intercept), 2.);
559  }
560  // if ( debug_ )
561  // std::cout << "chi^2 = " << sigma_ysq << std::endl;
562  sigma_ysq *= 1. / (n - 2.);
563 
564  sigma_m = sqrt(n * sigma_ysq / (n * xsq - x * x));
565  }
566 
567  // std::cout << "Slope is " << slope << std::endl;
569  if (sigma_m > 0)
570  sigma_m /= SECS_PER_LUMI_SECTION;
571  // if ( debug_ ) {
572  // std::cout << "Slope = " << slope << " +- " << sigma_m
573  // << std::endl;
574  // std::cout << "intercept is " << intercept
575  // << std::endl;
576  // }
577 
578  return std::pair<double, double>(slope, sigma_m);
579 }
static const double slope[3]
#define SECS_PER_LUMI_SECTION
T sqrt(T t)
Definition: SSEVec.h:19
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

◆ countHistories_

std::vector<MonitorElement *> HLTScalersClient::countHistories_
private

Definition at line 153 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ currentLumiBlockNumber_

int HLTScalersClient::currentLumiBlockNumber_
private

Definition at line 151 of file HLTScalersClient.h.

◆ currentNormRate_

MonitorElement* HLTScalersClient::currentNormRate_
private

Definition at line 164 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ currentRate_

MonitorElement* HLTScalersClient::currentRate_
private

Definition at line 150 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ currentRun_

int HLTScalersClient::currentRun_
private

Definition at line 148 of file HLTScalersClient.h.

◆ dbe_

DQMStore* HLTScalersClient::dbe_
private

Definition at line 144 of file HLTScalersClient.h.

Referenced by beginJob(), endLuminosityBlock(), and HLTScalersClient().

◆ debug_

bool HLTScalersClient::debug_
private

◆ first_

bool HLTScalersClient::first_
private

Definition at line 168 of file HLTScalersClient.h.

Referenced by beginJob(), beginRun(), endLuminosityBlock(), and endRun().

◆ folderName_

std::string HLTScalersClient::folderName_
private

Definition at line 169 of file HLTScalersClient.h.

Referenced by beginJob(), endLuminosityBlock(), and HLTScalersClient().

◆ hltCount_

MonitorElement* HLTScalersClient::hltCount_
private

Definition at line 157 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

◆ hltCurrentNormRate_

std::vector<MonitorElement *> HLTScalersClient::hltCurrentNormRate_
private

Definition at line 166 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ hltCurrentRate_

std::vector<MonitorElement *> HLTScalersClient::hltCurrentRate_
private

Definition at line 155 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ hltNormRate_

MonitorElement* HLTScalersClient::hltNormRate_
private

Definition at line 163 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

◆ hltRate_

MonitorElement* HLTScalersClient::hltRate_
private

Definition at line 156 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

◆ ignores_

std::deque<int> HLTScalersClient::ignores_
private

Definition at line 173 of file HLTScalersClient.h.

◆ kRateIntegWindow_

unsigned int HLTScalersClient::kRateIntegWindow_
private

Definition at line 170 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ maxFU_

int HLTScalersClient::maxFU_
private

Definition at line 178 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ mergeCount_

MonitorElement* HLTScalersClient::mergeCount_
private

Definition at line 160 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

◆ missingPathNames_

bool HLTScalersClient::missingPathNames_
private

Definition at line 168 of file HLTScalersClient.h.

Referenced by beginJob(), beginRun(), endLuminosityBlock(), and endRun().

◆ nev_

int HLTScalersClient::nev_
private

Definition at line 146 of file HLTScalersClient.h.

◆ nLumi_

int HLTScalersClient::nLumi_
private

Definition at line 147 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ processName_

std::string HLTScalersClient::processName_
private

Definition at line 171 of file HLTScalersClient.h.

◆ rateHistories_

std::vector<MonitorElement *> HLTScalersClient::rateHistories_
private

Definition at line 152 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ rateNormHistories_

std::vector<MonitorElement *> HLTScalersClient::rateNormHistories_
private

Definition at line 165 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ recentNormedOverallCountsPerLS_

CountLSFifo_t HLTScalersClient::recentNormedOverallCountsPerLS_
private

Definition at line 183 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ recentNormedPathCountsPerLS_

std::vector<CountLSFifo_t> HLTScalersClient::recentNormedPathCountsPerLS_
private

Definition at line 182 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ recentOverallCountsPerLS_

CountLSFifo_t HLTScalersClient::recentOverallCountsPerLS_
private

Definition at line 180 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ recentPathCountsPerLS_

std::vector<CountLSFifo_t> HLTScalersClient::recentPathCountsPerLS_
private

Definition at line 179 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

◆ textfile_

std::ofstream HLTScalersClient::textfile_
private

Definition at line 59 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), HLTScalersClient(), and ~HLTScalersClient().

◆ updates_

MonitorElement* HLTScalersClient::updates_
private

Definition at line 159 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().