Skip to content

Commit

Permalink
Merge pull request #1606 from mommsen/RemoveStreamerEOF
Browse files Browse the repository at this point in the history
DAQ updates -- Remove EOF record from streamer file
  • Loading branch information
ktf committed Nov 28, 2013
2 parents af3a3cf + e929c5d commit fc0d12c
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 454 deletions.
61 changes: 2 additions & 59 deletions EventFilter/Utilities/plugins/RecoEventWriterForFU.cc
Expand Up @@ -5,24 +5,13 @@
namespace evf {
RecoEventWriterForFU::RecoEventWriterForFU(edm::ParameterSet const& ps) :
stream_writer_preamble_(0),
stream_writer_postamble_(0),
stream_writer_events_(0),
hltCount_(0),
stream_eof_size_(0) {
stream_writer_events_(0)
{
}

RecoEventWriterForFU::~RecoEventWriterForFU() {
}

void RecoEventWriterForFU::stop() {
// User code of this class MUST call method

//Write the EOF Record Both at the end of Streamer file
uint32 const dummyStatusCode = 1234;

stream_eof_size_ = stream_writer_postamble_->writeEOF(dummyStatusCode, hltStats_);
}

void RecoEventWriterForFU::doOutputHeader(InitMsgBuilder const& init_message) {
//Let us turn it into a View
InitMsgView view(init_message.startAddress());
Expand All @@ -32,14 +21,6 @@ namespace evf {
void RecoEventWriterForFU::doOutputHeader(InitMsgView const& init_message) {
//Write the Init Message to Streamer file
stream_writer_preamble_->write(init_message);

//HLT Count
hltCount_ = init_message.get_hlt_bit_cnt();

//Initialize the HLT Stat vector with all ZEROs
for(uint32 i = 0; i != hltCount_; ++i) {
hltStats_.push_back(0);
}
}

void RecoEventWriterForFU::doOutputHeaderFragment(RecoEventWriterForFUHeaderParams const& hdrParams) {
Expand All @@ -48,30 +29,11 @@ namespace evf {
hdrParams.fragmentCount,
hdrParams.dataPtr,
hdrParams.dataSize);
if (hdrParams.fragmentIndex == 0) {
//HLT Count
hltCount_ = hdrParams.hltCount;

//Initialize the HLT Stat vector with all ZEROs
for(uint32 i = 0; i != hltCount_; ++i) {
hltStats_.push_back(0);
}
}
}

void RecoEventWriterForFU::doOutputEvent(EventMsgView const& msg) {
//Write the Event Message to Streamer file
stream_writer_events_->write(msg);

// Lets update HLT Stat, know how many
// Events for which Trigger are being written

//get the HLT Packed bytes
std::vector<uint8> packedHlt;
uint32 const hlt_sz = (hltCount_ != 0 ? 1 + ((hltCount_ - 1) / 4) : 0);
packedHlt.resize(hlt_sz);
msg.hltTriggerBits(&packedHlt[0]);
updateHLTStats(packedHlt);
}

void RecoEventWriterForFU::doOutputEvent(EventMsgBuilder const& msg) {
Expand All @@ -85,24 +47,6 @@ namespace evf {
evtParams.fragmentCount,
evtParams.dataPtr,
evtParams.dataSize);
if (evtParams.fragmentIndex == 0) {
// Lets update HLT Stat, know how many
// Events for which Trigger are being written
updateHLTStats(evtParams.hltBits);
}
}

void RecoEventWriterForFU::updateHLTStats(std::vector<uint8> const& packedHlt) {
unsigned int const packInOneByte = 4;
unsigned char const testAgaint = 0x01;
for(unsigned int i = 0; i != hltCount_; ++i) {
unsigned int const whichByte = i/packInOneByte;
unsigned int const indxWithinByte = i % packInOneByte;
if ((testAgaint << (2 * indxWithinByte)) & (packedHlt.at(whichByte))) {
++hltStats_[i];
}
//else std::cout <<"Bit "<<i<<" is not set"<< std::endl;
}
}

void RecoEventWriterForFU::fillDescription(edm::ParameterSetDescription& desc) {
Expand All @@ -111,7 +55,6 @@ namespace evf {
}
void RecoEventWriterForFU::setOutputFiles(std::string &init, std::string &eof){
stream_writer_preamble_.reset(new StreamerOutputFile(init));
stream_writer_postamble_.reset(new StreamerOutputFile(eof));
// stream_writer_events_.reset(new StreamerOutputFile(events));
}
void RecoEventWriterForFU::setOutputFile(std::string &events){
Expand Down
10 changes: 1 addition & 9 deletions EventFilter/Utilities/plugins/RecoEventWriterForFU.h
Expand Up @@ -63,22 +63,14 @@ namespace evf
void doOutputEventFragment(RecoEventWriterForFUEventParams const&);

void start(){}
void stop();
// Returns the sizes of EOF records, call them after
// u called stop, just before destruction
uint32 getStreamEOFSize() const {return stream_eof_size_;}
void stop(){};

uint32 get_adler32() const { return stream_writer_events_->adler32();}

private:
void updateHLTStats(std::vector<uint8> const& packedHlt);

std::auto_ptr<StreamerOutputFile> stream_writer_preamble_;
std::auto_ptr<StreamerOutputFile> stream_writer_postamble_;
std::auto_ptr<StreamerOutputFile> stream_writer_events_;
uint32 hltCount_;
std::vector<uint32> hltStats_;
uint32 stream_eof_size_;

};
}
Expand Down
72 changes: 0 additions & 72 deletions IOPool/Streamer/bin/DiagStreamerFile.cpp
Expand Up @@ -42,10 +42,8 @@ bool uncompressBuffer(unsigned char* inputBuffer,
unsigned int expectedFullSize);
bool test_chksum(EventMsgView const* eview);
bool test_uncompress(EventMsgView const* eview, std::vector<unsigned char> &dest);
bool test_hltStats(std::vector<uint32> const&, std::vector<uint32> const&);
void readfile(std::string filename, std::string outfile);
void help();
void updateHLTStats(std::vector<uint8> const& packedHlt, uint32 hltcount, std::vector<uint32> &hltStats);

//==========================================================================
int main(int argc, char* argv[]){
Expand Down Expand Up @@ -82,8 +80,6 @@ void readfile(std::string filename, std::string outfile) {
uint32 num_badchksum(0);
uint32 num_goodevents(0);
uint32 num_duplevents(0);
uint32 hltcount(0);
std::vector<uint32> hltStats(0);
std::vector<unsigned char> compress_buffer(7000000);
std::map<uint32, uint32> seenEventMap;
bool output(false);
Expand All @@ -105,10 +101,6 @@ void readfile(std::string filename, std::string outfile) {
if(output) {
stream_output.write(*init);
}
hltcount = init->get_hlt_bit_cnt();
//Initialize the HLT Stat vector with all ZEROs
for(uint32 i = 0; i != hltcount; ++i)
hltStats.push_back(0);

// ------- event
std::cout << "\n\n-------------EVENT Messages-------------------" << std::endl;
Expand Down Expand Up @@ -190,13 +182,6 @@ void readfile(std::string filename, std::string outfile) {
++num_goodevents;
stream_output.write(*eview);
}
//get the HLT Packed bytes
std::vector<uint8> packedHlt;
uint32 hlt_sz = 0;
if(hltcount != 0) hlt_sz = 1 + ((hltcount - 1)/4);
packedHlt.resize(hlt_sz);
eview->hltTriggerBits(&packedHlt[0]);
updateHLTStats(packedHlt, hltcount, hltStats);
//dumpEventView(eview);
}
if((num_events % 50) == 0) {
Expand All @@ -207,25 +192,6 @@ void readfile(std::string filename, std::string outfile) {
if(output) std::cout << "Wrote " << num_goodevents << " good events " << std::endl;
}
}

EOFRecordView* eofRecord(0);
if(!stream_reader.eofRecordMessage(hltcount, eofRecord)) {
std::cout << "Failed to read EOF record" << std::endl;
} else {
if(eofRecord->events() != num_events)
std::cout << "EOF record claims to have " << eofRecord->events()
<< " while there are " << num_events << " events" << std::endl;
if(eofRecord->run() != 1)
std::cout << "EOF record has dummy run number " << eofRecord->run()
<< " instead of 1" << std::endl;
if(eofRecord->statusCode() != 1234)
std::cout << "EOF record has dummy status Code " << eofRecord->statusCode()
<< " instead of 1234" << std::endl;

std::vector<uint32> eofHltStats;
eofRecord->hltStats(eofHltStats);
test_hltStats(eofHltStats,hltStats);
}

std::cout << std::endl << "------------END--------------" << std::endl
<< "read " << num_events << " events" << std::endl
Expand All @@ -235,8 +201,6 @@ void readfile(std::string filename, std::string outfile) {
<< "and " << num_duplevents << " duplicated event Id" << std::endl;

if(output) {
uint32 dummyStatusCode = 1234;
stream_output.writeEOF(dummyStatusCode, hltStats);
std::cout << "Wrote " << num_goodevents << " good events " << std::endl;
}

Expand Down Expand Up @@ -342,39 +306,3 @@ bool uncompressBuffer(unsigned char *inputBuffer,
return true;
}

//==========================================================================
bool test_hltStats(std::vector<uint32> const& hltStats1, std::vector<uint32> const& hltStats2)
{
bool is_bad(false);
const size_t hltcount = hltStats1.size();
if(hltcount != hltStats2.size()) {
std::cout << "HLT stats has different HLT counts: "
<< hltcount << " vs " << hltStats2.size() << std::endl;
is_bad = true;
}
for(size_t i = 0; i != hltcount; ++i) {
if(hltStats1[i] != hltStats2[i]) {
std::cout << "HLT stats for bit " << i << " differs: "
<< hltStats1[i] << " vs " << hltStats2[i] << std::endl;
is_bad = true;
}
}
return is_bad;
}


//==========================================================================
void updateHLTStats(std::vector<uint8> const& packedHlt, uint32 hltcount, std::vector<uint32> &hltStats)
{
unsigned int packInOneByte = 4;
unsigned char testAgaint = 0x01;
for(unsigned int i = 0; i != hltcount; ++i)
{
unsigned int whichByte = i/packInOneByte;
unsigned int indxWithinByte = i % packInOneByte;
if((testAgaint << (2 * indxWithinByte)) & (packedHlt.at(whichByte))) {
++hltStats[i];
}
}
}

56 changes: 0 additions & 56 deletions IOPool/Streamer/interface/EOFRecord.h

This file was deleted.

28 changes: 0 additions & 28 deletions IOPool/Streamer/interface/EOFRecordBuilder.h

This file was deleted.

2 changes: 1 addition & 1 deletion IOPool/Streamer/interface/MsgHeader.h
Expand Up @@ -12,7 +12,7 @@ struct Header
char_uint32 size_; // of entire message including all headers

// 20-Jul-2006, KAB: added enumeration for message types
enum Codes { INVALID = 0, INIT = 1, EVENT = 2, DONE = 3, EOFRECORD = 4,
enum Codes { INVALID = 0, INIT = 1, EVENT = 2, DONE = 3, // EOFRECORD = 4 is no longer used
HEADER_REQUEST = 5, EVENT_REQUEST = 6,
CONS_REG_REQUEST = 7, CONS_REG_RESPONSE = 8,
DQM_INIT = 9, DQM_EVENT = 10, DQMEVENT_REQUEST = 11,
Expand Down
4 changes: 0 additions & 4 deletions IOPool/Streamer/interface/StreamerInputFile.h
Expand Up @@ -2,7 +2,6 @@
#define IOPool_Streamer_StreamerInputFile_h

#include "IOPool/Streamer/interface/InitMessage.h"
#include "IOPool/Streamer/interface/EOFRecord.h"
#include "IOPool/Streamer/interface/EventMessage.h"
#include "IOPool/Streamer/interface/MsgTools.h"
#include "Utilities/StorageFactory/interface/IOTypes.h"
Expand Down Expand Up @@ -36,9 +35,6 @@ namespace edm {
EventMsgView const* currentRecord() const { return currentEvMsg_.get(); }
/** Points to current Record */

bool eofRecordMessage(uint32 const& hlt_path_cnt, EOFRecordView*&);
/** Returns to file end-of-file record if the file has been complete read */

bool newHeader() { bool tmp = newHeader_; newHeader_ = false; return tmp;} /** Test bit if a new header is encountered */

/// Needs to be public because of forking.
Expand Down
4 changes: 0 additions & 4 deletions IOPool/Streamer/interface/StreamerOutputFile.h
Expand Up @@ -52,10 +52,6 @@ class StreamerOutputFile
uint64 writeEventFragment(uint32 fragIndex, uint32 fragCount,
const char *dataPtr, uint32 dataSize);

//Returns how many bytes were written out
uint32 writeEOF(uint32 statusCode,
const std::vector<uint32>& hltStats);

uint32 adler32() const { return streamerfile_->adler32(); }

private:
Expand Down

0 comments on commit fc0d12c

Please sign in to comment.