#include <Root/RootNTupleCnv.h>
|
| RootNTupleCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr) |
| Standard constructor. More...
|
|
StatusCode | createRep (DataObject *pObj, IOpaqueAddress *&refpAdd) override |
| Converter overrides: Convert the transient object to the requested representation. More...
|
|
StatusCode | fillRepRefs (IOpaqueAddress *pAdd, DataObject *pObj) override |
| Resolve the references of the converted object. More...
|
|
StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override |
| Converter overrides: Update the references of an updated transient object. More...
|
|
StatusCode | fillObjRefs (IOpaqueAddress *, DataObject *) override |
| Converter overrides: Update the references of an updated transient object. More...
|
|
StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *pObject) override |
| Update the transient object: NTuples end here when reading records. More...
|
|
StatusCode | updateObjRefs (IOpaqueAddress *, DataObject *) override |
| Converter overrides: Update the references of an updated transient object. More...
|
|
StatusCode | updateRep (IOpaqueAddress *, DataObject *) override |
| Converter overrides: Update the converted representation of a transient object. More...
|
|
StatusCode | updateRepRefs (IOpaqueAddress *, DataObject *) override |
| Converter overrides: Update the converted representation of a transient object. More...
|
|
| RootStatCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr) |
| Initializing Constructor. More...
|
|
| RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr) |
| Initializing Constructor. More...
|
|
long | repSvcType () const override |
| Retrieve the class type of the data store the converter uses. More...
|
|
StatusCode | createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override |
| Converter overrides: Create transient object from persistent data. More...
|
|
StatusCode | fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override |
| Resolve the references of the created transient object. More...
|
|
StatusCode | createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override |
| Converter overrides: Convert the transient object to the requested representation. More...
|
|
StatusCode | fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override |
| Resolve the references of the created transient object. More...
|
|
StatusCode | initialize () override |
| Initialize the converter. More...
|
|
StatusCode | finalize () override |
| Initialize the converter. More...
|
|
StatusCode | setDataProvider (IDataProviderSvc *svc) override |
| Set Data provider service. More...
|
|
SmartIF< IDataProviderSvc > & | dataProvider () const override |
| Get Data provider service. More...
|
|
StatusCode | setConversionSvc (IConversionSvc *svc) override |
| Set conversion service the converter is connected to. More...
|
|
SmartIF< IConversionSvc > & | conversionSvc () const override |
| Get conversion service the converter is connected to. More...
|
|
StatusCode | setAddressCreator (IAddressCreator *creator) override |
| Set address creator facility. More...
|
|
SmartIF< IAddressCreator > & | addressCreator () const override |
| Retrieve address creator facility. More...
|
|
const CLID & | objType () const override |
| Retrieve the class type of objects the converter produces. More...
|
|
virtual long | i_repSvcType () const |
| Retrieve the class type of the data store the converter uses. More...
|
|
StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override |
| Create the transient representation of an object. More...
|
|
StatusCode | fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override |
| Resolve the references of the created transient object. More...
|
|
StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override |
| Update the transient object from the other representation. More...
|
|
StatusCode | updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override |
| Update the references of an updated transient object. More...
|
|
StatusCode | createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override |
| Convert the transient object to the requested representation. More...
|
|
StatusCode | fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override |
| Resolve the references of the converted object. More...
|
|
StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override |
| Update the converted representation of a transient object. More...
|
|
StatusCode | updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override |
| Update the references of an already converted object. More...
|
|
| Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0) |
| Standard Constructor. More...
|
|
SmartIF< IService > | service (const std::string &name, const bool createIf=true) const |
| Return a pointer to the service identified by name (or "type/name") More...
|
|
void const * | i_cast (const InterfaceID &tid) const override |
| Implementation of IInterface::i_cast. More...
|
|
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override |
| Implementation of IInterface::queryInterface. More...
|
|
std::vector< std::string > | getInterfaceNames () const override |
| Implementation of IInterface::getInterfaceNames. More...
|
|
| implements ()=default |
| Default constructor. More...
|
|
| implements (const implements &) |
| Copy constructor (zero the reference count) More...
|
|
implements & | operator= (const implements &) |
| Assignment operator (do not touch the reference count). More...
|
|
unsigned long | addRef () const override |
| Reference Interface instance
More...
|
|
unsigned long | release () const override |
| Release Interface instance
More...
|
|
unsigned long | refCount () const override |
| Current reference count
More...
|
|
NTuple converter class definition for NTuples writted/read using ROOT.
Description: Definition of the generic converter for row wise and column wise Ntuples.
- Author
- M.Frank
- Version
- 1.0
Definition at line 45 of file RootNTupleCnv.h.
◆ RootNTupleCnv()
Standard constructor.
- Parameters
-
clid | [IN] Class ID of the object type to be converted. |
db | [IN] Pointer to POOL database interface |
svc | [IN] Pointer to Gaudi service locator |
- Returns
- Reference to RootNTupleCnv object
Definition at line 64 of file RootNTupleCnv.h.
◆ createObj()
Converter overrides: Update the references of an updated transient object.
- Parameters
-
pAddress | [IN] Valid pointer to the object's opaque address |
refpObject | [OUT] Location to store pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 124 of file RootNTupleCnv.cpp.
127 IRegistry* pRegistry = pAddr->registry();
131 string*
par =
const_cast<string*
>( pAddr->par() );
134 string par_val, par_guid;
135 TBranch* b = con->
getBranch(
"##Descriptors",
"GaudiStatisticsDescription" );
139 b->SetAddress( &ptr );
140 for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
141 int nb = b->GetEntry( i );
150 par[2] = _tr( cntName );
152 if (
nullptr == tree ) {
return makeError(
"Failed to access N-Tuple tree:" + cntName ); }
153 if ( !par_val.empty() ) {
161 istringstream is( par_val );
162 getline( is, title,
';' ) >> clid >>
c >> siz >>
c;
163 status = ntupleSvc->create( clid, title, nt );
166 getline( is, title,
';' ) >> typ >>
c;
169 status = createItem( tree, nt, is, title,
true, (
unsigned char)0 );
172 status = createItem( tree, nt, is, title,
true, (
unsigned short)0 );
175 status = createItem( tree, nt, is, title,
true, 0u );
178 status = createItem( tree, nt, is, title,
true, 0ul );
181 status = createItem( tree, nt, is, title,
true,
char( 0 ) );
184 status = createItem( tree, nt, is, title,
true,
short( 0 ) );
187 status = createItem( tree, nt, is, title,
true, 0 );
190 status = createItem( tree, nt, is, title,
true, 0
l );
193 status = createItem( tree, nt, is, title,
true,
false );
196 status = createItem( tree, nt, is, title,
true, 0.f );
199 status = createItem( tree, nt, is, title,
true, 0. );
214 status = createItem( tree, nt, is, title,
false,
static_cast<IOpaqueAddress*
>(
nullptr ) );
217 status = createItem( tree, nt, is, title,
true,
static_cast<void*
>(
nullptr ) );
226 return makeError(
"createObj[NTuple]> Cannot determine column!" );
230 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
231 log() <<
MSG::DEBUG <<
"Created N-tuple with description:" << par_val << endl;
232 ipar[0] =
reinterpret_cast<uintptr_t
>( con );
237 refpObject =
nullptr;
◆ createRep()
Converter overrides: Convert the transient object to the requested representation.
Convert the transient object to the requested representation.
- Parameters
-
pObj | [IN] Valid pointer to DataObject |
refpAdd | [OUT] Location to store pointer to the object's opaque address |
- Returns
- Status code indicating success or failure
Definition at line 365 of file RootNTupleCnv.cpp.
369 if ( pAddr )
return S_OK;
374 string secName = cntName;
378 TTree* tree = con->
getSection( _tr( secName ),
true );
379 if (
nullptr != nt ) {
384 os << nt->
title() <<
';' << pObj->
clID() <<
';' << items.size() <<
';';
385 map<string, TBranch*> branches;
386 TBranch* b =
nullptr;
387 for ( item_no = 0; item_no < items.size(); ++item_no ) {
391 const string&
n = itm->
name();
392 switch ( itm->
type() ) {
395 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
399 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
403 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
407 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
411 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
415 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
419 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
423 b = tree->Branch(
n.c_str(),
const_cast<void*
>( itm->
buffer() ), desc.c_str() );
426 return makeError(
"Column " + it->
index() +
" is not a valid index column!" );
431 for ( item_no = 0; item_no < items.size(); ++item_no ) {
433 const string&
n = it->
name();
434 os <<
'{' <<
n <<
';' << it->
type() <<
';' << it->
length() <<
';' << it->
ndim() <<
';' << it->
hasIndex() <<
';';
436 os << it->
index() <<
';';
438 switch ( itm->
type() ) {
465 " is not a valid index column!" );
468 for (
long k = 0; k < it->
ndim(); k++ ) { os << it->
dim( k ) <<
';'; }
470 TClass* cl =
nullptr;
471 switch ( it->
type() ) {
474 os << 0 <<
';' << 0 <<
';';
478 os << 0 <<
';' << 0 <<
';';
481 if ( it->
length() == 1 ) {
483 os << 0 <<
';' << 0 <<
';';
484 cl = TClass::GetClass( desc.c_str(), kTRUE );
488 if ( it->
length() == 1 ) {
489 os << 0 <<
';' << 0 <<
';';
490 cl = TClass::GetClass( it->
typeID(), kTRUE );
542 if ( branches.find(
n ) == branches.end() ) {
545 switch ( it->
ndim() ) {
550 sprintf( text,
"[%ld]", it->
dim( 0 ) );
556 desc =
n + tmp +
"[" + itm->
name() +
"]" + desc;
558 sprintf( text,
"[%ld]", it->
dim( 0 ) );
559 desc =
n + tmp + text + desc;
563 switch ( it->
type() ) {
565 branches[
n] = tree->Branch(
n.c_str(), cl->GetName(),
const_cast<void*
>( it->
buffer() ) );
568 branches[
n] = tree->Branch(
n.c_str(), cl->GetName(),
const_cast<void*
>( it->
buffer() ) );
571 branches[
n] = tree->Branch(
n.c_str(),
const_cast<void*
>( it->
buffer() ), desc.c_str() );
582 string spar[] = {
path, cntName };
583 unsigned long ipar[] = { (
unsigned long)con, ~0x0u };
588 ( (
unsigned long*)rpA->
ipar() )[0] = (
unsigned long)con;
◆ fillObjRefs()
Converter overrides: Update the references of an updated transient object.
- Parameters
-
pAddress | [IN] Valid pointer to the object's opaque address |
pObject | [IN] Valid pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 105 of file RootNTupleCnv.h.
◆ fillRepRefs()
Resolve the references of the converted object.
- Parameters
-
pAdd | [IN] Valid pointer to the object's opaque address |
pObj | [IN] Valid pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 607 of file RootNTupleCnv.cpp.
612 if ( tupl && pReg && rpA ) {
614 unsigned long* ipar =
const_cast<unsigned long*
>( pAddr->ipar() );
619 Cont& it = tupl->
items();
620 size_t k,
n = it.size();
621 vector<RootRef*> paddr(
n );
622 vector<RootRef> addr(
n );
623 for ( k = 0; k <
n; ++k ) {
625 Cont::value_type
j = it[k];
626 switch (
j->type() ) {
633 addr[k].entry = pA->
ipar()[1];
635 tree->SetBranchAddress(
j->name().c_str(), &paddr[k] );
641 int nb = tree->Fill();
642 if ( nb > 1 ) ++ipar[1];
643 for ( k = 0; k <
n; ++k ) it[k]->reset();
646 return makeError(
"fillRepRefs> Failed to access data tree:" + cntName );
648 return makeError(
"fillRepRefs> Failed to access data source!" );
650 return makeError(
"fillRepRefs> Invalid Tuple reference." );
◆ i__updateObjRoot()
Update the transient object: NTuples end here when reading records.
Definition at line 266 of file RootNTupleCnv.cpp.
268 const string*
par = rpA->
par();
269 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
271 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
273 Cont& it = tupl->
items();
274 size_t k,
n = it.size();
275 vector<RootRef*> paddr(
n );
276 vector<RootRef> addr(
n );
277 for ( k = 0; k <
n; ++k ) {
278 Cont::value_type
j = it[k];
279 switch (
j->type() ) {
282 tree->SetBranchAddress(
j->name().c_str(), &paddr[k] );
289 ULong64_t last = tree->GetEntries();
293 if ( !( criteria.length() == 0 || criteria ==
"*" ) ) {
294 if ( rpA->
select ==
nullptr ) {
296 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.c_str(), tree );
298 rpA->
select->SetTree( tree );
299 for ( ; ipar[1] < last; ++ipar[1] ) {
300 tree->LoadTree( ipar[1] );
302 if ( fabs( rpA->
select->EvalInstance( 0 ) ) > std::numeric_limits<double>::epsilon() ) {
break; }
307 if ( ipar[1] < last ) {
308 unsigned long entry = ipar[1];
309 if ( tree->GetEntry( entry ) > 1 ) {
311 string* spar =
nullptr;
312 for ( k = 0; k <
n; ++k ) {
313 Cont::value_type
j = it[k];
314 switch (
j->type() ) {
319 spar = (
string*)pA->
par();
320 ipar = (
unsigned long*)pA->
ipar();
322 pair<const RootRef*, const RootDataConnection::ContainerSection*> ls =
325 if ( ls.first->dbase >= 0 ) {
329 r->
dbase += ls.first->dbase;
331 r->
link += ls.first->link;
333 if (
log().isActive() ) {
334 log() <<
"Refs: LS [" << entry <<
"] -> " << ls.first->dbase <<
"," << ls.first->container <<
","
335 << ls.first->link <<
"," << ls.first->entry <<
" DB:" << con->
getDb( r->
dbase ) <<
endmsg;
◆ updateObj()
Update the transient object: NTuples end here when reading records.
- Parameters
-
pAddress | [IN] Valid pointer to the object's opaque address |
pObject | [IN] Valid pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 247 of file RootNTupleCnv.cpp.
250 if ( !tupl || !rpA )
return makeError(
"updateObj> Invalid Tuple reference." );
252 if ( !con )
return makeError(
"updateObj> Failed to access data source!" );
254 if ( !tree )
return makeError(
"Failed to access data tree:" + pAddr->par()[1] );
257 #ifdef __POOL_COMPATIBILITY
259 return i__updateObjPool( rpA, tupl, tree, con );
261 return makeError(
"Failed to access reference branch for data tree:" + rpA->
par()[1] );
◆ updateObjRefs()
Converter overrides: Update the references of an updated transient object.
- Parameters
-
pAddress | [IN] Valid pointer to the object's opaque address |
pObject | [IN] Valid pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 126 of file RootNTupleCnv.h.
◆ updateRep()
Converter overrides: Update the converted representation of a transient object.
- Parameters
-
pAddress | [IN] Valid pointer to the object's opaque address |
pObject | [IN] Valid pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 138 of file RootNTupleCnv.h.
◆ updateRepRefs()
Converter overrides: Update the converted representation of a transient object.
- Parameters
-
pAddress | [IN] Valid pointer to the object's opaque address |
pObject | [IN] Valid pointer to DataObject |
- Returns
- Status code indicating success or failure
Definition at line 150 of file RootNTupleCnv.h.
The documentation for this class was generated from the following files:
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
virtual long type() const =0
Type information of the item.
virtual const std::string & index() const =0
Access the index _Item.
virtual long length() const =0
Access the buffer length.
TTreeFormula * select
Pointer to ROOT select statement (filled for N-tuples only)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
virtual unsigned long release()
release reference to object
const std::string & getLink(int which) const
Access link name from saved index.
int dbase
Data members to define object location in the persistent world.
void setSvcType(long typ)
Access : set the storage type of the class id.
void resetAge()
Reset age.
virtual long ndim() const =0
Dimension.
virtual const std::type_info & typeID() const =0
Compiler type ID.
Tool * tool() const
Access tool.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
void setClID(const CLID &clid)
Access : Set class ID of the link.
Abstract class describing basic data in an Ntuple.
virtual ItemContainer & items()=0
Access item container.
virtual bool hasIndex() const =0
Is the tuple have an index item?
virtual const name_type & name() const =0
Name of the directory (or key)
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Address creation.
const std::string & getDb(int which) const
Access database/file name from saved index.
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
std::vector< INTupleItem * > ItemContainer
virtual const void * buffer() const =0
Access data buffer (CONST)
StatusCode saveDescription(const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
Save statistics object description.
StatusCode commitOutput(const std::string &outputFile, bool do_commit) override
Commit pending output.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
const std::string & getCont(int which) const
Access container name from saved index.
std::string description
Description string.
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
unsigned int CLID
Class ID definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void makeRef(const IRegistry &pA, RootRef &ref)
Create reference object from registry entry.
RootStatCnv(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
virtual IRegistry * registry() const =0
Update branch name.
virtual long dim(long i) const =0
Access individual dimensions.
MsgStream & log() const
Helper to use mesage logger.
virtual ISelectStatement * selector()=0
Access selector.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
constexpr static const auto SUCCESS
Abstract base class which allows the user to interact with the actual N tuple implementation.
TTree * getSection(std::string_view sect, bool create=false)
Access TTree section from section name. The section is created if required.
const std::string * par() const override
Retrieve string parameters.
virtual const std::string & title() const =0
Object title.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(std::string_view container, int entry) const
Access link section for single container and entry.
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
virtual const std::string & name() const =0
Access _Item name.
constexpr static const auto FAILURE
std::string container
Identifier of description.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
IRegistry * registry() const
Get pointer to Registry.
const unsigned long * ipar() const override
Retrieve integer parameters.
StatusCode i__updateObjRoot(RootAddress *rpA, INTuple *tupl, TTree *tree, RootDataConnection *con)
Update the transient object: NTuples end here when reading records.
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
virtual const unsigned long * ipar() const =0
Access to generic link parameters.