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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | // //
|
---|
27 | // MRead //
|
---|
28 | // //
|
---|
29 | // Base class for all reading tasks //
|
---|
30 | // //
|
---|
31 | // You can set a selector. Depending on the impelementation in the derived //
|
---|
32 | // class it can be used to skip events, if the filter return kFALSE. //
|
---|
33 | // Make sure that the selector (filter) doesn't need information which //
|
---|
34 | // doesn't exist before reading an event! //
|
---|
35 | // //
|
---|
36 | /////////////////////////////////////////////////////////////////////////////
|
---|
37 | #include "MRead.h"
|
---|
38 |
|
---|
39 | #include "MLog.h"
|
---|
40 | #include "MLogManip.h"
|
---|
41 |
|
---|
42 | ClassImp(MRead);
|
---|
43 |
|
---|
44 | // --------------------------------------------------------------------------
|
---|
45 | //
|
---|
46 | // Read the setup from a TEnv:
|
---|
47 | // File0, File1, File2, ..., File10, ..., File100, ...
|
---|
48 | //
|
---|
49 | // Searching stops if the first key isn't found in the TEnv
|
---|
50 | //
|
---|
51 | // Enclosing quotation marks (") are removed
|
---|
52 | //
|
---|
53 | // Number of entries at the moment not supported
|
---|
54 | //
|
---|
55 | Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
56 | {
|
---|
57 | //
|
---|
58 | // Search (beginning with 0) all keys
|
---|
59 | //
|
---|
60 | int i=0;
|
---|
61 | while (1)
|
---|
62 | {
|
---|
63 | TString idx = "File";
|
---|
64 | idx += i;
|
---|
65 |
|
---|
66 | // Output if print set to kTRUE
|
---|
67 | if (!IsEnvDefined(env, prefix, idx, print))
|
---|
68 | break;
|
---|
69 |
|
---|
70 | // Try to get the file name
|
---|
71 | TString name = GetEnvValue(env, prefix, idx, "");
|
---|
72 | if (name.IsNull())
|
---|
73 | {
|
---|
74 | *fLog << warn << prefix+"."+idx << " empty." << endl;
|
---|
75 | continue;
|
---|
76 | }
|
---|
77 |
|
---|
78 | if (name.BeginsWith("\"") && name.EndsWith("\""))
|
---|
79 | {
|
---|
80 | name.Remove(name.Last('\"'), 1);
|
---|
81 | name.Remove(name.First('\"'), 1);
|
---|
82 | }
|
---|
83 |
|
---|
84 | *fLog << inf << "Add File: " << name << endl;
|
---|
85 |
|
---|
86 | AddFile(name);
|
---|
87 | i++;
|
---|
88 | }
|
---|
89 |
|
---|
90 | return i!=0;
|
---|
91 | }
|
---|