source: tags/Mars-V0.5/mbase/MReadMarsFile.cc

Last change on this file was 1036, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.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 (tbretz@uni-sw.gwdg.de)
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MReadMarsFile //
28// //
29// This task works more or less like MReadTree, but in addition PreProcess //
30// reads all the information from the 'RunHeader' tree. //
31// //
32// Warning: Until now this works only for 'one run header per file' //
33// //
34/////////////////////////////////////////////////////////////////////////////
35
36#include "MReadMarsFile.h"
37
38#include "MLog.h"
39
40ClassImp(MReadMarsFile);
41
42// --------------------------------------------------------------------------
43//
44// Default constructor. It creates a MReadTree object to read the
45// RunHeaders and disables Auto Scheme for this tree.
46//
47MReadMarsFile::MReadMarsFile(const char *tname, const char *fname,
48 const char *name, const char *title)
49 : MReadTree(tname, fname)
50{
51 fName = name ? name : "MReadMarsFile";
52 fTitle = title ? title : "Task to loop over all events in a tree of a Mars file.";
53
54 //
55 // open the input stream
56 //
57 fRun = new MReadTree("RunHeaders", fname);
58 fRun->DisableAutoScheme();
59}
60
61// --------------------------------------------------------------------------
62//
63// Destructor. Deleted the MReadTree object for the RunHeaders
64//
65MReadMarsFile::~MReadMarsFile()
66{
67 delete fRun;
68}
69
70// --------------------------------------------------------------------------
71//
72// see MReadTree::AddFile, too. The file is also added to the chain for
73// the run headers. If adding file gives a different result for both
74// chains -1 is returned, otherwise the number of files which were added.
75//
76Int_t MReadMarsFile::AddFile(const char *fname)
77{
78 //
79 // FIXME! A check is missing whether the file already exists or not.
80 //
81 //
82 // returns the number of file which were added
83 //
84 Int_t n1 = fRun->AddFile(fname);
85 Int_t n2 = MReadTree::AddFile(fname);
86
87 return n1 != n2 ? -1 : n1;
88}
89
90// --------------------------------------------------------------------------
91//
92// This overload MReadTree::Notify. Before the MReadTree Notify
93// TObjects are called the RunHeaders of the next files are read.
94//
95// WARNING: This doesn't work correctly yet, if the files are not read in
96// increasing order.
97//
98Bool_t MReadMarsFile::Notify()
99{
100 if (GetEventNum() == 0)
101 return kTRUE;
102
103 *fLog << "MReadMarsFile: Switching to next file '" << GetFileName() << "' ";
104 *fLog << "(before Event #" << GetEventNum()-1 << ")" << endl;
105 fRun->Process();
106
107 MReadTree::Notify();
108
109 return kTRUE;
110}
111
112// --------------------------------------------------------------------------
113//
114// PreProcessed the MReadTree to read the run headers and its base class.
115// see MReadTree::PreProcess for more information
116//
117Bool_t MReadMarsFile::PreProcess(MParList *pList)
118{
119 if (!fRun->PreProcess(pList))
120 return kFALSE;
121
122 return MReadTree::PreProcess(pList);
123}
124
Note: See TracBrowser for help on using the repository browser.