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

Last change on this file since 3897 was 3874, checked in by rico, 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(const char* runrange, const char *path=0);
45 Int_t AddRuns(UInt_t from, UInt_t to, const char *path=0)
46 {
47 Int_t n = 0;
48
49 for (UInt_t i=from; i<=to; i++)
50 AddRun(i, path);
51
52 return n;
53 }
54
55 UInt_t GetNumRuns() const { return fRuns.GetSize(); }
56 const TArrayI &GetRuns() const { return fRuns; }
57
58 TString GetRunsAsString() const {
59 TString txt;
60 for (int i=0; i<fRuns.GetSize(); i++)
61 {
62 txt += "#";
63 txt += fRuns[i];
64 if (i!=fRuns.GetSize()-1)
65 txt += " ";
66 }
67 return txt;
68 }
69 TString GetRunsAsFileName() const {
70 TString txt;
71 for (int i=0; i<fRuns.GetSize(); i++)
72 {
73 txt += fRuns[i];
74 if (i!=fRuns.GetSize()-1)
75 txt += "_";
76 }
77 return txt;
78 }
79
80 ClassDef(MRunIter, 1) // Iterator for runs
81};
82
83#endif
Note: See TracBrowser for help on using the repository browser.