source: trunk/MagicSoft/Mars/mjobs/MSequence.cc@ 8902

Last change on this file since 8902 was 8795, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 23.6 KB
Line 
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
149ClassImp(MSequence);
150
151using namespace std;
152
153MSequence::~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//
172void 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
215UInt_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
401MSequence::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("NoMoon", TString::kIgnoreCase))
409 return kNoMoon;
410 if (!str.CompareTo("Twilight", TString::kIgnoreCase))
411 return kTwilight;
412 if (!str.CompareTo("Moon", TString::kIgnoreCase))
413 return kMoon;
414 if (!str.CompareTo("Day", TString::kIgnoreCase))
415 return kDay;
416
417 gLog << warn;
418 gLog << "WARNING - in " << fFileName << ":" << endl;
419 gLog << " LightCondition-tag is '" << str << "' but must be n/a, no_moon, twilight, moon or day." << endl;
420 return kNA;
421}
422
423// --------------------------------------------------------------------------
424//
425// Read the file fname as setup file for the sequence.
426//
427MSequence::MSequence(const char *fname, const char *path, UInt_t seq)
428{
429 fName = fname;
430 fTitle = path;
431
432 fFileName = fname;
433 fDataPath = path;
434
435 gSystem->ExpandPathName(fName);
436 gSystem->ExpandPathName(fTitle);
437
438 const Bool_t rc1 = gSystem->AccessPathName(fName, kFileExists);
439 const Bool_t rc2 = !fTitle.IsNull() && gSystem->AccessPathName(fTitle, kFileExists);
440
441 if (rc1)
442 gLog << err << "ERROR - Sequence file '" << fName << "' doesn't exist." << endl;
443 if (rc2)
444 gLog << err << "ERROR - Directory '" << fTitle << "' doesn't exist." << endl;
445
446 MEnv env(fName);
447
448 fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq);
449 if (rc1 || rc2)
450 fSequence = (UInt_t)-1;
451
452 const TString prefix = Form("Sequence%08d", fSequence);
453
454 fLastRun = GetEnvValue2(env, prefix, "LastRun", -1);
455 fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
456 fPeriod = GetEnvValue2(env, prefix, "Period", -1);
457
458 fLightCondition = ReadLightCondition(env, prefix);
459
460 TString str;
461 str = GetEnvValue2(env, prefix, "Start", "");
462 fStart.SetSqlDateTime(str);
463 str = GetEnvValue2(env, prefix, "Night", "");
464 str += " 00:00:00";
465 fNight.SetSqlDateTime(str);
466
467 fProject = GetEnvValue2(env, prefix, "Project", "");
468 fSource = GetEnvValue2(env, prefix, "Source", "");
469 fTriggerTable = GetEnvValue2(env, prefix, "TriggerTable", "");
470 fHvSettings = GetEnvValue2(env, prefix, "HvSettings", "");
471 fMonteCarlo = GetEnvValue2(env, prefix, "MonteCarlo", kFALSE);
472 fComment = GetEnvValue2(env, prefix, "Comment", "");
473
474 str = GetEnvValue2(env, prefix, "Runs", "");
475 Split(str, fRuns);
476 str = GetEnvValue2(env, prefix, "CalRuns", "");
477 Split(str, fCalRuns);
478 str = GetEnvValue2(env, prefix, "PedRuns", "");
479 Split(str, fPedRuns);
480 str = GetEnvValue2(env, prefix, "DatRuns", "");
481 Split(str, fDatRuns);
482 str = GetEnvValue2(env, prefix, "Exclude", "");
483 Split(str, fExclRuns);
484
485 // GetFileNames(env, fRuns);
486 // GetFileNames(env, fCalRuns);
487 // GetFileNames(env, fPedRuns);
488 // GetFileNames(env, fDatRuns);
489
490 // Dummies:
491 env.Touch("ZdMin");
492 env.Touch("ZdMax");
493 env.Touch("L1TriggerTable");
494 env.Touch("L2TriggerTable");
495
496 if (seq<0 && env.GetNumUntouched()>0)
497 {
498 gLog << warn << "WARNING - At least one resource in the sequence-file has not been touched!" << endl;
499 env.PrintUntouched();
500 }
501}
502
503//---------------------------------------------------------------------------
504//
505// Make sure that the name used for writing doesn't contain a full path
506//
507const char *MSequence::GetName() const
508{
509 const char *pos = strrchr(GetRcName(), '/');
510 return pos>0 ? pos+1 : GetRcName();
511}
512
513// --------------------------------------------------------------------------
514//
515// Print the contents of the sequence
516//
517void MSequence::Print(Option_t *o) const
518{
519 const TString pre = TString(o).Contains("prefixed") ? Form("Sequence%08d.", fSequence) : "";
520
521 gLog << all;
522 if (!IsValid())
523 {
524 gLog << pre << "Sequence: " << fFileName << " <invalid>" << endl;
525 return;
526 }
527 gLog << "# Path: " << GetRcName() << endl;
528 gLog << "# Name: " << GetName() << endl;
529 gLog << endl;
530 if (pre.IsNull())
531 gLog << "Sequence: " << fSequence << endl;
532 if (fMonteCarlo)
533 gLog << pre << "MonteCarlo: Yes" << endl;
534 gLog << pre <<"Period: " << fPeriod << endl;
535 gLog << pre << "Night: " << fNight << endl << endl;
536 gLog << pre << "LightCondition: ";
537 switch (fLightCondition)
538 {
539 case kNA: gLog << "n/a" << endl; break;
540 case kNoMoon: gLog << "NoMoon" << endl; break;
541 case kTwilight: gLog << "Twilight" << endl; break;
542 case kMoon: gLog << "Moon" << endl; break;
543 case kDay: gLog << "Day" << endl; break;
544 }
545 gLog << pre << "Start: " << fStart << endl;
546 gLog << pre << "LastRun: " << fLastRun << endl;
547 gLog << pre << "NumEvents: " << fNumEvents << endl;
548 gLog << pre << "Project: " << fProject << endl;
549 gLog << pre << "Source: " << fSource << endl;
550 gLog << pre << "TriggerTable: " << fTriggerTable << endl;
551 gLog << pre << "HvSettings: " << fHvSettings << endl << endl;
552 if (fRuns.GetSize()>0)
553 {
554 gLog << pre << "Runs:";
555 for (int i=0; i<fRuns.GetSize(); i++)
556 gLog << " " << fRuns[i];
557 gLog << endl;
558 }
559 if (fCalRuns.GetSize()>0)
560 {
561 gLog << pre << "CalRuns:";
562 for (int i=0; i<fCalRuns.GetSize(); i++)
563 gLog << " " << fCalRuns[i];
564 gLog << endl;
565 }
566 if (fPedRuns.GetSize()>0)
567 {
568 gLog << pre << "PedRuns:";
569 for (int i=0; i<fPedRuns.GetSize(); i++)
570 gLog << " " << fPedRuns[i];
571 gLog << endl;
572 }
573 if (fDatRuns.GetSize()>0)
574 {
575 gLog << pre << "DatRuns:";
576 for (int i=0; i<fDatRuns.GetSize(); i++)
577 gLog << " " << fDatRuns[i];
578 gLog << endl;
579 }
580 if (fExclRuns.GetSize()>0)
581 {
582 gLog << pre << "Exclude:";
583 for (int i=0; i<fExclRuns.GetSize(); i++)
584 gLog << " " << fExclRuns[i];
585 gLog << endl;
586 }
587 if (!fDataPath.IsNull())
588 gLog << endl << pre << "DataPath: " << fDataPath << endl;
589
590 gLog << endl << pre << "Comment: " << fComment << endl;
591}
592
593// --------------------------------------------------------------------------
594//
595// Add all ped runs from the sequence to MDirIter.
596// If path==0 fDataPath is used instead. If it is also empty
597// the standard path of the data-center is assumed.
598// If you have the runs locally use path="."
599// Using raw=kTRUE you get correspodning raw-files setup.
600// Return the number of files added.
601//
602// Runs which are in fExlRuns are ignored.
603//
604UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
605{
606 return SetupRuns(iter, fPedRuns, raw?kRawPed:kRootPed, path);
607}
608
609// --------------------------------------------------------------------------
610//
611// Add all data runs from the sequence to MDirIter.
612// If path==0 fDataPath is used instead. If it is also empty
613// the standard path of the data-center is assumed.
614// If you have the runs locally use path="."
615// Using raw=kTRUE you get correspodning raw-files setup.
616// Return the number of files added.
617//
618// Runs which are in fExlRuns are ignored.
619//
620UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const
621{
622 return SetupRuns(iter, fDatRuns, raw?kRawDat:kRootDat, path);
623}
624
625// --------------------------------------------------------------------------
626//
627// Add all runs from the sequence to MDirIter.
628// If path==0 fDataPath is used instead. If it is also empty
629// the standard path of the data-center is assumed.
630// If you have the runs locally use path="."
631// Using raw=kTRUE you get correspodning raw-files setup.
632// Return the number of files added.
633//
634// Runs which are in fExlRuns are ignored.
635//
636UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const
637{
638 return SetupRuns(iter, fRuns, raw?kRawAll:kRootAll, path);
639}
640
641// --------------------------------------------------------------------------
642//
643// Add all calibration runs from the sequence to MDirIter.
644// If path==0 fDataPath is used instead. If it is also empty
645// the standard path of the data-center is assumed.
646// If you have the runs locally use path="."
647// Using raw=kTRUE you get correspodning raw-files setup.
648// Return the number of files added.
649//
650// Runs which are in fExlRuns are ignored.
651//
652UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const
653{
654 return SetupRuns(iter, fCalRuns, raw?kRawCal:kRootCal, path);
655}
656
657// --------------------------------------------------------------------------
658//
659// Add all data runs from the sequence to MDirIter.
660// If path==0 fDataPath is used instead. If it is also empty
661// the standard path of the data-center is assumed.
662// If you have the runs locally use path="."
663// Using raw=kTRUE you get correspodning raw-files setup.
664// Return the number of files added.
665//
666// Runs which are in fExlRuns are ignored.
667//
668UInt_t MSequence::SetupDatRuns(MDirIter &iter, FileType_t type, const char *path) const
669{
670 return SetupRuns(iter, fDatRuns, type, path);
671}
672
673// --------------------------------------------------------------------------
674//
675// If you want to add runs manually, use this function.
676//
677UInt_t MSequence::AddRuns(UInt_t first, UInt_t last, TArrayI *runs)
678{
679 if (last<first)
680 {
681 *fLog << warn << "MSequence::AddRuns - WARNING: Last runnumber " << last;
682 *fLog << " smaller than first " << first << "... ignored." << endl;
683 return 0;
684 }
685 if (!IsValid())
686 {
687 *fLog << inf << "Setting Sequence number to #" << first << endl;
688 fSequence = first;
689 }
690
691 const UInt_t nall = fRuns.GetSize();
692 const UInt_t nrun = runs ? runs->GetSize() : 0;
693 const UInt_t add = last-first+1;
694
695 fRuns.Set(nall+add);
696 if (runs)
697 runs->Set(nrun+add);
698
699 for (UInt_t i=0; i<add; i++)
700 {
701 fRuns[nall+i] = first+i;
702 if (runs)
703 (*runs)[nrun+i] = first+i;
704 }
705 return add;
706}
707
708Bool_t MSequence::IsContained(const TArrayI &arr, UInt_t run) const
709{
710 for (int i=0; i<arr.GetSize(); i++)
711 if (run==(UInt_t)arr[i])
712 return kTRUE;
713 return kFALSE;
714}
715
716/*
717// --------------------------------------------------------------------------
718//
719// Check if num is found in arr. If it is found remove it. Copy all
720// following entries one back and decrease the array size by 1.
721//
722void MSequence::ExcludeRun(TArrayI &arr, UInt_t num)
723{
724 UInt_t *ptr = (UInt_t*)arr.GetArray();
725
726 Int_t i = 0;
727 for (i=0; i<arr.GetSize(); i++)
728 if (ptr[i]==num)
729 break;
730
731 if (i==arr.GetSize())
732 return;
733
734 for (; i<arr.GetSize()-1; i++)
735 ptr[i] = ptr[i+1];
736
737 arr.Set(arr.GetSize()-1);
738}
739*/
740
741// --------------------------------------------------------------------------
742//
743// Exclude this run (i.e. add it to fExclRuns)
744//
745void MSequence::ExcludeRun(UInt_t num)
746{
747 /*
748 ExcludeRun(fRuns, num);
749 ExcludeRun(fCalRuns, num);
750 ExcludeRun(fPedRuns, num);
751 ExcludeRun(fDatRuns, num);
752 */
753
754 if (IsExcluded(num))
755 return;
756
757 // set new entry
758 const Int_t n = fExclRuns.GetSize();
759 fExclRuns.Set(n+1);
760 fExclRuns[n] = num;
761
762 MJob::SortArray(fExclRuns);
763}
764
765// --------------------------------------------------------------------------
766//
767// Exclude all runs which are found in the list, e.g. "100 102 105"
768//
769void MSequence::ExcludeRuns(TString runs)
770{
771 TArrayI data;
772 Split(runs, data);
773
774 for (int i=0; i<data.GetSize(); i++)
775 ExcludeRun(data[i]);
776}
777
778const TString MSequence::GetExcludedRuns() const
779{
780 TString rc;
781 for (int i=0; i<fExclRuns.GetSize(); i++)
782 {
783 rc += fExclRuns[i];
784 rc += " ";
785 }
786 return rc(0, rc.Length()-1);
787}
788
789// --------------------------------------------------------------------------
790//
791// If you want to change or set the night manually.
792// The Format is
793// SetNight("yyyy-mm-dd");
794//
795void MSequence::SetNight(const char *txt)
796{
797 TString night(txt);
798 night += " 00:00:00";
799 fNight.SetSqlDateTime(night);
800
801 fPeriod = MAstro::GetMagicPeriod(fNight.GetMjd());
802}
803
804// --------------------------------------------------------------------------
805//
806// If the sequence name seq is just a digit it is inflated to a full
807// path following the datacenter standard.
808//
809// Returns if file accessible or not.
810//
811Bool_t MSequence::InflatePath(TString &seq, Bool_t ismc)
812{
813 if (seq.IsDigit())
814 {
815 const Int_t numseq = seq.Atoi();
816 seq = "/magic/";
817 if (ismc)
818 seq += "montecarlo/";
819 seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
820 gLog << inf << "Inflated sequence file: " << seq << endl;
821 }
822
823 if (!gSystem->AccessPathName(seq, kFileExists))
824 return kTRUE;
825
826 gLog << err << "Sorry, sequence file '" << seq << "' doesn't exist." << endl;
827 return kFALSE;
828}
829
Note: See TracBrowser for help on using the repository browser.