File indexing completed on 2024-05-31 04:19:30
0001 #ifndef EVFRAWEVENTFILEWRITERFORBU
0002 #define EVFRAWEVENTFILEWRITERFORBU
0003
0004
0005 #include <cstdio>
0006 #include <fstream>
0007 #include <memory>
0008 #include <vector>
0009
0010
0011 #include <sys/stat.h>
0012 #include <sys/types.h>
0013 #include <unistd.h>
0014
0015
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 class RawEventFileWriterForBU {
0022 public:
0023 explicit RawEventFileWriterForBU(edm::ParameterSet const& ps);
0024 explicit RawEventFileWriterForBU(std::string const& fileName);
0025 ~RawEventFileWriterForBU();
0026
0027 void doOutputEvent(edm::streamer::FRDEventMsgView const& msg);
0028
0029 edm::streamer::uint32 adler32() const { return (adlerb_ << 16) | adlera_; }
0030
0031 void start() {}
0032 void stop();
0033 void initialize(std::string const& destinationDir, std::string const& name, int ls);
0034 void endOfLS(int ls);
0035 void makeRunPrefix(std::string const& destinationDir);
0036
0037 static void extendDescription(edm::ParameterSetDescription& desc);
0038
0039 private:
0040 bool closefd() {
0041 if (outfd_ >= 0) {
0042 close(outfd_);
0043 outfd_ = -1;
0044 return true;
0045 } else
0046 return false;
0047 }
0048 void finishFileWrite(int ls);
0049 void writeJsds();
0050 int outfd_ = -1;
0051
0052 int run_ = -1;
0053 std::string runPrefix_;
0054
0055 jsoncollector::IntJ perRunEventCount_;
0056 jsoncollector::IntJ perRunFileCount_;
0057 jsoncollector::IntJ perRunLumiCount_;
0058 jsoncollector::IntJ perRunLastLumi_;
0059
0060 jsoncollector::IntJ perLumiEventCount_;
0061 jsoncollector::IntJ perLumiFileCount_;
0062 jsoncollector::IntJ perLumiTotalEventCount_;
0063 jsoncollector::IntJ perLumiLostEventCount_;
0064 jsoncollector::IntJ perLumiSize_;
0065
0066 jsoncollector::IntJ perFileEventCount_;
0067 jsoncollector::IntJ perFileSize_;
0068
0069 jsoncollector::FastMonitor* fileMon_ = nullptr;
0070 jsoncollector::FastMonitor* lumiMon_ = nullptr;
0071 jsoncollector::FastMonitor* runMon_ = nullptr;
0072
0073 jsoncollector::DataPointDefinition rawJsonDef_;
0074 jsoncollector::DataPointDefinition eolJsonDef_;
0075 jsoncollector::DataPointDefinition eorJsonDef_;
0076 bool writtenJSDs_ = false;
0077
0078 std::unique_ptr<std::ofstream> ost_;
0079 std::string fileName_;
0080 std::string destinationDir_;
0081
0082 int microSleep_;
0083 unsigned int frdFileVersion_;
0084
0085 edm::streamer::uint32 adlera_;
0086 edm::streamer::uint32 adlerb_;
0087
0088 unsigned int lumiOpen_ = 0;
0089 unsigned int lumiClosed_ = 0;
0090 };
0091 #endif