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