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";
189 lseek(
outfd_, 0, SEEK_SET);
199 edm::LogInfo(
"FRDOutputModule") <<
"closed RAW input file";