Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:51

0001 #ifndef DQMSERVICES_COMPONENTS_DQMFILESAVERBASE_H
0002 #define DQMSERVICES_COMPONENTS_DQMFILESAVERBASE_H
0003 
0004 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0005 #include "DQMServices/Core/interface/DQMStore.h"
0006 
0007 #include "EventFilter/Utilities/interface/FastMonitoringService.h"
0008 #include "EventFilter/Utilities/interface/EvFDaqDirector.h"
0009 
0010 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0012 
0013 #include <sys/time.h>
0014 #include <string>
0015 #include <mutex>
0016 
0017 #include <boost/property_tree/ptree.hpp>
0018 
0019 namespace dqm {
0020 
0021   struct NoCache {};
0022 
0023   class DQMFileSaverBase : public edm::global::EDAnalyzer<edm::RunCache<NoCache>, edm::LuminosityBlockCache<NoCache> > {
0024   public:
0025     typedef dqm::legacy::MonitorElement MonitorElement;
0026     typedef dqm::legacy::DQMStore DQMStore;
0027 
0028     DQMFileSaverBase(const edm::ParameterSet &ps);
0029     ~DQMFileSaverBase() override;
0030 
0031   protected:
0032     // file name components, in order
0033     struct FileParameters {
0034       std::string path_;      //
0035       std::string producer_;  // DQM or Playback
0036       int version_;
0037       std::string tag_;
0038       long run_;
0039       long lumi_;
0040       std::string child_;  // child of a fork
0041     };
0042 
0043   protected:
0044     //virtual void beginJob(void) const override final;
0045     //virtual void endJob(void) const override final;
0046 
0047     std::shared_ptr<NoCache> globalBeginRun(const edm::Run &, const edm::EventSetup &) const final;
0048 
0049     std::shared_ptr<NoCache> globalBeginLuminosityBlock(const edm::LuminosityBlock &,
0050                                                         const edm::EventSetup &) const final;
0051 
0052     void analyze(edm::StreamID, const edm::Event &e, const edm::EventSetup &) const final;
0053 
0054     void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const final;
0055     void globalEndRun(const edm::Run &, const edm::EventSetup &) const final;
0056 
0057     // these method (and only these) should be overriden
0058     // so we need to call all file savers
0059     virtual void initRun() const {};
0060     virtual void saveLumi(const FileParameters &fp) const {};
0061     virtual void saveRun(const FileParameters &fp) const {};
0062 
0063     static const std::string filename(const FileParameters &fp, bool useLumi = false);
0064 
0065     // utilities
0066     void logFileAction(const std::string &msg, const std::string &fileName) const;
0067     void saveJobReport(const std::string &filename) const;
0068 
0069     // members
0070     mutable std::mutex initial_fp_lock_;
0071     FileParameters initial_fp_;
0072     int runNumber_;
0073 
0074   public:
0075     static void fillDescription(edm::ParameterSetDescription &d);
0076   };
0077 
0078 }  // namespace dqm
0079 
0080 #endif  // DQMSERVICES_COMPONENTS_DQMFILESAVERBASE_H