source: trunk/MagicSoft/Mars/mbase/MRunIter.h@ 8695

Last change on this file since 8695 was 5469, checked in by gaug, 20 years ago
*** empty log message ***
File size: 1.9 KB
Line 
1#ifndef MARS_MRunIter
2#define MARS_MRunIter
3
4#ifndef MARS_MDirIter
5#include "MDirIter.h"
6#endif
7
8#ifndef ROOT_TArrayI
9#include <TArrayI.h>
10#endif
11
12class MRunIter : public MDirIter
13{
14private:
15 TString fPath;
16 TArrayI fRuns;
17
18 Bool_t fIsRawFile;
19 Bool_t fIsStandardFile;
20
21 void AddRunNumber(UInt_t run)
22 {
23 fRuns.Set(fRuns.GetSize()+1);
24 fRuns[fRuns.GetSize()-1] = run;
25
26 SortRuns();
27
28 }
29
30 void SortRuns()
31 {
32 const int n = GetNumRuns();
33
34 TArrayI idx(n);
35 TMath::Sort(n, fRuns.GetArray(), idx.GetArray(), kFALSE);
36
37 for (int i=0; i<n; i++)
38 idx[i] = fRuns[idx[i]];
39
40 fRuns = idx;
41 }
42
43public:
44 MRunIter(const char *path=0) : fPath(path), fIsRawFile(0), fIsStandardFile(kFALSE) { }
45
46 void SetRawFile(Bool_t filetype) { fIsRawFile = filetype; }
47 void SetStandardFile(Bool_t filetype) { fIsStandardFile = filetype; }
48
49 Int_t AddRun(UInt_t run, const char *path=0);
50 Int_t AddRuns(const char* runrange, const char *path=0);
51 Int_t AddRuns(UInt_t from, UInt_t to, const char *path=0)
52 {
53 Int_t n = 0;
54
55 for (UInt_t i=from; i<=to; i++)
56 AddRun(i, path);
57
58 return n;
59 }
60
61 UInt_t GetNumRuns() const { return fRuns.GetSize(); }
62 const TArrayI &GetRuns() const { return fRuns; }
63
64 TString GetRunsAsString() const {
65 TString txt;
66 for (int i=0; i<fRuns.GetSize(); i++)
67 {
68 txt += "#";
69 txt += fRuns[i];
70 if (i!=fRuns.GetSize()-1)
71 txt += " ";
72 }
73 return txt;
74 }
75 TString GetRunsAsFileName() const {
76 TString txt;
77 for (int i=0; i<fRuns.GetSize(); i++)
78 {
79 txt += fRuns[i];
80 if (i!=fRuns.GetSize()-1)
81 txt += "_";
82 }
83 return txt;
84 }
85
86 ClassDef(MRunIter, 1) // Iterator for runs
87};
88
89#endif
Note: See TracBrowser for help on using the repository browser.