REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
TRestTask Class Reference

Detailed Description

Wrapping REST macros into tasks.

REST macros are actually ROOT scripts written in C++. TRestTask wraps them and turns them into application mateadata class. This is done by calling method TInterpreter::LoadFile() and TInterpreter::ProcessLine(). Turning REST-macro-defined functions into classes means that we are able to run the macros from rml file, by adding a section under the section "TRestManager". Another way to launch TRestTask is through restManager executable. By directly typing "restManager TASKNAME [ARG]" in bash we can run the macros like executables. We also allow users to write TRestTask inherted class in REST macros. This can enable more functionalities.


RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2017-Nov: First concept and implementation of TRestTask Kaixiang Ni


Definition at line 27 of file TRestTask.h.

#include <TRestTask.h>

Inheritance diagram for TRestTask:
TRestMetadata

Public Member Functions

 ClassDefOverride (TRestTask, 1)
 
REST_TASKMODE GetMode () const
 
void InitFromConfigFile () override
 Starter method. Looks through the rml sections and set argument/datamenber value. More...
 
virtual void PrintArgumentHelp ()
 Default helper method both for TRestTask and any TRestTask-inherited class. More...
 
virtual void RunTask (TRestManager *)
 Run the task with command line. More...
 
void SetArgumentValue (std::vector< std::string > arg)
 Set argument directly with a list of string. More...
 
void SetMode (REST_TASKMODE mod)
 
 TRestTask ()
 TRestTask default constructor. More...
 

Static Public Member Functions

static TRestTaskGetTaskFromCommand (TString cmd)
 
static TRestTaskGetTaskFromMacro (TString Name)
 Static method to instantiate a TRestTask object with "MacroName". More...
 

Protected Member Functions

 TRestTask (TString TaskString, REST_TASKMODE mode=TASK_MACRO)
 TRestTask constructor with macro file name. More...
 

Protected Attributes

std::vector< std::string > fArgumentNames
 
std::vector< int > fArgumentTypes
 
std::vector< std::string > fArgumentValues
 
std::string fConstructedCommand = ""
 
std::string fInvokeMethod = ""
 
std::string fInvokeObject = ""
 
REST_TASKMODE fMode
 
unsigned int fNRequiredArgument
 

Constructor & Destructor Documentation

◆ TRestTask() [1/2]

TRestTask::TRestTask ( TString  TaskString,
REST_TASKMODE  mode = TASK_MACRO 
)
protected

TRestTask constructor with macro file name.

The first method in the file is identified with its name and require arguments saved in the class. They will be used in forming the command line in the method TRestTask::InitTask()

Definition at line 65 of file TRestTask.cxx.

◆ TRestTask() [2/2]

TRestTask::TRestTask ( )

TRestTask default constructor.

Definition at line 51 of file TRestTask.cxx.

◆ ~TRestTask()

TRestTask::~TRestTask ( )
inline

Definition at line 59 of file TRestTask.h.

Member Function Documentation

◆ GetMode()

REST_TASKMODE TRestTask::GetMode ( ) const
inline

Definition at line 55 of file TRestTask.h.

◆ GetTaskFromCommand()

TRestTask * TRestTask::GetTaskFromCommand ( TString  cmd)
static

Definition at line 311 of file TRestTask.cxx.

◆ GetTaskFromMacro()

TRestTask * TRestTask::GetTaskFromMacro ( TString  taskName)
static

Static method to instantiate a TRestTask object with "MacroName".

REST macros are saved in the directory ./macros. They follow a naming logic, the naming style is like following: REST_[MacroName].hh

e.g. REST_ViewEvents.hh. Here we must add a prefix "REST_" with a macro name usually in verb form. When given the macro name, this method first calls TClass::GetClass() to find if there is a TRestTask-inherted class which has this name. If so, it returns the found class, if not, it finds a corresponding macro file and calls gInterpreter to load it, and then instantiates a TRestTask class wrapping this file.

Definition at line 269 of file TRestTask.cxx.

◆ InitFromConfigFile()

void TRestTask::InitFromConfigFile ( )
overridevirtual

Starter method. Looks through the rml sections and set argument/datamenber value.

Reimplemented from TRestMetadata.

Definition at line 144 of file TRestTask.cxx.

◆ PrintArgumentHelp()

void TRestTask::PrintArgumentHelp ( )
virtual

Default helper method both for TRestTask and any TRestTask-inherited class.

Definition at line 236 of file TRestTask.cxx.

◆ RunTask()

void TRestTask::RunTask ( TRestManager mgr)
virtual

Run the task with command line.

Definition at line 162 of file TRestTask.cxx.

◆ SetArgumentValue()

void TRestTask::SetArgumentValue ( std::vector< std::string >  arg)

Set argument directly with a list of string.

Argument list will be overwritten by the input list. It will also set the data member value for derived class

Definition at line 151 of file TRestTask.cxx.

◆ SetMode()

void TRestTask::SetMode ( REST_TASKMODE  mod)
inline

Definition at line 54 of file TRestTask.h.

Field Documentation

◆ fArgumentNames

std::vector<std::string> TRestTask::fArgumentNames
protected

Definition at line 38 of file TRestTask.h.

◆ fArgumentTypes

std::vector<int> TRestTask::fArgumentTypes
protected

Definition at line 37 of file TRestTask.h.

◆ fArgumentValues

std::vector<std::string> TRestTask::fArgumentValues
protected

Definition at line 39 of file TRestTask.h.

◆ fConstructedCommand

std::string TRestTask::fConstructedCommand = ""
protected

Definition at line 40 of file TRestTask.h.

◆ fInvokeMethod

std::string TRestTask::fInvokeMethod = ""
protected

Definition at line 34 of file TRestTask.h.

◆ fInvokeObject

std::string TRestTask::fInvokeObject = ""
protected

Definition at line 33 of file TRestTask.h.

◆ fMode

REST_TASKMODE TRestTask::fMode
protected

Definition at line 32 of file TRestTask.h.

◆ fNRequiredArgument

unsigned int TRestTask::fNRequiredArgument
protected

Definition at line 31 of file TRestTask.h.


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