REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTask.h
1 #ifndef RestCore_TRestTask
2 #define RestCore_TRestTask
3 
4 #include <TCanvas.h>
5 #include <TF1.h>
6 #include <TGeoManager.h>
7 #include <TH2D.h>
8 #include <TInterpreter.h>
9 #include <TLatex.h>
10 #include <TLegend.h>
11 #include <TObject.h>
12 #include <TROOT.h>
13 #include <TRandom.h>
14 #include <TStyle.h>
15 
16 #include <iostream>
17 #include <string>
18 
19 #include "TRestAnalysisTree.h"
20 #include "TRestRun.h"
21 
22 class TRestManager;
23 
24 enum REST_TASKMODE { TASK_ERROR = -1, TASK_MACRO = 0, TASK_CPPCMD = 1, TASK_CLASS = 2, TASK_SHELLCMD = 3 };
25 
27 class TRestTask : public TRestMetadata {
28  protected:
29  TRestTask(TString TaskString, REST_TASKMODE mode = TASK_MACRO);
30 
31  unsigned int fNRequiredArgument;
32  REST_TASKMODE fMode;
33  std::string fInvokeObject = "";
34  std::string fInvokeMethod = "";
35  // indicates whether the argument is std::string/TString/const char *. If so, the value would be 1. We
36  // need to add "" mark when constructing command. Otherwise the value is 0.
37  std::vector<int> fArgumentTypes;
38  std::vector<std::string> fArgumentNames;
39  std::vector<std::string> fArgumentValues;
40  std::string fConstructedCommand = "";
41 
42  public:
43  // define default values here
44  void InitFromConfigFile() override;
45 
46  void SetArgumentValue(std::vector<std::string> arg);
47 
48  static TRestTask* GetTaskFromMacro(TString Name);
49  static TRestTask* GetTaskFromCommand(TString cmd);
50 
51  virtual void RunTask(TRestManager*);
52  virtual void PrintArgumentHelp();
53 
54  void SetMode(REST_TASKMODE mod) { fMode = mod; }
55  inline REST_TASKMODE GetMode() const { return fMode; }
56 
57  // Constructor & Destructor
58  TRestTask();
59  ~TRestTask(){};
60 
61  ClassDefOverride(TRestTask, 1);
62 };
63 
64 #endif
Managing applications and executing tasks.
Definition: TRestManager.h:16
A base class for any REST metadata class.
Definition: TRestMetadata.h:74
Wrapping REST macros into tasks.
Definition: TRestTask.h:27
void SetArgumentValue(std::vector< std::string > arg)
Set argument directly with a list of string.
Definition: TRestTask.cxx:151
virtual void RunTask(TRestManager *)
Run the task with command line.
Definition: TRestTask.cxx:162
virtual void PrintArgumentHelp()
Default helper method both for TRestTask and any TRestTask-inherited class.
Definition: TRestTask.cxx:236
TRestTask()
TRestTask default constructor.
Definition: TRestTask.cxx:51
static TRestTask * GetTaskFromMacro(TString Name)
Static method to instantiate a TRestTask object with "MacroName".
Definition: TRestTask.cxx:269
void InitFromConfigFile() override
Starter method. Looks through the rml sections and set argument/datamenber value.
Definition: TRestTask.cxx:144