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

Last change on this file since 8680 was 8674, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 5.1 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;
27 TString fPathDataFiles;
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 void Split(TString &runs, TArrayI &data) const;
44 void ResolveSequences(TEnv &env, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const;
45 static void PrintFile(const MSequence &obj);
46
47 void ReplaceDir(TList &list, const TString &old, const TString &news) const;
48 void ReplaceFile(TList &list, const TString &old, const TString &news) const;
49
50 void SetupDefaultPath(TString &path, const TString &def) const
51 {
52 if (path.IsNull())
53 path = def;
54 if (!path.EndsWith("/"))
55 path += "/";
56 }
57
58 Bool_t HasSequence(UInt_t num, const TArrayI &seq) const
59 {
60 for (int i=0; i<seq.GetSize(); i++)
61 if ((UInt_t)seq[i]==num)
62 return kTRUE;
63 return kFALSE;
64 }
65
66public:
67 MDataSet(Int_t num=(UInt_t)-1) : fNumAnalysis(num) { }
68 MDataSet(const char *fname, TString sequences="", TString data="");
69
70 const char *GetName() const;
71 const char *GetRcName() const { return fName; }
72
73 void Copy(TObject &obj) const
74 {
75 MDataSet &ds = (MDataSet&)obj;
76 ds.fNumAnalysis = fNumAnalysis;
77 ds.fNumSequencesOn = fNumSequencesOn;
78 ds.fNumSequencesOff = fNumSequencesOff;
79 ds.fNameSource = fNameSource;
80 ds.fCatalog = fCatalog;
81 ds.fComment = fComment;
82 ds.fWobbleMode = fWobbleMode;
83 ds.fMonteCarlo = fMonteCarlo;
84
85 TObject *o=0;
86
87 ds.fSequencesOn.Delete();
88 ds.fSequencesOff.Delete();
89
90 TIter NextOn(&fSequencesOn);
91 while ((o=NextOn()))
92 ds.fSequencesOn.Add(o->Clone());
93
94 TIter NextOff(&fSequencesOff);
95 while ((o=NextOff()))
96 ds.fSequencesOff.Add(o->Clone());
97 }
98
99 // Getter
100 Bool_t IsValid() const { return fNumAnalysis!=(UInt_t)-1; }
101
102 UInt_t GetNumSequencesOn() const { return fNumSequencesOn.GetSize(); }
103 UInt_t GetNumSequencesOff() const { return fNumSequencesOff.GetSize(); }
104
105 Bool_t HasOffSequences() const { return GetNumSequencesOff()>0; }
106
107 Bool_t HasOffSequence(UInt_t num) const { return HasSequence(num, fNumSequencesOff); }
108 Bool_t HasOnSequence(UInt_t num) const { return HasSequence(num, fNumSequencesOn); }
109 Bool_t HasSequence(UInt_t num) const { return HasOnSequence(num) || HasOffSequence(num); }
110
111 UInt_t GetNumAnalysis() const { return fNumAnalysis; }
112 void SetNumAnalysis(UInt_t num) { fNumAnalysis=num; }
113
114 Bool_t HasSource() const { return !fNameSource.IsNull(); }
115 Bool_t GetSourcePos(MPointingPos &pos) const;
116
117 Bool_t IsWobbleMode() const { return fWobbleMode; }
118 Bool_t IsMonteCarlo() const { return fMonteCarlo; }
119
120 const char *GetDefPathDataFiles() const { return fMonteCarlo ? "/magic/montecarlo/star" : "/magic/data/star"; }
121 const char *GetDefPathSequences() const { return fMonteCarlo ? "/magic/montecarlo/sequences" : "/magic/sequences"; }
122
123 // Setter
124 void SetMonteCarlo(Bool_t ismc=kTRUE) { fMonteCarlo=ismc; }
125 void SetWobbleMode(Bool_t wobm=kTRUE) { fWobbleMode=wobm; }
126
127 static Bool_t AddSequencesFromList(const TList &list, MDirIter &files);
128 static Int_t AddFilesToChain(MDirIter &files, TChain &chain);
129
130 const TList &GetSequencesOn() const { return fSequencesOn; }
131 const TList &GetSequencesOff() const { return fSequencesOff; }
132
133 Bool_t AddFiles(MRead &read) const;
134 Bool_t AddFilesOn(MRead &read) const;
135 Bool_t AddFilesOff(MRead &read) const;
136
137 Bool_t AddFiles(TChain &read) const;
138 Bool_t AddFilesOn(TChain &read) const;
139 Bool_t AddFilesOff(TChain &read) const;
140
141 Bool_t AddFiles(MDirIter &iter) const;
142 Bool_t AddFilesOn(MDirIter &iter) const;
143 Bool_t AddFilesOff(MDirIter &iter) const;
144
145 void ReplaceDir(const TString &old, const TString &news)
146 {
147 ReplaceDir(fSequencesOn, old, news);
148 ReplaceDir(fSequencesOff, old, news);
149 }
150
151 void ReplaceFile(const TString &old, const TString &news)
152 {
153 ReplaceFile(fSequencesOn, old, news);
154 ReplaceFile(fSequencesOff, old, news);
155 }
156
157 // TObject
158 void Print(Option_t *o) const;
159 void Print() const { Print(); } //*MENU*
160
161 ClassDef(MDataSet, 2)
162};
163
164#endif
Note: See TracBrowser for help on using the repository browser.