27 edm::
one::OutputModule<
edm::
one::WatchLuminosityBlocks>(ps),
29 frdVersion_(ps.getUntrackedParameter<unsigned
int>(
"frdVersion")),
30 frdFileVersion_(ps.getUntrackedParameter<unsigned
int>(
"frdFileVersion")),
31 filePrefix_(ps.getUntrackedParameter<
std::
string>(
"filePrefix")),
32 fileName_(ps.getUntrackedParameter<
std::
string>(
"fileName")) {}
39 desc.addUntracked<
unsigned int>(
"frdFileVersion", 1),
desc.addUntracked<
unsigned int>(
"frdVersion", 6);
49 e.getByToken(
token_, fedBuffers);
54 int expectedSize = headerSize;
59 expectedSize += singleFED.
size();
63 std::unique_ptr<std::vector<unsigned char>> workBuffer(
64 std::make_unique<std::vector<unsigned char>>(expectedSize + 256));
70 if (!
e.eventAuxiliary().isRealData())
76 *bufPtr++ = (
uint32)
e.id().run();
77 *bufPtr++ = (
uint32)
e.luminosityBlock();
78 *bufPtr++ = (
uint32)
e.id().event();
86 fedsize[
idx] = singleFED.
size();
89 memcpy(bufPtr, fedsize, 1024 *
sizeof(
uint32));
92 *bufPtr++ = expectedSize - headerSize;
97 uint32* payloadPtr = bufPtr;
100 if (singleFED.
size() > 0) {
101 memcpy(bufPtr, singleFED.
data(), singleFED.
size());
102 bufPtr += singleFED.
size() / 4;
108 *(payloadPtr - 1) =
crc32c(crc, (
const unsigned char*)payloadPtr, expectedSize - headerSize);
113 cms::Adler32((
const char*)payloadPtr, expectedSize - headerSize, adlera, adlerb);
114 *(payloadPtr - 1) = (adlerb << 16) | adlera;
123 if ((
unsigned)retval !=
msg.size()) {
125 <<
"Error writing FED Raw Data event data to " <<
fileName_ <<
". Possibly the output disk " 126 <<
"is full?" << std::endl;
140 throw cms::Exception(
"RawEventFileWriterForBU",
"beginLuminosityBlock")
141 <<
"Multiple lumisections not supported in the same FRD file!";
145 std::stringstream
ss;
147 << lumiBlock.
run() <<
"_ls" << std::setfill(
'0') << std::setw(4) <<
ls <<
"_index000000.raw";
154 outfd_ = open(
fileName.c_str(), O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
158 throw cms::Exception(
"RawEventFileWriterForBU",
"beginLuminosityBlock")
159 <<
"Error opening FED Raw Data event output file: " <<
fileName <<
": " << strerror(errno) <<
"\n";
179 throw cms::Exception(
"RawEventFileWriterForBU",
"beginLuminosityBlock")
193 lseek(
outfd_, 0, SEEK_SET);
197 lseek(
outfd_, 0, SEEK_SET);
206 edm::LogInfo(
"FRDOutputModule") <<
"closed RAW input file";
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
LuminosityBlockNumber_t luminosityBlock() const
void finishFileWrite(unsigned int run, int ls)
const uint32_t frdFileVersion_
constexpr size_t FRDHeaderMaxVersion
uint32_t perFileEventCount_
size_t size() const
Lenght of the data buffer in bytes.
FRDOutputModule(edm::ParameterSet const &ps)
void endLuminosityBlock(edm::LuminosityBlockForOutput const &) override
~FRDOutputModule() override
void beginLuminosityBlock(edm::LuminosityBlockForOutput const &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
uint32_t crc32c(uint32_t crc, const unsigned char *buf, size_t len)
Log< level::Info, false > LogInfo
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
const edm::EDGetTokenT< FEDRawDataCollection > token_
LuminosityBlockID const & id() const
const uint32_t frdVersion_
const uint16 FRDEVENT_MASK_ISGENDATA
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
constexpr std::array< uint32, FRDHeaderMaxVersion+1 > FRDHeaderVersionSize
static constexpr int lastFEDId()
void write(edm::EventForOutput const &e) override