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

Last change on this file since 3969 was 3966, checked in by reyes, 20 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 SetRawFile(Bool_t filetype) { fIsRawFile = filetype; }
21
22 void AddRunNumber(UInt_t run)
23 {
24 fRuns.Set(fRuns.GetSize()+1);
25 fRuns[fRuns.GetSize()-1] = run;
26
27 Sort();
28
29 }
30
31 void Sort()
32 {
33 const int n = GetNumRuns();
34
35 TArrayI idx(n);
36 TMath::Sort(n, fRuns.GetArray(), idx.GetArray(), kFALSE);
37
38 for (int i=0; i<n; i++)
39 idx[i] = fRuns[idx[i]];
40
41 fRuns = idx;
42 }
43
44public:
45 MRunIter(const char *path=0) : fPath(path), fIsRawFile(0) { }
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.