CMS 3D CMS Logo

FRDOutputService.cc

Go to the documentation of this file.
00001 // $Id: FRDOutputService.cc,v 1.1 2008/08/13 22:48:12 biery Exp $
00002 
00003 #include <EventFilter/StorageManager/interface/FRDOutputService.h>
00004 #include <IOPool/Streamer/interface/FRDEventMessage.h>
00005 
00006 #include <iostream>
00007  
00008 using namespace edm;
00009 using namespace std;
00010 using boost::shared_ptr;
00011 
00012 
00013 //
00014 // *** FRDOutputService
00015 //
00016 FRDOutputService::FRDOutputService(boost::shared_ptr<FileRecord> file)
00017 {
00018   file_ = file;
00019 
00020   string fileName = file_ -> filePath() + file_ -> fileName() + file_ -> fileCounterStr() + ".dat";
00021 
00022   writer_ = shared_ptr<FRDEventFileWriter> (new FRDEventFileWriter(fileName));
00023 
00024   file_ -> firstEntry(getTimeStamp());
00025   file_ -> insertFileInDatabase();
00026 }
00027 
00028 
00029 //
00030 // *** call close file
00031 //
00032 FRDOutputService::~FRDOutputService()
00033 {
00034   //std::cout << "FRDOutputService Destructor called." << std::endl;
00035   closeFile();
00036 }
00037 
00038 
00039 //
00040 // *** write event to file
00041 // *** increase the file size
00042 // *** update time of last entry 
00043 // *** increase event count
00044 //
00045 void FRDOutputService::writeEvent(const uint8 * const bufPtr)
00046 {
00047   FRDEventMsgView view((void *) bufPtr);
00048   writer_ -> doOutputEvent(view);
00049   file_   -> increaseFileSize(view.size());
00050   file_   -> lastEntry(getTimeStamp());
00051   file_   -> increaseEventCount();
00052 }
00053 
00054 
00055 // 
00056 // *** stop file write
00057 // *** add end of file record size to file size
00058 // *** move file to "closed" directory
00059 // *** write to summary catalog
00060 // *** write to mail box
00061 //
00062 void FRDOutputService::closeFile()
00063 {
00064   writer_ -> stop();
00065   file_   -> moveErrorFileToClosed();
00066   file_   -> writeToSummaryCatalog();
00067   file_   -> updateDatabase();
00068 }
00069 
00070 
00071 //
00072 // *** report status of OutputService
00073 //
00074 void FRDOutputService::report(ostream &os, int indentation) const
00075 {
00076   string prefix(indentation, ' ');
00077   os << prefix << "------------- FRDOutputService -------------\n";
00078   file_ -> report(os,indentation);
00079   double time = (double) file_ -> lastEntry() - (double) file_ -> firstEntry();
00080   double rate = (time>0) ? (double) file_ -> events() / (double) time : 0.; 
00081   double tput = (time>0) ? (double) file_ -> fileSize() / ((double) time * 1048576.) : 0.; 
00082   os << prefix << "rate                " << rate            << " evts/s\n";
00083   os << prefix << "throughput          " << tput            << " MB/s\n";
00084   os << prefix << "time                " << time            << " s\n";
00085   os << prefix << "-----------------------------------------\n";  
00086 }

Generated on Tue Jun 9 17:34:57 2009 for CMSSW by  doxygen 1.5.4