CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FRDEventFileWriter Class Reference

#include <FRDEventFileWriter.h>

List of all members.

Public Member Functions

uint32 adler32 () const
void doOutputEvent (FRDEventMsgView const &msg)
void doOutputEventFragment (unsigned char *dataPtr, unsigned long dataSize)
 FRDEventFileWriter (std::string const &fileName)
 FRDEventFileWriter (edm::ParameterSet const &ps)
void start ()
void stop ()
 ~FRDEventFileWriter ()

Private Member Functions

void initialize (std::string const &name)

Private Attributes

uint32 adlera_
uint32 adlerb_
std::string fileName_
std::auto_ptr< std::ofstream > ost_

Detailed Description

Definition at line 11 of file FRDEventFileWriter.h.


Constructor & Destructor Documentation

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

Definition at line 8 of file FRDEventFileWriter.cc.

References edm::ParameterSet::getUntrackedParameter(), and initialize().

{
  initialize(ps.getUntrackedParameter<std::string>("fileName", "testFRDfile.dat"));
}
FRDEventFileWriter::FRDEventFileWriter ( std::string const &  fileName) [explicit]

Definition at line 13 of file FRDEventFileWriter.cc.

References initialize().

FRDEventFileWriter::~FRDEventFileWriter ( )

Definition at line 18 of file FRDEventFileWriter.cc.

References ost_.

{
  ost_->close();
}

Member Function Documentation

uint32 FRDEventFileWriter::adler32 ( ) const [inline]

Definition at line 23 of file FRDEventFileWriter.h.

References adlera_, and adlerb_.

{ return (adlerb_ << 16) | adlera_; }
void FRDEventFileWriter::doOutputEvent ( FRDEventMsgView const &  msg)

Definition at line 23 of file FRDEventFileWriter.cc.

References cms::Adler32(), adlera_, adlerb_, Exception, fileName_, ost_, FRDEventMsgView::size(), and FRDEventMsgView::startAddress().

{
  ost_->write((const char*) msg.startAddress(), msg.size());
  if (ost_->fail()) {
    throw cms::Exception("FRDEventFileWriter", "doOutputEvent")
      << "Error writing FED Raw Data event data to "
      << fileName_ << ".  Possibly the output disk "
      << "is full?" << std::endl;
  }

  ost_->flush();
  if (ost_->fail()) {
    throw cms::Exception("FRDEventFileWriter", "doOutputEvent")
      << "Error writing FED Raw Data event data to "
      << fileName_ << ".  Possibly the output disk "
      << "is full?" << std::endl;
  }
  
  cms::Adler32((const char*) msg.startAddress(), msg.size(), adlera_, adlerb_);
}
void FRDEventFileWriter::doOutputEventFragment ( unsigned char *  dataPtr,
unsigned long  dataSize 
)

Definition at line 44 of file FRDEventFileWriter.cc.

References cms::Adler32(), adlera_, adlerb_, Exception, fileName_, and ost_.

{
  ost_->write((const char*) dataPtr, dataSize);
  if (ost_->fail()) {
    throw cms::Exception("FRDEventFileWriter", "doOutputEventFragment")
      << "Error writing FED Raw Data event data to "
      << fileName_ << ".  Possibly the output disk "
      << "is full?" << std::endl;
  }

  ost_->flush();
  if (ost_->fail()) {
    throw cms::Exception("FRDEventFileWriter", "doOutputEventFragment")
      << "Error writing FED Raw Data event data to "
      << fileName_ << ".  Possibly the output disk "
      << "is full?" << std::endl;
  }

  cms::Adler32((const char*) dataPtr, dataSize, adlera_, adlerb_);
}
void FRDEventFileWriter::initialize ( std::string const &  name) [private]

Definition at line 66 of file FRDEventFileWriter.cc.

References adlera_, adlerb_, Exception, fileName_, mergeVDriftHistosByStation::name, ost_, and dbtoconf::out.

Referenced by FRDEventFileWriter().

{
  fileName_ = name;
  ost_.reset(new std::ofstream(name.c_str(), std::ios_base::binary | std::ios_base::out));

  if (!ost_->is_open()) {
    throw cms::Exception("FRDEventFileWriter","initialize")
      << "Error opening FED Raw Data event output file: " << name << "\n";
  }

  adlera_ = 1;
  adlerb_ = 0;
}
void FRDEventFileWriter::start ( void  ) [inline]

Definition at line 25 of file FRDEventFileWriter.h.

{}
void FRDEventFileWriter::stop ( ) [inline]

Definition at line 26 of file FRDEventFileWriter.h.

{}

Member Data Documentation

Definition at line 35 of file FRDEventFileWriter.h.

Referenced by adler32(), doOutputEvent(), doOutputEventFragment(), and initialize().

Definition at line 36 of file FRDEventFileWriter.h.

Referenced by adler32(), doOutputEvent(), doOutputEventFragment(), and initialize().

std::string FRDEventFileWriter::fileName_ [private]

Definition at line 33 of file FRDEventFileWriter.h.

Referenced by doOutputEvent(), doOutputEventFragment(), and initialize().

std::auto_ptr<std::ofstream> FRDEventFileWriter::ost_ [private]