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

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