source: trunk/MagicSoft/Mars/mfileio/MRead.cc@ 1896

Last change on this file since 1896 was 1896, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.1 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 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
42ClassImp(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//
55Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
56{
57 //
58 // Don't allow 'global' setup of files
59 //
60 if (prefix.IsNull())
61 return kFALSE;
62
63 //
64 // Search (beginning with 0) all keys
65 //
66 for (int i=0;; i++)
67 {
68 TString idx = "File";
69 idx += i;
70
71 // Output if print set to kTRUE
72 IsEnvDefined(env, prefix, idx, print);
73
74 // Try to get the file name
75 TString name = GetEnvValue(env, prefix, idx, "");
76 if (name.IsNull())
77 break;
78
79 if (name.BeginsWith("\"") && name.EndsWith("\""))
80 {
81 name.Remove(name.Last('\"'), 1);
82 name.Remove(name.First('\"'), 1);
83 }
84
85 if (print)
86 *fLog << all << "Add File: " << name << endl;
87 AddFile(name);
88 }
89
90 return kTRUE;
91}
Note: See TracBrowser for help on using the repository browser.