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

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