source: trunk/MagicSoft/Mars/mjobs/MSequence.h@ 8988

Last change on this file since 8988 was 8969, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.0 KB
Line 
1#ifndef MARS_MSequence
2#define MARS_MSequence
3
4#ifndef ROOT_TArrayI
5#include <TArrayI.h>
6#endif
7
8#ifndef MARS_MTime
9#include "MTime.h"
10#endif
11
12class MDirIter;
13
14class MSequence : public MParContainer
15{
16public:
17 enum LightCondition_t { kNA, kNoMoon, kTwilight, kMoon, kDay };
18 enum FileType_t {
19 kRawDat, kRawPed, kRawCal, kRawAll,
20 kRootDat, kRootPed, kRootCal, kRootAll,
21 kCalibrated, kImages
22 };
23private:
24 TString fFileName;
25 TString fDataPath;
26
27 UInt_t fSequence;
28
29 MTime fStart;
30
31 UInt_t fLastRun;
32 UInt_t fNumEvents;
33
34 UInt_t fPeriod;
35 MTime fNight;
36
37 LightCondition_t fLightCondition;
38
39 TString fProject;
40 TString fSource;
41 TString fTriggerTable;
42 TString fHvSettings;
43 TString fComment;
44
45 TArrayI fRuns;
46 TArrayI fRunsSub;
47
48 TArrayI fCalRuns;
49 TArrayI fCalRunsSub;
50
51 TArrayI fPedRuns;
52 TArrayI fPedRunsSub;
53
54 TArrayI fDatRuns;
55 TArrayI fDatRunsSub;
56
57 TArrayI fExclRuns;
58 TArrayI fExclRunsSub;
59
60 Bool_t fMonteCarlo;
61
62 // Helper for interpretation
63 void AddEntry(Int_t run, Int_t file, TArrayI &data, TArrayI &sub) const;
64 void EvalEntry(const TEnv *env, const TString &prefix, const TString &num, TArrayI &data, TArrayI &sub) const;
65
66 void Split(TString &runs, TArrayI &data, TArrayI &sub, const TEnv *env=0, const TString prefix="") const;
67 void Split(const TEnv &env, const TString &prefix, const char *name, TArrayI &data, TArrayI &sub) const;
68
69 LightCondition_t ReadLightCondition(TEnv &env, const char *prefix) const;
70
71 // Helper for file setup
72 TString GetPathName(TString d, FileType_t type) const;
73 TString GetFileName(UInt_t num, const TArrayI &arr, const TArrayI &sub, FileType_t type) const;
74 UInt_t SetupRuns(MDirIter &iter, const TArrayI &arr, const TArrayI &file, FileType_t type, const char *path=0) const;
75
76 // Helper for Print()
77 TString GetNumSequence(Int_t pos, Int_t n, const TArrayI &f) const;
78 TString GetNumSequence(Int_t &pos, const TArrayI &n, const TArrayI &f) const;
79
80 void PrintRunsClassic(const char *pre, const char *name, const TArrayI &r) const;
81 TString PrintRuns(const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const;
82
83 // General helper
84 Bool_t HasSubRuns() const { return fRunsSub.GetSize()!=0 || fDatRunsSub.GetSize()!=0 || fPedRunsSub.GetSize()!=0 || fCalRunsSub.GetSize()!=0 || fExclRunsSub.GetSize()!=0; }
85 Bool_t IsContained(const TArrayI &arr, const TArrayI &sub, UInt_t num, UInt_t file) const;
86
87 // Some helpers to handle the arrays
88 static Int_t SortArraySub(Int_t p, Int_t n, Int_t *arr1, Int_t *arr2);
89 static void SortArrays(TArrayI &arr1, TArrayI &arr2);
90 static Int_t GetSubArray(Int_t p, Int_t n, Int_t *arr1);
91
92public:
93 MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
94 fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE) { }
95 MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
96 MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart),
97 fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
98 fNight(s.fNight), fProject(s.fProject), fSource(s.fSource),
99 fTriggerTable(s.fTriggerTable), fHvSettings(s.fHvSettings),
100 fRuns(s.fRuns), fCalRuns(s.fCalRuns), fPedRuns(s.fPedRuns),
101 fDatRuns(s.fDatRuns), fMonteCarlo(s.fMonteCarlo) { }
102
103 // TObject
104 void Print(Option_t *o) const;
105 void Print() const { Print(""); } //*MENU*
106
107 const char *GetName() const;
108 const char *GetRcName() const { return fName; }
109
110 // Genaral interface
111 Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
112 Bool_t IsMonteCarlo() const { return fMonteCarlo; }
113 Bool_t IsExcluded(UInt_t run, UInt_t file) const { return IsContained(fExclRuns, fExclRunsSub, run, file); }
114 Bool_t IsContained(UInt_t run, UInt_t file) const { return IsContained(fCalRuns, fCalRunsSub, run, file) || IsContained(fPedRuns, fPedRunsSub, run, file) || IsContained(fDatRuns, fDatRunsSub, run, file); }
115
116 // Setter
117 void SetNight(const char*night);
118
119 void AddRun(UInt_t run, char type='*') { AddFile(run, 0, type); }
120 void AddRuns(UInt_t run1, UInt_t run2, char type='*') { for (UInt_t i=run1; i<=run2; i++) AddFile(i, 0, type); }
121 void AddFile(UInt_t run, UInt_t file, char type='*');
122 void AddFiles(UInt_t run, UInt_t f1, UInt_t f2, char type='*') { for (UInt_t i=f1; i<=f2; i++) AddFile(run, i, type); }
123
124 void ExcludeFile(UInt_t num, UInt_t file=0);
125 void ExcludeRuns(TString runs);
126
127 void SetMonteCarlo(Bool_t ismc=kTRUE) { fMonteCarlo=ismc; }
128
129 // Getter
130 UInt_t GetNumExclRuns() const { return fExclRuns.GetSize(); }
131
132 UInt_t GetSequence() const { return fSequence; }
133 UInt_t GetLastRun() const { return fLastRun; }
134 UInt_t GetPeriod() const { return fPeriod; }
135 Bool_t HasMoon() const { return fLightCondition==kMoon; }
136
137 LightCondition_t GetLightCondition() const { return fLightCondition; }
138
139 const MTime &GetStart() const { return fStart; }
140 const MTime &GetNight() const { return fNight; }
141 const TString &GetSource() const { return fSource; }
142
143 const TString GetExcludedRuns() const;
144
145 // Filesystem interface
146 UInt_t SetupPedRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
147 UInt_t SetupDatRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
148 UInt_t SetupAllRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
149 UInt_t SetupCalRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
150 UInt_t SetupDatRuns(MDirIter &iter, FileType_t type, const char *path=0) const;
151
152 // Filesystem getter
153 const TString &GetFileName() const { return fFileName; }
154 const TString &GetDataPath() const { return fDataPath; }
155
156 const TString GetStandardPath() const { return fMonteCarlo?"/magic/montecarlo/":"/magic/data/"; }
157
158 static Bool_t InflatePath(TString &seq, Bool_t ismc=kFALSE);
159
160 ClassDef(MSequence, 5) // Describes a sequences, reads and writes sequence files
161};
162
163#endif
Note: See TracBrowser for help on using the repository browser.