/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
DybDataSvc Class Reference

A DybDataSvc is the base class for event services. More...

#include <DybDataSvc.h>

Inheritance diagram for DybDataSvc:
Inheritance graph
[legend]
Collaboration diagram for DybDataSvc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual StatusCode initialize ()
 Service initialisation.
virtual StatusCode reinitialize ()
 Service reinitialisation.
virtual StatusCode finalize ()
 Service finalization.
 DybDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~DybDataSvc ()
 Standard Destructor.
StatusCode setRoot (const std::string &root_path, DataObject *pRootObj)
 Override existing methods.
StatusCode setRoot (const std::string &root_path, IOpaqueAddress *pRootAddr)
StatusCode loadObject (IConversionSvc *pLoader, IRegistry *pRegistry)
 Override main 'loadObject' method.
StatusCode registerAddress (IRegistry *parentObj, const std::string &objPath, IOpaqueAddress *pAddress)
 Override main 'registerObject' method.
StatusCode registerObject (DataObject *parentObj, const std::string &objPath, DataObject *pObject)
 Override main 'registerObject' method.
void inhibit ()
 Inhibit some features, specifically filling the AES and firing EventStoreIncidents.
void enable ()
 Enable features that may have previously been inhibit()ed.
virtual StatusCode queryInterface (const InterfaceID &id, void **interface)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

IDataProviderSvc * archiveSvc () const
 Get ArchiveDataSvc.
StatusCode archiveObject (DataObject *pObject)
StatusCode sequenceObject (DataObject *pObject)
void fireIncident (DataObject *obj)

Private Attributes

StringProperty m_regSeqPath
IDataProviderSvc * m_archiveSvc
IConversionSvc * m_cnvSvc
bool m_useAes
bool m_fesi
bool m_inhibit
IIncidentSvc * m_incSvc

Friends

class SvcFactory< DybDataSvc >

Detailed Description

A DybDataSvc is the base class for event services.

Author:
S. Patton

Definition at line 18 of file DybDataSvc.h.


Constructor & Destructor Documentation

DybDataSvc::DybDataSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Standard Constructor.

Definition at line 31 of file DybDataSvc.cpp.

    : DataSvc(name,svc)
    , m_archiveSvc(0)
    , m_cnvSvc(0)
    , m_useAes(true)
    , m_fesi(false)
    , m_inhibit(false)
    , m_incSvc(0)
{


  declareProperty("RegSeqPath",
                  m_regSeqPath=RegistrationSequence::defaultLocation(),
                  "Path, in the TES, where the RegistrationSequnce object is kept");
  declareProperty("UseAes",m_useAes=true,
                  "Whether or not to use the AES, (def=true)");
  declareProperty("FireEventStoreIncidents",m_fesi=false,
                  "Wheter or not to fire an EventStoreIncident when objects are accepted (def=false)");

  setProperty("ForceLeaves", "true");
  

  MsgStream log(msgSvc(), name);
  log << MSG::DEBUG
      << "constructing"
      << endreq;
}
DybDataSvc::~DybDataSvc ( ) [virtual]

Standard Destructor.

Definition at line 61 of file DybDataSvc.cpp.

{
  if (0 != m_archiveSvc) {
    m_archiveSvc->release();
  }

  if (0 != m_cnvSvc) {
    m_cnvSvc->release();
  }
}

Member Function Documentation

StatusCode DybDataSvc::initialize ( ) [virtual]

Service initialisation.

Definition at line 73 of file DybDataSvc.cpp.

{
  StatusCode status  = DataSvc::initialize();
  if (status.isFailure()) {
    throw GaudiException("Could not initialize super class",
                         name(),
                         status);
  }

  MsgStream log(msgSvc(), name());
  log << MSG::DEBUG << "initializing DybDataSvc @"
      << (void*)this
      << " named " << name()
      << " UseAes is " << m_useAes
      << " ForceLeaves is " << m_forceLeaves
      << endreq;

  ISvcLocator*    svc_loc = serviceLocator();

  status = svc_loc->service("EventPersistencySvc",
                            m_cnvSvc,
                            true);
  if( status.isFailure() ) {
    throw GaudiException("Service [EventPersistencySvc] not found",
                         name(),
                         status);
  }
  status = setDataLoader( m_cnvSvc );
  if( status.isFailure() ) {
    throw GaudiException("Could not set DataLoader",
                         name(),
                         status);
  }

  status = service("IncidentSvc", m_incSvc, true);
  if (status.isFailure()) {
    log << MSG::ERROR
        << "Failed to get IncidentSvc" << endmsg;
    return status;
  }

  log << MSG::DEBUG << "DybDataSvc @" << (void*)this
      << " has UseAes = " << m_useAes << endreq;

  if (m_useAes && !m_inhibit) {
    log << MSG::INFO
        << "Using [EvtDataSvc] as the archive service"
        << endreq;

    status = svc_loc->service("EventDataArchiveSvc", m_archiveSvc, true);
    if( status.isFailure() || !m_archiveSvc ) {
      log << MSG::ERROR << "Service [EventDataArchiveSvc] not found" << endreq;
      return status;
    }
    SmartIF<IProperty> property(m_archiveSvc);
    if (!property) {
      log << MSG::ERROR
          << "The EvtDataSvc has no property interface" << endreq;
      return StatusCode::FAILURE;
    }
    property->setProperty("ForceLeaves","true");
  }
  else {
    log << MSG::DEBUG
        << "DybDataSvc @"
        << (void*)this
        << ", not using Archive Event Store (AES)"
        << endreq;
  }
  return status;
}
StatusCode DybDataSvc::reinitialize ( ) [virtual]

Service reinitialisation.

Definition at line 146 of file DybDataSvc.cpp.

{
  // Do nothing for this service
  return StatusCode::SUCCESS;
}
StatusCode DybDataSvc::finalize ( ) [virtual]

Service finalization.

Definition at line 153 of file DybDataSvc.cpp.

{
  MsgStream log(msgSvc(), name());
  log << MSG::DEBUG << "finalizing" << endreq;

  if( 0 != m_archiveSvc ) {
    m_archiveSvc->release();
  }
  m_archiveSvc = 0;

  if (m_incSvc) {
    m_incSvc->release();
    m_incSvc = 0;
  }

  if( 0 != m_cnvSvc ) {
    m_cnvSvc->release();
  }
  m_cnvSvc = 0;

  return DataSvc::finalize();
}
StatusCode DybDataSvc::setRoot ( const std::string &  root_path,
DataObject *  pRootObj 
)

Override existing methods.

Definition at line 195 of file DybDataSvc.cpp.

                                                     {
  StatusCode result = DataSvc::setRoot(root_path,
                                       pRootObj);
  if (m_useAes && !m_inhibit) {
    DataObject* existingRoot = 0;
    archiveSvc()->retrieveObject(root_path,
                                 existingRoot).ignore();
    if ( 0 == existingRoot ) {
      IDataManagerSvc* archiveMgr = dynamic_cast<IDataManagerSvc*>(archiveSvc());
      StatusCode status = archiveMgr->setRoot(root_path,
                                              new DybArchiveList());
      if (status.isFailure()) return status;
    }
  }
  return result;
}
StatusCode DybDataSvc::setRoot ( const std::string &  root_path,
IOpaqueAddress *  pRootAddr 
)

Definition at line 215 of file DybDataSvc.cpp.

                                                          {
  StatusCode result = DataSvc::setRoot(root_path,
                                       pRootAddr);
  if (m_useAes && !m_inhibit) {
    DataObject* existingRoot = 0;
    archiveSvc()->retrieveObject(root_path,
                                 existingRoot).ignore();
    if ( 0 == existingRoot ) {
      IDataManagerSvc* archiveMgr = dynamic_cast<IDataManagerSvc*>(archiveSvc());
      StatusCode status = archiveMgr->setRoot(root_path,
                                              new DybArchiveList());
      if (status.isFailure()) return status;
    }
  }
  return result;
}
StatusCode DybDataSvc::loadObject ( IConversionSvc *  pLoader,
IRegistry *  pRegistry 
)

Override main 'loadObject' method.

Get loaded object an place in archive collection

Definition at line 234 of file DybDataSvc.cpp.

                                                        {

  MsgStream log(msgSvc(), name());
  log << MSG::DEBUG
      << "loading "<<pRegistry->identifier()
      << " with loader "<<pLoader
      << endreq;
  
  StatusCode result = DataSvc::loadObject(pLoader,
                                          pRegistry);
  if (result.isFailure()) {
    return result;
  }

  RegEntry *pEntry = CAST_REGENTRY(RegEntry*,pRegistry);
  DataObject* pObject = pEntry->object();

  fireIncident(pObject);

  if (0 == pObject) {
    return result;
  }

  log << MSG::DEBUG
      << " registry->identifier() == " << pRegistry->identifier()
      << " pObject->registry()->identifier() == " << pObject->registry()->identifier()
      << endreq;

  result = sequenceObject(pObject);
  if (result.isFailure()) return result;

  if (m_useAes && ! m_inhibit) {
    result = archiveObject(pObject);
  }
  return result;
}
StatusCode DybDataSvc::registerAddress ( IRegistry *  parentObj,
const std::string &  objPath,
IOpaqueAddress *  pAddress 
)

Override main 'registerObject' method.

Do NOT 'archive' address ... wait for loadObject to be called.

Definition at line 274 of file DybDataSvc.cpp.

{
  MsgStream log(msgSvc(), name());

  log << MSG::DEBUG
      << "registerAddress " << objPath
      << " " << (parentObj ? parentObj->name() : "no parent")
      << endreq;

  StatusCode result = DataSvc::registerAddress(parentObj,
                                               objPath,
                                               pAddress);
  if (result.isFailure()) {
      return result;
  }

  // Do nothing more if there is no parent object (as this will be
  // handled later by the recursion).
  if (0 == parentObj ) {
    return result;
  }

  // Do nothing more if the object path contains a separator (as this
  // will be handled later by the recursion).
  std::string::size_type sep = objPath.find(SEPARATOR,1);
  if ( sep != std::string::npos ) {
    return result;
  }

  // Get the full path of the registered object.
  if (0 == pAddress) {
    return result;
  }

  IRegistry* entry = pAddress->registry();
  if (0 == entry) {
    return result;
  }

  if (m_useAes && !m_inhibit) {
    // Retrieve collection
    DataObject* collection=0;
    archiveSvc()->retrieveObject(entry->identifier(),
                                 collection).ignore();

    if (0 == collection) {
      StatusCode status = archiveSvc()->registerObject(entry->identifier(),
                                                       new DybArchiveList());
      if (status.isFailure()) return status;
    }
  }


  return StatusCode::SUCCESS;
}
StatusCode DybDataSvc::registerObject ( DataObject *  parentObj,
const std::string &  objPath,
DataObject *  pObject 
)

Override main 'registerObject' method.

Definition at line 334 of file DybDataSvc.cpp.

{
  MsgStream log(msgSvc(), name());
  log << MSG::DEBUG
      << "use aes = " << m_useAes << " "
      << "parent = \"" << (parentObj ? parentObj->name() : "(none)")  << "\" "
      << "path = \"" << objPath << "\" "
      << "obj = \"" << (pObject ? pObject->name() : "(none)") << "\""
      << endreq;

  // wangzhe
  // The following part makes sure put() method can deal with TES, AES
  // smoothly. User will not worry about AES usage and unregisterObject again.
  // When the second header object comes into TES, the existing object in that 
  // path will be unregistered.
  // By doing this the last data object produced is always in TES.
  // When the event rate is low the data in TES in top stage using in Fifteen
  // is the same as push method
  if(m_useAes && !m_inhibit) {
    // This story is not about usual data object.
    if( pObject->clID() != DataObject::classID() ) {
      // If choose to use AES, firstly check whether that path exists 
      // and whether there are data object with it.
      // Because some data object might already be there.
      // If it really exists unregister it since it is in AES now.
      // It is safe to remove it from TES.
      DataObject* pEstObj=0;
      StatusCode sc = DataSvc::findObject(parentObj,objPath,pEstObj);
      if(sc.isSuccess()) {
        if(pEstObj!=0) {
          log << MSG::DEBUG
              << "Unregistering pre-existing object " 
              << (void*)pEstObj << " at " << objPath << endreq;
          DataSvc::unregisterObject(pEstObj);
          // Why there is a release? See DocDB 3242, page 2 memo
          // Gaudi isn't perfect and has defect.
          pEstObj->release();
        }
      }
    }
  } else {
    // If AES is not chosen to use, then ignore this step.
    // For the case of only using TES, such an operation will possibly remove that
    // object from memory if there is no other place holding it.
    // From this point of view it is dangerous to unregister an object like this.
    // If user really want to register two objects in the same path,
    // it is strongly encouraged that he/she should do it by themselves.
  }
  // wz

  StatusCode result = DataSvc::registerObject(parentObj,
                                              objPath,
                                              pObject);

  if (result.isFailure()) {
    return result;
  }

  fireIncident(pObject);

  // Do nothing more if there is no parent object (as this will be
  // handled later by the recursion).
  if (0 == parentObj ) {
    return result;
  }

  // Do nothing more if the object path contains a separator (as this
  // will be handled later by the recursion).
  std::string::size_type sep = objPath.find(SEPARATOR,1);
  if ( sep != std::string::npos ) {
    return result;
  }

  // Get the full path of the registered object.
  if (0 == pObject) {
    return result;
  }

  IRegistry* pRegistry = pObject->registry();
  if (0 == pRegistry) {
    return result;
  }

  result = sequenceObject(pObject);
  if (result.isFailure()) return result;

  if (m_useAes && !m_inhibit) {
    result = archiveObject(pObject);
  }
  return result;
}
void DybDataSvc::inhibit ( ) [virtual]

Inhibit some features, specifically filling the AES and firing EventStoreIncidents.

Implements IAesFeeder.

Definition at line 182 of file DybDataSvc.cpp.

{
  m_inhibit = true;
}
void DybDataSvc::enable ( ) [virtual]

Enable features that may have previously been inhibit()ed.

Implements IAesFeeder.

Definition at line 188 of file DybDataSvc.cpp.

{
  m_inhibit = false;
}
StatusCode DybDataSvc::queryInterface ( const InterfaceID &  id,
void **  interface 
) [virtual]

Definition at line 559 of file DybDataSvc.cpp.

{
  if (IAesFeeder::interfaceID().versionMatch(id)) {
    *interface = (IAesFeeder*)this;
    addRef();
    return StatusCode::SUCCESS;
  } 
  return DataSvc::queryInterface(id, interface);
}
IDataProviderSvc * DybDataSvc::archiveSvc ( ) const [private]

Get ArchiveDataSvc.

Definition at line 177 of file DybDataSvc.cpp.

{
  return m_archiveSvc;
}
StatusCode DybDataSvc::archiveObject ( DataObject *  pObject) [private]

Definition at line 428 of file DybDataSvc.cpp.

                                                        {

  std::string path = pObject->registry()->identifier();

  MsgStream log(msgSvc(), name());

  if (!m_useAes || m_inhibit) {
    log << MSG::ERROR << "archiveObject() called but told not to use AES"
        << endreq;
    return StatusCode::FAILURE;
  }

  if (pObject->clID() == DataObject::classID()) {
      log << MSG::DEBUG
          << "Not archiving plain DataObject at "
          << path << endreq;
      return StatusCode::SUCCESS;
  }

  // Retrieve collection and add object.
  DataObject* collection=0;
  StatusCode sc =  archiveSvc()->retrieveObject(path, collection);
  sc.ignore();
  //if (sc.isFailure()) {
  //    log << MSG::WARNING << "failed to retrieve list at "
  //        << pRegistry->identifier()
  //        << " will register new one" << endreq;
  //}

  DybArchiveList* list = 0;
  if (0 == collection) {
    list = new DybArchiveList();
    StatusCode status = archiveSvc()->registerObject(path, list);
    if (!status.isSuccess()) {
      log << MSG::WARNING << "failed to register list at "
          << path << endreq;
      return StatusCode(status.getCode(),
                        status.severity());
    }
  } else {
    list = dynamic_cast<DybArchiveList*>(collection);
  }

  list->push_front((DybArchiveList::const_reference)pObject);

  return StatusCode::SUCCESS;
}
StatusCode DybDataSvc::sequenceObject ( DataObject *  pObject) [private]

Definition at line 476 of file DybDataSvc.cpp.

{
  MsgStream log(msgSvc(), name());

  // Record registration sequence of this object.

  // Don't sequence base DataObject, they just make up directory structure.
  if (pObject->clID() == CLID_DataObject) return StatusCode::SUCCESS;

  std::string path = pObject->registry()->identifier();

  // Do not sequence the RegistrationSequnce to avoid infinite loop
  if (m_regSeqPath.value() == path) {
    return StatusCode::SUCCESS;
  }

  {
      DataObject* dobj = 0;
      StatusCode sc = retrieveObject("/Event",dobj);
      if (sc.isFailure()) {
          log << MSG::ERROR << "falied to retrieve /Event" << endreq;
          return sc;
      }
      else {
          //log << MSG::INFO << "got /Event" << endreq;
      }
  }

  // Retieve registration sequence object.
  DataObject* object = 0;
  StatusCode sc = retrieveObject(m_regSeqPath.value(),object);
  sc.ignore();
  //if (sc.isFailure()) {
  //    log << MSG::WARNING << "failed to retrieve reg seq obj from "
  //        << m_regSeqPath.value() << " will register new one " << endreq;
  //}
  RegistrationSequence* regSeq = 0;
  if (0 == object) {
    regSeq = new RegistrationSequence();
    StatusCode status = registerObject(0,m_regSeqPath.value(),regSeq);
    if (!status.isSuccess()) {
      log << MSG::WARNING << "failed to register object "
          << m_regSeqPath.value() << endreq;

      return StatusCode(status.getCode(),
                        status.severity());
    }
  } else {
    regSeq = dynamic_cast<RegistrationSequence*>(object);
  }

  HeaderObject* ho = dynamic_cast<HeaderObject*>(pObject);
  if (ho) {
    log << MSG::DEBUG << "inserting into RegSeq: " << path 
        << " execNum=" << ho->execNumber() << endreq;
  }
  else {
    log << MSG::DEBUG << "inserting into RegSeq: " << path << endreq;
  }

  regSeq->insert(pObject->registry(), pObject, true);

  return StatusCode::SUCCESS;
}
void DybDataSvc::fireIncident ( DataObject *  obj) [private]

Definition at line 541 of file DybDataSvc.cpp.

{
  MsgStream log(msgSvc(), name());
  if (m_fesi) {
    log << MSG::DEBUG
        << "Fire EventStoreIncident with "
        << obj->registry()->identifier() << " " << (void*)obj
        << endreq;
    m_incSvc->fireIncident(EventStoreIncident(obj,true,name()));
  }
  else {
    log << MSG::DEBUG
        << "No fire EventStoreIncident "
        << obj->registry()->identifier() << " " << (void*)obj
        << endreq;
  }
}

Friends And Related Function Documentation

friend class SvcFactory< DybDataSvc > [friend]

Definition at line 19 of file DybDataSvc.h.


Member Data Documentation

StringProperty DybDataSvc::m_regSeqPath [private]

Definition at line 66 of file DybDataSvc.h.

IDataProviderSvc* DybDataSvc::m_archiveSvc [private]

Definition at line 68 of file DybDataSvc.h.

IConversionSvc* DybDataSvc::m_cnvSvc [private]

Definition at line 69 of file DybDataSvc.h.

bool DybDataSvc::m_useAes [private]

Definition at line 70 of file DybDataSvc.h.

bool DybDataSvc::m_fesi [private]

Definition at line 70 of file DybDataSvc.h.

bool DybDataSvc::m_inhibit [private]

Definition at line 70 of file DybDataSvc.h.

IIncidentSvc* DybDataSvc::m_incSvc [private]

Definition at line 71 of file DybDataSvc.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 Fri May 16 2014 10:09:08 for DybEventMgr by doxygen 1.7.4