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 if (!templateConsumer_->sharedMode())
163 templateConsumer_->doOutputEvent(
msg);
166 template <
class Consumer>
169 templateConsumer_->start();
172 template <
class Consumer>
174 templateConsumer_->stop();
177 template <
class Consumer>
182 std::cout <<
" writing to destination dir " << destinationDir <<
" name: " <<
filename << std::endl;
183 templateConsumer_->initialize(destinationDir,
filename,
ls.id().luminosityBlock());
187 ::gettimeofday(&
now,
nullptr);
193 writtenSizeLast = writtensize;
194 ::gettimeofday(&startOfLastLumi,
nullptr);
197 ::gettimeofday(&startOfLastLumi,
nullptr);
203 template <
class Consumer>
206 templateConsumer_->endOfLS(
ls.id().luminosityBlock());
209 template <
class Consumer>
213 desc.add<
unsigned int>(
"numEventsPerFile", 100);
214 desc.add<
unsigned int>(
"frdVersion", 6);
215 Consumer::extendDescription(
desc);
220 #endif // IOPool_Streamer_interface_RawEventOutputModuleForBU_h