| 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 char *path) const
|
|---|
| 66 | {
|
|---|
| 67 | TString d(path);
|
|---|
| 68 |
|
|---|
| 69 | // Setup path
|
|---|
| 70 | if (!path)
|
|---|
| 71 | {
|
|---|
| 72 | d = Form("/data/MAGIC/Period%03d/rootdata/", fPeriod);
|
|---|
| 73 | d += fNight.GetStringFmt("%Y_%m_%d");
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | for (int i=0; i<arr.GetSize(); i++)
|
|---|
| 77 | {
|
|---|
| 78 | TString n;
|
|---|
| 79 |
|
|---|
| 80 | // Create file name
|
|---|
| 81 | n = fNight.GetStringFmt("%Y%m%d_");
|
|---|
| 82 | n += Form("%05d_*_E.root", arr[i]);
|
|---|
| 83 |
|
|---|
| 84 | // Add Path/File to TIter
|
|---|
| 85 | iter.AddDirectory(d, n, 0);
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | MSequence::MSequence(const char *fname)
|
|---|
| 90 | {
|
|---|
| 91 | fName = fname;
|
|---|
| 92 | fTitle = Form("Sequence contained in file %s", fName.Data());
|
|---|
| 93 |
|
|---|
| 94 | TEnv env(fname);
|
|---|
| 95 |
|
|---|
| 96 | TString str;
|
|---|
| 97 |
|
|---|
| 98 | fSequence = env.GetValue("Sequence", -1);
|
|---|
| 99 | fLastRun = env.GetValue("LastRun", -1);
|
|---|
| 100 | fNumEvents = env.GetValue("NumEvents", -1);
|
|---|
| 101 | fPeriod = env.GetValue("Period", -1);
|
|---|
| 102 |
|
|---|
| 103 | str = env.GetValue("Start", "");
|
|---|
| 104 | fStart.SetSqlDateTime(str);
|
|---|
| 105 | str = env.GetValue("Night", "");
|
|---|
| 106 | str += " 00:00:00";
|
|---|
| 107 | fNight.SetSqlDateTime(str);
|
|---|
| 108 |
|
|---|
| 109 | fProject = env.GetValue("Project", "");
|
|---|
| 110 | fSource = env.GetValue("Source", "");
|
|---|
| 111 | fTriggerTable = env.GetValue("TriggerTable", "");
|
|---|
| 112 | fHvSettings = env.GetValue("HvSettings", "");
|
|---|
| 113 |
|
|---|
| 114 | str = env.GetValue("Runs", "");
|
|---|
| 115 | Split(str, fRuns);
|
|---|
| 116 | str = env.GetValue("CalRuns", "");
|
|---|
| 117 | Split(str, fCalRuns);
|
|---|
| 118 | str = env.GetValue("PedRuns", "");
|
|---|
| 119 | Split(str, fPedRuns);
|
|---|
| 120 | str = env.GetValue("DatRuns", "");
|
|---|
| 121 | Split(str, fDatRuns);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | void MSequence::Print(Option_t *o) const
|
|---|
| 125 | {
|
|---|
| 126 | gLog << all;
|
|---|
| 127 | gLog << "Sequence: " << fSequence << endl;
|
|---|
| 128 | gLog << "Period: " << fPeriod << endl;
|
|---|
| 129 | gLog << "Night: " << fNight << endl << endl;
|
|---|
| 130 | gLog << "Start: " << fStart << endl;
|
|---|
| 131 | gLog << "LastRun: " << fLastRun << endl;
|
|---|
| 132 | gLog << "NumEvents: " << fNumEvents << endl;
|
|---|
| 133 | gLog << "Project: " << fProject << endl;
|
|---|
| 134 | gLog << "Source: " << fSource << endl;
|
|---|
| 135 | gLog << "TriggerTable: " << fTriggerTable << endl;
|
|---|
| 136 | gLog << "HvSettings: " << fHvSettings << endl << endl;
|
|---|
| 137 | gLog << "Runs:";
|
|---|
| 138 | for (int i=0; i<fRuns.GetSize(); i++)
|
|---|
| 139 | gLog << " " << fRuns[i];
|
|---|
| 140 | gLog << endl;
|
|---|
| 141 | gLog << "CalRuns:";
|
|---|
| 142 | for (int i=0; i<fCalRuns.GetSize(); i++)
|
|---|
| 143 | gLog << " " << fCalRuns[i];
|
|---|
| 144 | gLog << endl;
|
|---|
| 145 | gLog << "PedRuns:";
|
|---|
| 146 | for (int i=0; i<fPedRuns.GetSize(); i++)
|
|---|
| 147 | gLog << " " << fPedRuns[i];
|
|---|
| 148 | gLog << endl;
|
|---|
| 149 | gLog << "DatRuns:";
|
|---|
| 150 | for (int i=0; i<fDatRuns.GetSize(); i++)
|
|---|
| 151 | gLog << " " << fDatRuns[i];
|
|---|
| 152 | gLog << endl;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | void MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
|
|---|
| 156 | {
|
|---|
| 157 | SetupRuns(iter, fPedRuns, path);
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | void MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
|
|---|
| 161 | {
|
|---|
| 162 | SetupRuns(iter, fDatRuns, path);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | void MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
|
|---|
| 166 | {
|
|---|
| 167 | SetupRuns(iter, fRuns, path);
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | void MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
|
|---|
| 171 | {
|
|---|
| 172 | SetupRuns(iter, fCalRuns, path);
|
|---|
| 173 | }
|
|---|