source: trunk/MagicSoft/Mars/mbase/MReadMarsFile.cc@ 1084

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