29 edm::
one::OutputModule<
edm::
one::WatchLuminosityBlocks>(ps),
31 frdVersion_(ps.getUntrackedParameter<unsigned
int>(
"frdVersion")),
32 frdFileVersion_(ps.getUntrackedParameter<unsigned
int>(
"frdFileVersion")),
33 filePrefix_(ps.getUntrackedParameter<
std::
string>(
"filePrefix")),
34 fileName_(ps.getUntrackedParameter<
std::
string>(
"fileName")) {}
41 desc.addUntracked<
unsigned int>(
"frdFileVersion", 1),
desc.addUntracked<
unsigned int>(
"frdVersion", 6);
51 e.getByToken(
token_, fedBuffers);
56 int expectedSize = headerSize;
61 expectedSize += singleFED.
size();
65 std::unique_ptr<std::vector<unsigned char>> workBuffer(
66 std::make_unique<std::vector<unsigned char>>(expectedSize + 256));
72 if (!
e.eventAuxiliary().isRealData())
78 *bufPtr++ = (
uint32)
e.id().run();
79 *bufPtr++ = (
uint32)
e.luminosityBlock();
80 *bufPtr++ = (
uint32)
e.id().event();
88 fedsize[
idx] = singleFED.
size();
91 memcpy(bufPtr, fedsize, 1024 *
sizeof(
uint32));
94 *bufPtr++ = expectedSize - headerSize;
99 uint32* payloadPtr = bufPtr;
102 if (singleFED.
size() > 0) {
103 memcpy(bufPtr, singleFED.
data(), singleFED.
size());
104 bufPtr += singleFED.
size() / 4;
110 *(payloadPtr - 1) =
crc32c(crc, (
const unsigned char*)payloadPtr, expectedSize - headerSize);
115 cms::Adler32((
const char*)payloadPtr, expectedSize - headerSize, adlera, adlerb);
116 *(payloadPtr - 1) = (adlerb << 16) | adlera;
125 if ((
unsigned)retval !=
msg.size()) {
127 <<
"Error writing FED Raw Data event data to " <<
fileName_ <<
". Possibly the output disk " 128 <<
"is full?" << std::endl;
142 throw cms::Exception(
"RawEventFileWriterForBU",
"beginLuminosityBlock")
143 <<
"Multiple lumisections not supported in the same FRD file!";
147 std::stringstream
ss;
149 << lumiBlock.
run() <<
"_ls" << std::setfill(
'0') << std::setw(4) <<
ls <<
"_index000000.raw";
156 outfd_ = open(
fileName.c_str(), O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
160 throw cms::Exception(
"RawEventFileWriterForBU",
"beginLuminosityBlock")
161 <<
"Error opening FED Raw Data event output file: " <<
fileName <<
": " << strerror(errno) <<
"\n";
181 throw cms::Exception(
"RawEventFileWriterForBU",
"beginLuminosityBlock")
195 lseek(
outfd_, 0, SEEK_SET);
199 lseek(
outfd_, 0, SEEK_SET);
208 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_
uint32_t perFileEventCount_
constexpr std::array< uint32, FRDHeaderMaxVersion+1 > FRDHeaderVersionSize
constexpr size_t FRDHeaderMaxVersion
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
const uint16 FRDEVENT_MASK_ISGENDATA
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 unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static constexpr int lastFEDId()
void write(edm::EventForOutput const &e) override