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-2003
|
---|
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 | using namespace std;
|
---|
45 |
|
---|
46 | Bool_t MRead::Rewind()
|
---|
47 | {
|
---|
48 | *fLog << err << "ERROR - Rewind() not implemented for " << GetDescriptor() << endl;
|
---|
49 | return kFALSE;
|
---|
50 | }
|
---|
51 |
|
---|
52 | // --------------------------------------------------------------------------
|
---|
53 | //
|
---|
54 | // Read the setup from a TEnv:
|
---|
55 | // File0, File1, File2, ..., File10, ..., File100, ...
|
---|
56 | //
|
---|
57 | // Searching stops if the first key isn't found in the TEnv
|
---|
58 | //
|
---|
59 | // Enclosing quotation marks (") are removed
|
---|
60 | //
|
---|
61 | // Number of entries at the moment not supported
|
---|
62 | //
|
---|
63 | Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
64 | {
|
---|
65 | //
|
---|
66 | // Search (beginning with 0) all keys
|
---|
67 | //
|
---|
68 | int i=0;
|
---|
69 | while (1)
|
---|
70 | {
|
---|
71 | TString idx = "File";
|
---|
72 | idx += i;
|
---|
73 |
|
---|
74 | // Output if print set to kTRUE
|
---|
75 | if (!IsEnvDefined(env, prefix, idx, print))
|
---|
76 | break;
|
---|
77 |
|
---|
78 | // Try to get the file name
|
---|
79 | TString name = GetEnvValue(env, prefix, idx, "");
|
---|
80 | if (name.IsNull())
|
---|
81 | {
|
---|
82 | *fLog << warn << prefix+"."+idx << " empty." << endl;
|
---|
83 | continue;
|
---|
84 | }
|
---|
85 |
|
---|
86 | if (name.BeginsWith("\"") && name.EndsWith("\""))
|
---|
87 | {
|
---|
88 | name.Remove(name.Last('\"'), 1);
|
---|
89 | name.Remove(name.First('\"'), 1);
|
---|
90 | }
|
---|
91 |
|
---|
92 | *fLog << inf << "Add File: " << name << endl;
|
---|
93 |
|
---|
94 | AddFile(name);
|
---|
95 | i++;
|
---|
96 | }
|
---|
97 |
|
---|
98 | return i!=0;
|
---|
99 | }
|
---|