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

In This Package:

DybIODaqSvc Class Reference

#include <DybIODaqSvc.h>

Inheritance diagram for DybIODaqSvc:

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

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

Public Member Functions

 DybIODaqSvc (const std::string &name, ISvcLocator *svc)
 Creates an instance of this class.
virtual StatusCode queryInterface (const InterfaceID &id, void **interface)
 Resolve what interface is supported by this implementation.
virtual StatusCode finalize ()
 Cleans up before this instance is destroyed.
virtual StatusCode setEventEntry (const unsigned int entry)
 Sets the entry number within the ROOT stream of the incoming Event.
virtual unsigned long addRef ()
virtual unsigned long release ()
virtual const std::string & name () const
virtual const InterfaceIDtype () const
virtual StatusCode configure ()
virtual StatusCode initialize ()
virtual StatusCode start ()
virtual StatusCode stop ()
virtual StatusCode terminate ()
virtual Gaudi::StateMachine::State FSMState () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual StatusCode reinitialize ()
virtual StatusCode restart ()
virtual StatusCode sysInitialize ()
virtual StatusCode sysStart ()
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()
virtual StatusCode setProperty (const Property &p)
virtual StatusCode setProperty (const std::string &s)
virtual StatusCode setProperty (const std::string &n, const std::string &v)
StatusCode setProperty (const std::string &name, const TYPE &value)
virtual StatusCode getProperty (Property *p) const
virtual const PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
ISvcLocatorserviceLocator () const
IMessageSvcmsgSvc ()
IMessageSvcmsgSvc () const
IMessageSvcmessageService ()
IMessageSvcmessageService () const
StatusCode setProperties ()
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IAuditorSvcauditorSvc () const

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
 Retrieve interface ID.

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

Protected Member Functions

int outputLevel () const

Protected Attributes

IntegerProperty m_outputLevel
Gaudi::StateMachine::State m_state
Gaudi::StateMachine::State m_targetState
IMessageSvcm_messageSvc

Private Member Functions

DayaBay::DaqBlockHeaderreadDaqBlockHeader ()
 Reads the next DaqBlock in the ROOT file.
StatusCode findDaqReadoutSvc ()
 Finds the DaqReadoutSvc to hold the DAQ context.
StatusCode findInputStream ()
 Finds the RootInputStream containing the DaqBlock tree, if it has not already been found.
StatusCode findConverter ()
 Finds the Converter used to convert DaqBlocks to and from ROOT, if it has not already been found.
StatusCode parseDaqBlock (const DayaBay::DaqBlock &block)
 Parse out the contents of a DaqBlock into its File Records.

Private Attributes

std::string m_daqBlockLocation
 Location in file where DAQ block will be saved.
IRootIOSvcm_rioSvc
 The ROOT service.
RootInputStreamm_input
 The RootInputStream containing the DaqBlock tree.
IConversionSvcm_convSvc
 The conversion service.
DaqReadoutSvcm_daqSvc
 The DAQ service that contains the current DAQ content.
RootIOTypedCnv< PerDaqBlockHeader,
DayaBay::DaqBlockHeader > * 
m_daqBlockCnv
 The Converter used to convert DaqBlocks to and from ROOT.
unsigned int m_nextInsertion
 The entry number in the ROOT stream of wheere the next DaqBlock should be inserted.
unsigned int m_entry
 The entry in the RootInputStream.
DayaBay::DaqBlockHeaderm_pendingHeader
 The DaqBlockHeader containing the next DaqBlock to be inserted.

Friends

friend class ServiceManager

Detailed Description

Definition at line 31 of file DybIODaqSvc.h.


Constructor & Destructor Documentation

DybIODaqSvc::DybIODaqSvc ( const std::string &  name,
ISvcLocator svc 
)

Creates an instance of this class.

Definition at line 35 of file DybIODaqSvc.cc.

00036                                              :
00037     Service(name,
00038             svc),
00039     m_rioSvc(0),
00040     m_input(0),
00041     m_convSvc(0),
00042     m_daqSvc(0),
00043     m_daqBlockCnv(0),
00044     m_nextInsertion(0),
00045     m_entry(0),
00046     m_pendingHeader(0) {
00047     declareProperty("DaqBlockLocation",
00048                     m_daqBlockLocation=DayaBay::DaqBlockHeaderLocation::Default,
00049                     "Location in file where DAQ block will be saved.");
00050 }


Member Function Documentation

StatusCode DybIODaqSvc::queryInterface ( const InterfaceID id,
void **  interface 
) [virtual]

Resolve what interface is supported by this implementation.

Reimplemented from Service.

Definition at line 52 of file DybIODaqSvc.cc.

00053                                                           {
00054     if (IDybIODaqSvc::interfaceID().versionMatch(id)) {
00055         // Good enough. Return this object
00056         *interface = dynamic_cast<IDybIODaqSvc*>(this);
00057         addRef();
00058         return StatusCode::SUCCESS;
00059     }
00060     // Try base class
00061     return Service::queryInterface(id,
00062                                    interface);
00063 }

StatusCode DybIODaqSvc::finalize (  )  [virtual]

Cleans up before this instance is destroyed.

Reimplemented from Service.

Definition at line 65 of file DybIODaqSvc.cc.

00065                                  {
00066     if (0 != m_pendingHeader) {
00067         delete m_pendingHeader;
00068     }
00069     if (0 != m_daqSvc) {
00070       m_daqSvc->release();
00071     }
00072     if (0 != m_convSvc) {
00073       m_convSvc->release();
00074     }
00075     if (0 != m_rioSvc) {
00076       m_rioSvc->release();
00077     }
00078     return Service::finalize();
00079 }

StatusCode DybIODaqSvc::setEventEntry ( const unsigned int  entry  )  [virtual]

Sets the entry number within the ROOT stream of the incoming Event.

Implements IDybIODaqSvc.

Definition at line 81 of file DybIODaqSvc.cc.

00081                                                               {
00082     findDaqReadoutSvc();
00083     if (0 != m_daqSvc) {
00084         m_daqSvc->setFileRecord((const FileEndRecord*)0);
00085     }
00086     while (m_nextInsertion == entry) {
00087         if (0 != m_pendingHeader) {
00088             parseDaqBlock(*(m_pendingHeader->daqBlock()));
00089             delete m_pendingHeader;
00090         }
00091         m_pendingHeader = readDaqBlockHeader();
00092         if (0 == m_pendingHeader) {
00093             return StatusCode::FAILURE;
00094         }
00095         m_nextInsertion += m_pendingHeader->deltaEvents();
00096     }
00097     return StatusCode::SUCCESS;
00098 }

DaqBlockHeader * DybIODaqSvc::readDaqBlockHeader (  )  [private]

Reads the next DaqBlock in the ROOT file.

Definition at line 243 of file DybIODaqSvc.cc.

00243                                                 {
00244     MsgStream log(msgSvc(),
00245                   "DybIODaqSvc");
00246 
00247     StatusCode sc = findInputStream();
00248     if (sc.isFailure()) {
00249         return 0;
00250     }
00251     sc = findConverter();
00252     if (sc.isFailure()) {
00253         return 0;
00254     }
00255 
00256     m_input->setEntry(m_entry);
00257     log << MSG::DEBUG
00258         << "Return status of read: "
00259         << m_input->read()
00260         << "\t" 
00261         << m_input->obj()
00262         << endreq;
00263     PerDaqBlockHeader* perDaqBlockHeader = (PerDaqBlockHeader*)(m_input->obj());
00264     if(0 == perDaqBlockHeader){
00265         log << MSG::ERROR
00266             << "Failed to get persistent DaqBlockHeader"
00267             << endreq;
00268         return 0;
00269     }
00270 
00271     DaqBlockHeader* result = new DaqBlockHeader;
00272     sc = m_daqBlockCnv->PerToTran(*perDaqBlockHeader,
00273                                   *result);
00274     if (sc.isFailure()) {
00275         log << MSG::ERROR
00276             << "Failed to translate persistent DaqBlockHeader" 
00277             << endreq;
00278         return 0;
00279     } else {
00280         ++m_entry;
00281     }
00282     return result;
00283 }

StatusCode DybIODaqSvc::findDaqReadoutSvc (  )  [private]

Finds the DaqReadoutSvc to hold the DAQ context.

Definition at line 128 of file DybIODaqSvc.cc.

00128                                           {
00129     if (0 != m_daqSvc) {
00130       return StatusCode::SUCCESS;
00131     }
00132     MsgStream log(msgSvc(),
00133                   "DybIODaqSvc");
00134     IService* isvc = 0; 
00135     StatusCode status = service("DaqReadoutSvc",
00136                                 "DaqReadoutSvc",
00137                                 isvc);
00138     if (status.isFailure() ) {
00139         log << MSG::ERROR
00140             << "Failed to get IDaqReadoutSvc as IService"
00141             << endreq;
00142         return status;
00143     }
00144     IDaqReadoutSvc* daqSvc = 0;
00145     status = isvc->queryInterface(IDaqReadoutSvc::interfaceID(),
00146                                   (void**)&daqSvc);
00147     if (status.isFailure()) {
00148         log << MSG::ERROR
00149             << "Service does not implement IDaqReadoutSvc interface"
00150             << endreq;
00151         return status;
00152     }
00153     m_daqSvc = dynamic_cast<DaqReadoutSvc*>(daqSvc);
00154     return StatusCode::SUCCESS;
00155 }

StatusCode DybIODaqSvc::findInputStream (  )  [private]

Finds the RootInputStream containing the DaqBlock tree, if it has not already been found.

Definition at line 157 of file DybIODaqSvc.cc.

00157                                         {
00158     if (0 != m_input) {
00159       return StatusCode::SUCCESS;
00160     }
00161     MsgStream log(msgSvc(),
00162                   "DybIODaqSvc");
00163     IService* isvc = 0; 
00164     StatusCode sc = service("RootIOCnvSvc",
00165                             isvc,
00166                             true);
00167     if(sc.isFailure()){
00168         log << MSG::ERROR
00169             << "Failed to get RootIOCnvSvc as IService"
00170             << endreq;
00171         return sc;
00172     }
00173     sc = isvc->queryInterface(IRootIOSvc::interfaceID(),
00174                               (void**)&m_rioSvc);
00175     if (sc.isFailure()) {
00176         log << MSG::ERROR
00177             << "Conversion service RootIOCnvSvc"
00178             << " does not implement IRootIOCnvSvc"
00179             << endreq;
00180         return sc;
00181     }
00182 
00183     IRootIOSvc::InputStreamMap& ism = m_rioSvc->inputStreams();
00184     const IRootIOSvc::InputStreamMap::iterator finished = ism.end();
00185     for (IRootIOSvc::InputStreamMap::iterator it = ism.begin();
00186          finished != it;
00187          ++it) {
00188         log << MSG::DEBUG
00189             << "checking input stream: "
00190             << it->first << endreq;
00191         if( it->first == m_daqBlockLocation ){
00192             m_input = it->second;
00193             return StatusCode::SUCCESS;
00194         }
00195     }
00196     return StatusCode::FAILURE;
00197 }

StatusCode DybIODaqSvc::findConverter (  )  [private]

Finds the Converter used to convert DaqBlocks to and from ROOT, if it has not already been found.

Definition at line 199 of file DybIODaqSvc.cc.

00199                                       {
00200     if (0 != m_daqBlockCnv) {
00201       return StatusCode::SUCCESS;
00202     }
00203     MsgStream log(msgSvc(),
00204                   "DybIODaqSvc");
00205     IService* isvc = 0; 
00206     StatusCode sc = service("RootIOCnvSvc",
00207                             isvc,
00208                             true);
00209     if(sc.isFailure()){
00210         log << MSG::ERROR
00211             << "Failed to get RootIOCnvSvc as IService"
00212             << endreq;
00213         return sc;
00214     }
00215     sc = isvc->queryInterface(IConversionSvc::interfaceID(),
00216                               (void**)&m_convSvc);
00217     if (sc.isFailure()) {
00218         log << MSG::ERROR
00219             << "Conversion service RootIOCnvSvc"
00220             << " does not implement IConversionSvc"
00221             << endreq;
00222         return sc;
00223     }
00224 
00225     DaqBlockHeader daqBlockHeader;
00226     IConverter* converter = m_convSvc->converter(daqBlockHeader.classID());
00227     if (0 == converter) {
00228         log << MSG::ERROR
00229             << "Failed to get DaqBlockHeader converter"
00230             << endreq;
00231         return StatusCode::FAILURE;
00232     }
00233     m_daqBlockCnv = dynamic_cast< RootIOTypedCnv<PerDaqBlockHeader, DaqBlockHeader>* >(converter);
00234     if (0 == m_daqBlockCnv) {
00235         log << MSG::ERROR
00236             << "Failed to cast DaqBlockHeader converter"
00237             << endreq;
00238         return StatusCode::FAILURE;
00239     }
00240     return StatusCode::SUCCESS;
00241 }

StatusCode DybIODaqSvc::parseDaqBlock ( const DayaBay::DaqBlock block  )  [private]

Parse out the contents of a DaqBlock into its File Records.

Definition at line 100 of file DybIODaqSvc.cc.

00100                                                               {
00101     string content((const char*)(&((*(daqBlock.bytes()))[0])),
00102                    daqBlock.size() * ByteBuffer::BYTES_IN_INT);
00103     DaqFromStrStream reader;
00104     reader.openWithString(content);
00105     const FileBuffer* record = reader.nextRecord();
00106     while (0 != record) {
00107         if(record->isMarked(FileTraits::kDataSeparatorRecord)) {
00108             return StatusCode::FAILURE;
00109         } else {
00110             if (0 != m_daqSvc) {
00111                 m_daqSvc->setFileRecord(record);
00112             }
00113             std::stringstream message;
00114             message << '\n';
00115             DaqXmlStream xmlStream(message,
00116                                    kTwoSpaces,
00117                                    true);
00118             xmlStream.dumpElement(*record);
00119             MsgStream log(msgSvc(),
00120                           "DaqFormatContext");
00121             log << MSG::INFO << message.str() << endreq;        
00122         }
00123         record = reader.nextRecord();
00124     }
00125     return StatusCode::SUCCESS;
00126 }

static const InterfaceID& IDybIODaqSvc::interfaceID (  )  [inline, static, inherited]

Retrieve interface ID.

Reimplemented from IInterface.

Definition at line 19 of file IDybIODaqSvc.h.

00019                                             {
00020         return IID_IDybIODaqSvc;
00021     }


Member Data Documentation

std::string DybIODaqSvc::m_daqBlockLocation [private]

Location in file where DAQ block will be saved.

Definition at line 89 of file DybIODaqSvc.h.

IRootIOSvc* DybIODaqSvc::m_rioSvc [private]

The ROOT service.

This is held to ensure it does not vanish while the RootInputStream is in use.

Definition at line 94 of file DybIODaqSvc.h.

RootInputStream* DybIODaqSvc::m_input [private]

The RootInputStream containing the DaqBlock tree.

Definition at line 99 of file DybIODaqSvc.h.

IConversionSvc* DybIODaqSvc::m_convSvc [private]

The conversion service.

This is held to ensure it does not vanish while the Converter is in use.

Definition at line 104 of file DybIODaqSvc.h.

DaqReadoutSvc* DybIODaqSvc::m_daqSvc [private]

The DAQ service that contains the current DAQ content.

Definition at line 109 of file DybIODaqSvc.h.

RootIOTypedCnv<PerDaqBlockHeader, DayaBay::DaqBlockHeader>* DybIODaqSvc::m_daqBlockCnv [private]

The Converter used to convert DaqBlocks to and from ROOT.

Definition at line 114 of file DybIODaqSvc.h.

unsigned int DybIODaqSvc::m_nextInsertion [private]

The entry number in the ROOT stream of wheere the next DaqBlock should be inserted.

Definition at line 119 of file DybIODaqSvc.h.

unsigned int DybIODaqSvc::m_entry [private]

The entry in the RootInputStream.

Definition at line 124 of file DybIODaqSvc.h.

DayaBay::DaqBlockHeader* DybIODaqSvc::m_pendingHeader [private]

The DaqBlockHeader containing the next DaqBlock to be inserted.

Definition at line 129 of file DybIODaqSvc.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:47:46 2011 for DybIO by doxygen 1.4.7