ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EL::NTupleSvc Class Reference

#include <NTupleSvc.h>

Inheritance diagram for EL::NTupleSvc:
Collaboration diagram for EL::NTupleSvc:

Classes

struct  CopyInfo
 description: the information we need for copying branches More...
 
struct  WhiteInfo
 description: the information we need for whiteboard variables More...
 

Public Member Functions

void testInvariant () const
 effects: test the invariant of this object guarantee: no-fail More...
 
 NTupleSvc (const std::string &val_outputName="output")
 effects: standard constructor guarantee: strong failures: out of memory I requires: !val_outputName.empty() More...
 
 ~NTupleSvc ()
 effects: standard destructor guarantee: no-fail More...
 
void copyBranch (const std::string &name)
 effects: add another branch to copy. More...
 
void copyBranchList (const std::string &fileName)
 effects: read a list of branches to copy from a file. More...
 
void addWhiteFloat (const std::string &varName)
 effects: add a float from the whiteboard guarantee: strong failures: out of memory II More...
 
void addWhiteArray (const std::string &varName)
 effects: add an array from the whiteboard guarantee: strong failures: out of memory II More...
 
TTree * tree () const
 returns: the tree we are writing out guarantee: no-fail requires(soft): initialize() has been called postcondition: result != 0 More...
 
bool getFilterPassed () const
 returns: whether the current event will be taken guarantee: no-fail More...
 
void setFilterPassed (bool passed=true)
 effects: take the current event if passed is set, otherwise perform a no-op guarantee: no-fail More...
 
const std::string & treeName () const
 description: the name of the tree, or the empty string to use the name of the input tree guarantee: no-fail / strong failures: out of memory II More...
 
void treeName (const std::string &val_treeName)
 
virtual const char * GetName () const
 effects: return the name of this algorithm guarantee: no-fail More...
 
IWorkerwk () const
 description: the worker that is controlling us guarantee: no-fail More...
 
void book (const TH1 &hist)
 book the given histogram More...
 
TH1 * hist (const std::string &name) const
 get the histogram with the given name More...
 
asg::SgTEventevtStore () const
 get the (main) event store for this algorithm More...
 
virtual const std::string & name () const
 

Private Types

typedef std::set< std::string >::iterator m_copyBranchesIter
 
typedef std::set< std::string >::iterator m_whiteFloatIter
 
typedef std::set< std::string >::iterator m_whiteArrayIter
 
typedef std::vector< CopyInfo >::iterator copyInfoMIter
 
typedef std::vector< WhiteInfo >::iterator whiteInfoMIter
 

Private Member Functions

virtual StatusCode setupJob (Job &job)
 effects: give the algorithm a chance to intialize the job with anything this algorithm needs. More...
 
virtual StatusCode changeInput (bool firstFile)
 effects: do all changes to work with a new input file, e.g. More...
 
virtual StatusCode initialize ()
 effects: do everything that needs to be done before running the algorithm, e.g. More...
 
virtual StatusCode execute ()
 effects: process the next event guarantee: basic failures: algorithm dependent rationale: the virtual part of Algorithm::process More...
 
virtual StatusCode postExecute ()
 effects: do the post-processing for the event guarantee: basic failures: algorithm dependent rationale: the virtual part of Algorithm::process rationale: this is mainly used for specialized services that need to get input from subsequent algorithms before filling their event data More...
 
virtual bool hasName (const std::string &name) const
 returns: whether this algorithm has the given name guarantee: basic failures: algorithm dependent rationale: this is to allow an algorithm to be known by multiple names. More...
 
void initBranches ()
 effects: create all the branches when called for the first time guarantee: basic, may create some failures: out of memory III failures: branch not found More...
 
void findBranches (std::set< std::string > &branchList)
 effects: find the branches in the input tree guarantee: basic, may create some failures: out of memory III failures: branch not found More...
 
void initOutput (const std::string &branchName)
 effects: create the branch in the output tree guarantee: basic, may create some failures: out of memory II failures: branch not found failures: branch not copyable rationale: it is safe to call this function for branches that are already configured, since this function can call itself recursively. More...
 
void initOutput (const std::set< std::string > &branchList)
 effects: create the branches in the output tree guarantee: basic, may create some failures: out of memory II failures: branch not found failures: branch not copyable More...
 
void copyInput ()
 effects: copy the input branches to the output branches guarantee: basic, may copy some failures: out of memory III More...
 
 ClassDef (NTupleSvc, 1)
 
virtual StatusCode fileExecute ()
 effects: do all the processing that needs to be done once per file More...
 
virtual StatusCode endOfFile ()
 effects: do the post-processing for each input file guarantee: basic failures: algorithm dependent rationale: this is mainly used for specialized services that need to save partial results for each input file More...
 
virtual StatusCode histInitialize ()
 effects: this is a pre-initialization routine that is called before changeInput is called. More...
 
virtual StatusCode finalize ()
 effects: do everything that needs to be done after completing work on this worker guarantee: basic failures: algorithm dependent rationale: currently there is no use foreseen, but this routine is provided regardless More...
 
virtual StatusCode histFinalize ()
 effects: this is a post-initialization routine that is called after finalize has been called. More...
 
void sysSetupJob (Job &job)
 effects: give the algorithm a chance to intialize the job with anything this algorithm needs. More...
 

Private Attributes

std::string m_outputName
 description: the name of the output stream More...
 
std::string m_treeName
 description: the name of the output tree More...
 
std::string m_tree_title
 description: the title of the output tree More...
 
std::set< std::string > m_copyBranches
 description: the list of branches we copy More...
 
std::set< std::string > m_whiteFloat
 description: the list of whiteboard floats we copy More...
 
std::set< std::string > m_whiteArray
 description: the list of whiteboard arrays we copy More...
 
TFile * m_file
 description: the file we are writing out More...
 
TTree * m_tree
 description: the tree we are writing out More...
 
bool m_initialized
 description: whether we initialized the tree we are writing out More...
 
bool m_taken
 description: whether we take the current event More...
 
bool m_connected
 description: whether our output branches are properly connected to the input tree More...
 
WhiteBoardSvcm_whiteboard
 description: the white board service, if we are using it More...
 
std::vector< CopyInfom_copyInfo
 
std::vector< WhiteInfom_whiteInfo
 
IWorkerm_wk
 
asg::SgTEventm_evtStorePtr = nullptr
 the value of evtStore More...
 
asg::SgTEvent m_evtStore
 when configured, the object returned by evtStore More...
 
MsgStream * m_msg = nullptr
 the message stream, if it has been instantiated More...
 
std::string m_msgName
 the algorithm name for which the message stream has been instantiated More...
 
int m_msgLevel = 3
 the message level configured More...
 
std::string m_nameCache
 the cache for name More...
 

Detailed Description

Definition at line 48 of file NTupleSvc.h.

Member Typedef Documentation

◆ copyInfoMIter

typedef std::vector<CopyInfo>::iterator EL::NTupleSvc::copyInfoMIter
private

Definition at line 289 of file NTupleSvc.h.

◆ m_copyBranchesIter

typedef std::set<std::string>::iterator EL::NTupleSvc::m_copyBranchesIter
private

Definition at line 231 of file NTupleSvc.h.

◆ m_whiteArrayIter

typedef std::set<std::string>::iterator EL::NTupleSvc::m_whiteArrayIter
private

Definition at line 241 of file NTupleSvc.h.

◆ m_whiteFloatIter

typedef std::set<std::string>::iterator EL::NTupleSvc::m_whiteFloatIter
private

Definition at line 236 of file NTupleSvc.h.

◆ whiteInfoMIter

typedef std::vector<WhiteInfo>::iterator EL::NTupleSvc::whiteInfoMIter
private

Definition at line 313 of file NTupleSvc.h.

Constructor & Destructor Documentation

◆ NTupleSvc()

EL::NTupleSvc::NTupleSvc ( const std::string &  val_outputName = "output")

effects: standard constructor guarantee: strong failures: out of memory I requires: !val_outputName.empty()

◆ ~NTupleSvc()

EL::NTupleSvc::~NTupleSvc ( )

effects: standard destructor guarantee: no-fail

Member Function Documentation

◆ addWhiteArray()

void EL::NTupleSvc::addWhiteArray ( const std::string &  varName)

effects: add an array from the whiteboard guarantee: strong failures: out of memory II

◆ addWhiteFloat()

void EL::NTupleSvc::addWhiteFloat ( const std::string &  varName)

effects: add a float from the whiteboard guarantee: strong failures: out of memory II

◆ book()

void EL::Algorithm::book ( const TH1 &  hist)
inherited

book the given histogram

Guarantee
strong
Failures
histogram booking error

◆ changeInput()

virtual StatusCode EL::NTupleSvc::changeInput ( bool  firstFile)
privatevirtual

effects: do all changes to work with a new input file, e.g.

set new branch addresses. if firstFile is set, this method is called just before init() is called guarantee: basic failures: algorithm dependent

Reimplemented from EL::Algorithm.

◆ ClassDef()

EL::NTupleSvc::ClassDef ( NTupleSvc  ,
 
)
private

◆ copyBranch()

void EL::NTupleSvc::copyBranch ( const std::string &  name)

effects: add another branch to copy.

allows use of regular expressions guarantee: strong failures: out of memory II

◆ copyBranchList()

void EL::NTupleSvc::copyBranchList ( const std::string &  fileName)

effects: read a list of branches to copy from a file.

allows use of regular expressions inside the file. leading and trailing spaces are ignored. lines starting with # are ignored. guarantee: strong failures: out of memory III failures: i/o errors

◆ copyInput()

void EL::NTupleSvc::copyInput ( )
private

effects: copy the input branches to the output branches guarantee: basic, may copy some failures: out of memory III

◆ endOfFile()

virtual StatusCode EL::Algorithm::endOfFile ( )
privatevirtualinherited

effects: do the post-processing for each input file guarantee: basic failures: algorithm dependent rationale: this is mainly used for specialized services that need to save partial results for each input file

Reimplemented in EL::MetricsSvc.

◆ evtStore()

asg::SgTEvent* EL::Algorithm::evtStore ( ) const
inherited

get the (main) event store for this algorithm

This is mostly to mirror the method of the same name in AthAlgorithm, allowing to make the tutorial instructions more dual-use.

Guarantee
strong
Failures
out of memory I
job not configured for xAODs

◆ execute()

virtual StatusCode EL::NTupleSvc::execute ( )
privatevirtual

effects: process the next event guarantee: basic failures: algorithm dependent rationale: the virtual part of Algorithm::process

Reimplemented from EL::Algorithm.

◆ fileExecute()

virtual StatusCode EL::Algorithm::fileExecute ( )
privatevirtualinherited

effects: do all the processing that needs to be done once per file

Warning: The user should not expect this to be called at any particular point in execution. If a file is split between multiple jobs this will be called in only one of these jobs, and not the others. It usually gets called before the first event in a file, but that is not guaranteed and relying on this is a bug. Take a look at changeInput if you want something that is guaranteed to be executed at the beginning of each input file.

Warning: The execution order of changeInput and fileExecute is currently unspecified.

guarantee: basic failures: algorithm dependent rationale: this is to read per-file accounting data, e.g. the list of lumi-blocks processed

Reimplemented in EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, and EL::MetricsSvc.

◆ finalize()

virtual StatusCode EL::Algorithm::finalize ( )
privatevirtualinherited

effects: do everything that needs to be done after completing work on this worker guarantee: basic failures: algorithm dependent rationale: currently there is no use foreseen, but this routine is provided regardless

Reimplemented in EL::UnitTestAlg1, EL::UnitTestAlg, and EL::UnitTestAlgXAOD.

◆ findBranches()

void EL::NTupleSvc::findBranches ( std::set< std::string > &  branchList)
private

effects: find the branches in the input tree guarantee: basic, may create some failures: out of memory III failures: branch not found

◆ getFilterPassed()

bool EL::NTupleSvc::getFilterPassed ( ) const

returns: whether the current event will be taken guarantee: no-fail

◆ GetName()

virtual const char* EL::NTupleSvc::GetName ( ) const
virtual

effects: return the name of this algorithm guarantee: no-fail

◆ hasName()

virtual bool EL::NTupleSvc::hasName ( const std::string &  name) const
privatevirtual

returns: whether this algorithm has the given name guarantee: basic failures: algorithm dependent rationale: this is to allow an algorithm to be known by multiple names.

this is needed for NTupleSvc, so that it can be located with and without the output tree name.

Reimplemented from EL::Algorithm.

◆ hist()

TH1* EL::Algorithm::hist ( const std::string &  name) const
inherited

get the histogram with the given name

Guarantee
strong
Failures
histogram not found

◆ histFinalize()

virtual StatusCode EL::Algorithm::histFinalize ( )
privatevirtualinherited

effects: this is a post-initialization routine that is called after finalize has been called.

guarantee: basic failures: algorithm dependent rationale: unlike finalize(), this method is called all the time, even on empty input files.

Reimplemented in EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, and EL::MetricsSvc.

◆ histInitialize()

virtual StatusCode EL::Algorithm::histInitialize ( )
privatevirtualinherited

effects: this is a pre-initialization routine that is called before changeInput is called.

guarantee: basic failures: algorithm dependent rationale: unlike initialize(), this method is called all the time, even on empty input files. so you should create any histograms or n-tuples here that subsequent code expects

Reimplemented in EL::UnitTestAlg1, EL::UnitTestAlg, EL::UnitTestAlgXAOD, EL::MetricsSvc, and EL::VomsProxySvc.

◆ initBranches()

void EL::NTupleSvc::initBranches ( )
private

effects: create all the branches when called for the first time guarantee: basic, may create some failures: out of memory III failures: branch not found

◆ initialize()

virtual StatusCode EL::NTupleSvc::initialize ( )
privatevirtual

effects: do everything that needs to be done before running the algorithm, e.g.

create output n-tuples and histograms. this method is called only once right after changeInput(true) is called guarantee: basic failures: algorithm dependent rationale: in principle all this work could be done on changeInput(true). However, providing this method should make it easier for the user to set up all his outputs and to do so only once.

Reimplemented from EL::Algorithm.

◆ initOutput() [1/2]

void EL::NTupleSvc::initOutput ( const std::set< std::string > &  branchList)
private

effects: create the branches in the output tree guarantee: basic, may create some failures: out of memory II failures: branch not found failures: branch not copyable

◆ initOutput() [2/2]

void EL::NTupleSvc::initOutput ( const std::string &  branchName)
private

effects: create the branch in the output tree guarantee: basic, may create some failures: out of memory II failures: branch not found failures: branch not copyable rationale: it is safe to call this function for branches that are already configured, since this function can call itself recursively.

◆ msg() [1/2]

MsgStream& EL::Algorithm::msg ( ) const
inherited

messaging interface

this is the interface to work with the standard messaging macros from AsgTools. Instead of enums I pass ints, so that I can avoid the include dependency (forward declarations are only allowed for enum classes AFAIK).

the standard message stream for this object

Guarantee
strong
Failures
code not compiled with AsgTools support

◆ msg() [2/2]

MsgStream& EL::Algorithm::msg ( int  level) const
inherited

the message stream for this object, configured for the given level

Guarantee
strong
Failures
code not compiled with AsgTools support

◆ msgLvl()

bool EL::Algorithm::msgLvl ( int  lvl) const
inherited

whether we are configured to print messages at the given level

Guarantee
no-fail

◆ name()

virtual const std::string& EL::Algorithm::name ( ) const
virtualinherited

◆ postExecute()

virtual StatusCode EL::NTupleSvc::postExecute ( )
privatevirtual

effects: do the post-processing for the event guarantee: basic failures: algorithm dependent rationale: the virtual part of Algorithm::process rationale: this is mainly used for specialized services that need to get input from subsequent algorithms before filling their event data

Reimplemented from EL::Algorithm.

◆ setFilterPassed()

void EL::NTupleSvc::setFilterPassed ( bool  passed = true)

effects: take the current event if passed is set, otherwise perform a no-op guarantee: no-fail

◆ setMsgLevel()

void EL::Algorithm::setMsgLevel ( int  level)
inherited

set the message level for the message stream for this object

Guarantee
no-fail

◆ setupJob()

virtual StatusCode EL::NTupleSvc::setupJob ( Job job)
privatevirtual

effects: give the algorithm a chance to intialize the job with anything this algorithm needs.

this method is automatically called before the algorithm is actually added to the job. guarantee: basic failures: algorithm dependent rationale: this is currently used to give algorithms a chance to register their output datasets, but can also be used for other stuff.

Reimplemented from EL::Algorithm.

◆ sysSetupJob()

void EL::Algorithm::sysSetupJob ( Job job)
privateinherited

effects: give the algorithm a chance to intialize the job with anything this algorithm needs.

this method is automatically called before the algorithm is actually added to the job. guarantee: basic failures: algorithm dependent rationale: this is currently used to give algorithms a chance to register their output datasets, but can also be used for other stuff.

◆ testInvariant()

void EL::NTupleSvc::testInvariant ( ) const

effects: test the invariant of this object guarantee: no-fail

◆ tree()

TTree* EL::NTupleSvc::tree ( ) const

returns: the tree we are writing out guarantee: no-fail requires(soft): initialize() has been called postcondition: result != 0

◆ treeName() [1/2]

const std::string& EL::NTupleSvc::treeName ( ) const

description: the name of the tree, or the empty string to use the name of the input tree guarantee: no-fail / strong failures: out of memory II

◆ treeName() [2/2]

void EL::NTupleSvc::treeName ( const std::string &  val_treeName)

◆ wk()

IWorker* EL::Algorithm::wk ( ) const
inherited

description: the worker that is controlling us guarantee: no-fail

Member Data Documentation

◆ m_connected

bool EL::NTupleSvc::m_connected
private

description: whether our output branches are properly connected to the input tree

Definition at line 262 of file NTupleSvc.h.

◆ m_copyBranches

std::set<std::string> EL::NTupleSvc::m_copyBranches
private

description: the list of branches we copy

Definition at line 230 of file NTupleSvc.h.

◆ m_copyInfo

std::vector<CopyInfo> EL::NTupleSvc::m_copyInfo
private

Definition at line 288 of file NTupleSvc.h.

◆ m_evtStore

asg::SgTEvent EL::Algorithm::m_evtStore
mutableprivateinherited

when configured, the object returned by evtStore

Definition at line 329 of file Algorithm.h.

◆ m_evtStorePtr

asg::SgTEvent* EL::Algorithm::m_evtStorePtr = nullptr
mutableprivateinherited

the value of evtStore

Definition at line 325 of file Algorithm.h.

◆ m_file

TFile* EL::NTupleSvc::m_file
private

description: the file we are writing out

Definition at line 245 of file NTupleSvc.h.

◆ m_initialized

bool EL::NTupleSvc::m_initialized
private

description: whether we initialized the tree we are writing out

Definition at line 253 of file NTupleSvc.h.

◆ m_msg

MsgStream* EL::Algorithm::m_msg = nullptr
mutableprivateinherited

the message stream, if it has been instantiated

Definition at line 333 of file Algorithm.h.

◆ m_msgLevel

int EL::Algorithm::m_msgLevel = 3
privateinherited

the message level configured

Definition at line 342 of file Algorithm.h.

◆ m_msgName

std::string EL::Algorithm::m_msgName
mutableprivateinherited

the algorithm name for which the message stream has been instantiated

Definition at line 338 of file Algorithm.h.

◆ m_nameCache

std::string EL::Algorithm::m_nameCache
mutableprivateinherited

the cache for name

Definition at line 346 of file Algorithm.h.

◆ m_outputName

std::string EL::NTupleSvc::m_outputName
private

description: the name of the output stream

Definition at line 218 of file NTupleSvc.h.

◆ m_taken

bool EL::NTupleSvc::m_taken
private

description: whether we take the current event

Definition at line 257 of file NTupleSvc.h.

◆ m_tree

TTree* EL::NTupleSvc::m_tree
private

description: the tree we are writing out

Definition at line 249 of file NTupleSvc.h.

◆ m_tree_title

std::string EL::NTupleSvc::m_tree_title
private

description: the title of the output tree

Definition at line 226 of file NTupleSvc.h.

◆ m_treeName

std::string EL::NTupleSvc::m_treeName
private

description: the name of the output tree

Definition at line 222 of file NTupleSvc.h.

◆ m_whiteArray

std::set<std::string> EL::NTupleSvc::m_whiteArray
private

description: the list of whiteboard arrays we copy

Definition at line 240 of file NTupleSvc.h.

◆ m_whiteboard

WhiteBoardSvc* EL::NTupleSvc::m_whiteboard
private

description: the white board service, if we are using it

Definition at line 266 of file NTupleSvc.h.

◆ m_whiteFloat

std::set<std::string> EL::NTupleSvc::m_whiteFloat
private

description: the list of whiteboard floats we copy

Definition at line 235 of file NTupleSvc.h.

◆ m_whiteInfo

std::vector<WhiteInfo> EL::NTupleSvc::m_whiteInfo
private

Definition at line 312 of file NTupleSvc.h.

◆ m_wk

IWorker* EL::Algorithm::m_wk
privateinherited

Definition at line 321 of file Algorithm.h.


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