CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FRDEventFileWriter.cc
Go to the documentation of this file.
1 
5 #include <iostream>
6 
8 {
9  initialize(ps.getUntrackedParameter<std::string>("fileName", "testFRDfile.dat"));
10 }
11 
13 {
14  initialize(fileName);
15 }
16 
18 {
19  ost_->close();
20 }
21 
23 {
24  ost_->write((const char*) msg.startAddress(), msg.size());
25  if (ost_->fail()) {
26  throw cms::Exception("FRDEventFileWriter", "doOutputEvent")
27  << "Error writing FED Raw Data event data to "
28  << fileName_ << ". Possibly the output disk "
29  << "is full?" << std::endl;
30  }
31 
32  ost_->flush();
33  if (ost_->fail()) {
34  throw cms::Exception("FRDEventFileWriter", "doOutputEvent")
35  << "Error writing FED Raw Data event data to "
36  << fileName_ << ". Possibly the output disk "
37  << "is full?" << std::endl;
38  }
39 
40  cms::Adler32((const char*) msg.startAddress(), msg.size(), adlera_, adlerb_);
41 }
42 
43 void FRDEventFileWriter::doOutputEventFragment(unsigned char* dataPtr,
44  unsigned long dataSize)
45 {
46  ost_->write((const char*) dataPtr, dataSize);
47  if (ost_->fail()) {
48  throw cms::Exception("FRDEventFileWriter", "doOutputEventFragment")
49  << "Error writing FED Raw Data event data to "
50  << fileName_ << ". Possibly the output disk "
51  << "is full?" << std::endl;
52  }
53 
54  ost_->flush();
55  if (ost_->fail()) {
56  throw cms::Exception("FRDEventFileWriter", "doOutputEventFragment")
57  << "Error writing FED Raw Data event data to "
58  << fileName_ << ". Possibly the output disk "
59  << "is full?" << std::endl;
60  }
61 
62  cms::Adler32((const char*) dataPtr, dataSize, adlera_, adlerb_);
63 }
64 
66 {
67  fileName_ = name;
68  ost_.reset(new std::ofstream(name.c_str(), std::ios_base::binary | std::ios_base::out));
69 
70  if (!ost_->is_open()) {
71  throw cms::Exception("FRDEventFileWriter","initialize")
72  << "Error opening FED Raw Data event output file: " << name << "\n";
73  }
74 
75  adlera_ = 1;
76  adlerb_ = 0;
77 }
T getUntrackedParameter(std::string const &, T const &) const
FRDEventFileWriter(edm::ParameterSet const &ps)
std::auto_ptr< std::ofstream > ost_
uint32 size() const
void doOutputEventFragment(unsigned char *dataPtr, unsigned long dataSize)
uint8 * startAddress() const
void initialize(std::string const &name)
tuple out
Definition: dbtoconf.py:99
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
void doOutputEvent(FRDEventMsgView const &msg)