REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Private Attributes
TRestProcessRunner Class Reference

Detailed Description

Running the processes efficiently with fantastic display.

This class implements REST's main functionality - process running. multi- thread is enabled here which improves efficiency. Pause menu and progress bar is also provided which makes the work easier!


RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2014-june: First concept. As part of conceptualization of previous REST code (REST v2) Igor G. Irastorza

2017-Aug: Major change: added for multi-thread capability Kaixiang Ni


Definition at line 28 of file TRestProcessRunner.h.

#include <TRestProcessRunner.h>

Inheritance diagram for TRestProcessRunner:
TRestMetadata

Public Member Functions

void BeginOfInit ()
 Reads information from rml config file. More...
 
 ClassDefOverride (TRestProcessRunner, 7)
 
void ConfigOutputFile ()
 Forming an output file. More...
 
void EndOfInit ()
 Ending of the startup procedure. More...
 
void FillThreadEventFunc (TRestThread *t)
 Calling back the FillEvent() method in TRestThread. More...
 
Long64_t GetFileSplitSize () const
 
TRestAnalysisTreeGetInputAnalysisTree ()
 
TRestEventGetInputEvent ()
 
Int_t GetNextevtFunc (TRestEvent *targetevt, TRestAnalysisTree *targettree)
 Get next event and copy it to the address of targetevt. More...
 
int GetNProcessedEvents () const
 
int GetNProcesses () const
 
int GetNThreads () const
 
TRestAnalysisTreeGetOutputAnalysisTree ()
 
TFile * GetOutputDataFile ()
 
std::string GetProcInfo (std::string infoname)
 
double GetReadingSpeed ()
 
ProcStatus GetStatus () const
 
void InitFromConfigFile () override
 To make settings from rml file. This method must be implemented in the derived class. More...
 
void Initialize () override
 REST run class. More...
 
TRestEventProcessInstantiateProcess (TString type, TiXmlElement *ele)
 InstantiateProcess in sequential start up. More...
 
std::string MakeProgressBar (int progress100, int length=100)
 Make a string of progress bar with given length and percentage. More...
 
void MergeOutputFile ()
 Calls TRestRun::MergeOutputFile() to merge the main file with process's tmp file. More...
 
void PauseMenu ()
 A pause menu providing some functions during the process. More...
 
void PrintMetadata () override
 Implemented it in the derived metadata class to print out specific metadata information. More...
 
void PrintProcessedEvents (Int_t rateE)
 Print number of events processed, file read speed, ETA and a progress bar. More...
 
Int_t ReadConfig (const std::string &keydeclare, TiXmlElement *e)
 method to deal with iterated child elements More...
 
void ReadProcInfo ()
 Create a process info list which used called by TRestRun::FormFormat(). More...
 
void ResetRunTimes ()
 Reset running time count to 0. More...
 
void RunProcess ()
 The main executer of event process. More...
 
bool UseTestRun () const
 
void WriteProcessesMetadata ()
 Write process metadata to fOutputDataFile. More...
 

Private Attributes

TRestAnalysisTreefAnalysisTree
 
Int_t fEventsToProcess
 
TTree * fEventTree
 
Int_t fFileCompression
 
Long64_t fFileSplitSize
 
Int_t fFirstEntry
 
Bool_t fInputAnalysisStorage
 
TRestEventfInputEvent
 
Bool_t fInputEventStorage
 
Int_t fNBranches
 
Int_t fNFilesSplit
 
Bool_t fOutputAnalysisStorage
 
TFile * fOutputDataFile
 
TString fOutputDataFileName
 the TFile pointer being used More...
 
TRestEventfOutputEvent
 
Bool_t fOutputEventStorage
 
Int_t fProcessedEvents
 
std::map< std::string, std::string > fProcessInfo
 
Int_t fProcessNumber
 
ProcStatus fProcStatus
 
TRestRunfRunInfo
 
Bool_t fSortOutputEvents
 
Int_t fThreadNumber
 
std::vector< TRestThread * > fThreads
 
Bool_t fUsePauseMenu
 
Bool_t fUseTestRun
 Number of files being split. More...
 
Bool_t fValidateObservables
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ TRestProcessRunner()

TRestProcessRunner::TRestProcessRunner ( )

Definition at line 66 of file TRestProcessRunner.cxx.

◆ ~TRestProcessRunner()

TRestProcessRunner::~TRestProcessRunner ( )

Definition at line 68 of file TRestProcessRunner.cxx.

Member Function Documentation

◆ BeginOfInit()

void TRestProcessRunner::BeginOfInit ( )

Reads information from rml config file.

It first checks if a friendly TRestRun object is initialized in TRestManager, if so, it reads the following configuration items:

  1. firstEntry, lastEntry, eventsToProcess. These indicates how many events we need to process.
  2. Tree branch list. can be inputAnalysis, inputEvent, outputEvent.
  3. Number of thread needed. A list TRestThread will then be instantiated.

Definition at line 114 of file TRestProcessRunner.cxx.

◆ ConfigOutputFile()

void TRestProcessRunner::ConfigOutputFile ( )

Forming an output file.

Merge all the process's file together, write TRestRun metadata, and then save process metadata to that file

Definition at line 951 of file TRestProcessRunner.cxx.

◆ EndOfInit()

void TRestProcessRunner::EndOfInit ( )

Ending of the startup procedure.

It first sets input event as the first event in process chain, and then do a Validation of the process chain. Finally it calls ReadProcInfo() and create a process info list

Definition at line 282 of file TRestProcessRunner.cxx.

◆ FillThreadEventFunc()

void TRestProcessRunner::FillThreadEventFunc ( TRestThread t)

Calling back the FillEvent() method in TRestThread.

This method is locked by mutex. There can never be two of it running simultaneously in two threads. As a result threads will not write their files together, thus preventing segmentaion violation.

Definition at line 792 of file TRestProcessRunner.cxx.

◆ GetFileSplitSize()

Long64_t TRestProcessRunner::GetFileSplitSize ( ) const
inline

Definition at line 124 of file TRestProcessRunner.h.

◆ GetInputAnalysisTree()

TRestAnalysisTree * TRestProcessRunner::GetInputAnalysisTree ( )

Definition at line 1170 of file TRestProcessRunner.cxx.

◆ GetInputEvent()

TRestEvent * TRestProcessRunner::GetInputEvent ( )

Definition at line 1168 of file TRestProcessRunner.cxx.

◆ GetNextevtFunc()

Int_t TRestProcessRunner::GetNextevtFunc ( TRestEvent targetevt,
TRestAnalysisTree targettree 
)

Get next event and copy it to the address of targetevt.

If can, it will also set the observal value of targettree according to the local analysis tree.

This method is locked by mutex. There can never be two of it running simultaneously in two threads.

If there is a single thread process, the local input event will be set to the out put of this process. The targettree will not be changed.

If not, the local input event and analysis tree will be updated after calling TTree::GetEntry(). The observables in the local tree will be copyed to the targettree.

Finally the data in the input event will get cloned to the targetevt by root streamer.

If the current entry is the last entry of the input tree, or the single thread process stops to give a concret pointer as the output, the process is over. This method returns -1.

Definition at line 759 of file TRestProcessRunner.cxx.

◆ GetNProcessedEvents()

int TRestProcessRunner::GetNProcessedEvents ( ) const
inline

Definition at line 120 of file TRestProcessRunner.h.

◆ GetNProcesses()

int TRestProcessRunner::GetNProcesses ( ) const
inline

Definition at line 119 of file TRestProcessRunner.h.

◆ GetNThreads()

int TRestProcessRunner::GetNThreads ( ) const
inline

Definition at line 118 of file TRestProcessRunner.h.

◆ GetOutputAnalysisTree()

TRestAnalysisTree * TRestProcessRunner::GetOutputAnalysisTree ( )
inline

Definition at line 113 of file TRestProcessRunner.h.

◆ GetOutputDataFile()

TFile * TRestProcessRunner::GetOutputDataFile ( )
inline

Definition at line 114 of file TRestProcessRunner.h.

◆ GetProcInfo()

std::string TRestProcessRunner::GetProcInfo ( std::string  infoname)
inline

Definition at line 115 of file TRestProcessRunner.h.

◆ GetReadingSpeed()

double TRestProcessRunner::GetReadingSpeed ( )

Definition at line 1062 of file TRestProcessRunner.cxx.

◆ GetStatus()

ProcStatus TRestProcessRunner::GetStatus ( ) const
inline

Definition at line 123 of file TRestProcessRunner.h.

◆ InitFromConfigFile()

void TRestProcessRunner::InitFromConfigFile ( )
inlineoverridevirtual

To make settings from rml file. This method must be implemented in the derived class.

Reimplemented from TRestMetadata.

Definition at line 73 of file TRestProcessRunner.h.

◆ Initialize()

void TRestProcessRunner::Initialize ( )
overridevirtual

REST run class.

Setting default values of class' data member.

Reimplemented from TRestMetadata.

Definition at line 73 of file TRestProcessRunner.cxx.

◆ InstantiateProcess()

TRestEventProcess * TRestProcessRunner::InstantiateProcess ( TString  type,
TiXmlElement *  ele 
)

InstantiateProcess in sequential start up.

It instantiates a the object by the method TClass::GetClass(), giving it type name. Then it asks the process object to LoadConfigFromFile() with an xml section.

Definition at line 1049 of file TRestProcessRunner.cxx.

◆ MakeProgressBar()

string TRestProcessRunner::MakeProgressBar ( int  progress100,
int  length = 100 
)

Make a string of progress bar with given length and percentage.

Definition at line 1156 of file TRestProcessRunner.cxx.

◆ MergeOutputFile()

void TRestProcessRunner::MergeOutputFile ( )

Calls TRestRun::MergeOutputFile() to merge the main file with process's tmp file.

After this operation, fOutputDataFile will be set to TRestRun's output file

Definition at line 1006 of file TRestProcessRunner.cxx.

◆ PauseMenu()

void TRestProcessRunner::PauseMenu ( )

A pause menu providing some functions during the process.

It can:

  1. Change verbose level
  2. Change number of events to process
  3. Push forward event by event
  4. Print the latest processed event
  5. Quit the process directly with file saved

Definition at line 554 of file TRestProcessRunner.cxx.

◆ PrintMetadata()

void TRestProcessRunner::PrintMetadata ( )
overridevirtual

Implemented it in the derived metadata class to print out specific metadata information.

Prints metadata content on screen. Usually overloaded by the derived metadata class.

Reimplemented from TRestMetadata.

Definition at line 1172 of file TRestProcessRunner.cxx.

◆ PrintProcessedEvents()

void TRestProcessRunner::PrintProcessedEvents ( Int_t  rateE)

Print number of events processed, file read speed, ETA and a progress bar.

Definition at line 1073 of file TRestProcessRunner.cxx.

◆ ReadConfig()

Int_t TRestProcessRunner::ReadConfig ( const std::string &  keydeclare,
TiXmlElement *  e 
)

method to deal with iterated child elements

If child element is declared as "addProcess", then multiple new process will be instantiated using sequential startup method, by calling InstantiateProcess() The processes will be added into each TRestThread instance. If the process is external process, then it will be sent to TRestRun.

Definition at line 213 of file TRestProcessRunner.cxx.

◆ ReadProcInfo()

void TRestProcessRunner::ReadProcInfo ( )

Create a process info list which used called by TRestRun::FormFormat().

Items: FirstProcess, LastProcess, ProcNumber

Definition at line 314 of file TRestProcessRunner.cxx.

◆ ResetRunTimes()

void TRestProcessRunner::ResetRunTimes ( )

Reset running time count to 0.

Definition at line 1033 of file TRestProcessRunner.cxx.

◆ RunProcess()

void TRestProcessRunner::RunProcess ( )

The main executer of event process.

Things doing in this method:

  1. Call each thread to prepare their process chain, output tree and output file. The method is PrepareToProcess().
  2. Print metadata for each process
  3. Set output tree by cloning the TRestThread output tree
  4. Reset run count, modify ROOT mutex to make it support multi-thread.
  5. Call each thread to start. The threads running the processes are detatched after this calling.
  6. The main thread loops for progress bar while waiting the child threads to finish.
  7. After finished, print some information, reset ROOT mutexs.
  8. Call ConfigOutputFile() method to save the output file

!!!!!!!!!!!Important!!!!!!!!!!!!

Definition at line 342 of file TRestProcessRunner.cxx.

◆ UseTestRun()

bool TRestProcessRunner::UseTestRun ( ) const
inline

Definition at line 122 of file TRestProcessRunner.h.

◆ WriteProcessesMetadata()

void TRestProcessRunner::WriteProcessesMetadata ( )

Write process metadata to fOutputDataFile.

Definition at line 989 of file TRestProcessRunner.cxx.

Field Documentation

◆ fAnalysisTree

TRestAnalysisTree* TRestProcessRunner::fAnalysisTree
private

Definition at line 43 of file TRestProcessRunner.h.

◆ fEventsToProcess

Int_t TRestProcessRunner::fEventsToProcess
private

Definition at line 60 of file TRestProcessRunner.h.

◆ fEventTree

TTree* TRestProcessRunner::fEventTree
private

indicates the name of the first file created as output data file. The actual output file maybe changed if tree is too large

Definition at line 42 of file TRestProcessRunner.h.

◆ fFileCompression

Int_t TRestProcessRunner::fFileCompression
private

Definition at line 64 of file TRestProcessRunner.h.

◆ fFileSplitSize

Long64_t TRestProcessRunner::fFileSplitSize
private

Definition at line 63 of file TRestProcessRunner.h.

◆ fFirstEntry

Int_t TRestProcessRunner::fFirstEntry
private

Definition at line 59 of file TRestProcessRunner.h.

◆ fInputAnalysisStorage

Bool_t TRestProcessRunner::fInputAnalysisStorage
private

Definition at line 53 of file TRestProcessRunner.h.

◆ fInputEvent

TRestEvent* TRestProcessRunner::fInputEvent
private

Definition at line 34 of file TRestProcessRunner.h.

◆ fInputEventStorage

Bool_t TRestProcessRunner::fInputEventStorage
private

Definition at line 54 of file TRestProcessRunner.h.

◆ fNBranches

Int_t TRestProcessRunner::fNBranches
private

Definition at line 45 of file TRestProcessRunner.h.

◆ fNFilesSplit

Int_t TRestProcessRunner::fNFilesSplit
private

Definition at line 46 of file TRestProcessRunner.h.

◆ fOutputAnalysisStorage

Bool_t TRestProcessRunner::fOutputAnalysisStorage
private

Definition at line 56 of file TRestProcessRunner.h.

◆ fOutputDataFile

TFile* TRestProcessRunner::fOutputDataFile
private

Definition at line 39 of file TRestProcessRunner.h.

◆ fOutputDataFileName

TString TRestProcessRunner::fOutputDataFileName
private

the TFile pointer being used

Definition at line 40 of file TRestProcessRunner.h.

◆ fOutputEvent

TRestEvent* TRestProcessRunner::fOutputEvent
private

Definition at line 35 of file TRestProcessRunner.h.

◆ fOutputEventStorage

Bool_t TRestProcessRunner::fOutputEventStorage
private

Definition at line 55 of file TRestProcessRunner.h.

◆ fProcessedEvents

Int_t TRestProcessRunner::fProcessedEvents
private

Definition at line 61 of file TRestProcessRunner.h.

◆ fProcessInfo

std::map<std::string, std::string> TRestProcessRunner::fProcessInfo
private

Definition at line 65 of file TRestProcessRunner.h.

◆ fProcessNumber

Int_t TRestProcessRunner::fProcessNumber
private

Definition at line 58 of file TRestProcessRunner.h.

◆ fProcStatus

ProcStatus TRestProcessRunner::fProcStatus
private

Definition at line 44 of file TRestProcessRunner.h.

◆ fRunInfo

TRestRun* TRestProcessRunner::fRunInfo
private

Definition at line 31 of file TRestProcessRunner.h.

◆ fSortOutputEvents

Bool_t TRestProcessRunner::fSortOutputEvents
private

Definition at line 52 of file TRestProcessRunner.h.

◆ fThreadNumber

Int_t TRestProcessRunner::fThreadNumber
private

Definition at line 57 of file TRestProcessRunner.h.

◆ fThreads

std::vector<TRestThread*> TRestProcessRunner::fThreads
private

Definition at line 38 of file TRestProcessRunner.h.

◆ fUsePauseMenu

Bool_t TRestProcessRunner::fUsePauseMenu
private

Definition at line 50 of file TRestProcessRunner.h.

◆ fUseTestRun

Bool_t TRestProcessRunner::fUseTestRun
private

Number of files being split.

Definition at line 49 of file TRestProcessRunner.h.

◆ fValidateObservables

Bool_t TRestProcessRunner::fValidateObservables
private

Definition at line 51 of file TRestProcessRunner.h.


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