CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

edm::StreamerFileWriter Class Reference

#include <StreamerFileWriter.h>

List of all members.

Public Member Functions

void doOutputEvent (EventMsgBuilder const &msg)
void doOutputEvent (EventMsgView const &msg)
void doOutputEventFragment (StreamerFileWriterEventParams const &)
void doOutputHeader (InitMsgView const &init_message)
void doOutputHeader (InitMsgBuilder const &init_message)
void doOutputHeaderFragment (StreamerFileWriterHeaderParams const &)
uint32 get_adler32 () const
uint32 getStreamEOFSize () const
void start ()
void stop ()
 StreamerFileWriter (edm::ParameterSet const &ps)
 StreamerFileWriter (std::string const &fileName)
 ~StreamerFileWriter ()

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)

Private Member Functions

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

Private Attributes

uint32 hltCount_
std::vector< uint32hltStats_
uint32 stream_eof_size_
std::auto_ptr< StreamerOutputFilestream_writer_

Detailed Description

Definition at line 46 of file StreamerFileWriter.h.


Constructor & Destructor Documentation

edm::StreamerFileWriter::StreamerFileWriter ( edm::ParameterSet const &  ps) [explicit]

Definition at line 5 of file StreamerFileWriter.cc.

                                                                  :
    stream_writer_(new StreamerOutputFile(
                      ps.getUntrackedParameter<std::string>("fileName"))),
    hltCount_(0),
    stream_eof_size_(0) {
  }
edm::StreamerFileWriter::StreamerFileWriter ( std::string const &  fileName) [explicit]
edm::StreamerFileWriter::~StreamerFileWriter ( )

Definition at line 18 of file StreamerFileWriter.cc.

                                          {
  }

Member Function Documentation

void edm::StreamerFileWriter::doOutputEvent ( EventMsgBuilder const &  msg)

Definition at line 81 of file StreamerFileWriter.cc.

References EventMsgBuilder::startAddress().

                                                                   {
    EventMsgView eview(msg.startAddress());
    doOutputEvent(eview);
  }
void edm::StreamerFileWriter::doOutputEvent ( EventMsgView const &  msg)

Definition at line 66 of file StreamerFileWriter.cc.

References hltCount_, EventMsgView::hltTriggerBits(), stream_writer_, and updateHLTStats().

                                                                {
    //Write the Event Message to Streamer file
    stream_writer_->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 edm::StreamerFileWriter::doOutputEventFragment ( StreamerFileWriterEventParams const &  evtParams)

Definition at line 86 of file StreamerFileWriter.cc.

References edm::StreamerFileWriterEventParams::dataPtr, edm::StreamerFileWriterEventParams::dataSize, edm::StreamerFileWriterEventParams::fragmentCount, edm::StreamerFileWriterEventParams::fragmentIndex, edm::StreamerFileWriterEventParams::hltBits, stream_writer_, and updateHLTStats().

                                                                                               {
    //Write the Event Message to Streamer file
    stream_writer_->writeEventFragment(evtParams.fragmentIndex,
                                       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 edm::StreamerFileWriter::doOutputHeader ( InitMsgBuilder const &  init_message)

Definition at line 30 of file StreamerFileWriter.cc.

References InitMsgBuilder::startAddress().

                                                                            {
    //Let us turn it into a View
    InitMsgView view(init_message.startAddress());
    doOutputHeader(view);
  }
void edm::StreamerFileWriter::doOutputHeader ( InitMsgView const &  init_message)

Definition at line 36 of file StreamerFileWriter.cc.

References InitMsgView::get_hlt_bit_cnt(), hltCount_, hltStats_, i, and stream_writer_.

                                                                         {
    //Write the Init Message to Streamer file
    stream_writer_->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 edm::StreamerFileWriter::doOutputHeaderFragment ( StreamerFileWriterHeaderParams const &  hdrParams)

Definition at line 49 of file StreamerFileWriter.cc.

References edm::StreamerFileWriterHeaderParams::dataPtr, edm::StreamerFileWriterHeaderParams::dataSize, edm::StreamerFileWriterHeaderParams::fragmentCount, edm::StreamerFileWriterHeaderParams::fragmentIndex, edm::StreamerFileWriterHeaderParams::hltCount, hltCount_, hltStats_, i, and stream_writer_.

                                                                                                 {
    //Write the Init Message to Streamer file
    stream_writer_->writeInitFragment(hdrParams.fragmentIndex,
                                        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 edm::StreamerFileWriter::fillDescription ( ParameterSetDescription desc) [static]

Definition at line 112 of file StreamerFileWriter.cc.

References edm::ParameterSetDescription::addUntracked(), and edm::ParameterSetDescription::setComment().

                                                                        {
    desc.setComment("Writes events into a streamer output file.");
    desc.addUntracked<std::string>("fileName", "teststreamfile.dat")->setComment("Name of output file.");
  }
uint32 edm::StreamerFileWriter::get_adler32 ( ) const [inline]

Definition at line 70 of file StreamerFileWriter.h.

References stream_writer_.

{ return stream_writer_->adler32();}
uint32 edm::StreamerFileWriter::getStreamEOFSize ( ) const [inline]

Definition at line 68 of file StreamerFileWriter.h.

References stream_eof_size_.

{return stream_eof_size_;}
void edm::StreamerFileWriter::start ( void  ) [inline]

Definition at line 64 of file StreamerFileWriter.h.

{}
void edm::StreamerFileWriter::stop ( )

Definition at line 21 of file StreamerFileWriter.cc.

References hltStats_, stream_eof_size_, and stream_writer_.

                                {
    // 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_->writeEOF(dummyStatusCode, hltStats_);
  }
void edm::StreamerFileWriter::updateHLTStats ( std::vector< uint8 > const &  packedHlt) [private]

Definition at line 99 of file StreamerFileWriter.cc.

References hltCount_, hltStats_, and i.

Referenced by doOutputEvent(), and doOutputEventFragment().

                                                                           {
    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;
    }
  }

Member Data Documentation

Definition at line 77 of file StreamerFileWriter.h.

Referenced by doOutputHeader(), doOutputHeaderFragment(), stop(), and updateHLTStats().

Definition at line 78 of file StreamerFileWriter.h.

Referenced by getStreamEOFSize(), and stop().