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

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