Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:06

0001 #ifndef EventFilter_Utilities_EvFOutputModule_h
0002 #define EventFilter_Utilities_EvFOutputModule_h
0003 
0004 #include "IOPool/Streamer/interface/StreamerOutputFile.h"
0005 #include "FWCore/Framework/interface/one/OutputModule.h"
0006 #include "IOPool/Streamer/interface/StreamerOutputModuleCommon.h"
0007 #include "FWCore/Utilities/interface/EDGetToken.h"
0008 #include "DataFormats/Streamer/interface/StreamedProducts.h"
0009 
0010 #include "EventFilter/Utilities/interface/JsonMonitorable.h"
0011 #include "EventFilter/Utilities/interface/FastMonitor.h"
0012 #
0013 typedef edm::detail::TriggerResultsBasedEventSelector::handle_t Trig;
0014 
0015 namespace evf {
0016 
0017   class FastMonitoringService;
0018   //  class EvFOutputEventWriter;
0019 
0020   class EvFOutputEventWriter {
0021   public:
0022     explicit EvFOutputEventWriter(std::string const& filePath)
0023         : filePath_(filePath), accepted_(0), stream_writer_events_(new StreamerOutputFile(filePath)) {}
0024 
0025     ~EvFOutputEventWriter() {}
0026 
0027     void close() { stream_writer_events_->close(); }
0028 
0029     void doOutputEvent(EventMsgBuilder const& msg) {
0030       EventMsgView eview(msg.startAddress());
0031       stream_writer_events_->write(eview);
0032     }
0033 
0034     uint32 get_adler32() const { return stream_writer_events_->adler32(); }
0035 
0036     std::string const& getFilePath() const { return filePath_; }
0037 
0038     unsigned long getAccepted() const { return accepted_; }
0039     void incAccepted() { accepted_++; }
0040 
0041   private:
0042     std::string filePath_;
0043     unsigned long accepted_;
0044     edm::propagate_const<std::unique_ptr<StreamerOutputFile>> stream_writer_events_;
0045   };
0046 
0047   class EvFOutputJSONWriter {
0048   public:
0049     EvFOutputJSONWriter(edm::ParameterSet const& ps,
0050                         edm::SelectedProducts const* selections,
0051                         std::string const& streamLabel,
0052                         std::string const& moduleLabel);
0053 
0054     edm::StreamerOutputModuleCommon streamerCommon_;
0055 
0056     jsoncollector::IntJ processed_;
0057     jsoncollector::IntJ accepted_;
0058     jsoncollector::IntJ errorEvents_;
0059     jsoncollector::IntJ retCodeMask_;
0060     jsoncollector::StringJ filelist_;
0061     jsoncollector::IntJ filesize_;
0062     jsoncollector::StringJ inputFiles_;
0063     jsoncollector::IntJ fileAdler32_;
0064     jsoncollector::StringJ transferDestination_;
0065     jsoncollector::StringJ mergeType_;
0066     jsoncollector::IntJ hltErrorEvents_;
0067     std::shared_ptr<jsoncollector::FastMonitor> jsonMonitor_;
0068     jsoncollector::DataPointDefinition outJsonDef_;
0069   };
0070 
0071   typedef edm::one::OutputModule<edm::one::WatchRuns, edm::LuminosityBlockCache<evf::EvFOutputEventWriter>>
0072       EvFOutputModuleType;
0073 
0074   class EvFOutputModule : public EvFOutputModuleType {
0075   public:
0076     explicit EvFOutputModule(edm::ParameterSet const& ps);
0077     ~EvFOutputModule() override;
0078     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0079 
0080   private:
0081     void beginRun(edm::RunForOutput const& run) override;
0082     void write(edm::EventForOutput const& e) override;
0083 
0084     //pure in parent class but unused here
0085     void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {}
0086     void writeRun(edm::RunForOutput const&) override {}
0087     void endRun(edm::RunForOutput const&) override {}
0088 
0089     std::shared_ptr<EvFOutputEventWriter> globalBeginLuminosityBlock(
0090         edm::LuminosityBlockForOutput const& iLB) const override;
0091     void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override;
0092 
0093     Trig getTriggerResults(edm::EDGetTokenT<edm::TriggerResults> const& token, edm::EventForOutput const& e) const;
0094 
0095     edm::ParameterSet const& ps_;
0096     std::string streamLabel_;
0097     edm::EDGetTokenT<edm::TriggerResults> trToken_;
0098     edm::EDGetTokenT<edm::SendJobHeader::ParameterSetMap> psetToken_;
0099 
0100     evf::FastMonitoringService* fms_;
0101 
0102     std::unique_ptr<evf::EvFOutputJSONWriter> jsonWriter_;
0103 
0104   };  //end-of-class-def
0105 
0106 }  // namespace evf
0107 
0108 #endif