source: trunk/MagicSoft/Mars/mjobs/MDataSet.h@ 9143

Last change on this file since 9143 was 8989, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.4 KB
Line 
1#ifndef MARS_MDataSet
2#define MARS_MDataSet
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8#ifndef ROOT_TArrayI
9#include <TArrayI.h>
10#endif
11
12class TChain;
13
14class MRead;
15class MDirIter;
16class MSequence;
17class MPointingPos;
18
19class MDataSet : public MParContainer
20{
21private:
22 static const TString fgCatalog; //! Default Catalog path
23
24 TString fFileName; // File name to original file (MParContainer::fName is not streamed)
25 TString fDataSet; // Name of the dataset given by the user
26
27 UInt_t fNumAnalysis; // Analysis number (artificial)
28
29 TString fPathSequences; // Default path to the sequence files
30 TString fPathDataFiles; // Default path to the data files
31
32 TArrayI fNumSequencesOn; // number of on-sequences
33 TArrayI fNumSequencesOff; // number of off-sequences
34
35 TList fSequencesOn; // list of names and paths of on-sequences
36 TList fSequencesOff; // list of names and paths of off-sequences
37
38 TString fNameSource; // Name of source from catalog
39 TString fCatalog; // edb catalog (magic_favourites.edb)
40
41 TString fComment; // Comment from DS file
42
43 Bool_t fWobbleMode; // Wobble Mode for this dataset?
44 Bool_t fMonteCarlo; // For default paths use MC or data path
45
46 // Helper functions for constrcutors
47 void Split(TString &runs, TArrayI &data) const;
48 void ResolveSequences(const TEnv &env, const TString &prefix, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const;
49 Bool_t GetWobbleMode(const TEnv &env, const TString &prefix) const;
50 static void PrintFile(ostream &out, const MSequence &obj);
51 void PrintSeq(ostream &out, const MSequence &seq) const;
52
53 // Directory and file handling
54 //void ReplaceDir(TList &list, const TString &old, const TString &news) const;
55 //void ReplaceFile(TList &list, const TString &old, const TString &news) const;
56
57 void SetupDefaultPath(TString &path, const TString &def) const
58 {
59 if (path.IsNull())
60 path = def;
61 if (!path.EndsWith("/"))
62 path += "/";
63 }
64
65 Bool_t HasSequence(UInt_t num, const TArrayI &seq) const
66 {
67 for (int i=0; i<seq.GetSize(); i++)
68 if ((UInt_t)seq[i]==num)
69 return kTRUE;
70 return kFALSE;
71 }
72
73 // Initialize from constrcutors
74 void Init(const char *fname, const UInt_t num, TString sequences, TString &data);
75
76public:
77 MDataSet() : fNumAnalysis((UInt_t)-1)
78 {
79 fName = "MDataSet";
80 fTitle = "DataSet file";
81 }
82 MDataSet(const char *fname, TString sequences="", TString data="");
83 MDataSet(const char *fname, Int_t num, TString sequences="", TString data="");
84
85 const char *GetBaseName() const;
86 const char *GetFilePath() const;
87 const TString &GetFileName() const { return fFileName; }
88 const TString &GetDataSet() const { return fDataSet; }
89
90 void Copy(TObject &obj) const
91 {
92 MDataSet &ds = (MDataSet&)obj;
93 ds.fNumAnalysis = fNumAnalysis;
94 ds.fNumSequencesOn = fNumSequencesOn;
95 ds.fNumSequencesOff = fNumSequencesOff;
96 ds.fNameSource = fNameSource;
97 ds.fCatalog = fCatalog;
98 ds.fComment = fComment;
99 ds.fWobbleMode = fWobbleMode;
100 ds.fMonteCarlo = fMonteCarlo;
101
102 TObject *o=0;
103
104 ds.fSequencesOn.Delete();
105 ds.fSequencesOff.Delete();
106
107 TIter NextOn(&fSequencesOn);
108 while ((o=NextOn()))
109 ds.fSequencesOn.Add(o->Clone());
110
111 TIter NextOff(&fSequencesOff);
112 while ((o=NextOff()))
113 ds.fSequencesOff.Add(o->Clone());
114 }
115
116 // Getter
117 Bool_t IsValid() const { return fNumAnalysis!=(UInt_t)-1 && GetNumSequencesOn()>0; }
118
119 UInt_t GetNumSequencesOn() const { return fNumSequencesOn.GetSize(); }
120 UInt_t GetNumSequencesOff() const { return fNumSequencesOff.GetSize(); }
121
122 Bool_t HasOffSequences() const { return GetNumSequencesOff()>0; }
123
124 Bool_t HasOffSequence(UInt_t num) const { return HasSequence(num, fNumSequencesOff); }
125 Bool_t HasOnSequence(UInt_t num) const { return HasSequence(num, fNumSequencesOn); }
126 Bool_t HasSequence(UInt_t num) const { return HasOnSequence(num) || HasOffSequence(num); }
127
128 UInt_t GetNumAnalysis() const { return fNumAnalysis; }
129 void SetNumAnalysis(UInt_t num) { fNumAnalysis=num; }
130
131 Bool_t HasSource() const { return !fNameSource.IsNull(); }
132 Bool_t GetSourcePos(MPointingPos &pos) const;
133
134 Bool_t IsWobbleMode() const { return fWobbleMode; }
135 Bool_t IsMonteCarlo() const { return fMonteCarlo; }
136
137 const char *GetDefPathDataFiles() const { return fMonteCarlo ? "/magic/montecarlo/star" : "/magic/data/star"; }
138 const char *GetDefPathSequences() const { return fMonteCarlo ? "/magic/montecarlo/sequences" : "/magic/sequences"; }
139
140 // Setter
141 void SetMonteCarlo(Bool_t ismc=kTRUE) { fMonteCarlo=ismc; }
142 void SetWobbleMode(Bool_t wobm=kTRUE) { fWobbleMode=wobm; }
143
144 static Bool_t AddSequencesFromList(const TList &list, MDirIter &files);
145 static Int_t AddFilesToChain(MDirIter &files, TChain &chain);
146
147 const TList &GetSequencesOn() const { return fSequencesOn; }
148 const TList &GetSequencesOff() const { return fSequencesOff; }
149
150 const TArrayI &GetSequencesNumOn() const { return fNumSequencesOn; }
151 const TArrayI &GetSequencesNumOff() const { return fNumSequencesOff; }
152
153 Bool_t AddFiles(MRead &read) const;
154 Bool_t AddFilesOn(MRead &read) const;
155 Bool_t AddFilesOff(MRead &read) const;
156
157 Bool_t AddFiles(TChain &read) const;
158 Bool_t AddFilesOn(TChain &read) const;
159 Bool_t AddFilesOff(TChain &read) const;
160
161 Bool_t AddFiles(MDirIter &iter) const;
162 Bool_t AddFilesOn(MDirIter &iter) const;
163 Bool_t AddFilesOff(MDirIter &iter) const;
164
165 /*
166 void ReplaceDir(const TString &old, const TString &news)
167 {
168 ReplaceDir(fSequencesOn, old, news);
169 ReplaceDir(fSequencesOff, old, news);
170 }
171
172 void ReplaceFile(const TString &old, const TString &news)
173 {
174 ReplaceFile(fSequencesOn, old, news);
175 ReplaceFile(fSequencesOff, old, news);
176 }
177 */
178
179 // I/O
180 void WriteFile(const char *filename, const Option_t *o) const;
181 void WriteFile(const char *filename) const { WriteFile(filename,""); } //*MENU *ARGS={filename=>fBaseName}
182
183 // TObject
184 void Print(ostream &out, Option_t *o) const;
185 void Print(Option_t *o) const;
186 void Print() const { Print(""); } //*MENU*
187
188 ClassDef(MDataSet, 3)
189};
190
191#endif
Note: See TracBrowser for help on using the repository browser.