1 | #ifndef MARS_MJob
|
---|
2 | #define MARS_MJob
|
---|
3 |
|
---|
4 | #ifndef MARS_MSequence
|
---|
5 | #include "MSequence.h"
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | class MEnv;
|
---|
9 | class MEvtLoop;
|
---|
10 |
|
---|
11 | class MJob : public MParContainer
|
---|
12 | {
|
---|
13 | private:
|
---|
14 | enum { kIsOwner = BIT(14) };
|
---|
15 |
|
---|
16 | // Helper functions for paths
|
---|
17 | static TString CombinePath(TString path, TString fname);
|
---|
18 | static void FixPath(TString &path);
|
---|
19 |
|
---|
20 | // Helper functions to set a new fEnv
|
---|
21 | void SetPrefix(const char *prefix);
|
---|
22 | void ClearEnv();
|
---|
23 |
|
---|
24 | // Data members for resource files
|
---|
25 | const MEnv *fEnv; // Resource file
|
---|
26 | TString fEnvPrefix; // Prefix for resources
|
---|
27 | Int_t fEnvDebug; // Debug setup of resources
|
---|
28 |
|
---|
29 | protected:
|
---|
30 | TString fPathOut; // Directory to write output file to (eg. calib*.root)
|
---|
31 | TString fPathIn; // Directory to read output from (eg. calib*.root)
|
---|
32 |
|
---|
33 | Bool_t fOverwrite; // Allow overwriting output files
|
---|
34 | Int_t fMaxEvents; // Maximum number of events
|
---|
35 |
|
---|
36 | Bool_t fNullOut; // Suppress output files
|
---|
37 |
|
---|
38 | // FIXME: Split into MJobSequence and MJobDataSet
|
---|
39 | MSequence fSequence; // Sequence
|
---|
40 |
|
---|
41 | const TEnv *GetEnv() const;
|
---|
42 | const MEnv *GetMEnv() const { return fEnv; }
|
---|
43 | const TString &GetEnvPrefix() const { return fEnvPrefix; }
|
---|
44 | Int_t GetEnvDebug() const { return fEnvDebug; }
|
---|
45 |
|
---|
46 | Int_t GetEnv(const char *name, Int_t dflt) const;
|
---|
47 | Double_t GetEnv(const char *name, Double_t dflt) const;
|
---|
48 | const char *GetEnv(const char *name, const char *dflt) const;
|
---|
49 | Bool_t HasEnv(const char *name) const;
|
---|
50 |
|
---|
51 | Bool_t InitRandomNumberGenerator() const;
|
---|
52 | Bool_t SetupEnv(MEvtLoop &loop) const;
|
---|
53 | Bool_t CheckEnv();
|
---|
54 | Bool_t CheckEnv(MParContainer &c) const;
|
---|
55 | void PrintUntouchedEnv() const;
|
---|
56 | virtual Bool_t CheckEnvLocal() { return kTRUE; }
|
---|
57 |
|
---|
58 | Bool_t WriteContainer(TCollection &list) const;
|
---|
59 | Bool_t ReadContainer(TCollection &list) const;
|
---|
60 | Bool_t WriteContainer(TCollection &cont, const char *name, const char *option="RECREATE", const int compr=2) const;
|
---|
61 | Bool_t WriteDisplay(const char *name, const char *option="RECREATE", const int comp=2) const;
|
---|
62 |
|
---|
63 | public:
|
---|
64 | MJob(const char *name=NULL, const char *title=NULL);
|
---|
65 | ~MJob();
|
---|
66 |
|
---|
67 | // Setter
|
---|
68 | void SetPathOut(const char *path=".");
|
---|
69 | void SetPathIn(const char *path=".");
|
---|
70 |
|
---|
71 | void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
|
---|
72 | Bool_t SetEnv(const char *env, const char *prefix=0);
|
---|
73 | void SetEnv(MEnv *env, const char *prefix=0);
|
---|
74 | void SetEnvDebug(Int_t d=2) { fEnvDebug=d; }
|
---|
75 |
|
---|
76 | void SetMaxEvents(Int_t max) { fMaxEvents = max; }
|
---|
77 | void SetSequence(const MSequence &seq) { fSequence = seq; }
|
---|
78 |
|
---|
79 | void SetNullOut(Bool_t b=kTRUE) { fNullOut=b; }
|
---|
80 |
|
---|
81 | // Getter
|
---|
82 | TString GetPathOut() const { return fPathOut; }
|
---|
83 | TString GetPathIn() const { return fPathIn; }
|
---|
84 |
|
---|
85 | Bool_t HasWritePermission(TString fname) const;
|
---|
86 |
|
---|
87 | Bool_t HasNullOut() const { return fNullOut; }
|
---|
88 |
|
---|
89 | // Others
|
---|
90 | MStatusDisplay *GetDisplay() { return fDisplay; }
|
---|
91 |
|
---|
92 | static TString ExpandPath(TString fname);
|
---|
93 | static void SortArray(TArrayI &arr);
|
---|
94 |
|
---|
95 | static TString Esc(TString esc) { esc.ReplaceAll("/", "\\/"); return esc; }
|
---|
96 |
|
---|
97 | ClassDef(MJob, 0) // Bas class for Jobs
|
---|
98 | };
|
---|
99 |
|
---|
100 | #endif
|
---|