22 #define GAUDISVC_NTUPLESVC_CPP
55 inline std::string
toStr(
long id) {
56 std::ostringstream
s; s << id;
90 for ( DBaseEntries::iterator j =
m_input.begin(); j !=
m_input.end(); ++j ) {
114 if ( 0 != pRegistry ) {
118 std::string
path = (idx==std::string::npos) ? full : full.substr(0, idx);
121 return (*i).second.service;
128 typedef std::vector<IRegistry*> Leaves;
129 long need_update = 0;
139 for ( Leaves::iterator d = leaves.begin(); d != leaves.end(); d++ ) {
140 if ( (*d)->object() ) {
143 unsigned long typ = pA->
ipar()[1];
144 if ( typ ==
'R' || typ ==
'N' || typ ==
'U' ) {
152 for(
int i = sel->size()-1;
i >= 0;
i-- ) {
160 for(
int j = sel->size()-1; j >= 0; j-- ) {
168 if ( iret.
isSuccess() ) need_update += sel->size();
180 else if ( need_update > 0 ) {
190 isvc->finalize().ignore();
227 return connect(ident, logName);
237 std::vector<Prop> props;
238 long loc = ident.find(
" ");
239 std::string filename, auth, svc =
"", db_typ =
"";
240 logname = ident.substr(0,loc);
241 tok.
analyse(ident.substr(loc+1,ident.length()),
" ",
"",
"",
"=",
"'",
"'");
242 for ( Tokenizer::Items::iterator
i = tok.
items().begin();
i != tok.
items().end(); ++
i) {
243 const std::string& tag = (*i).tag();
249 filename = (*i).value();
252 switch( ::
toupper((*i).value()[0]) ) {
271 db_typ = (*i).value();
274 props.push_back(
Prop((*i).tag(), (*i).value()));
290 log <<
MSG::ERROR <<
"Cannot add " << ident <<
" invalid filename!" <<
endmsg;
295 const std::string& typ,
296 const std::vector<Prop>& ,
313 log <<
MSG::ERROR <<
"Could not get NTuple Persistency format"
314 <<
" from ApplicationMgr properties" <<
endmsg;
319 if ( sp.
value() ==
"HBOOK" ) {
322 else if ( sp.
value() ==
"ROOT" ) {
333 if ( typ.length() > 0 && typ != sp.
value() ) {
336 <<
"Type given by job option "
337 <<
"NTupleSvc.Input/Output ignored!" <<
endmsg;
369 if ( typ == CLID_ColumnWiseTuple ) {
372 else if ( typ == CLID_RowWiseTuple ) {
389 std::string
path = fullPath;
400 std::string p_path (path, 0, sep);
401 std::string o_path (path, sep, path.length());
406 log <<
MSG::ERROR <<
"Cannot book N-tuple " << path <<
" (Unknown reason)" <<
endmsg;
410 log <<
MSG::ERROR <<
"Cannot book N-tuple " << path <<
" (Invalid parent directory)" <<
endmsg;
413 log <<
MSG::ERROR <<
"Cannot book N-tuple " << path <<
" (Invalid path)" <<
endmsg;
416 log <<
MSG::ERROR <<
"Cannot book N-tuple " << path <<
" (Exists already)" <<
endmsg;
422 std::string full = dirPath;
425 return book(full, type, title);
430 return book( dirPath,
toStr(
id), type, title);
440 status =
create( type, title, pObj);
457 const std::string& title) {
458 return book( pParent,
toStr(
id), type, title);
463 const std::string& relPath) {
464 if ( 0 != pParent ) {
468 full += (relPath[0]==
'/') ?
"" :
"/";
488 std::string full = dirPath;
489 full += (relPath[0]==
'/') ?
"" :
"/";
503 entryname += logname;
505 new GenericAddress(t, CLID_NTupleFile, filename, entryname, 0, typ);
508 log <<
MSG::INFO <<
"Added stream file:" << filename <<
" as " << logname <<
endmsg;
513 log <<
MSG::ERROR <<
"Cannot add file:" << filename <<
" as " << logname <<
endmsg;
524 std::string relPath = fullPath.substr(0, sep2);
572 return save ( pObj );
584 if ( 0 != pSvc && 0 != pReg ) {
605 return save ( pObj );
672 status = pSvc->
updateObj(pAddr, n_tuple);
void releaseConnection(Connection &c)
Finalize single service.
const long TEST_StorageType
const char * toStr(IAuditor::StandardEventType e)
Simple mapping function from IAuditor::StandardEventType to string.
Definition of the MsgStream class used to transmit messages.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const long HBOOK_StorageType
virtual StatusCode findObject(const std::string &fullPath, DataObject *&pObject)
Find object identified by its full path in the data store.
virtual StatusCode getProperty(Property *p) const =0
Get the property by property.
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)
Register object with the data store.
DataSelectionAgent base in charge of collecting all the refereces to DataObjects in a transient store...
Items & items()
Access token collection.
virtual StatusCode finalize()
DataSvc overrides: stop the service.
virtual StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves)
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
virtual StatusCode save(const std::string &fullPath)
Save N tuple to disk. Must be called in order to close the ntuple file properly.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
No data loader available.
std::string m_rootName
Name of root event.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
void analyse(const std::string &s, const char *delim, const char *tagBegin, const char *tagEnd, const char *eq, const char *valBegin, const char *valEnd)
Analyse tokens from string.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
Generic Transient Address.
virtual NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title)
Create Ntuple directory and register it with the data store.
virtual StatusCode registerAddress(const std::string &fullPath, IOpaqueAddress *pAddress)
IDataManagerSvc: Register object address with the data store.
virtual StatusCode readRecord(NTuple::Tuple *tuple)
Read single record from N tuple.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
IRegistry * registry() const
Get pointer to Registry.
StatusCode updateDirectories()
Update directory data.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
#define DECLARE_COMPONENT(type)
IDataSelector * selectedObjects()
Return the set of selected DataObjects.
virtual StatusCode setRoot(const std::string &root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
virtual StatusCode sysInitialize()=0
Initialize Service.
virtual unsigned long release()
release reference to object
std::pair< std::string, std::string > Prop
bool isValid() const
Allow for check if smart pointer is valid.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
General service interface definition.
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
virtual StatusCode reinitialize()
DataSvc overrides: reinitialize service.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
const long ROOT_StorageType
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)
Retrieve object from data store.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
unsigned int CLID
Class ID definition.
virtual StatusCode connect(const std::string &ident)
Add file to list I/O list.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title)
Book Ntuple and register it with the data store.
const TYPE & value() const
explicit conversion
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
DBaseEntries m_input
Input streams.
virtual const std::string & name() const
Retrieve name of the service.
virtual StatusCode initialize()
Service initialization.
Abstract base class which allows the user to interact with the actual N tuple implementation.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
virtual StatusCode writeRecord(NTuple::Tuple *tuple)
Write single record to N tuple.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
DataSvc overrides: Retrieve data loader.
virtual unsigned long release()
release reference to object
virtual unsigned long release()=0
Release Interface instance.
#define DECLARE_NAMESPACE_OBJECT_FACTORY(n, x)
virtual StatusCode clearStore()
IDataManagerSvc: Remove all data objects in the data store.
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
virtual StatusCode unregisterObject(const std::string &fullPath)
Unregister object from the data store.
void setTupleService(INTupleSvc *svc)
Access conversion service.
DBaseEntries m_output
Output streams.
Object pointer is invalid.
Templated class to add the standard messaging functionalities.
virtual NTuple::Tuple * access(const std::string &fullPath, const std::string &filename)
Access N tuple on disk.
CLID m_rootCLID
Integer Property corresponding to CLID of root entry.
virtual StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple)
Create requested N tuple (Hide constructor)
virtual StatusCode traverseSubTree(const std::string &sub_tree_path, IDataStoreAgent *pAgent)
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
virtual StatusCode initialize()
DataSvc overrides: Initialize the service.
virtual const id_type & identifier() const =0
Full identifier (or key)
Invalid path from root to object request failed.
void setConversionService(IConversionSvc *svc)
Access conversion service.
Opaque address interface definition.
Base class for all conversion services.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
The IProperty is the basic interface for all components which have properties that can be set or get...
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
virtual StatusCode disconnect(const std::string &nam)
Close open connection.
virtual StatusCode disconnectAll()
Close all open connections.
A DataObject is the base class of any identifiable object on any data store.
Small class representing an N tuple directory in the transient store.
virtual bool isConnected(const std::string &identifier) const
Check if a datasource is connected.
virtual ~NTupleSvc()
Standard Destructor.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work! M...
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
void toupper(std::string &s)
virtual StatusCode finalize()
Service initialization.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
IConversionSvc * conversionService() const
Access conversion service.
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
Connections m_connections
Container of connection points.