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