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

Last change on this file since 3544 was 2993, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 1.6 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 void AddRunNumber(UInt_t run)
19 {
20 fRuns.Set(fRuns.GetSize()+1);
21 fRuns[fRuns.GetSize()-1] = run;
22
23 Sort();
24
25 }
26
27 void Sort()
28 {
29 const int n = GetNumRuns();
30
31 TArrayI idx(n);
32 TMath::Sort(n, fRuns.GetArray(), idx.GetArray(), kFALSE);
33
34 for (int i=0; i<n; i++)
35 idx[i] = fRuns[idx[i]];
36
37 fRuns = idx;
38 }
39
40public:
41 MRunIter(const char *path=0) : fPath(path) { }
42
43 Int_t AddRun(UInt_t run, const char *path=0);
44 Int_t AddRuns(UInt_t from, UInt_t to, const char *path=0)
45 {
46 Int_t n = 0;
47
48 for (UInt_t i=from; i<=to; i++)
49 AddRun(i, path);
50
51 return n;
52 }
53
54 UInt_t GetNumRuns() const { return fRuns.GetSize(); }
55 const TArrayI &GetRuns() const { return fRuns; }
56
57 TString GetRunsAsString() const {
58 TString txt;
59 for (int i=0; i<fRuns.GetSize(); i++)
60 {
61 txt += "#";
62 txt += fRuns[i];
63 if (i!=fRuns.GetSize()-1)
64 txt += " ";
65 }
66 return txt;
67 }
68 TString GetRunsAsFileName() const {
69 TString txt;
70 for (int i=0; i<fRuns.GetSize(); i++)
71 {
72 txt += fRuns[i];
73 if (i!=fRuns.GetSize()-1)
74 txt += "_";
75 }
76 return txt;
77 }
78
79 ClassDef(MRunIter, 1) // Iterator for runs
80};
81
82#endif
Note: See TracBrowser for help on using the repository browser.