ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
SH::SampleGrid Class Reference

This class implements a Sample located on the grid. More...

#include <SampleGrid.h>

Inheritance diagram for SH::SampleGrid:
Collaboration diagram for SH::SampleGrid:

Public Member Functions

void testInvariant () const
 test the invariant of this object More...
 
 SampleGrid ()
 standard constructor More...
 
 SampleGrid (const std::string &name)
 standard constructor More...
 
const std::string & name () const
 the name of the sample we are using More...
 
void name (std::string val_name)
 set the value of name More...
 
std::size_t numFiles () const
 the number of files in the sample More...
 
std::string fileName (std::size_t index) const
 the name of the file with the given index More...
 
SamplePtr makeLocal () const
 Make this a local sample, i.e. More...
 
const TagListtags () const
 the tag list we are using More...
 
void tags (const TagList &tags)
 set the content of tags() More...
 
void addTag (const std::string &tag)
 add a tag to the content of tags() More...
 
void updateLocation (const std::string &from, const std::string &to)
 update all file references starting with from to to More...
 
MetaObjectmeta ()
 the meta-information for this sample More...
 
const MetaObjectmeta () const
 the meta-information for this sample More...
 
std::vector< std::string > makeFileList () const
 make a list of all files, prestaging them if necessary More...
 
TChain * makeTChain () const
 create a TChain object, containing all these files More...
 
TObject * readHist (const std::string &name) const
 read an object from a histogram file More...
 
bool contains (const std::string &name) const
 whether this sample contains a sample of the given name More...
 
void addSamples (SampleHandler &result)
 add all samples this sample corresponds to to the given sample handler More...
 
void print () const
 print the debugging output to the screen More...
 
void printContent () const
 print the debugging output to the screen More...
 
Long64_t getNumEntries () const
 get the number of entries More...
 
TCollection * metaDataList ()
 get the meta-data list More...
 
const TCollection * metaDataList () const
 get the meta-data list More...
 
void removeMeta (const std::string &name)
 remove all meta-information with the given name More...
 
void addReplaceMeta (TNamed *meta_swallow)
 add a meta-data object and remove any existing meta-data with the same name More...
 
TObject * getMeta (const std::string &name)
 the meta-data object with the given name More...
 
const TObject * getMeta (const std::string &name) const
 the meta-data object with the given name More...
 
double getMetaDouble (const std::string &name, double def_val=0) const
 the meta-data double with the given name More...
 
std::string getMetaString (const std::string &name, const std::string &def_val="") const
 the meta-data string with the given name More...
 
void setMetaDouble (const std::string &name, double value)
 set the meta-data double with the given name More...
 
void setMetaString (const std::string &name, const std::string &value)
 set the meta-data string with the given name More...
 
void fetchMeta (const Sample &source)
 fetch the meta-data from the given sample. More...
 

Protected Member Functions

virtual std::size_t getNumFiles () const
 the number of files in the sample More...
 
virtual std::string getFileName (std::size_t index) const
 the name of the file with the given index More...
 
virtual SamplePtr doMakeLocal () const
 Make this a local sample, i.e. More...
 
virtual std::vector< std::string > doMakeFileList () const
 make a list of all files, prestaging them if necessary More...
 
 ClassDef (SampleGrid, 1)
 
virtual void doUpdateLocation (const std::string &from, const std::string &to)
 update all file references starting with from to to More...
 
virtual TObject * doReadHist (const std::string &name) const
 read an object from a histogram file More...
 
virtual bool getContains (const std::string &name) const
 whether this sample contains a sample of the given name More...
 
virtual void doAddSamples (SampleHandler &result)
 add all samples this sample corresponds to to the given sample handler More...
 

Private Member Functions

void alloc () const
 increase the reference count by one More...
 
void release () const
 decrease the reference count by one More...
 

Private Attributes

std::string m_name
 the name of the sample we are using More...
 
TagList m_tags
 the tag list we are using More...
 
MetaObjectm_meta
 the meta-information for this sample More...
 
std::atomic< unsigned > m_references
 the reference count More...
 

Related Functions

(Note that these are not member functions.)

std::string dbg (const Sample &obj, unsigned verbosity=0)
 the debugging info of this object More...
 

Detailed Description

This class implements a Sample located on the grid.

This sample is (somewhat) special, in that it doesn't contain a file list per se. Instead it relies on its meta-data entries to identify a grid dataset or dataset container, and a pattern for the files to use within.

The main purpose as such is to pass it as an input sample into the EL::PrunDriver. However, in practice one can still use this like a regular sample (using direct access via FAX, or pre-loading via rucio).

Normally you will not create these samples directly, but rely on the various data discovery methods, or one at a time via addGrid()

See also
https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/SampleHandler#Grid_Data_Discovery_Using_DQ2

Definition at line 43 of file SampleGrid.h.

Constructor & Destructor Documentation

◆ SampleGrid() [1/2]

SH::SampleGrid::SampleGrid ( )

standard constructor

Guarantee
strong
Failures
out of memory I
Warning
only to be used by serialization code

◆ SampleGrid() [2/2]

SH::SampleGrid::SampleGrid ( const std::string &  name)

standard constructor

Parameters
namethe name of the sample
Guarantee
strong
Failures
low level errors II

Member Function Documentation

◆ addReplaceMeta()

void SH::Sample::addReplaceMeta ( TNamed *  meta_swallow)
inherited

add a meta-data object and remove any existing meta-data with the same name

Parameters
meta_swallowthe meta-object to add
Precondition
meta_swallow != 0
Guarantee
basic, may delete some entries without adding the new one
Failures
out of memory II

◆ addSamples()

void SH::Sample::addSamples ( SampleHandler result)
inherited

add all samples this sample corresponds to to the given sample handler

Guarantee
basic, may only add some
Failures
out of memory II
Rationale this is used with composite samples to find the
actual list of samples to run on.

◆ addTag()

void SH::Sample::addTag ( const std::string &  tag)
inherited

add a tag to the content of tags()

Guarantee
strong
Failures
out of memory II

◆ alloc()

void SH::Sample::alloc ( ) const
privateinherited

increase the reference count by one

Guarantee
no-fail

◆ ClassDef()

SH::SampleGrid::ClassDef ( SampleGrid  ,
 
)
protected

◆ contains()

bool SH::Sample::contains ( const std::string &  name) const
inherited

whether this sample contains a sample of the given name

Returns
whether this sample contains a sample of the given name (or whether the sample itself has the given name)
Guarantee
no-fail
Rationale
this is used with composite sample to make sure we don't create ring like structures that would lead to endless recursion. the reason to check by name, not by address is that we will probably want to add these samples to a sample handler at some point.

◆ doAddSamples()

virtual void SH::Sample::doAddSamples ( SampleHandler result)
protectedvirtualinherited

add all samples this sample corresponds to to the given sample handler

Guarantee
basic, may only add some
Failures
out of memory II
Rationale this is used with composite samples to find the
actual list of samples to run on.
Rationale
the virtual part of SH::Sample::addSamples()

Reimplemented in SH::SampleComposite.

◆ doMakeFileList()

virtual std::vector<std::string> SH::SampleGrid::doMakeFileList ( ) const
protectedvirtual

make a list of all files, prestaging them if necessary

Guarantee
basic
Failures
out of memory III
file catalogue failures
prestaging failures
Rationale
the virtual part of Sample::makeFileList

Implements SH::Sample.

◆ doMakeLocal()

virtual SamplePtr SH::SampleGrid::doMakeLocal ( ) const
protectedvirtual

Make this a local sample, i.e.

one which can be directly opened with TFile::Open

Returns
the local sample, or "this" if this already is a local sample
Guarantee
strong
Failures
out of memory III
can not make local sample
Rationale
the virtual part of SH::Sample::makeLocal()

Implements SH::Sample.

◆ doReadHist()

virtual TObject* SH::Sample::doReadHist ( const std::string &  name) const
protectedvirtualinherited

read an object from a histogram file

Returns
the object read or NULL if it was not found
Guarantee
strong
Failures
out of memory II
i/o errors
Rationale
the virtual part of SH::Sample::readHist()

Reimplemented in SH::SampleHist.

◆ doUpdateLocation()

virtual void SH::Sample::doUpdateLocation ( const std::string &  from,
const std::string &  to 
)
protectedvirtualinherited

update all file references starting with from to to

Parameters
fromthe original path to the data area
tothe new path to the data area
Guarantee
basic, may update partially
Failures
out of memory II
Precondition
!from.empty()
Postcondition
!to.empty()
Rationale
this is needed when moving data around without recreating the samples from scratch
Rationale
the virtual part of SH::Sample::updateLocation()

Reimplemented in SH::SampleLocal, SH::SampleComposite, and SH::SampleHist.

◆ fetchMeta()

void SH::Sample::fetchMeta ( const Sample source)
inherited

fetch the meta-data from the given sample.

fields that have a name that starts with "nc_" are not copied.

Guarantee
basic, may only fetch some meta-data
Failures
out of memory II
Rationale this is used by EventLoop, to copy the
meta-data from the input samples to the output samples. the prefix "nc_" is used to indicate meta-data entries that only apply to the current sample, or are options to the specific EventLoop job.

◆ fileName()

std::string SH::Sample::fileName ( std::size_t  index) const
inherited

the name of the file with the given index

Parameters
indexthe index of the file
Guarantee
no-fail
Precondition
index < numFiles()
Postcondition
!result.empty()
Warning
this is meant more for debugging and may or may not do what you want, e.g. if this is a grid dataset the file may not be directly accessible.

◆ getContains()

virtual bool SH::Sample::getContains ( const std::string &  name) const
protectedvirtualinherited

whether this sample contains a sample of the given name

Returns
whether this sample contains a sample of the given name (or whether the sample itself has the given name)
Guarantee
no-fail
Rationale
this is used with composite sample to make sure we don't create ring like structures that would lead to endless recursion. the reason to check by name, not by address is that we will probably want to add these samples to a sample handler at some point.
Rationale
the virtual part of SH::Sample::contains()

Reimplemented in SH::SampleComposite.

◆ getFileName()

virtual std::string SH::SampleGrid::getFileName ( std::size_t  index) const
protectedvirtual

the name of the file with the given index

Parameters
indexthe index of the file
Guarantee
no-fail
Precondition
index < numFiles()
Postcondition
!result.empty()
Warning
this is meant more for debugging and may or may not do what you want, e.g. if this is a grid dataset the file may not be directly accessible.
Rationale
the virtual part of Sample::fileName()

Implements SH::Sample.

◆ getMeta() [1/2]

TObject* SH::Sample::getMeta ( const std::string &  name)
inherited

the meta-data object with the given name

Returns
the meta-data object with the given name, or NULL if there is no such entry
Parameters
namethe name of the meta-data object
Guarantee
no-fail

◆ getMeta() [2/2]

const TObject* SH::Sample::getMeta ( const std::string &  name) const
inherited

the meta-data object with the given name

Returns
the meta-data object with the given name, or NULL if there is no such entry
Parameters
namethe name of the meta-data object
Guarantee
no-fail

◆ getMetaDouble()

double SH::Sample::getMetaDouble ( const std::string &  name,
double  def_val = 0 
) const
inherited

the meta-data double with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail

◆ getMetaString()

std::string SH::Sample::getMetaString ( const std::string &  name,
const std::string &  def_val = "" 
) const
inherited

the meta-data string with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail
Rationale
I return the string by value, because returning by reference seems to break the python binding.

◆ getNumEntries()

Long64_t SH::Sample::getNumEntries ( ) const
inherited

get the number of entries

Guarantee
strong
Failures
i/o errors

◆ getNumFiles()

virtual std::size_t SH::SampleGrid::getNumFiles ( ) const
protectedvirtual

the number of files in the sample

Guarantee
no-fail
Rationale
the virtual part of Sample::numFiles()

Implements SH::Sample.

◆ makeFileList()

std::vector<std::string> SH::Sample::makeFileList ( ) const
inherited

make a list of all files, prestaging them if necessary

Guarantee
basic
Failures
out of memory III
file catalogue failures
prestaging failures

◆ makeLocal()

SamplePtr SH::Sample::makeLocal ( ) const
inherited

Make this a local sample, i.e.

one which can be directly opened with TFile::Open

Returns
the local sample, or "this" if this already is a local sample
Guarantee
strong
Failures
out of memory III
can not make local sample

◆ makeTChain()

TChain* SH::Sample::makeTChain ( ) const
inherited

create a TChain object, containing all these files

Guarantee
strong
Failures
out of memory II
chain making not supported
Postcondition
result != 0

◆ meta() [1/2]

MetaObject* SH::Sample::meta ( )
inherited

the meta-information for this sample

Guarantee
no-fail
Invariant
meta != 0

◆ meta() [2/2]

const MetaObject* SH::Sample::meta ( ) const
inherited

the meta-information for this sample

Guarantee
no-fail
Invariant
meta != 0

◆ metaDataList() [1/2]

TCollection* SH::Sample::metaDataList ( )
inherited

get the meta-data list

Guarantee
no-fail
Postcondition
result != 0
Deprecated:
use meta() instead, or (preferably) access of meta-data by name

◆ metaDataList() [2/2]

const TCollection* SH::Sample::metaDataList ( ) const
inherited

get the meta-data list

Guarantee
no-fail
Postcondition
result != 0
Deprecated:
use meta() instead, or (preferably) access of meta-data by name

◆ name() [1/2]

const std::string& SH::Sample::name ( ) const
inherited

the name of the sample we are using

Guarantee
no-fail

◆ name() [2/2]

void SH::Sample::name ( std::string  val_name)
inherited

set the value of name

Guarantee
no-fail / strong
Failures
out of memory II
Failures
Sample already owned by SampleHandler
Rationale
setting the sample name can be beneficial, if the sample auto-discovery set a duplicate (or otherwise unsuitable) name.
Warning
this must be done before adding it to the SampleHandler, or alternatively a clone must be made that can then be added to a new SampleHandler.

◆ numFiles()

std::size_t SH::Sample::numFiles ( ) const
inherited

the number of files in the sample

Guarantee
no-fail

◆ print()

void SH::Sample::print ( ) const
inherited

print the debugging output to the screen

Guarantee
basic, may print partially
Failures
out of memory II
Failures
stream errors

◆ printContent()

void SH::Sample::printContent ( ) const
inherited

print the debugging output to the screen

Guarantee
basic, may print partially
Failures
out of memory II
Failures
stream errors
Rationale
added a second print method for python where print is a keyword

◆ readHist()

TObject* SH::Sample::readHist ( const std::string &  name) const
inherited

read an object from a histogram file

Returns
the object read or NULL if it was not found
Guarantee
strong
Failures
out of memory II
i/o errors

◆ release()

void SH::Sample::release ( ) const
privateinherited

decrease the reference count by one

Side Effects
release this sample if that was the last reference
Guarantee
no-fail
Precondition
reference count > 0

◆ removeMeta()

void SH::Sample::removeMeta ( const std::string &  name)
inherited

remove all meta-information with the given name

Parameters
namethe meta-data name to remove
Guarantee
basic, may only delete some entries
Failures
out of memory II

◆ setMetaDouble()

void SH::Sample::setMetaDouble ( const std::string &  name,
double  value 
)
inherited

set the meta-data double with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

◆ setMetaString()

void SH::Sample::setMetaString ( const std::string &  name,
const std::string &  value 
)
inherited

set the meta-data string with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

◆ tags() [1/2]

const TagList& SH::Sample::tags ( ) const
inherited

the tag list we are using

Guarantee
no-fail

◆ tags() [2/2]

void SH::Sample::tags ( const TagList tags)
inherited

set the content of tags()

Guarantee
strong
Failures
out of memory II

◆ testInvariant()

void SH::SampleGrid::testInvariant ( ) const

test the invariant of this object

Guarantee
no-fail

◆ updateLocation()

void SH::Sample::updateLocation ( const std::string &  from,
const std::string &  to 
)
inherited

update all file references starting with from to to

Parameters
fromthe original path to the data area
tothe new path to the data area
Guarantee
basic, may update partially
Failures
out of memory II
Precondition
!from.empty()
Postcondition
!to.empty()
Rationale
this is needed when moving data around without recreating the samples from scratch

Friends And Related Function Documentation

◆ dbg()

std::string dbg ( const Sample obj,
unsigned  verbosity = 0 
)
related

the debugging info of this object

Returns
a string representation of the object content
Parameters
objthe object to be presented
verbositythe level of verbosity (higher number -> more information)
Guarantee
strong
Failures
out of memory II

Member Data Documentation

◆ m_meta

MetaObject* SH::Sample::m_meta
privateinherited

the meta-information for this sample

See also
meta

Definition at line 483 of file Sample.h.

◆ m_name

std::string SH::Sample::m_name
privateinherited

the name of the sample we are using

See also
name

Definition at line 475 of file Sample.h.

◆ m_references

std::atomic<unsigned> SH::Sample::m_references
mutableprivateinherited

the reference count

Definition at line 487 of file Sample.h.

◆ m_tags

TagList SH::Sample::m_tags
privateinherited

the tag list we are using

See also
tags

Definition at line 479 of file Sample.h.


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