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-2007
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MSequence
|
---|
28 | //
|
---|
29 | // This class describes a sequence. For sequences see:
|
---|
30 | // http://db.astro.uni-wuerzburg.de
|
---|
31 | //
|
---|
32 | // A sequence is a collection of runs which should be used together.
|
---|
33 | // Any run can be contained only once.
|
---|
34 | //
|
---|
35 | // Here is an example how a file describing a sequence could look like.
|
---|
36 | //
|
---|
37 | // Reading the file is based on TEnv. For more details see also
|
---|
38 | // the class reference of TEnv.
|
---|
39 | //
|
---|
40 | // ===========================================================================
|
---|
41 | //
|
---|
42 | // sequence.txt
|
---|
43 | // ------------
|
---|
44 | //
|
---|
45 | // # Sequence number (identifier) - necessary if the path
|
---|
46 | // # contains the sequence number, e.g. image files
|
---|
47 | // Sequence: 31015
|
---|
48 | //
|
---|
49 | // # Observation Period (not needed)
|
---|
50 | // Period: 18
|
---|
51 | //
|
---|
52 | // # Date of sunrise of the observation night - necessary if the path
|
---|
53 | // # contains the date, e.g. raw data
|
---|
54 | // Night: 2004-06-24
|
---|
55 | //
|
---|
56 | // # Start time of the sequence (first data run, not needed)
|
---|
57 | // Start: 2004-06-24 03:12:42
|
---|
58 | //
|
---|
59 | // # Run number of last data run in sequence (not needed)
|
---|
60 | // LastRun: 31032
|
---|
61 | //
|
---|
62 | // # Project name of data-runs of sequence (not needed)
|
---|
63 | // Project: 3EG2033+41
|
---|
64 | //
|
---|
65 | // # Source name of all runs of sequence (not needed)
|
---|
66 | // Source: 3EG2033+41
|
---|
67 | //
|
---|
68 | // # Trigger table of data-runs of sequence (not needed)
|
---|
69 | // TriggerTable: L1_4NN:L2_DEFAULT
|
---|
70 | //
|
---|
71 | // # HV Setting table of data-runs of sequence (not needed)
|
---|
72 | // HvSettings: HVSettings_FF36q
|
---|
73 | //
|
---|
74 | // # Total number of data-events in sequence (not needed)
|
---|
75 | // NumEvents: 250914
|
---|
76 | //
|
---|
77 | // # Whether this is MC data or not (necessary in case of MCs if
|
---|
78 | // # default paths should be used)
|
---|
79 | // MonteCarlo: Yes
|
---|
80 | //
|
---|
81 | // # List of all runs of this sequence (not needed)
|
---|
82 | // Runs: 31015 31016 31017 31018 31019 31020 31021 31022 31023 31024 31025 31026 31027 31028 31029 31030 31031 31032
|
---|
83 | //
|
---|
84 | // # List of all calibration runs of this sequence (necessary if accessed)
|
---|
85 | // CalRuns: 31015 31016 31017
|
---|
86 | // # List of pedestal runs belonging to the calibration runs of this sequence (necessary if accessed)
|
---|
87 | // PedRuns: 31018
|
---|
88 | // # List of all data runs belonging to this sequence (necessary)
|
---|
89 | // DatRuns: 31019 31020 31022 31023 31024 31025 31027 31028 31030 31032
|
---|
90 | //
|
---|
91 | // # Just for fun ;-) (not needed, but helpful)
|
---|
92 | // Comment: This is a template for a sequence file
|
---|
93 | //
|
---|
94 | // ===========================================================================
|
---|
95 | //
|
---|
96 | // For special cases you can also setup a sequence directly from a macro,
|
---|
97 | // for example:
|
---|
98 | //
|
---|
99 | // MDirIter pediter, datiter, caliter;
|
---|
100 | //
|
---|
101 | // MSequence seq;
|
---|
102 | // seq.SetNight("2004-07-06");
|
---|
103 | // seq.AddPedRuns(31751);
|
---|
104 | // seq.AddCalRuns(31752);
|
---|
105 | // seq.AddDatRuns(31753, 31764);
|
---|
106 | // seq.SetupPedRuns(pediter);
|
---|
107 | // seq.SetupCalRuns(caliter);
|
---|
108 | // seq.SetupDatRuns(datiter);
|
---|
109 | //
|
---|
110 | // or
|
---|
111 | //
|
---|
112 | // MDirIter iter;
|
---|
113 | //
|
---|
114 | // MSequence seq;
|
---|
115 | // seq.SetNight("2004-07-06");
|
---|
116 | // seq.AddRuns(31753, 31764);
|
---|
117 | // seq.SetupRuns(iter);
|
---|
118 | // seq.SetupPedRuns(iter, "/mypath", "[DPC]");
|
---|
119 | //
|
---|
120 | // ===========================================================================
|
---|
121 | //
|
---|
122 | // Class Version 2:
|
---|
123 | // + fMonteCarlo
|
---|
124 | //
|
---|
125 | // Class Version 3:
|
---|
126 | // + fComment
|
---|
127 | //
|
---|
128 | // Class Version 4:
|
---|
129 | // + fExclRuns
|
---|
130 | //
|
---|
131 | /////////////////////////////////////////////////////////////////////////////
|
---|
132 | #include "MSequence.h"
|
---|
133 |
|
---|
134 | #include <stdlib.h>
|
---|
135 |
|
---|
136 | #include <TEnv.h>
|
---|
137 | #include <TRegexp.h>
|
---|
138 | #include <TSystem.h> // TSystem::ExpandPath
|
---|
139 |
|
---|
140 | #include "MLog.h"
|
---|
141 | #include "MLogManip.h"
|
---|
142 |
|
---|
143 | #include "MEnv.h"
|
---|
144 | #include "MJob.h"
|
---|
145 | #include "MAstro.h"
|
---|
146 | #include "MString.h"
|
---|
147 | #include "MDirIter.h"
|
---|
148 |
|
---|
149 | ClassImp(MSequence);
|
---|
150 |
|
---|
151 | using namespace std;
|
---|
152 |
|
---|
153 | MSequence::~MSequence()
|
---|
154 | {
|
---|
155 | /*
|
---|
156 | TExMapIter iter(&fFileNames);
|
---|
157 |
|
---|
158 | Long_t key, val;
|
---|
159 |
|
---|
160 | while (iter.Next(key, val))
|
---|
161 | delete (TString*)val;
|
---|
162 | */
|
---|
163 | }
|
---|
164 |
|
---|
165 |
|
---|
166 | // --------------------------------------------------------------------------
|
---|
167 | //
|
---|
168 | // Copy the run numbers from the TString runs into the TArrayI data.
|
---|
169 | // Runs which are twice in the list are only added once. In this case
|
---|
170 | // a warning is emitted.
|
---|
171 | //
|
---|
172 | void MSequence::Split(TString &runs, TArrayI &data) const
|
---|
173 | {
|
---|
174 | const TRegexp regexp("[0-9]+");
|
---|
175 |
|
---|
176 | data.Set(0);
|
---|
177 |
|
---|
178 | runs.ReplaceAll("\t", " ");
|
---|
179 | runs = runs.Strip(TString::kBoth);
|
---|
180 |
|
---|
181 | while (!runs.IsNull())
|
---|
182 | {
|
---|
183 | const TString num = runs(regexp);
|
---|
184 |
|
---|
185 | if (num.IsNull())
|
---|
186 | {
|
---|
187 | *fLog << warn << "WARNING - Run is NaN (not a number): '" << runs << "'" << endl;
|
---|
188 | break;
|
---|
189 | }
|
---|
190 |
|
---|
191 | const Int_t run = atoi(num.Data());
|
---|
192 | const Int_t n = data.GetSize();
|
---|
193 |
|
---|
194 | // skip already existing entries
|
---|
195 | int i;
|
---|
196 | for (i=0; i<n; i++)
|
---|
197 | if (data[i] == run)
|
---|
198 | break;
|
---|
199 |
|
---|
200 | if (i<n)
|
---|
201 | *fLog << warn << "WARNING - Run #" << run << " already in list... skipped." << endl;
|
---|
202 | else
|
---|
203 | {
|
---|
204 | // set new entry
|
---|
205 | data.Set(n+1);
|
---|
206 | data[n] = run;
|
---|
207 | }
|
---|
208 |
|
---|
209 | runs.Remove(0, runs.First(num)+num.Length());
|
---|
210 | }
|
---|
211 |
|
---|
212 | MJob::SortArray(data);
|
---|
213 | }
|
---|
214 |
|
---|
215 | UInt_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, FileType_t type, const char *path) const
|
---|
216 | {
|
---|
217 | TString d(path);
|
---|
218 | if (d.IsNull())
|
---|
219 | d = fDataPath;
|
---|
220 |
|
---|
221 | const Bool_t def = d.IsNull();
|
---|
222 |
|
---|
223 | // For this particular case we assume that the files are added one by
|
---|
224 | // one without wildcards.
|
---|
225 | const Int_t n0 = iter.GetNumEntries();
|
---|
226 |
|
---|
227 | // Setup path
|
---|
228 | if (def)
|
---|
229 | {
|
---|
230 | d = GetStandardPath();
|
---|
231 | switch (type)
|
---|
232 | {
|
---|
233 | case kRawDat: // rawdata
|
---|
234 | case kRawPed:
|
---|
235 | case kRawCal:
|
---|
236 | case kRawAll:
|
---|
237 | case kRootDat: // mcdata
|
---|
238 | case kRootPed:
|
---|
239 | case kRootCal:
|
---|
240 | case kRootAll:
|
---|
241 | d += "rawfiles/";
|
---|
242 | d += fNight.GetStringFmt("%Y/%m/%d");
|
---|
243 | break;
|
---|
244 | case kCalibrated:
|
---|
245 | d += Form("callisto/%04d/%08d", fSequence/10000, fSequence);
|
---|
246 | break;
|
---|
247 | case kImages:
|
---|
248 | d += Form("star/%04d/%08d", fSequence/10000, fSequence);
|
---|
249 | break;
|
---|
250 | }
|
---|
251 | }
|
---|
252 | else
|
---|
253 | gSystem->ExpandPathName(d);
|
---|
254 |
|
---|
255 | if (!d.EndsWith("/"))
|
---|
256 | d += '/';
|
---|
257 |
|
---|
258 | Int_t excluded = 0;
|
---|
259 | for (int i=0; i<arr.GetSize(); i++)
|
---|
260 | {
|
---|
261 | if (IsExcluded(arr[i]))
|
---|
262 | {
|
---|
263 | excluded++;
|
---|
264 | continue;
|
---|
265 | }
|
---|
266 |
|
---|
267 | // R. DeLosReyes and T. Bretz
|
---|
268 | // Changes to read the DAQ numbering format. Changes takes place
|
---|
269 | // between runs 35487 and 00035488 (2004_08_30)
|
---|
270 | const char *fmt = arr[i]>35487 || fMonteCarlo ? "%08d_%s_*_E" : "%05d_%s_*_E";
|
---|
271 |
|
---|
272 | TString n;
|
---|
273 | const char *id="_";
|
---|
274 | switch (type)
|
---|
275 | {
|
---|
276 | case kRawDat:
|
---|
277 | case kRootDat:
|
---|
278 | id = "D";
|
---|
279 | break;
|
---|
280 | case kRawPed:
|
---|
281 | case kRootPed:
|
---|
282 | id = "P";
|
---|
283 | break;
|
---|
284 | case kRawCal:
|
---|
285 | case kRootCal:
|
---|
286 | id = "C";
|
---|
287 | break;
|
---|
288 | case kRawAll:
|
---|
289 | case kRootAll:
|
---|
290 | id = "[PCD]";
|
---|
291 | break;
|
---|
292 | case kCalibrated:
|
---|
293 | id = "Y";
|
---|
294 | break;
|
---|
295 | case kImages:
|
---|
296 | id = "I";
|
---|
297 | break;
|
---|
298 | }
|
---|
299 |
|
---|
300 | // Create file name
|
---|
301 | n = fNight.GetStringFmt("%Y%m%d_");
|
---|
302 | n += Form(fmt, arr[i], id);
|
---|
303 |
|
---|
304 | switch (type)
|
---|
305 | {
|
---|
306 | case kRawDat:
|
---|
307 | case kRawPed:
|
---|
308 | case kRawCal:
|
---|
309 | case kRawAll:
|
---|
310 | n += ".raw.?g?z?";
|
---|
311 | break;
|
---|
312 | default:
|
---|
313 | n += ".root";
|
---|
314 | }
|
---|
315 |
|
---|
316 | // Check existance and accessibility of file
|
---|
317 | MDirIter file(d, n, 0);
|
---|
318 | TString name = file();
|
---|
319 | gSystem->ExpandPathName(name);
|
---|
320 | if (gSystem->AccessPathName(name, kFileExists))
|
---|
321 | {
|
---|
322 | *fLog << err;
|
---|
323 | *fLog << "ERROR - File " << d << n << " not accessible!" << endl;
|
---|
324 | return 0;
|
---|
325 | }
|
---|
326 | if (!file().IsNull())
|
---|
327 | {
|
---|
328 | *fLog << err;
|
---|
329 | *fLog << "ERROR - Searching for file " << d << n << " gave more than one result!" << endl;
|
---|
330 | return 0;
|
---|
331 | }
|
---|
332 |
|
---|
333 | // Add Path/File to TIter
|
---|
334 | iter.AddDirectory(d, n, 0);
|
---|
335 | }
|
---|
336 |
|
---|
337 | // n0: The previous contents of the iter
|
---|
338 | // n1: The number of files which have been added to the iter
|
---|
339 | // n2: The number of files which should have been added from the array
|
---|
340 | const Int_t n1 = iter.GetNumEntries()-n0;
|
---|
341 | const Int_t n2 = arr.GetSize()-excluded;
|
---|
342 | if (n1==0)
|
---|
343 | {
|
---|
344 | *fLog << err;
|
---|
345 | *fLog << "ERROR - No input files for sequence #" << GetSequence() << endl;
|
---|
346 | *fLog << " read from " << GetName() << endl;
|
---|
347 | *fLog << " found in" << (def?" default-path ":" ") << d << endl;
|
---|
348 | return 0;
|
---|
349 | }
|
---|
350 |
|
---|
351 | if (n1==n2)
|
---|
352 | return n1;
|
---|
353 |
|
---|
354 | *fLog << err;
|
---|
355 | *fLog << "ERROR - " << n1 << " input files for sequence #" << GetSequence() << " found in" << endl;
|
---|
356 | *fLog << " " << (def?" default-path ":" ") << d << endl;
|
---|
357 | *fLog << " but " << n2 << " files were defined in sequence file" << endl;
|
---|
358 | *fLog << " " << GetName() << endl;
|
---|
359 | if (fLog->GetDebugLevel()<=4)
|
---|
360 | return 0;
|
---|
361 |
|
---|
362 | *fLog << inf << "Files which are searched for this sequence:" << endl;
|
---|
363 | iter.Print();
|
---|
364 | return 0;
|
---|
365 | }
|
---|
366 |
|
---|
367 | // --------------------------------------------------------------------------
|
---|
368 | //
|
---|
369 | // Read the file fname as setup file for the sequence.
|
---|
370 | //
|
---|
371 | //void MSequence::GetFileNames(TEnv &env, const TArrayI &arr)
|
---|
372 | //{
|
---|
373 | /*
|
---|
374 | for (int i=0; i<arr.GetSize(); i++)
|
---|
375 | {
|
---|
376 | // Get run number
|
---|
377 | const Int_t num = arr[i];
|
---|
378 |
|
---|
379 | // Check if name already set
|
---|
380 | if (fFileNames.GetValue(num))
|
---|
381 | continue;
|
---|
382 |
|
---|
383 | TString *str = new TString(env.GetValue(Form("%d", num), ""));
|
---|
384 | fFileNames.Add(num, (Long_t)str);
|
---|
385 | }
|
---|
386 | */
|
---|
387 | //}
|
---|
388 |
|
---|
389 | // --------------------------------------------------------------------------
|
---|
390 | //
|
---|
391 | // Get a file name corresponding to the run-number num, returns 0 if n/a
|
---|
392 | //
|
---|
393 | //const char *MSequence::GetFileName(UInt_t num)
|
---|
394 | //{
|
---|
395 | // return 0;
|
---|
396 | /*
|
---|
397 | TString *str = (TString*)fFileNames.GetValue(num);
|
---|
398 | return str ? str->Data() : 0;*/
|
---|
399 | //}
|
---|
400 |
|
---|
401 | MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env, const char *prefix) const
|
---|
402 | {
|
---|
403 | TString str = GetEnvValue2(env, prefix, "LightConditions", "n/a");
|
---|
404 | if (!str.CompareTo("n/a", TString::kIgnoreCase))
|
---|
405 | return kNA;
|
---|
406 | if (!str.CompareTo("No_Moon", TString::kIgnoreCase))
|
---|
407 | return kNoMoon;
|
---|
408 | if (!str.CompareTo("Twilight", TString::kIgnoreCase))
|
---|
409 | return kTwilight;
|
---|
410 | if (!str.CompareTo("Moon", TString::kIgnoreCase))
|
---|
411 | return kMoon;
|
---|
412 | if (!str.CompareTo("Day", TString::kIgnoreCase))
|
---|
413 | return kDay;
|
---|
414 |
|
---|
415 | gLog << warn;
|
---|
416 | gLog << "WARNING - in " << fFileName << ":" << endl;
|
---|
417 | gLog << " LightCondition-tag is '" << str << "' but must be n/a, no_moon, twilight, moon or day." << endl;
|
---|
418 | return kNA;
|
---|
419 | }
|
---|
420 |
|
---|
421 | // --------------------------------------------------------------------------
|
---|
422 | //
|
---|
423 | // Read the file fname as setup file for the sequence.
|
---|
424 | //
|
---|
425 | MSequence::MSequence(const char *fname, const char *path, UInt_t seq)
|
---|
426 | {
|
---|
427 | fName = fname;
|
---|
428 | fTitle = path;
|
---|
429 |
|
---|
430 | fFileName = fname;
|
---|
431 | fDataPath = path;
|
---|
432 |
|
---|
433 | gSystem->ExpandPathName(fName);
|
---|
434 | gSystem->ExpandPathName(fTitle);
|
---|
435 |
|
---|
436 | const Bool_t rc1 = gSystem->AccessPathName(fName, kFileExists);
|
---|
437 | const Bool_t rc2 = !fTitle.IsNull() && gSystem->AccessPathName(fTitle, kFileExists);
|
---|
438 |
|
---|
439 | if (rc1)
|
---|
440 | gLog << err << "ERROR - Sequence file '" << fName << "' doesn't exist." << endl;
|
---|
441 | if (rc2)
|
---|
442 | gLog << err << "ERROR - Directory '" << fTitle << "' doesn't exist." << endl;
|
---|
443 |
|
---|
444 | MEnv env(fName);
|
---|
445 |
|
---|
446 | fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq);
|
---|
447 | if (rc1 || rc2)
|
---|
448 | fSequence = (UInt_t)-1;
|
---|
449 |
|
---|
450 | const TString prefix = Form("Sequence%08d", fSequence);
|
---|
451 |
|
---|
452 | fLastRun = GetEnvValue2(env, prefix, "LastRun", -1);
|
---|
453 | fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
|
---|
454 | fPeriod = GetEnvValue2(env, prefix, "Period", -1);
|
---|
455 |
|
---|
456 | fLightCondition = ReadLightCondition(env, prefix);
|
---|
457 |
|
---|
458 | TString str;
|
---|
459 | str = GetEnvValue2(env, prefix, "Start", "");
|
---|
460 | fStart.SetSqlDateTime(str);
|
---|
461 | str = GetEnvValue2(env, prefix, "Night", "");
|
---|
462 | str += " 00:00:00";
|
---|
463 | fNight.SetSqlDateTime(str);
|
---|
464 |
|
---|
465 | fProject = GetEnvValue2(env, prefix, "Project", "");
|
---|
466 | fSource = GetEnvValue2(env, prefix, "Source", "");
|
---|
467 | fTriggerTable = GetEnvValue2(env, prefix, "TriggerTable", "");
|
---|
468 | fHvSettings = GetEnvValue2(env, prefix, "HvSettings", "");
|
---|
469 | fMonteCarlo = GetEnvValue2(env, prefix, "MonteCarlo", kFALSE);
|
---|
470 | fComment = GetEnvValue2(env, prefix, "Comment", "");
|
---|
471 |
|
---|
472 | str = GetEnvValue2(env, prefix, "Runs", "");
|
---|
473 | Split(str, fRuns);
|
---|
474 | str = GetEnvValue2(env, prefix, "CalRuns", "");
|
---|
475 | Split(str, fCalRuns);
|
---|
476 | str = GetEnvValue2(env, prefix, "PedRuns", "");
|
---|
477 | Split(str, fPedRuns);
|
---|
478 | str = GetEnvValue2(env, prefix, "DatRuns", "");
|
---|
479 | Split(str, fDatRuns);
|
---|
480 | str = GetEnvValue2(env, prefix, "Exclude", "");
|
---|
481 | Split(str, fExclRuns);
|
---|
482 |
|
---|
483 | // GetFileNames(env, fRuns);
|
---|
484 | // GetFileNames(env, fCalRuns);
|
---|
485 | // GetFileNames(env, fPedRuns);
|
---|
486 | // GetFileNames(env, fDatRuns);
|
---|
487 |
|
---|
488 | // Dummies:
|
---|
489 | env.Touch("ZdMin");
|
---|
490 | env.Touch("ZdMax");
|
---|
491 | env.Touch("L1TriggerTable");
|
---|
492 | env.Touch("L2TriggerTable");
|
---|
493 |
|
---|
494 | if (seq<0 && env.GetNumUntouched()>0)
|
---|
495 | {
|
---|
496 | gLog << warn << "WARNING - At least one resource in the sequence-file has not been touched!" << endl;
|
---|
497 | env.PrintUntouched();
|
---|
498 | }
|
---|
499 | }
|
---|
500 |
|
---|
501 | //---------------------------------------------------------------------------
|
---|
502 | //
|
---|
503 | // Make sure that the name used for writing doesn't contain a full path
|
---|
504 | //
|
---|
505 | const char *MSequence::GetName() const
|
---|
506 | {
|
---|
507 | const char *pos = strrchr(GetRcName(), '/');
|
---|
508 | return pos>0 ? pos+1 : GetRcName();
|
---|
509 | }
|
---|
510 |
|
---|
511 | // --------------------------------------------------------------------------
|
---|
512 | //
|
---|
513 | // Print the contents of the sequence
|
---|
514 | //
|
---|
515 | void MSequence::Print(Option_t *o) const
|
---|
516 | {
|
---|
517 | const TString pre = TString(o).Contains("prefixed") ? Form("Sequence%08d.", fSequence) : "";
|
---|
518 |
|
---|
519 | gLog << all;
|
---|
520 | if (!IsValid())
|
---|
521 | {
|
---|
522 | gLog << pre << "Sequence: " << fFileName << " <invalid>" << endl;
|
---|
523 | return;
|
---|
524 | }
|
---|
525 | gLog << "# Path: " << GetRcName() << endl;
|
---|
526 | gLog << "# Name: " << GetName() << endl;
|
---|
527 | gLog << endl;
|
---|
528 | if (pre.IsNull())
|
---|
529 | gLog << "Sequence: " << fSequence << endl;
|
---|
530 | if (fMonteCarlo)
|
---|
531 | gLog << pre << "MonteCarlo: Yes" << endl;
|
---|
532 | gLog << pre <<"Period: " << fPeriod << endl;
|
---|
533 | gLog << pre << "Night: " << fNight << endl << endl;
|
---|
534 | gLog << pre << "LightCondition: ";
|
---|
535 | switch (fLightCondition)
|
---|
536 | {
|
---|
537 | case kNA: gLog << "n/a" << endl; break;
|
---|
538 | case kNoMoon: gLog << "NoMoon" << endl; break;
|
---|
539 | case kTwilight: gLog << "Twilight" << endl; break;
|
---|
540 | case kMoon: gLog << "Moon" << endl; break;
|
---|
541 | case kDay: gLog << "Day" << endl; break;
|
---|
542 | }
|
---|
543 | gLog << pre << "Start: " << fStart << endl;
|
---|
544 | gLog << pre << "LastRun: " << fLastRun << endl;
|
---|
545 | gLog << pre << "NumEvents: " << fNumEvents << endl;
|
---|
546 | gLog << pre << "Project: " << fProject << endl;
|
---|
547 | gLog << pre << "Source: " << fSource << endl;
|
---|
548 | gLog << pre << "TriggerTable: " << fTriggerTable << endl;
|
---|
549 | gLog << pre << "HvSettings: " << fHvSettings << endl << endl;
|
---|
550 | if (fRuns.GetSize()>0)
|
---|
551 | {
|
---|
552 | gLog << pre << "Runs:";
|
---|
553 | for (int i=0; i<fRuns.GetSize(); i++)
|
---|
554 | gLog << " " << fRuns[i];
|
---|
555 | gLog << endl;
|
---|
556 | }
|
---|
557 | if (fCalRuns.GetSize()>0)
|
---|
558 | {
|
---|
559 | gLog << pre << "CalRuns:";
|
---|
560 | for (int i=0; i<fCalRuns.GetSize(); i++)
|
---|
561 | gLog << " " << fCalRuns[i];
|
---|
562 | gLog << endl;
|
---|
563 | }
|
---|
564 | if (fPedRuns.GetSize()>0)
|
---|
565 | {
|
---|
566 | gLog << pre << "PedRuns:";
|
---|
567 | for (int i=0; i<fPedRuns.GetSize(); i++)
|
---|
568 | gLog << " " << fPedRuns[i];
|
---|
569 | gLog << endl;
|
---|
570 | }
|
---|
571 | if (fDatRuns.GetSize()>0)
|
---|
572 | {
|
---|
573 | gLog << pre << "DatRuns:";
|
---|
574 | for (int i=0; i<fDatRuns.GetSize(); i++)
|
---|
575 | gLog << " " << fDatRuns[i];
|
---|
576 | gLog << endl;
|
---|
577 | }
|
---|
578 | if (fExclRuns.GetSize()>0)
|
---|
579 | {
|
---|
580 | gLog << pre << "Exclude:";
|
---|
581 | for (int i=0; i<fExclRuns.GetSize(); i++)
|
---|
582 | gLog << " " << fExclRuns[i];
|
---|
583 | gLog << endl;
|
---|
584 | }
|
---|
585 | if (!fDataPath.IsNull())
|
---|
586 | gLog << endl << pre << "DataPath: " << fDataPath << endl;
|
---|
587 |
|
---|
588 | gLog << endl << pre << "Comment: " << fComment << endl;
|
---|
589 | }
|
---|
590 |
|
---|
591 | // --------------------------------------------------------------------------
|
---|
592 | //
|
---|
593 | // Add all ped runs from the sequence to MDirIter.
|
---|
594 | // If path==0 fDataPath is used instead. If it is also empty
|
---|
595 | // the standard path of the data-center is assumed.
|
---|
596 | // If you have the runs locally use path="."
|
---|
597 | // Using raw=kTRUE you get correspodning raw-files setup.
|
---|
598 | // Return the number of files added.
|
---|
599 | //
|
---|
600 | // Runs which are in fExlRuns are ignored.
|
---|
601 | //
|
---|
602 | UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
|
---|
603 | {
|
---|
604 | return SetupRuns(iter, fPedRuns, raw?kRawPed:kRootPed, path);
|
---|
605 | }
|
---|
606 |
|
---|
607 | // --------------------------------------------------------------------------
|
---|
608 | //
|
---|
609 | // Add all data runs from the sequence to MDirIter.
|
---|
610 | // If path==0 fDataPath is used instead. If it is also empty
|
---|
611 | // the standard path of the data-center is assumed.
|
---|
612 | // If you have the runs locally use path="."
|
---|
613 | // Using raw=kTRUE you get correspodning raw-files setup.
|
---|
614 | // Return the number of files added.
|
---|
615 | //
|
---|
616 | // Runs which are in fExlRuns are ignored.
|
---|
617 | //
|
---|
618 | UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const
|
---|
619 | {
|
---|
620 | return SetupRuns(iter, fDatRuns, raw?kRawDat:kRootDat, path);
|
---|
621 | }
|
---|
622 |
|
---|
623 | // --------------------------------------------------------------------------
|
---|
624 | //
|
---|
625 | // Add all runs from the sequence to MDirIter.
|
---|
626 | // If path==0 fDataPath is used instead. If it is also empty
|
---|
627 | // the standard path of the data-center is assumed.
|
---|
628 | // If you have the runs locally use path="."
|
---|
629 | // Using raw=kTRUE you get correspodning raw-files setup.
|
---|
630 | // Return the number of files added.
|
---|
631 | //
|
---|
632 | // Runs which are in fExlRuns are ignored.
|
---|
633 | //
|
---|
634 | UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const
|
---|
635 | {
|
---|
636 | return SetupRuns(iter, fRuns, raw?kRawAll:kRootAll, path);
|
---|
637 | }
|
---|
638 |
|
---|
639 | // --------------------------------------------------------------------------
|
---|
640 | //
|
---|
641 | // Add all calibration runs from the sequence to MDirIter.
|
---|
642 | // If path==0 fDataPath is used instead. If it is also empty
|
---|
643 | // the standard path of the data-center is assumed.
|
---|
644 | // If you have the runs locally use path="."
|
---|
645 | // Using raw=kTRUE you get correspodning raw-files setup.
|
---|
646 | // Return the number of files added.
|
---|
647 | //
|
---|
648 | // Runs which are in fExlRuns are ignored.
|
---|
649 | //
|
---|
650 | UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const
|
---|
651 | {
|
---|
652 | return SetupRuns(iter, fCalRuns, raw?kRawCal:kRootCal, path);
|
---|
653 | }
|
---|
654 |
|
---|
655 | // --------------------------------------------------------------------------
|
---|
656 | //
|
---|
657 | // Add all data runs from the sequence to MDirIter.
|
---|
658 | // If path==0 fDataPath is used instead. If it is also empty
|
---|
659 | // the standard path of the data-center is assumed.
|
---|
660 | // If you have the runs locally use path="."
|
---|
661 | // Using raw=kTRUE you get correspodning raw-files setup.
|
---|
662 | // Return the number of files added.
|
---|
663 | //
|
---|
664 | // Runs which are in fExlRuns are ignored.
|
---|
665 | //
|
---|
666 | UInt_t MSequence::SetupDatRuns(MDirIter &iter, FileType_t type, const char *path) const
|
---|
667 | {
|
---|
668 | return SetupRuns(iter, fDatRuns, type, path);
|
---|
669 | }
|
---|
670 |
|
---|
671 | // --------------------------------------------------------------------------
|
---|
672 | //
|
---|
673 | // If you want to add runs manually, use this function.
|
---|
674 | //
|
---|
675 | UInt_t MSequence::AddRuns(UInt_t first, UInt_t last, TArrayI *runs)
|
---|
676 | {
|
---|
677 | if (last<first)
|
---|
678 | {
|
---|
679 | *fLog << warn << "MSequence::AddRuns - WARNING: Last runnumber " << last;
|
---|
680 | *fLog << " smaller than first " << first << "... ignored." << endl;
|
---|
681 | return 0;
|
---|
682 | }
|
---|
683 | if (!IsValid())
|
---|
684 | {
|
---|
685 | *fLog << inf << "Setting Sequence number to #" << first << endl;
|
---|
686 | fSequence = first;
|
---|
687 | }
|
---|
688 |
|
---|
689 | const UInt_t nall = fRuns.GetSize();
|
---|
690 | const UInt_t nrun = runs ? runs->GetSize() : 0;
|
---|
691 | const UInt_t add = last-first+1;
|
---|
692 |
|
---|
693 | fRuns.Set(nall+add);
|
---|
694 | if (runs)
|
---|
695 | runs->Set(nrun+add);
|
---|
696 |
|
---|
697 | for (UInt_t i=0; i<add; i++)
|
---|
698 | {
|
---|
699 | fRuns[nall+i] = first+i;
|
---|
700 | if (runs)
|
---|
701 | (*runs)[nrun+i] = first+i;
|
---|
702 | }
|
---|
703 | return add;
|
---|
704 | }
|
---|
705 |
|
---|
706 | Bool_t MSequence::IsContained(const TArrayI &arr, UInt_t run) const
|
---|
707 | {
|
---|
708 | for (int i=0; i<arr.GetSize(); i++)
|
---|
709 | if (run==(UInt_t)arr[i])
|
---|
710 | return kTRUE;
|
---|
711 | return kFALSE;
|
---|
712 | }
|
---|
713 |
|
---|
714 | /*
|
---|
715 | // --------------------------------------------------------------------------
|
---|
716 | //
|
---|
717 | // Check if num is found in arr. If it is found remove it. Copy all
|
---|
718 | // following entries one back and decrease the array size by 1.
|
---|
719 | //
|
---|
720 | void MSequence::ExcludeRun(TArrayI &arr, UInt_t num)
|
---|
721 | {
|
---|
722 | UInt_t *ptr = (UInt_t*)arr.GetArray();
|
---|
723 |
|
---|
724 | Int_t i = 0;
|
---|
725 | for (i=0; i<arr.GetSize(); i++)
|
---|
726 | if (ptr[i]==num)
|
---|
727 | break;
|
---|
728 |
|
---|
729 | if (i==arr.GetSize())
|
---|
730 | return;
|
---|
731 |
|
---|
732 | for (; i<arr.GetSize()-1; i++)
|
---|
733 | ptr[i] = ptr[i+1];
|
---|
734 |
|
---|
735 | arr.Set(arr.GetSize()-1);
|
---|
736 | }
|
---|
737 | */
|
---|
738 |
|
---|
739 | // --------------------------------------------------------------------------
|
---|
740 | //
|
---|
741 | // Exclude this run (i.e. add it to fExclRuns)
|
---|
742 | //
|
---|
743 | void MSequence::ExcludeRun(UInt_t num)
|
---|
744 | {
|
---|
745 | /*
|
---|
746 | ExcludeRun(fRuns, num);
|
---|
747 | ExcludeRun(fCalRuns, num);
|
---|
748 | ExcludeRun(fPedRuns, num);
|
---|
749 | ExcludeRun(fDatRuns, num);
|
---|
750 | */
|
---|
751 |
|
---|
752 | if (IsExcluded(num))
|
---|
753 | return;
|
---|
754 |
|
---|
755 | // set new entry
|
---|
756 | const Int_t n = fExclRuns.GetSize();
|
---|
757 | fExclRuns.Set(n+1);
|
---|
758 | fExclRuns[n] = num;
|
---|
759 |
|
---|
760 | MJob::SortArray(fExclRuns);
|
---|
761 | }
|
---|
762 |
|
---|
763 | // --------------------------------------------------------------------------
|
---|
764 | //
|
---|
765 | // Exclude all runs which are found in the list, e.g. "100 102 105"
|
---|
766 | //
|
---|
767 | void MSequence::ExcludeRuns(TString runs)
|
---|
768 | {
|
---|
769 | TArrayI data;
|
---|
770 | Split(runs, data);
|
---|
771 |
|
---|
772 | for (int i=0; i<data.GetSize(); i++)
|
---|
773 | ExcludeRun(data[i]);
|
---|
774 | }
|
---|
775 |
|
---|
776 | const TString MSequence::GetExcludedRuns() const
|
---|
777 | {
|
---|
778 | TString rc;
|
---|
779 | for (int i=0; i<fExclRuns.GetSize(); i++)
|
---|
780 | {
|
---|
781 | rc += fExclRuns[i];
|
---|
782 | rc += " ";
|
---|
783 | }
|
---|
784 | return rc(0, rc.Length()-1);
|
---|
785 | }
|
---|
786 |
|
---|
787 | // --------------------------------------------------------------------------
|
---|
788 | //
|
---|
789 | // If you want to change or set the night manually.
|
---|
790 | // The Format is
|
---|
791 | // SetNight("yyyy-mm-dd");
|
---|
792 | //
|
---|
793 | void MSequence::SetNight(const char *txt)
|
---|
794 | {
|
---|
795 | TString night(txt);
|
---|
796 | night += " 00:00:00";
|
---|
797 | fNight.SetSqlDateTime(night);
|
---|
798 |
|
---|
799 | fPeriod = MAstro::GetMagicPeriod(fNight.GetMjd());
|
---|
800 | }
|
---|
801 |
|
---|
802 | // --------------------------------------------------------------------------
|
---|
803 | //
|
---|
804 | // If the sequence name seq is just a digit it is inflated to a full
|
---|
805 | // path following the datacenter standard.
|
---|
806 | //
|
---|
807 | // Returns if file accessible or not.
|
---|
808 | //
|
---|
809 | Bool_t MSequence::InflatePath(TString &seq, Bool_t ismc)
|
---|
810 | {
|
---|
811 | if (seq.IsDigit())
|
---|
812 | {
|
---|
813 | const Int_t numseq = seq.Atoi();
|
---|
814 | seq = "/magic/";
|
---|
815 | if (ismc)
|
---|
816 | seq += "montecarlo/";
|
---|
817 | seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
|
---|
818 | gLog << inf << "Inflated sequence file: " << seq << endl;
|
---|
819 | }
|
---|
820 |
|
---|
821 | if (!gSystem->AccessPathName(seq, kFileExists))
|
---|
822 | return kTRUE;
|
---|
823 |
|
---|
824 | gLog << err << "Sorry, sequence file '" << seq << "' doesn't exist." << endl;
|
---|
825 | return kFALSE;
|
---|
826 | }
|
---|
827 |
|
---|