Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-11 04:32:38

0001 #ifndef SiPixel_DefaultTemplates_h
0002 #define SiPixel_DefaultTemplates_h
0003 //
0004 // This defines two classes, one that has to be extended to make a new plugin,
0005 // and one that can be used as-is for the Harvesting.
0006 //
0007 // As with the entire SiPixelPhase1Common framework, you do not have to use
0008 // this but can still use the other helpers. However, the HistogramManager
0009 // needs to run in step1 and step2 of the DQM, and need to have exactly the
0010 // same spec to work properly. This has to be guranteed by the configuration.
0011 //
0012 // Original Author: Marcel Schneider
0013 //
0014 
0015 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0016 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/Transition.h"
0019 #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
0020 
0021 #include "DQM/SiPixelPhase1Common/interface/HistogramManager.h"
0022 
0023 #include <utility>
0024 #include <vector>
0025 
0026 // used as a mixin for Analyzer and Harvester.
0027 class HistogramManagerHolder {
0028 public:
0029   HistogramManagerHolder(const edm::ParameterSet& iConfig,
0030                          edm::ConsumesCollector&& iC,
0031                          edm::Transition transition = edm::Transition::BeginRun)
0032       : geometryInterface(iConfig.getParameter<edm::ParameterSet>("geometry"), std::move(iC), transition) {
0033     auto histograms = iConfig.getParameter<edm::VParameterSet>("histograms");
0034     for (const auto& histoconf : histograms) {
0035       histo.emplace_back(HistogramManager(histoconf, geometryInterface));
0036     }
0037   };
0038 
0039 protected:
0040   std::vector<HistogramManager> histo;
0041   GeometryInterface geometryInterface;
0042 };
0043 
0044 // This is the base class your plugin may derive from. You are not required to
0045 // use it but if you just need some normal HistogramManager this should be perfect.
0046 class SiPixelPhase1Base : public DQMEDAnalyzer, public HistogramManagerHolder {
0047 public:
0048   SiPixelPhase1Base(const edm::ParameterSet& iConfig);
0049 
0050   // You should analyze something, and call histoman.fill(...). Setting to pure virtual function
0051   void analyze(edm::Event const& e, edm::EventSetup const&) override = 0;
0052 
0053   // This booking is usually fine.
0054   // Also used to store the required triggers
0055   void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const&) override;
0056 
0057   ~SiPixelPhase1Base() override {}
0058 
0059 protected:
0060   // Returns a value of whether the trigger stored at position "trgidx" is properly fired.
0061   bool checktrigger(const edm::Event& iEvent, const edm::EventSetup&, const unsigned trgidx) const;
0062 
0063   // must match order in TriggerEventFlag_cfi.py
0064   enum { DCS };
0065 
0066 private:
0067   // Storing the trigger objects per plugin instance
0068   std::vector<std::unique_ptr<GenericTriggerEventFlag>> triggerlist;
0069 };
0070 
0071 // This wraps the Histogram Managers into a DQMEDHarvester. It
0072 // provides sane default implementations, so most plugins don't care about this.
0073 // However, you have to instantiate one with the same config as your Analyzer
0074 // to get the Harvesting done.
0075 // For custom harvesting, you have to derive from this.
0076 class SiPixelPhase1Harvester : public DQMEDHarvester, public HistogramManagerHolder {
0077 public:
0078   SiPixelPhase1Harvester(const edm::ParameterSet& iConfig)
0079       : DQMEDHarvester(), HistogramManagerHolder(iConfig, consumesCollector(), edm::Transition::EndLuminosityBlock) {}
0080 
0081   void dqmEndLuminosityBlock(DQMStore::IBooker& iBooker,
0082                              DQMStore::IGetter& iGetter,
0083                              edm::LuminosityBlock const& lumiBlock,
0084                              edm::EventSetup const&) override;
0085   void dqmEndJob(DQMStore::IBooker& iBooker, DQMStore::IGetter& iGetter) override;
0086 };
0087 #endif