Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
tasks.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_legacy
3/// Example of TTasks.
4/// Create a hierarchy of objects derived from TTask in library Mytasks
5/// Show the tasks in a browser.
6/// To execute a Task, use the context context menu and select
7/// the item "ExecuteTask"
8/// see also other functions in the TTask context menu, such as
9/// - setting a breakpoint in one or more tasks
10/// - enabling/disabling one task, etc
11///
12/// As of 2021, tbb is a fine replacement for ROOT's task system. It
13/// offers better interplay with non-ROOT multi-threading use cases.
14///
15/// \macro_code
16///
17/// \author Rene Brun
18
19#ifndef __RUN_TASKS__
20
21void tasks()
22{
23 TString dir = gSystem->UnixPathName(__FILE__);
24 dir.ReplaceAll("tasks.C","");
25 dir.ReplaceAll("/./","/");
26 gROOT->LoadMacro(dir +"MyTasks.cxx+");
27
28 gROOT->ProcessLine("#define __RUN_TASKS__ 1");
29 gROOT->ProcessLine(TString("#include \"") + dir + "tasks.C\"");
30 gROOT->ProcessLine("runtasks()");
31 gROOT->ProcessLine("#undef __RUN_TASKS__");
32}
33
34#else
35
36void runtasks()
37//void tasks()
38{
39 TTask *run = new MyRun("run","Process one run");
40 TTask *event = new MyEvent("event","Process one event");
41 TTask *geomInit = new MyGeomInit("geomInit","Geometry Initialisation");
42 TTask *matInit = new MyMaterialInit("matInit","Materials Initialisation");
43 TTask *tracker = new MyTracker("tracker","Tracker manager");
44 TTask *tpc = new MyRecTPC("tpc","TPC Reconstruction");
45 TTask *its = new MyRecITS("its","ITS Reconstruction");
46 TTask *muon = new MyRecMUON("muon","MUON Reconstruction");
47 TTask *phos = new MyRecPHOS("phos","PHOS Reconstruction");
48 TTask *rich = new MyRecRICH("rich","RICH Reconstruction");
49 TTask *trd = new MyRecTRD("trd","TRD Reconstruction");
50 TTask *global = new MyRecGlobal("global","Global Reconstruction");
51
52 run->Add(geomInit);
53 run->Add(matInit);
54 run->Add(event);
55 event->Add(tracker);
56 event->Add(global);
57 tracker->Add(tpc);
58 tracker->Add(its);
59 tracker->Add(muon);
60 tracker->Add(phos);
61 tracker->Add(rich);
62 tracker->Add(trd);
63
64 gROOT->GetListOfTasks()->Add(run);
65 gROOT->GetListOfBrowsables()->Add(run);
66 new TBrowser;
67}
68
69#endif
#define gROOT
Definition TROOT.h:406
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Basic string class.
Definition TString.h:136
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1061
TTask is a base class that can be used to build a complex tree of Tasks.
Definition TTask.h:35
virtual void Add(TTask *task)
Add TTask to this.
Definition TTask.cxx:172