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

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