Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-12 23:41:44

0001 #ifndef EVFRAWEVENTFILEWRITERFORBU
0002 #define EVFRAWEVENTFILEWRITERFORBU
0003 
0004 // C++ headers
0005 #include <cstdio>
0006 #include <fstream>
0007 #include <memory>
0008 #include <vector>
0009 
0010 // system headers
0011 #include <sys/stat.h>
0012 #include <sys/types.h>
0013 #include <unistd.h>
0014 
0015 // CMSSW headers
0016 #include "EventFilter/Utilities/interface/FastMonitor.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0019 #include "IOPool/Streamer/interface/FRDEventMessage.h"
0020 
0021 namespace evf {
0022   class FastMonitoringService;
0023 }
0024 
0025 class RawEventFileWriterForBU {
0026 public:
0027   explicit RawEventFileWriterForBU(edm::ParameterSet const& ps);
0028   explicit RawEventFileWriterForBU(std::string const& fileName);
0029   ~RawEventFileWriterForBU();
0030 
0031   void doOutputEvent(edm::streamer::FRDEventMsgView const& msg);
0032   void doOutputEvent(void* startAddress, size_t size);
0033 
0034   edm::streamer::uint32 adler32() const { return (adlerb_ << 16) | adlera_; }
0035 
0036   void start() {}
0037   void stop();
0038   void initialize(std::string const& destinationDir, std::string const& name, int run, unsigned int ls);
0039   void endOfLS(unsigned int ls);
0040 
0041   static void extendDescription(edm::ParameterSetDescription& desc);
0042 
0043 private:
0044   bool closefd() {
0045     if (outfd_ >= 0) {
0046       close(outfd_);
0047       outfd_ = -1;
0048       return true;
0049     } else
0050       return false;
0051   }
0052   void finishFileWrite(unsigned int ls);
0053   void writeJsds();
0054   int outfd_ = -1;
0055 
0056   int run_ = -1;
0057   std::string runPrefix_;
0058   evf::FastMonitoringService* fms_ = nullptr;
0059 
0060   jsoncollector::IntJ perRunEventCount_;
0061   jsoncollector::IntJ perRunFileCount_;
0062   jsoncollector::IntJ perRunLumiCount_;
0063   jsoncollector::IntJ perRunLastLumi_;
0064   jsoncollector::IntJ perRunTotalEventCount_;
0065   jsoncollector::IntJ perRunLostEventCount_;
0066 
0067   jsoncollector::IntJ perLumiEventCount_;
0068   jsoncollector::IntJ perLumiFileCount_;
0069   jsoncollector::IntJ perLumiTotalEventCount_;
0070   jsoncollector::IntJ perLumiLostEventCount_;
0071   jsoncollector::IntJ perLumiSize_;
0072 
0073   jsoncollector::IntJ perFileEventCount_;
0074   jsoncollector::IntJ perFileSize_;
0075 
0076   jsoncollector::FastMonitor* fileMon_ = nullptr;
0077   jsoncollector::FastMonitor* lumiMon_ = nullptr;
0078   jsoncollector::FastMonitor* runMon_ = nullptr;
0079 
0080   jsoncollector::DataPointDefinition rawJsonDef_;
0081   jsoncollector::DataPointDefinition eolJsonDef_;
0082   jsoncollector::DataPointDefinition eorJsonDef_;
0083   bool writtenJSDs_ = false;
0084 
0085   std::unique_ptr<std::ofstream> ost_;
0086   std::string fileName_;
0087   std::string destinationDir_;
0088 
0089   int microSleep_;
0090   unsigned int frdFileVersion_;
0091 
0092   edm::streamer::uint32 adlera_;
0093   edm::streamer::uint32 adlerb_;
0094 
0095   unsigned int lumiOpen_ = 0;
0096   unsigned int lumiClosed_ = 0;
0097 };
0098 #endif