1 | #ifndef MARS_MTask
|
---|
2 | #define MARS_MTask
|
---|
3 |
|
---|
4 | /////////////////////////////////////////////////////////////////////////////
|
---|
5 | // //
|
---|
6 | // MTask //
|
---|
7 | // //
|
---|
8 | // Abstract base class for a task //
|
---|
9 | // //
|
---|
10 | /////////////////////////////////////////////////////////////////////////////
|
---|
11 |
|
---|
12 | #ifndef MARS_MInputStreamID
|
---|
13 | #include "MInputStreamID.h"
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | class TList;
|
---|
17 | class TStopwatch;
|
---|
18 |
|
---|
19 | class MFilter;
|
---|
20 | class MParList;
|
---|
21 |
|
---|
22 | class MTask : public MInputStreamID
|
---|
23 | {
|
---|
24 | public:
|
---|
25 | enum {
|
---|
26 | kAccStandard = 0,
|
---|
27 | kAccDontCount = BIT(1),
|
---|
28 | kAccDontTime = BIT(2),
|
---|
29 | kAccDontReset = BIT(3)
|
---|
30 | };
|
---|
31 |
|
---|
32 | private:
|
---|
33 | TList *fListOfBranches; //! List of Branch names for auto enabeling scheme
|
---|
34 |
|
---|
35 | MFilter *fFilter; // Filter for conditional task execution
|
---|
36 | Byte_t fSerialNumber; // Serial number having more than one detector of the same type
|
---|
37 |
|
---|
38 | Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
|
---|
39 |
|
---|
40 | TStopwatch *fStopwatch; //! Count the execution time and number of executions
|
---|
41 | UInt_t fNumExec0; //! Total number of executions at PreProcess
|
---|
42 | Byte_t fAccelerator; //!
|
---|
43 |
|
---|
44 | virtual Int_t PreProcess(MParList *pList);
|
---|
45 | virtual Int_t Process();
|
---|
46 | virtual Int_t PostProcess();
|
---|
47 |
|
---|
48 | protected:
|
---|
49 | void AddToBranchList(const char *b);
|
---|
50 | void AddToBranchList(const TString &str);
|
---|
51 | void AddToBranchList(const char *master, const char *sub, const UInt_t first, const UInt_t last)
|
---|
52 | {
|
---|
53 | if (first==0 && last==0)
|
---|
54 | {
|
---|
55 | AddToBranchList(sub);
|
---|
56 | return;
|
---|
57 | }
|
---|
58 |
|
---|
59 | for (unsigned int i=first; i<last+1; i++)
|
---|
60 | AddToBranchList(Form("%s;%d.%s", master, i, sub));
|
---|
61 | }
|
---|
62 | void AddToBranchList(TString &master, TString &sub, const UInt_t first, const UInt_t last)
|
---|
63 | {
|
---|
64 | AddToBranchList((const char*)master, (const char*)sub, first, last);
|
---|
65 | }
|
---|
66 | void AddToBranchList(const char *master, const char *sub, const UInt_t num)
|
---|
67 | {
|
---|
68 | AddToBranchList(master, sub, 0, num);
|
---|
69 | }
|
---|
70 | void AddToBranchList(TString &master, TString &sub, const UInt_t num)
|
---|
71 | {
|
---|
72 | AddToBranchList(master, sub, 0, num);
|
---|
73 | }
|
---|
74 |
|
---|
75 | public:
|
---|
76 | MTask(const char *name=NULL, const char *title=NULL);
|
---|
77 | MTask(MTask &t);
|
---|
78 | virtual ~MTask();
|
---|
79 |
|
---|
80 | const TList *GetListOfBranches() const { return fListOfBranches; }
|
---|
81 | Bool_t OverwritesProcess(TClass *cls=NULL) const;
|
---|
82 |
|
---|
83 | // Filter functions
|
---|
84 | virtual void SetFilter(MFilter *filter);
|
---|
85 | const MFilter *GetFilter() const { return fFilter; }
|
---|
86 | MFilter *GetFilter() { return fFilter; } // for MContinue only
|
---|
87 |
|
---|
88 | // Display functions
|
---|
89 | void SetDisplay(MStatusDisplay *d);
|
---|
90 |
|
---|
91 | // Acceleration Control
|
---|
92 | virtual void SetAccelerator(Byte_t acc=kAccStandard) { fAccelerator=acc; }
|
---|
93 | Byte_t GetAccelerator() const { return fAccelerator; }
|
---|
94 | Bool_t HasAccelerator(Byte_t acc) const { return fAccelerator&acc; }
|
---|
95 |
|
---|
96 | // Function for parallel executions
|
---|
97 | static TString AddSerialNumber(const char *str, UInt_t num) { TString s(str); if (num==0) return s; s += ";"; s += num; return s; }
|
---|
98 | static TString AddSerialNumber(const TString &str, UInt_t num) { return AddSerialNumber((const char*)str, num); }
|
---|
99 | TString AddSerialNumber(const char *str) const { return AddSerialNumber(str, fSerialNumber); }
|
---|
100 | TString AddSerialNumber(const TString &str) const { return AddSerialNumber(str, fSerialNumber); }
|
---|
101 |
|
---|
102 | virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
|
---|
103 | Byte_t GetSerialNumber() const { return fSerialNumber; }
|
---|
104 |
|
---|
105 | const TString GetDescriptor() const;
|
---|
106 |
|
---|
107 | // Task execution statistics
|
---|
108 | UInt_t GetNumExecutions() const;
|
---|
109 | UInt_t GetNumExecutionsTotal() const;
|
---|
110 | Double_t GetCpuTime() const;
|
---|
111 | Double_t GetRealTime() const;
|
---|
112 | virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
|
---|
113 | virtual void PrintSkipped(UInt_t n, const char *str);
|
---|
114 |
|
---|
115 | // Task overwrite functions
|
---|
116 | virtual Bool_t ReInit(MParList *pList);
|
---|
117 |
|
---|
118 | virtual Int_t CallPreProcess(MParList *plist);
|
---|
119 | virtual Int_t CallProcess();
|
---|
120 | virtual Int_t CallPostProcess();
|
---|
121 |
|
---|
122 | void SavePrimitive(ofstream &out, Option_t *o="");
|
---|
123 |
|
---|
124 | ClassDef(MTask, 2) //Abstract base class for a task
|
---|
125 | };
|
---|
126 |
|
---|
127 | #endif
|
---|