| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DybDaq::DaqFormatContext Class Reference

#include <DaqFormatContext.h>

Inheritance diagram for DybDaq::DaqFormatContext:

[legend]
Collaboration diagram for DybDaq::DaqFormatContext:
[legend]
List of all members.

Public Member Functions

virtual ~DaqFormatContext ()
 Destroys the instance of this class.
virtual void * identifier () const
const DybDaq::EventReadoutevent () const
 Returns the current event.

Static Public Attributes

static const unsigned int kExitOnInvalid = 0
 Exit when encountering invalid event.
static const unsigned int kSkipInvalid = DaqFormatContext::kExitOnInvalid + 1
 Skip invalid events.
static const unsigned int kProcessInvalid = DaqFormatContext::kSkipInvalid + 1
 Process invalid events.

Protected Member Functions

 DaqFormatContext (const std::vector< std::string > &inputFiles, const unsigned int actionOnInvalid, IMessageSvc &msgSvc, IDaqReadoutSvc &daqSvc)
 Suppress default.
StatusCode jump (int distance)
 Changes this object to point to a new event.
StatusCode isGoodEvent () const
 Returns true if the current event is good.

Private Member Functions

 DaqFormatContext ()
 Suppress default.
 DaqFormatContext (const DaqFormatContext &rhs)
 Suppress default.
DaqFormatContextoperator= (const DaqFormatContext &rhs)
 Suppress default.
StatusCode moveToNextEvent ()
 Moves this object to point to the next event.
DybDaq::DaqFromFStreamopenNextFile ()
 Opens the next file in the list for reading.

Private Attributes

IMessageSvcm_messageSvc
 MessageSvc reference.
DaqReadoutSvcm_daqSvc
 The service managing DAQ formatted file data.
bool m_expiredEndRecord
 True if at least one event has been read after the file_end_record.
DybDaq::DaqFromFStreamm_reader
 The DaqFromFStream currently being used to read the DAQ data.
const DybDaq::EventReadoutm_event
 The current event this object is pointing to.
std::vector< std::string
>::const_iterator 
m_nextFile
 The iterator pointing to the next DAQ file name to be read.
std::vector< std::string
>::const_iterator 
m_endFile
 The iterator pointing to one-past-the-end of DAQ file name list.
bool m_warnedAboutSkip
 True when the skip warning has been logged.
unsigned int m_actionOnInvalid
 The flag defining what action to take when an invalid event is found.

Friends

class DaqFormatSelector

Detailed Description

Definition at line 30 of file DaqFormatContext.h.


Constructor & Destructor Documentation

DaqFormatContext::~DaqFormatContext (  )  [virtual]

Destroys the instance of this class.

Definition at line 55 of file DaqFormatContext.cc.

00055                                     {
00056 }

DaqFormatContext::DaqFormatContext ( const std::vector< std::string > &  inputFiles,
const unsigned int  actionOnInvalid,
IMessageSvc msgSvc,
IDaqReadoutSvc daqSvc 
) [protected]

Suppress default.

Definition at line 40 of file DaqFormatContext.cc.

00043                                                            :
00044 m_messageSvc(msgSvc),
00045 m_daqSvc(dynamic_cast<DaqReadoutSvc*>(&daqSvc)),
00046 m_expiredEndRecord(true),
00047 m_reader(0),
00048 m_event(0),
00049 m_nextFile(inputFiles.begin()),
00050 m_endFile(inputFiles.end()),
00051 m_warnedAboutSkip(false),
00052 m_actionOnInvalid(actionOnInvalid) {
00053 }

DybDaq::DaqFormatContext::DaqFormatContext (  )  [private]

Suppress default.

DybDaq::DaqFormatContext::DaqFormatContext ( const DaqFormatContext rhs  )  [private]

Suppress default.


Member Function Documentation

void * DaqFormatContext::identifier (  )  const [virtual]

Implements IEvtSelector::Context.

Definition at line 58 of file DaqFormatContext.cc.

00058                                          {
00059     return 0;
00060 }

const EventReadout * DaqFormatContext::event (  )  const

Returns the current event.

Definition at line 62 of file DaqFormatContext.cc.

00062                                                   {
00063     return m_event;
00064 }

StatusCode DaqFormatContext::jump ( int  distance  )  [protected]

Changes this object to point to a new event.

Definition at line 66 of file DaqFormatContext.cc.

00066                                                     {
00067     if (0 > distance) {
00068         MsgStream log(&m_messageSvc,
00069                        "DaqFormatContext");
00070         log << MSG::ERROR << "Can not move backward in a file" << endreq;
00071         return StatusCode::FAILURE;
00072     }
00073     for (int count = 0;
00074          distance != count;
00075          ++count) {
00076         StatusCode status = moveToNextEvent();
00077         if (status.isFailure()) {
00078             return status;
00079         }
00080     }
00081     if ((kProcessInvalid != m_actionOnInvalid) && (m_event->header().invalidData())) {
00082         MsgStream log(&m_messageSvc,
00083                       "DaqFormatContext");
00084         if (kExitOnInvalid == m_actionOnInvalid) {
00085             delete m_event;
00086             m_event = 0;
00087             log << MSG::ERROR << "Exiting as Invalid Event has been detected" << endreq;
00088             return StatusCode::FAILURE;
00089         }
00090         if (kSkipInvalid == m_actionOnInvalid) {
00091             if (!m_warnedAboutSkip) {
00092                 log << MSG::WARNING << "One or more Invalid Event has been detected, they will be skipped" << endreq;
00093                 m_warnedAboutSkip = true;
00094             }
00095             do {
00096                 delete m_event;
00097                 StatusCode status = moveToNextEvent();
00098                 if (status.isFailure()) {
00099                     return status;
00100                 }
00101             } while (m_event->header().invalidData());
00102         }
00103     }
00104     return StatusCode::SUCCESS;
00105 }

StatusCode DaqFormatContext::isGoodEvent (  )  const [protected]

Returns true if the current event is good.

Definition at line 107 of file DaqFormatContext.cc.

00107                                                {
00108     if (0 == m_event) {
00109         return StatusCode::FAILURE;
00110     }
00111     return StatusCode::SUCCESS;
00112 }

DaqFormatContext& DybDaq::DaqFormatContext::operator= ( const DaqFormatContext rhs  )  [private]

Suppress default.

StatusCode DaqFormatContext::moveToNextEvent (  )  [private]

Moves this object to point to the next event.

Definition at line 114 of file DaqFormatContext.cc.

00114                                              {
00115     m_event = 0;
00116     while (0 == m_event) {
00117         if(0 == m_reader){
00118             m_reader = openNextFile();
00119             if(0 == m_reader){
00120                 return StatusCode::FAILURE;
00121             }
00122         }
00123         
00124         const FileBuffer* record = m_reader->nextRecord();
00125         if(0 == record){
00126             MsgStream log(&m_messageSvc,
00127                           "DaqFormatContext");
00128             log << MSG::ERROR << "Failed to read next record from file: " << (*m_nextFile) << endreq;
00129             return StatusCode::FAILURE;
00130         }
00131         
00132         // Check the record type
00133 
00134         if (m_expiredEndRecord && (0 != m_daqSvc)) {
00135             m_daqSvc->setFileRecord((const FileEndRecord*)0);
00136         }
00137         if(record->isMarked(FileTraits::kDataSeparatorRecord)) {
00138             const DataSeparatorRecord* dataSeparator = dynamic_cast<const DataSeparatorRecord*>(record);
00139             m_event = dataSeparator->extractBlock();
00140             delete record;
00141             m_expiredEndRecord = true;
00142         } else {
00143             if (0 != m_daqSvc) {
00144                 m_daqSvc->setFileRecord(record);
00145             }
00146             if(record->isMarked(FileTraits::kFileEndRecord)) {
00147                 m_expiredEndRecord = false;
00148             }
00149             std::stringstream message;
00150             message << '\n';
00151             DaqXmlStream xmlStream(message,
00152                                    kTwoSpaces,
00153                                    true);
00154             xmlStream.dumpElement(*record);
00155             MsgStream log(&m_messageSvc,
00156                           "DaqFormatContext");
00157             log << MSG::INFO << message.str() << endreq;        
00158             if(record->isMarked(FileTraits::kFileEndRecord)) {
00159                 delete m_reader;
00160                 m_reader = 0;
00161                 ++m_nextFile;
00162             }
00163         }
00164     }
00165     return StatusCode::SUCCESS;
00166 }

DybDaq::DaqFromFStream * DaqFormatContext::openNextFile (  )  [private]

Opens the next file in the list for reading.

Definition at line 168 of file DaqFormatContext.cc.

00168                                                      {
00169     DaqFromFStream* result = 0;
00170     
00171     if (m_nextFile == m_endFile) {
00172         MsgStream log(&m_messageSvc,
00173                       "DaqFormatContext");
00174         log << MSG::INFO << "End of input file list" << endreq;
00175         return result;
00176     }
00177     
00178     result = new DaqFromFStream();
00179     if(0 == result){
00180             MsgStream log(&m_messageSvc,
00181                           "DaqFormatContext");
00182             log << MSG::ERROR << "Failed to create new file reader" << endreq;
00183         return result;
00184     }
00185     
00186     const bool opened = result->openFile((*m_nextFile).c_str());
00187     if (!opened) {
00188         MsgStream log(&m_messageSvc,
00189                       "DaqFormatContext");
00190         log << MSG::ERROR << "Failed to open input file: " << (*m_nextFile) << endreq;
00191         delete result;
00192         result = 0;
00193     }
00194     return result;
00195 }


Friends And Related Function Documentation

friend class DaqFormatSelector [friend]

Definition at line 34 of file DaqFormatContext.h.


Member Data Documentation

const unsigned int DaqFormatContext::kExitOnInvalid = 0 [static]

Exit when encountering invalid event.

Definition at line 39 of file DaqFormatContext.h.

const unsigned int DaqFormatContext::kSkipInvalid = DaqFormatContext::kExitOnInvalid + 1 [static]

Skip invalid events.

Definition at line 44 of file DaqFormatContext.h.

const unsigned int DaqFormatContext::kProcessInvalid = DaqFormatContext::kSkipInvalid + 1 [static]

Process invalid events.

Definition at line 49 of file DaqFormatContext.h.

IMessageSvc& DybDaq::DaqFormatContext::m_messageSvc [private]

MessageSvc reference.

Definition at line 113 of file DaqFormatContext.h.

DaqReadoutSvc* DybDaq::DaqFormatContext::m_daqSvc [private]

The service managing DAQ formatted file data.

Definition at line 118 of file DaqFormatContext.h.

bool DybDaq::DaqFormatContext::m_expiredEndRecord [private]

True if at least one event has been read after the file_end_record.

Definition at line 123 of file DaqFormatContext.h.

DybDaq::DaqFromFStream* DybDaq::DaqFormatContext::m_reader [private]

The DaqFromFStream currently being used to read the DAQ data.

Definition at line 128 of file DaqFormatContext.h.

const DybDaq::EventReadout* DybDaq::DaqFormatContext::m_event [private]

The current event this object is pointing to.

Definition at line 133 of file DaqFormatContext.h.

std::vector<std::string>::const_iterator DybDaq::DaqFormatContext::m_nextFile [private]

The iterator pointing to the next DAQ file name to be read.

Definition at line 138 of file DaqFormatContext.h.

std::vector<std::string>::const_iterator DybDaq::DaqFormatContext::m_endFile [private]

The iterator pointing to one-past-the-end of DAQ file name list.

Definition at line 143 of file DaqFormatContext.h.

bool DybDaq::DaqFormatContext::m_warnedAboutSkip [private]

True when the skip warning has been logged.

Definition at line 148 of file DaqFormatContext.h.

unsigned int DybDaq::DaqFormatContext::m_actionOnInvalid [private]

The flag defining what action to take when an invalid event is found.

Definition at line 153 of file DaqFormatContext.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:46:30 2011 for DaqFormatModules by doxygen 1.4.7