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

Last change on this file since 7846 was 7492, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 4.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 MPointingPos;
17
18class MDataSet : public MParContainer
19{
20private:
21 static const TString fgCatalog; //! Default Catalog path
22 static const TString fgPathDataFiles; //! Default path to data files
23 static const TString fgPathSequences; //! Default path to sequences
24
25 UInt_t fNumAnalysis; // Analysis number (artificial)
26
27 TArrayI fNumSequencesOn; // number of on-sequences
28 TArrayI fNumSequencesOff; // number of off-sequences
29
30 TList fSequencesOn; // list of names and paths of on-sequences
31 TList fSequencesOff; // list of names and paths of off-sequences
32
33 TString fNameSource; // Name of source from catalog
34 TString fCatalog; // edb catalog (magic_favourites.edb)
35
36 TString fComment; // Comment from DS file
37
38 Bool_t fIsWobbleMode; // Wobble Mode for this dataset?
39
40 void Split(TString &runs, TArrayI &data) const;
41 void ResolveSequences(TEnv &env, const TArrayI &num, TList &list, const TString &sequences, const TString &data) const;
42 static void PrintFile(const TObject &obj);
43
44 void ReplaceDir(TList &list, const TString &old, const TString &news) const;
45 void ReplaceFile(TList &list, const TString &old, const TString &news) const;
46
47 void SetupDefaultPath(TString &path, const TString &def) const
48 {
49 if (path.IsNull())
50 path = def;
51 if (!path.EndsWith("/"))
52 path += "/";
53 }
54
55 Bool_t HasSequence(UInt_t num, const TArrayI &seq) const
56 {
57 for (int i=0; i<seq.GetSize(); i++)
58 if ((UInt_t)seq[i]==num)
59 return kTRUE;
60 return kFALSE;
61 }
62
63public:
64 MDataSet(Int_t num=(UInt_t)-1) : fNumAnalysis(num) { }
65 MDataSet(const char *fname, TString sequences="", TString data="");
66
67 void Copy(TObject &obj) const
68 {
69 MDataSet &ds = (MDataSet&)obj;
70 ds.fNumAnalysis = fNumAnalysis;
71 ds.fNumSequencesOn = fNumSequencesOn;
72 ds.fNumSequencesOff = fNumSequencesOff;
73 ds.fNameSource = fNameSource;
74 ds.fCatalog = fCatalog;
75 ds.fComment = fComment;
76 ds.fIsWobbleMode = fIsWobbleMode;
77
78 TObject *o=0;
79
80 ds.fSequencesOn.Delete();
81 ds.fSequencesOff.Delete();
82
83 TIter NextOn(&fSequencesOn);
84 while ((o=NextOn()))
85 ds.fSequencesOn.Add(o->Clone());
86
87 TIter NextOff(&fSequencesOff);
88 while ((o=NextOff()))
89 ds.fSequencesOff.Add(o->Clone());
90 }
91
92 // Getter
93 Bool_t IsValid() const { return fNumAnalysis!=(UInt_t)-1; }
94
95 UInt_t GetNumSequencesOn() const { return fNumSequencesOn.GetSize(); }
96 UInt_t GetNumSequencesOff() const { return fNumSequencesOff.GetSize(); }
97
98 Bool_t HasOffSequences() const { return GetNumSequencesOff()>0; }
99
100 Bool_t HasOffSequence(UInt_t num) const { return HasSequence(num, fNumSequencesOff); }
101 Bool_t HasOnSequence(UInt_t num) const { return HasSequence(num, fNumSequencesOn); }
102 Bool_t HasSequence(UInt_t num) const { return HasOnSequence(num) || HasOffSequence(num); }
103
104 UInt_t GetNumAnalysis() const { return fNumAnalysis; }
105 void SetNumAnalysis(UInt_t num) { fNumAnalysis=num; }
106
107 Bool_t HasSource() const { return !fNameSource.IsNull(); }
108 Bool_t GetSourcePos(MPointingPos &pos) const;
109
110 Bool_t IsWobbleMode() const { return fIsWobbleMode; }
111
112 // Setter
113 static Bool_t AddSequencesFromList(const TList &list, MDirIter &files);
114 static Int_t AddFilesToChain(MDirIter &files, TChain &chain);
115
116 const TList &GetSequencesOn() const { return fSequencesOn; }
117 const TList &GetSequencesOff() const { return fSequencesOff; }
118
119 Bool_t AddFiles(MRead &read) const;
120 Bool_t AddFilesOn(MRead &read) const;
121 Bool_t AddFilesOff(MRead &read) const;
122
123 Bool_t AddFiles(TChain &read) const;
124 Bool_t AddFilesOn(TChain &read) const;
125 Bool_t AddFilesOff(TChain &read) const;
126
127 void ReplaceDir(const TString &old, const TString &news)
128 {
129 ReplaceDir(fSequencesOn, old, news);
130 ReplaceDir(fSequencesOff, old, news);
131 }
132
133 void ReplaceFile(const TString &old, const TString &news)
134 {
135 ReplaceFile(fSequencesOn, old, news);
136 ReplaceFile(fSequencesOff, old, news);
137 }
138
139 // TObject
140 void Print(Option_t *o="") const;
141
142 ClassDef(MDataSet, 0)
143};
144
145#endif
Note: See TracBrowser for help on using the repository browser.