HistogramManagerHolder

SiPixelPhase1Base

SiPixelPhase1Harvester

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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#ifndef SiPixel_DefaultTemplates_h
#define SiPixel_DefaultTemplates_h
//
// This defines two classes, one that has to be extended to make a new plugin,
// and one that can be used as-is for the Harvesting.
//
// As with the entire SiPixelPhase1Common framework, you do not have to use
// this but can still use the other helpers. However, the HistogramManager
// needs to run in step1 and step2 of the DQM, and need to have exactly the
// same spec to work properly. This has to be guranteed by the configuration.
//
// Original Author: Marcel Schneider
//

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMEDHarvester.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/Transition.h"
#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"

#include "DQM/SiPixelPhase1Common/interface/HistogramManager.h"

#include <utility>
#include <vector>

// used as a mixin for Analyzer and Harvester.
class HistogramManagerHolder {
public:
  HistogramManagerHolder(const edm::ParameterSet& iConfig,
                         edm::ConsumesCollector&& iC,
                         edm::Transition transition = edm::Transition::BeginRun)
      : geometryInterface(iConfig.getParameter<edm::ParameterSet>("geometry"), std::move(iC), transition) {
    auto histograms = iConfig.getParameter<edm::VParameterSet>("histograms");
    for (const auto& histoconf : histograms) {
      histo.emplace_back(HistogramManager(histoconf, geometryInterface));
    }
  };

protected:
  std::vector<HistogramManager> histo;
  GeometryInterface geometryInterface;
};

// This is the base class your plugin may derive from. You are not required to
// use it but if you just need some normal HistogramManager this should be perfect.
class SiPixelPhase1Base : public DQMEDAnalyzer, public HistogramManagerHolder {
public:
  SiPixelPhase1Base(const edm::ParameterSet& iConfig);

  // You should analyze something, and call histoman.fill(...). Setting to pure virtual function
  void analyze(edm::Event const& e, edm::EventSetup const&) override = 0;

  // This booking is usually fine.
  // Also used to store the required triggers
  void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const&) override;

  ~SiPixelPhase1Base() override {}

protected:
  // Returns a value of whether the trigger stored at position "trgidx" is properly fired.
  bool checktrigger(const edm::Event& iEvent, const edm::EventSetup&, const unsigned trgidx) const;

  // must match order in TriggerEventFlag_cfi.py
  enum { DCS };

private:
  // Storing the trigger objects per plugin instance
  std::vector<std::unique_ptr<GenericTriggerEventFlag>> triggerlist;
};

// This wraps the Histogram Managers into a DQMEDHarvester. It
// provides sane default implementations, so most plugins don't care about this.
// However, you have to instantiate one with the same config as your Analyzer
// to get the Harvesting done.
// For custom harvesting, you have to derive from this.
class SiPixelPhase1Harvester : public DQMEDHarvester, public HistogramManagerHolder {
public:
  SiPixelPhase1Harvester(const edm::ParameterSet& iConfig)
      : DQMEDHarvester(), HistogramManagerHolder(iConfig, consumesCollector(), edm::Transition::EndLuminosityBlock) {}

  void dqmEndLuminosityBlock(DQMStore::IBooker& iBooker,
                             DQMStore::IGetter& iGetter,
                             edm::LuminosityBlock const& lumiBlock,
                             edm::EventSetup const&) override;
  void dqmEndJob(DQMStore::IBooker& iBooker, DQMStore::IGetter& iGetter) override;
};
#endif