ATLAS Offline Software
Loading...
Searching...
No Matches
pool::RootCollection::RootCollection Class Reference

Collection (and CollectionProxy) implementation based on ROOT trees. More...

#include <RootCollection.h>

Inheritance diagram for pool::RootCollection::RootCollection:
Collaboration diagram for pool::RootCollection::RootCollection:

Public Types

typedef Gaudi::PluginService::Factory< ICollection *(const ICollectionDescription *, ICollection::OpenMode, ISession *)> Factory
enum  OpenMode { CREATE , CREATE_AND_OVERWRITE , UPDATE , READ }
 Enumeration of the possible open modes of the collection. More...

Public Member Functions

 RootCollection (const pool::ICollectionDescription *description, pool::ICollection::OpenMode mode, pool::ISession *)
 Constructor.
 ~RootCollection ()
 Destructor.
virtual void addTreeBranch (const std::string &name, const std::string &type_name)
virtual ICollection::OpenMode openMode () const final override
 Return openMode.
virtual void open () final override
 Explicitly re-opens the collection after it has been closed.
virtual bool isOpen () const final override
 Checks if the collection is open.
virtual void insertRow (const pool::CollectionRowBuffer &inputRowBuffer) final override
 Adds a new row of data to the collection.
virtual void commit (bool restartTransaction=false) final override
 Commits the last changes made to the collection.
virtual void close () final override
 Explicitly closes the collection.
virtual const ICollectionDescriptiondescription () const final override
 Returns an object used to describe the collection properties.
virtual ICollectionCursorcursor () final override
 Returns a cursor for the collection.
virtual void initNewRow (pool::CollectionRowBuffer &row) const
 Initialize a new RowBuffer by adding all Attributes adn Tokens of this collection to it.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Attributes

static const unsigned int c_maxLengthOfStrings = 5000
static const char *const poolOptToRootOpt []
static const Io::IoFlags poolOptToFileMgrOpt []
static const char *const c_tokenBranchName
static const char *const c_attributeListLayoutName

Private Member Functions

 RootCollection (const RootCollection &)
 copying unimplemented in this class.
RootCollectionoperator= (const RootCollection &)
 copying unimplemented in this class.
void delayedFileOpen (const std::string &method)
TTree * getCollectionTree ()
void setupTree () const
void readAttributeListSpecification () const
void writeAttributeListSpecification ()
void cleanup ()
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

CollectionDescription m_description
std::string m_name
std::string m_fileName
ICollection::OpenMode m_mode
TTree * m_tree
TFile * m_file
ISessionm_session
bool m_open
bool m_readOnly
bool m_schemaWritten
SmartIF< IFileMgr > m_fileMgr
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Collection (and CollectionProxy) implementation based on ROOT trees.

Implementation details:

  • Token and meta data attributes are stored in a simple TTree
  • Tokens are stored as (compressed) C-string
  • Each attribute is written to a separate branch of the TTree
    ROOT documentation can be found at http://root.cern.ch/

Definition at line 45 of file RootCollection.h.

Member Typedef Documentation

◆ Factory

Definition at line 48 of file RootCollection.h.

Member Enumeration Documentation

◆ OpenMode

Enumeration of the possible open modes of the collection.

Enumerator
CREATE 
CREATE_AND_OVERWRITE 
UPDATE 
READ 

Definition at line 26 of file ICollection.h.

OpenMode
Enumeration of the possible open modes of the collection.
Definition ICollection.h:26

Constructor & Destructor Documentation

◆ RootCollection() [1/2]

pool::RootCollection::RootCollection::RootCollection ( const pool::ICollectionDescription * description,
pool::ICollection::OpenMode mode,
pool::ISession *  )

Constructor.

Parameters
sessionIf you want to access the referenced objects you have to provide an ISession
connectionThe location of the collection file is uniquely defined by the parameters name and connection
nameThe location of the collection file is uniquely defined by the parameters name and connection
modeThe open mode of the collection
  • The path to the collection file is simply created by the following concatenation:
    connection+name+".root"
  • name: Name of the collection file
  • connection:
    • It can be a relative or absolute path
    • In case of an empty connection string it is assumed that the file is located in the current directory
    • Remote access via rootd: e.g. "root://pcepsft02.cern.ch:9090//localdisk/
      Further documentation can be found in the class description of TNetFile (http://root.cern.ch/root/html/TNetFile.html)

◆ ~RootCollection()

pool::RootCollection::RootCollection::~RootCollection ( )

Destructor.

◆ RootCollection() [2/2]

pool::RootCollection::RootCollection::RootCollection ( const RootCollection & )
private

copying unimplemented in this class.

Member Function Documentation

◆ addTreeBranch()

virtual void pool::RootCollection::RootCollection::addTreeBranch ( const std::string & name,
const std::string & type_name )
virtual

◆ cleanup()

void pool::RootCollection::RootCollection::cleanup ( )
private

◆ close()

virtual void pool::RootCollection::RootCollection::close ( )
finaloverridevirtual

Explicitly closes the collection.

Implements pool::ICollection.

◆ commit()

virtual void pool::RootCollection::RootCollection::commit ( bool restartTransaction = false)
finaloverridevirtual

Commits the last changes made to the collection.

Implements pool::ICollection.

◆ cursor()

virtual ICollectionCursor & pool::RootCollection::RootCollection::cursor ( )
finaloverridevirtual

Returns a cursor for the collection.

Implements pool::ICollection.

◆ delayedFileOpen()

void pool::RootCollection::RootCollection::delayedFileOpen ( const std::string & method)
private

◆ description()

virtual const ICollectionDescription & pool::RootCollection::RootCollection::description ( ) const
finaloverridevirtual

Returns an object used to describe the collection properties.

Implements pool::ICollection.

◆ getCollectionTree()

TTree * pool::RootCollection::RootCollection::getCollectionTree ( )
private

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ initNewRow()

virtual void pool::ICollection::initNewRow ( pool::CollectionRowBuffer & row) const
virtualinherited

Initialize a new RowBuffer by adding all Attributes adn Tokens of this collection to it.

◆ insertRow()

virtual void pool::RootCollection::RootCollection::insertRow ( const pool::CollectionRowBuffer & inputRowBuffer)
finaloverridevirtual

Adds a new row of data to the collection.

Implements pool::ICollection.

◆ isOpen()

virtual bool pool::RootCollection::RootCollection::isOpen ( ) const
finaloverridevirtual

Checks if the collection is open.

Implements pool::ICollection.

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ open()

virtual void pool::RootCollection::RootCollection::open ( )
finaloverridevirtual

Explicitly re-opens the collection after it has been closed.

Implements pool::ICollection.

◆ openMode()

virtual ICollection::OpenMode pool::RootCollection::RootCollection::openMode ( ) const
finaloverridevirtual

Return openMode.

Implements pool::ICollection.

◆ operator=()

RootCollection & pool::RootCollection::RootCollection::operator= ( const RootCollection & )
private

copying unimplemented in this class.

◆ readAttributeListSpecification()

void pool::RootCollection::RootCollection::readAttributeListSpecification ( ) const
private

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setupTree()

void pool::RootCollection::RootCollection::setupTree ( ) const
private

◆ writeAttributeListSpecification()

void pool::RootCollection::RootCollection::writeAttributeListSpecification ( )
private

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ c_attributeListLayoutName

const char* const pool::RootCollection::RootCollection::c_attributeListLayoutName
static

Definition at line 121 of file RootCollection.h.

◆ c_maxLengthOfStrings

const unsigned int pool::RootCollection::RootCollection::c_maxLengthOfStrings = 5000
static

Definition at line 117 of file RootCollection.h.

◆ c_tokenBranchName

const char* const pool::RootCollection::RootCollection::c_tokenBranchName
static

Definition at line 120 of file RootCollection.h.

◆ m_description

CollectionDescription pool::RootCollection::RootCollection::m_description
private

Definition at line 125 of file RootCollection.h.

◆ m_file

TFile* pool::RootCollection::RootCollection::m_file
private

Definition at line 131 of file RootCollection.h.

◆ m_fileMgr

SmartIF<IFileMgr> pool::RootCollection::RootCollection::m_fileMgr
private

Definition at line 137 of file RootCollection.h.

◆ m_fileName

std::string pool::RootCollection::RootCollection::m_fileName
private

Definition at line 128 of file RootCollection.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_mode

ICollection::OpenMode pool::RootCollection::RootCollection::m_mode
private

Definition at line 129 of file RootCollection.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string pool::RootCollection::RootCollection::m_name
private

Definition at line 127 of file RootCollection.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_open

bool pool::RootCollection::RootCollection::m_open
private

Definition at line 133 of file RootCollection.h.

◆ m_readOnly

bool pool::RootCollection::RootCollection::m_readOnly
private

Definition at line 134 of file RootCollection.h.

◆ m_schemaWritten

bool pool::RootCollection::RootCollection::m_schemaWritten
private

Definition at line 135 of file RootCollection.h.

◆ m_session

ISession* pool::RootCollection::RootCollection::m_session
private

Definition at line 132 of file RootCollection.h.

◆ m_tree

TTree* pool::RootCollection::RootCollection::m_tree
private

Definition at line 130 of file RootCollection.h.

◆ poolOptToFileMgrOpt

const Io::IoFlags pool::RootCollection::RootCollection::poolOptToFileMgrOpt[]
static

Definition at line 119 of file RootCollection.h.

◆ poolOptToRootOpt

const char* const pool::RootCollection::RootCollection::poolOptToRootOpt[]
static

Definition at line 118 of file RootCollection.h.


The documentation for this class was generated from the following file: