EcalDQMonitor

EcalLSCache

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#ifndef EcalDQMonitor_H
#define EcalDQMonitor_H

#include <string>
#include <vector>

#include "DQWorker.h"

#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

namespace edm {
  class ParameterSet;
  class Run;
  class LuminosityBlock;
  class EventSetup;
}  // namespace edm

namespace ecaldqm {
  struct EcalLSCache {
    std::map<std::string, bool> ByLumiPlotsResetSwitches;
    bool lhcStatusSet_;
  };

  class EcalDQMonitor {
  public:
    EcalDQMonitor(edm::ParameterSet const &);
    virtual ~EcalDQMonitor() noexcept(false);

    static void fillDescriptions(edm::ParameterSetDescription &);

  protected:
    void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &);
    void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &);
    void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const;
    void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &);

    template <typename FuncOnWorker>
    void executeOnWorkers_(FuncOnWorker,
                           std::string const &,
                           std::string const & = "",
                           int = 1) const;  // loop over workers and capture exceptions

    std::vector<DQWorker *> workers_;
    std::string const moduleName_;
    const int verbosity_;
  };

  template <typename FuncOnWorker>
  void EcalDQMonitor::executeOnWorkers_(FuncOnWorker _func,
                                        std::string const &_context,
                                        std::string const &_message /* = ""*/,
                                        int _verbThreshold /* = 1*/) const {
    std::for_each(workers_.begin(), workers_.end(), [&](DQWorker *worker) {
      if (verbosity_ > _verbThreshold && !_message.empty())
        edm::LogInfo("EcalDQM") << moduleName_ << ": " << _message << " @ " << worker->getName();
      try {
        _func(worker);
      } catch (std::exception &) {
        edm::LogError("EcalDQM") << moduleName_ << ": Exception in " << _context << " @ " << worker->getName();
        throw;
      }
    });
  }
}  // namespace ecaldqm

#endif