1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 8/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MSequence
|
---|
28 | //
|
---|
29 | /////////////////////////////////////////////////////////////////////////////
|
---|
30 | #include "MSequence.h"
|
---|
31 |
|
---|
32 | #include <stdlib.h>
|
---|
33 |
|
---|
34 | #include <TEnv.h>
|
---|
35 | #include <TRegexp.h>
|
---|
36 |
|
---|
37 | #include "MLog.h"
|
---|
38 | #include "MLogManip.h"
|
---|
39 |
|
---|
40 | #include "MDirIter.h"
|
---|
41 |
|
---|
42 | ClassImp(MSequence);
|
---|
43 |
|
---|
44 | using namespace std;
|
---|
45 |
|
---|
46 | void MSequence::Split(TString &runs, TArrayI &data) const
|
---|
47 | {
|
---|
48 | const TRegexp regexp("[0-9]+");
|
---|
49 |
|
---|
50 | data.Set(0);
|
---|
51 | runs = runs.Strip(TString::kTrailing);
|
---|
52 |
|
---|
53 | while (!runs.IsNull())
|
---|
54 | {
|
---|
55 | TString num = runs(regexp);
|
---|
56 |
|
---|
57 | const Int_t n = data.GetSize();
|
---|
58 | data.Set(n+1);
|
---|
59 | data[n] = atoi(num.Data());
|
---|
60 |
|
---|
61 | runs.Remove(0, runs.First(num)+num.Length());
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | void MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr) const
|
---|
66 | {
|
---|
67 | for (int i=0; i<arr.GetSize(); i++)
|
---|
68 | {
|
---|
69 | TString d, n;
|
---|
70 | d = "/data/MAGIC/Period";
|
---|
71 | d += Form("%03d", fPeriod);
|
---|
72 | d += "/rootdata/";
|
---|
73 | d += fNight.GetStringFmt("%Y_%m_%d");
|
---|
74 | n = fNight.GetStringFmt("%Y%m%d_");
|
---|
75 | n += Form("%05d", arr[i]);
|
---|
76 | n += "_*_E.root";
|
---|
77 |
|
---|
78 | iter.AddDirectory(d, n, 0);
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 | MSequence::MSequence(const char *fname)
|
---|
83 | {
|
---|
84 | fName = fname;
|
---|
85 | fTitle = Form("Sequence contained in file %s", fName.Data());
|
---|
86 |
|
---|
87 | TEnv env(fname);
|
---|
88 |
|
---|
89 | TString str;
|
---|
90 |
|
---|
91 | fSequence = env.GetValue("Sequence", -1);
|
---|
92 | fLastRun = env.GetValue("LastRun", -1);
|
---|
93 | fNumEvents = env.GetValue("NumEvents", -1);
|
---|
94 | fPeriod = env.GetValue("Period", -1);
|
---|
95 |
|
---|
96 | str = env.GetValue("Start", "");
|
---|
97 | fStart.SetSqlDateTime(str);
|
---|
98 | str = env.GetValue("Night", "");
|
---|
99 | str += " 00:00:00";
|
---|
100 | fNight.SetSqlDateTime(str);
|
---|
101 |
|
---|
102 | fProject = env.GetValue("Project", "");
|
---|
103 | fSource = env.GetValue("Source", "");
|
---|
104 | fTriggerTable = env.GetValue("TriggerTable", "");
|
---|
105 | fHvSettings = env.GetValue("HvSettings", "");
|
---|
106 |
|
---|
107 | str = env.GetValue("Runs", "");
|
---|
108 | Split(str, fRuns);
|
---|
109 | str = env.GetValue("CalRuns", "");
|
---|
110 | Split(str, fCalRuns);
|
---|
111 | str = env.GetValue("PedRuns", "");
|
---|
112 | Split(str, fPedRuns);
|
---|
113 | str = env.GetValue("DatRuns", "");
|
---|
114 | Split(str, fDatRuns);
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MSequence::Print(Option_t *o) const
|
---|
118 | {
|
---|
119 | gLog << all;
|
---|
120 | gLog << "Sequence: " << fSequence << endl;
|
---|
121 | gLog << "Period: " << fPeriod << endl;
|
---|
122 | gLog << "Night: " << fNight << endl << endl;
|
---|
123 | gLog << "Start: " << fStart << endl;
|
---|
124 | gLog << "LastRun: " << fLastRun << endl;
|
---|
125 | gLog << "NumEvents: " << fNumEvents << endl;
|
---|
126 | gLog << "Project: " << fProject << endl;
|
---|
127 | gLog << "Source: " << fSource << endl;
|
---|
128 | gLog << "TriggerTable: " << fTriggerTable << endl;
|
---|
129 | gLog << "HvSettings: " << fHvSettings << endl << endl;
|
---|
130 | gLog << "Runs:";
|
---|
131 | for (int i=0; i<fRuns.GetSize(); i++)
|
---|
132 | gLog << " " << fRuns[i];
|
---|
133 | gLog << endl;
|
---|
134 | gLog << "CalRuns:";
|
---|
135 | for (int i=0; i<fCalRuns.GetSize(); i++)
|
---|
136 | gLog << " " << fCalRuns[i];
|
---|
137 | gLog << endl;
|
---|
138 | gLog << "PedRuns:";
|
---|
139 | for (int i=0; i<fPedRuns.GetSize(); i++)
|
---|
140 | gLog << " " << fPedRuns[i];
|
---|
141 | gLog << endl;
|
---|
142 | gLog << "DatRuns:";
|
---|
143 | for (int i=0; i<fDatRuns.GetSize(); i++)
|
---|
144 | gLog << " " << fDatRuns[i];
|
---|
145 | gLog << endl;
|
---|
146 | }
|
---|
147 |
|
---|
148 | void MSequence::SetupPedRuns(MDirIter &iter) const
|
---|
149 | {
|
---|
150 | SetupRuns(iter, fPedRuns);
|
---|
151 | }
|
---|
152 |
|
---|
153 | void MSequence::SetupDatRuns(MDirIter &iter) const
|
---|
154 | {
|
---|
155 | SetupRuns(iter, fDatRuns);
|
---|
156 | }
|
---|
157 |
|
---|
158 | void MSequence::SetupAllRuns(MDirIter &iter) const
|
---|
159 | {
|
---|
160 | SetupRuns(iter, fRuns);
|
---|
161 | }
|
---|
162 |
|
---|
163 | void MSequence::SetupCalRuns(MDirIter &iter) const
|
---|
164 | {
|
---|
165 | SetupRuns(iter, fCalRuns);
|
---|
166 | }
|
---|