LBNL Homepage IOVSvc Documentation NERSC Homepage
homepage
Current Projects
HENP
LBNL
ATLAS
D0
Benchmarks of gcc
Contact
miscellaneous crap
pictures and cool stuff
quotes
Latest release
IOVSvc-00-06-162008-10-01


Release History
See ChangeLog


Purpose

  • Provides the ability to associate ranges of validity with objects.

  • Objects can either be pure data, in the form of DataHandles<>, which are refreshed whenever a new range of validity is entered, or callback functions, which are triggered when a new range of validity is detected.


Links

  • Atlas Software Week (11/18/02) Architecture Session: pdf,ppt
  • EDM Workshop (01/27/03) Detector Description Session: ppt,ps
  • Atlas Software Week (03/03/03) Architecture Session: ppt
  • Atlas Software Week (05/12/03) Architecture Session: ppt
  • Atlas Software Week (12/01/03) Architecture Session: ppt ps pdf

  • Old Sequence Diagram (IOVSvc-00-02-0x and below): ps, pdf

  • New Sequence Diagram (IOVSvc-00-03-00 and above): ps, pdf

  • CHEP 2005 poster: ps, pdf

  • LXR at BNL


StoreGate User Methods

The following methods are accessed via StoreGate, using a pointer to the Detector Store.

  • StatusCode regHandle(const DataHandle &handle, 
                         const std::string &key)
    Registers a DataHandle identified by a key with the IOVSvc. The DataHandle must be declared as const. This handle will be stored in the ConditionsStore, and will be reset when it is no longer valid. You do not need to register it with StoreGate yourself. It will not be loaded from persistent store until it is dereferenced.

  • StatusCode regFcn(StatusCode (T::*fcn)(IOVSVC_CALLBACK_ARGS), 
                      const T* obj, const DataHandle& handle, 
                      const std::string& key, bool trigger=false)
    Registers a callback function and a const DataHandle with the IOVSvc. The handle will be stored in the ConditionsStore, and will be reset when no longer valid. The callback function is identified by the fully qualified address of the function (fcn), as well as a pointer to the object (obj) it is associated with (see below). It must be a public virtual method of a class. It will be called when the DataHandle is reset. If the DataHandle has already been registered by the IOVSvc, a warning message will be displayed - the handle will not be registered a second time.

    The arguements of the callback function are given by IOVSVC_CALLBACK_ARGS, which is a macro defined in "AthenaKernel/IOVSvcDefs.h" to simplify usage. It expands to (int& idx, std::list<std::string>& keylist). idx is not currently used. keylist is the list of database keys that have triggered the callback.

    If the optional bool trigger argument is set to true (default is false), the IOVSvc will attempt to trigger the callback function as soon as it is registered. Triggering the callback will fail if the first BeginEvent incident has not occurred, producing a non fatal ERROR message, however the function will be triggered at the start of the first event as usual. It should only be used when regFcn() is called after the initialize phase, such as when an AlgTool is instantiated during an Algorithm's execute() phase.

  • StatusCode regFcn(StatusCode (T::*fcn1)(IOVSVC_CALLBACK_ARGS), 
                      const T* obj1, 
                      StatusCode (T::*fcn2)(IOVSVC_CALLBACK_ARGS), 
                      const T* obj2, bool trigger=false) 
    Registers a callback function (2) to be called when another, already registered callback function (1) is triggered. See above for further details.

  • StatusCode regFcn(const std::string& toolName, 
                      StatusCode (T::*fcn2)(IOVSVC_CALLBACK_ARGS), 
                      const T* obj2, bool trigger=false) 
    Registers a callback function to be called when another, already registered and created AlgTool with name toolName is triggered.

The following methods are accessed directly via the IOVSvc.

  • StatusCode setRange(const CLID& clid, const std::string& key,
                        IOVRange& iov)
    Sets the interval of validity(iov) for the object identified by (clid,key).

  • StatusCode getRange(const CLID& clid, const std::string& key,
                        IOVRange& iov) const
    Returns the interval of validity
  • StatusCode getTriggeredTools(const std::string& key, 
                                 std::set<std::string> toolNames)
    Fills a set with the names of all tools or functions that have been triggered by key. If none are found, or the key is unknown, will return a FAILURE.



Job Options

  • bool preLoadData (default = false)

    pre-load both the Ranges and the Data of the associated DataHandles at the start of the first event.

  • bool preLoadProxies (default = false)

    pre-load the Ranges (via the proxies) at the start of the first event.

  • string updateInterval (default = "Event")

    interval at which IOV data is checked for validity. Can be one of "Event", "Run", or "Job".



Usage

Below is shown a simple algorithm which registers two DataHandles with the IOVSvc, and associates callback functions with them.

IOVExampleAlg.h

#ifndef __IOVEXAMPLEALG_H__
#define __IOVEXAMPLEALG_H__

#include "GaudiKernel/Algorithm.h"
#include "StoreGate/DataHandle.h"
#include "AthenaKernel/IOVSvcDefs.h"

#include "IOVExample/TCell.h"

class IIOVSvc;
class StoreGateSvc;

/////////////////////////////////////////////////////////////////////////////

class IOVExampleAlg:public Algorithm {
public:
  IOVExampleAlg (const std::string& name, ISvcLocator* pSvcLocator);
  StatusCode initialize();
  StatusCode execute();
  StatusCode finalize();

  // Callback Functions   
  virtual StatusCode OutOfRangeFcn(IOVSVC_CALLBACK_ARGS);
  virtual StatusCode OutOfRangeFcn2(IOVSVC_CALLBACK_ARGS);

private:

  IIOVSvc *p_IOVSvc;
  StoreGateSvc *p_sgSvc, *p_detSvc;

  // DataHandles to objects in the ConditionStore that will
  // be automatically updated. Must be const. 
  const DataHandle<TCell> m_cell1;
  const DataHandle<TCell> m_cell2;

};

#endif

IOVExampleAlg.cxx
#include "IOVExample/IOVExampleAlg.h"

#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/AlgFactory.h"
#include "StoreGate/StoreGateSvc.h"

#include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h"

#include "AthenaKernel/IIOVSvc.h"

static const AlgFactory<IOVExampleAlg>    AFactory;
const IAlgFactory& IOVExampleAlgFactory = AFactory;
 

///////////////////////////////////////////////////////////////////////////


IOVExampleAlg::IOVExampleAlg(const std::string& name, 
			     ISvcLocator* pSvcLocator) :
  Algorithm(name, pSvcLocator){}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

StatusCode IOVExampleAlg::initialize() {
  MsgStream log(msgSvc(), name());
  log << MSG::INFO << "new initialize()" << endreq;

  if (service("StoreGateSvc", p_sgSvc).isFailure()) {
    log << MSG::ERROR << "Unable to get the StoreGateSvc" << endreq;
    return StatusCode::FAILURE;
  }

  if (service("DetectorStore", p_detSvc).isFailure()) {
    log << MSG::ERROR << "Unable to get the Detector Store" << endreq;
    return StatusCode::FAILURE;
  }

  if (service("IOVSvc", p_IOVSvc, true).isFailure()) {
    log << MSG::ERROR << "Unable to get the IOVSvc" << endreq;
    return StatusCode::FAILURE;
  }

  std::string cell_key1 = "ckey1";
  std::string cell_key2 = "ckey2";

  // Register DataHandle with key "ckey1"
  p_detSvc->regHandle(m_cell1, cell_key1);

  // Register Callback function OutOfRangeFcn with handle m_cell2
  // and key cell_key2
  p_detSvc->regFcn(&IOVExampleAlg::OutOfRangeFcn, this, m_cell2, cell_key2);

  // Register Callback function OutOfRangeFcn2 with OutOfRangeFcn1
  p_detSvc->regFcn(&IOVExampleAlg::OutOfRangeFcn1, this, 
		   &IOVExampleAlg::OutOfRangeFcn2, this);

  return StatusCode::SUCCESS;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

StatusCode IOVExampleAlg::execute() {

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

  const DataHandle evt;
  if (StatusCode::SUCCESS != p_sgSvc->retrieve(evt)) {
    log << MSG::ERROR << "couldn't get event" << endreq;
    return StatusCode::FAILURE;
  }

  log << MSG::INFO << "execute(): [" << evt->Event_ID()->run_number()
      << "," << evt->Event_ID()->event_number() << "]" << endreq;

  // Print out the values of the DataHandles. They numbers will always be
  // up to date.
  log << MSG::INFO << "TCell1 pos: " << m_cell1->Pos() << endreq;
  log << MSG::INFO << "TCell2 pos: " << m_cell2->Pos() << endreq;

  // To retrieve an object with no associated callback function
  // can do a simple retrieve, assuming that the associated AddressCreator
  // (eg IOVDbSvc), has preloaded the proxy with the same [classID,key] pair.
  TCell *tc;
  p_detSvc->retrieve(tc,"ckey9");
  log << MSG::INFO << "position: " << tc->Pos() << endreq;


  return StatusCode::SUCCESS;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

StatusCode IOVExampleAlg::finalize() {

  MsgStream log(msgSvc(), name());
  log << MSG::INFO << "finalize()" << endreq;

  return StatusCode::SUCCESS;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

StatusCode IOVExampleAlg::OutOfRangeFcn( IOVSVC_CALLBACK_ARGS_P(I,keys) ) {

  // IOVSVC_CALLBACK_ARGS_P is a macro that supplies the correct
  // signature for the callback function. The arguments are the variable
  // names for the integer and list key parameters.

  MsgStream log(msgSvc(), name());
  log << MSG::INFO << "OutOfRangeFcn() has been triggered by: ";

  // Print out all keys of DataHandles that this function was registered 
  // against which were reset.
  std::list::const_iterator itr;
  for (itr=keys.begin(); itr!=keys.end(); ++itr) {
    log << *itr << " ";
  }
  log << endreq;

  return StatusCode::SUCCESS;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

StatusCode IOVExampleAlg::OutOfRangeFcn2(int &I, std::list& keys) {
  // Here we see the true signature of the callback function.

  MsgStream log(msgSvc(), name());
  log << MSG::INFO << "OutOfRangeFcn2() has been triggered by: ";

  std::list::const_iterator itr;
  for (itr=keys.begin(); itr!=keys.end(); ++itr) {
    log << *itr << " ";
  }
  log << endreq;

  return StatusCode::SUCCESS;

};

last modifed on: Tuesday, 12-May-2009 16:21:35 PDT