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

Last change on this file since 8498 was 8442, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 4.9 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 void Copy(TObject &obj) const
71 {
72 MDataSet &ds = (MDataSet&)obj;
73 ds.fNumAnalysis = fNumAnalysis;
74 ds.fNumSequencesOn = fNumSequencesOn;
75 ds.fNumSequencesOff = fNumSequencesOff;
76 ds.fNameSource = fNameSource;
77 ds.fCatalog = fCatalog;
78 ds.fComment = fComment;
79 ds.fWobbleMode = fWobbleMode;
80 ds.fMonteCarlo = fMonteCarlo;
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 fWobbleMode; }
115 Bool_t IsMonteCarlo() const { return fMonteCarlo; }
116
117 const char *GetDefPathDataFiles() const { return fMonteCarlo ? "/magic/montecarlo/star" : "/magic/data/star"; }
118 const char *GetDefPathSequences() const { return fMonteCarlo ? "/magic/montecarlo/sequences" : "/magic/sequences"; }
119
120 // Setter
121 void SetMonteCarlo(Bool_t ismc=kTRUE) { fMonteCarlo=ismc; }
122 void SetWobbleMode(Bool_t wobm=kTRUE) { fWobbleMode=wobm; }
123
124 static Bool_t AddSequencesFromList(const TList &list, MDirIter &files);
125 static Int_t AddFilesToChain(MDirIter &files, TChain &chain);
126
127 const TList &GetSequencesOn() const { return fSequencesOn; }
128 const TList &GetSequencesOff() const { return fSequencesOff; }
129
130 Bool_t AddFiles(MRead &read) const;
131 Bool_t AddFilesOn(MRead &read) const;
132 Bool_t AddFilesOff(MRead &read) const;
133
134 Bool_t AddFiles(TChain &read) const;
135 Bool_t AddFilesOn(TChain &read) const;
136 Bool_t AddFilesOff(TChain &read) const;
137
138 void ReplaceDir(const TString &old, const TString &news)
139 {
140 ReplaceDir(fSequencesOn, old, news);
141 ReplaceDir(fSequencesOff, old, news);
142 }
143
144 void ReplaceFile(const TString &old, const TString &news)
145 {
146 ReplaceFile(fSequencesOn, old, news);
147 ReplaceFile(fSequencesOff, old, news);
148 }
149
150 // TObject
151 void Print(Option_t *o="") const; //*MENU*
152
153 ClassDef(MDataSet, 2)
154};
155
156#endif
Note: See TracBrowser for help on using the repository browser.