Skip to content

Commit

Permalink
Merge pull request #30181 from camolezi/reduce-boost-shared_array-Eve…
Browse files Browse the repository at this point in the history
…ntFilter2

Reduce boost use in EventFilter/Utilities
  • Loading branch information
cmsbuild committed Jun 11, 2020
2 parents f02d916 + 7ed8acf commit 78c22b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
6 changes: 0 additions & 6 deletions EventFilter/Utilities/plugins/RawEventFileWriterForBU.cc
Expand Up @@ -107,12 +107,6 @@ void RawEventFileWriterForBU::doOutputEvent(FRDEventMsgView const& msg) {
// cms::Adler32((const char*) msg.startAddress(), msg.size(), adlera_, adlerb_);
}

void RawEventFileWriterForBU::doOutputEventFragment(unsigned char* dataPtr, unsigned long dataSize) {
throw cms::Exception("RawEventFileWriterForBU", "doOutputEventFragment") << "Unsupported output mode ";

//cms::Adler32((const char*) dataPtr, dataSize, adlera_, adlerb_);
}

void RawEventFileWriterForBU::initialize(std::string const& destinationDir, std::string const& name, int ls) {
destinationDir_ = destinationDir;

Expand Down
8 changes: 4 additions & 4 deletions EventFilter/Utilities/plugins/RawEventFileWriterForBU.h
Expand Up @@ -12,8 +12,10 @@
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "boost/shared_array.hpp"
#include <memory>
#include <vector>

class RawEventFileWriterForBU {
public:
Expand All @@ -22,9 +24,7 @@ class RawEventFileWriterForBU {
~RawEventFileWriterForBU();

void doOutputEvent(FRDEventMsgView const& msg);
void doOutputEvent(boost::shared_array<unsigned char>& msg){};
void doOutputEventFragment(unsigned char* dataPtr, unsigned long dataSize);
//void doFlushFile();

uint32 adler32() const { return (adlerb_ << 16) | adlera_; }

void start() {}
Expand Down
14 changes: 7 additions & 7 deletions EventFilter/Utilities/plugins/RawEventOutputModuleForBU.h
Expand Up @@ -18,7 +18,8 @@
#include "FWCore/Utilities/interface/Adler32Calculator.h"
#include "EventFilter/Utilities/interface/crc32c.h"

#include "boost/shared_array.hpp"
#include <memory>
#include <vector>

class FRDEventMsgView;
template <class Consumer>
Expand Down Expand Up @@ -107,8 +108,9 @@ void RawEventOutputModuleForBU<Consumer>::write(edm::EventForOutput const& e) {

totsize += expectedSize;
// build the FRDEvent into a temporary buffer
boost::shared_array<unsigned char> workBuffer(new unsigned char[expectedSize + 256]);
uint32* bufPtr = (uint32*)workBuffer.get();
std::unique_ptr<std::vector<unsigned char>> workBuffer(
std::make_unique<std::vector<unsigned char>>(expectedSize + 256));
uint32* bufPtr = (uint32*)(workBuffer.get()->data());
*bufPtr++ = (uint32)frdVersion_; // version number
*bufPtr++ = (uint32)e.id().run();
*bufPtr++ = (uint32)e.luminosityBlock();
Expand Down Expand Up @@ -152,12 +154,10 @@ void RawEventOutputModuleForBU<Consumer>::write(edm::EventForOutput const& e) {
}

// create the FRDEventMsgView and use the template consumer to write it out
FRDEventMsgView msg(workBuffer.get());
FRDEventMsgView msg(workBuffer.get()->data());
writtensize += msg.size();

if (templateConsumer_->sharedMode())
templateConsumer_->doOutputEvent(workBuffer);
else
if (!templateConsumer_->sharedMode())
templateConsumer_->doOutputEvent(msg);
}

Expand Down

0 comments on commit 78c22b0

Please sign in to comment.