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")) {}
54 int expectedSize = headerSize;
57 for (
int idx = 0; idx < nFeds; ++idx) {
58 FEDRawData singleFED = fedBuffers->FEDData(idx);
59 expectedSize += singleFED.
size();
63 std::unique_ptr<std::vector<unsigned char>> workBuffer(
64 std::make_unique<std::vector<unsigned char>>(expectedSize + 256));
73 *((
uint16*)bufPtr + 1) = flags;
84 for (
int idx = 0; idx < 1024; ++idx) {
85 FEDRawData singleFED = fedBuffers->FEDData(idx);
86 fedsize[idx] = singleFED.
size();
89 memcpy(bufPtr, fedsize, 1024 *
sizeof(
uint32));
92 *bufPtr++ = expectedSize - headerSize;
97 uint32* payloadPtr = bufPtr;
98 for (
int idx = 0; idx < nFeds; ++idx) {
99 FEDRawData singleFED = fedBuffers->FEDData(idx);
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";
EventNumber_t event() const
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
EventID const & id() const
EventAuxiliary const & eventAuxiliary() const
const uint32_t frdFileVersion_
constexpr size_t FRDHeaderMaxVersion
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
uint32_t perFileEventCount_
void finishFileWrite(int ls)
FRDOutputModule(edm::ParameterSet const &ps)
void endLuminosityBlock(edm::LuminosityBlockForOutput const &) override
size_t size() const
Lenght of the data buffer in bytes.
~FRDOutputModule() override
void beginLuminosityBlock(edm::LuminosityBlockForOutput const &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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_
LuminosityBlockNumber_t luminosityBlock() const
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) 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.
LuminosityBlockNumber_t luminosityBlock() const
constexpr std::array< uint32, FRDHeaderMaxVersion+1 > FRDHeaderVersionSize
LuminosityBlockID const & id() const
static constexpr int lastFEDId()
void write(edm::EventForOutput const &e) override