RunStore Class Reference

Ratpac-two: RAT::DS::RunStore Class Reference
Ratpac-two

Public Member Functions

 RunStore ()
 
RunInstanceGetRun (Root *ds)
 
RunInstanceGetRun (int runID)
 
void InstanceSetReadTree (TTree *tree)
 
void InstanceSetWriteTree (TTree *tree)
 
void InstanceFlushWriteTree ()
 
void InstanceAddNewRun (Run *run)
 
void InstancePreloadFromTree (TTree *tree, bool writtenToDisk=false)
 
 ClassDef (RunStore, 2)
 

Static Public Member Functions

static RunStoreGet ()
 
static RunGetRun (Root *ds)
 
static RunGetRun (int runID)
 
static RunGetCurrentRun ()
 
static void SetReadTree (TTree *tree)
 
static void SetWriteTree (TTree *tree)
 
static void FlushWriteTree ()
 
static void AddNewRun (Run *run)
 
static void PreloadFromTree (TTree *tree, bool alreadyWrittenToDisk=false)
 

Protected Attributes

TTree * fReadTree
 
RunfReadRun
 
TTree * fWriteTree
 
RunfWriteRun
 
std::map< int, RunRecord * > fCache
 

Static Protected Attributes

static RunStorefgStore = 0
 
static int currentRunID = -9999
 

Constructor & Destructor Documentation

◆ RunStore()

RAT::DS::RunStore::RunStore ( )

You probably want the static interface above.

Member Function Documentation

◆ AddNewRun()

static void RAT::DS::RunStore::AddNewRun ( Run run)
inlinestatic

Adds a new run record to the cache.

The run record is added to the cache for later access by GetRun(), and the record will be sent to the write tree when FlushWriteTree() is called.

◆ FlushWriteTree()

static void RAT::DS::RunStore::FlushWriteTree ( )
inlinestatic

Writes all unwritten run records to the write tree.

This function must be called before closing the write tree. A flag is kept for each run record indicating whether it has already been written to disk, so FlushWriteTree() can be called many times without duplication of run records in the write tree.

Note that this function flushes run records from the cache into the tree. It does not Write() the tree to an output root file, which is still the responsibility of the caller to ensure tree contents are flushed to disk.

◆ Get()

static RunStore* RAT::DS::RunStore::Get ( )
inlinestatic

Static interface Get a pointer to the global RunStore instance.

You generally don't need to use this function.

◆ GetCurrentRun()

static Run* RAT::DS::RunStore::GetCurrentRun ( )
inlinestatic

Get the run object that is associated with the current.

The current runID whe a new run is added to the RunStore. Hence This method assumes that the "current run" is the one most recently instantiated.

◆ GetRun() [1/2]

static Run* RAT::DS::RunStore::GetRun ( int  runID)
inlinestatic

Get the Run object associated with the given runID.

GetRun(Root* ds) should be used in preference to this method in case future versions of RunStore use additional criteria to identify run records, like eventID ranges. If that happens, this method will change.

◆ GetRun() [2/2]

static Run* RAT::DS::RunStore::GetRun ( Root ds)
inlinestatic

Get the Run object associated with event ds.

If the run information is in the cache, it is returned, otherwise a potentially slow search is made through the input tree of run records, if available. If the record cannot be found, 0 is returned.

◆ PreloadFromTree()

static void RAT::DS::RunStore::PreloadFromTree ( TTree *  tree,
bool  alreadyWrittenToDisk = false 
)
inlinestatic

Preloads the cache from a run tree.

All of the run records in the tree are added to the cache. If alreadyWrittenToDisk is true, then the records will NOT be send to the write tree when FlushWriteTree() is called. This can be useful if you are appending to an existing tree, since you cannot make the same tree both a read an write tree. Instead you can preload the cache from the tree at the beginning, then write only the new run records to it.

◆ SetReadTree()

static void RAT::DS::RunStore::SetReadTree ( TTree *  tree)
inlinestatic

Sets the TTree from which Run records can be read.

This tree will not be written to, but will be searched as needed. No assumption is made about the numerical ordering of runs in the tree.

The caller retains ownership of the tree, although this class will call GetEntry(), SetBranchAddress(), and SetBranchStatus() on the tree at will.

◆ SetWriteTree()

static void RAT::DS::RunStore::SetWriteTree ( TTree *  tree)
inlinestatic

Sets the TTree to which Run records are written.

All records loaded by RunStore, either from the read tree, or new records added with AddNewRun(), will be written to the write tree. The only exception to this rule are run records added using PreloadFromTree() with alreadWrittenToDisk==true.

Run records are written to the output tree before being removed from the cache. Currently records are never written to the cache, so only FlushWriteTree() actually triggers a write.

The caller retains ownership of the tree.


The documentation for this class was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/RunStore.hh
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/src/RunStore.cc