| 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 | ClassImp(MRead);
|
|---|
| 40 |
|
|---|
| 41 | // --------------------------------------------------------------------------
|
|---|
| 42 | //
|
|---|
| 43 | // Read the setup from a TEnv:
|
|---|
| 44 | // File0, File1, File2, ..., File10, ..., File100, ...
|
|---|
| 45 | //
|
|---|
| 46 | // Searching stops if the first key isn't found in the TEnv
|
|---|
| 47 | //
|
|---|
| 48 | // Enclosing quotation marks (") are removed
|
|---|
| 49 | //
|
|---|
| 50 | // Number of entries at the moment not supported
|
|---|
| 51 | //
|
|---|
| 52 | Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
|---|
| 53 | {
|
|---|
| 54 | //
|
|---|
| 55 | // Don't allow 'global' setup of files
|
|---|
| 56 | //
|
|---|
| 57 | if (prefix.IsNull())
|
|---|
| 58 | return kFALSE;
|
|---|
| 59 |
|
|---|
| 60 | //
|
|---|
| 61 | // Search (beginning with 0) all keys
|
|---|
| 62 | //
|
|---|
| 63 | for (int i=0;; i++)
|
|---|
| 64 | {
|
|---|
| 65 | TString idx = "File";
|
|---|
| 66 | idx += i;
|
|---|
| 67 |
|
|---|
| 68 | // Output if print set to kTRUE
|
|---|
| 69 | IsEnvDefined(env, prefix, idx, print);
|
|---|
| 70 |
|
|---|
| 71 | // Try to get the file name
|
|---|
| 72 | TString name = GetEnvValue(env, prefix, idx, "");
|
|---|
| 73 | if (name.IsNull())
|
|---|
| 74 | return kTRUE;
|
|---|
| 75 |
|
|---|
| 76 | if (name.BeginsWith("\"") && name.EndsWith("\""))
|
|---|
| 77 | {
|
|---|
| 78 | name.Remove(name.Last('\"'), 1);
|
|---|
| 79 | name.Remove(name.First('\"'), 1);
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | AddFile(name);
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | return kTRUE;
|
|---|
| 86 | }
|
|---|