1 #ifndef IOPool_Streamer_interface_RawEventOutputModuleForBU_h
2 #define IOPool_Streamer_interface_RawEventOutputModuleForBU_h
25 template <
class Consumer>
64 template <
class Consumer>
68 templateConsumer_(new Consumer(ps)),
70 numEventsPerFile_(ps.getParameter<unsigned
int>(
"numEventsPerFile")),
71 frdVersion_(ps.getParameter<unsigned
int>(
"frdVersion")) {}
73 template <
class Consumer>
76 template <
class Consumer>
78 unsigned int ls =
e.luminosityBlock();
79 if (totevents > 0 && totevents % numEventsPerFile_ == 0) {
83 templateConsumer_->initialize(destinationDir,
filename,
ls);
89 e.getByToken(token_, fedBuffers);
94 int expectedSize = headerSize;
99 expectedSize += singleFED.
size();
102 totsize += expectedSize;
104 std::unique_ptr<std::vector<unsigned char>> workBuffer(
105 std::make_unique<std::vector<unsigned char>>(expectedSize + 256));
107 if (frdVersion_ <= 5) {
108 *bufPtr++ = (
uint32)frdVersion_;
111 if (!
e.eventAuxiliary().isRealData())
117 *bufPtr++ = (
uint32)
e.id().run();
118 *bufPtr++ = (
uint32)
e.luminosityBlock();
119 *bufPtr++ = (
uint32)
e.id().event();
120 if (frdVersion_ == 4)
123 if (frdVersion_ < 3) {
127 fedsize[
idx] = singleFED.
size();
130 memcpy(bufPtr, fedsize, 1024 *
sizeof(
uint32));
133 *bufPtr++ = expectedSize - headerSize;
135 if (frdVersion_ <= 4)
138 uint32* payloadPtr = bufPtr;
141 if (singleFED.
size() > 0) {
142 memcpy(bufPtr, singleFED.
data(), singleFED.
size());
143 bufPtr += singleFED.
size() / 4;
146 if (frdVersion_ > 4) {
149 *(payloadPtr - 1) =
crc32c(crc, (
const unsigned char*)payloadPtr, expectedSize - headerSize);
150 }
else if (frdVersion_ >= 3) {
154 cms::Adler32((
const char*)payloadPtr, expectedSize - headerSize, adlera, adlerb);
155 *(payloadPtr - 1) = (adlerb << 16) | adlera;
160 writtensize +=
msg.size();
162 templateConsumer_->doOutputEvent(
msg);
165 template <
class Consumer>
168 templateConsumer_->start();
171 template <
class Consumer>
173 templateConsumer_->stop();
176 template <
class Consumer>
181 std::cout <<
" writing to destination dir " << destinationDir <<
" name: " <<
filename << std::endl;
182 templateConsumer_->initialize(destinationDir,
filename,
ls.id().luminosityBlock());
186 ::gettimeofday(&
now,
nullptr);
192 writtenSizeLast = writtensize;
193 ::gettimeofday(&startOfLastLumi,
nullptr);
196 ::gettimeofday(&startOfLastLumi,
nullptr);
202 template <
class Consumer>
205 templateConsumer_->endOfLS(
ls.id().luminosityBlock());
208 template <
class Consumer>
212 desc.add<
unsigned int>(
"numEventsPerFile", 100);
213 desc.add<
unsigned int>(
"frdVersion", 6);
214 Consumer::extendDescription(
desc);
219 #endif // IOPool_Streamer_interface_RawEventOutputModuleForBU_h