source: trunk/MagicSoft/Mars/mdata/MDataArray.cc@ 1521

Last change on this file since 1521 was 1499, checked in by wittek, 22 years ago
Default argument opt=" " removed (Alpha-problem)
File size: 3.0 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 08/2002 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MDataArray
28//
29/////////////////////////////////////////////////////////////////////////////
30#include "MDataArray.h"
31
32#include <fstream.h>
33
34#include "MLog.h"
35#include "MLogManip.h"
36
37#include "MDataChain.h"
38
39ClassImp(MDataArray);
40
41static const TString gsDefName = "MDataArray";
42static const TString gsDefTitle = "Array to store MData cntainers";
43
44MDataArray::MDataArray(const char *name, const char *title)
45{
46 fName = name ? name : gsDefName.Data();
47 fTitle = title ? title : gsDefTitle.Data();
48}
49
50void MDataArray::AddEntry(const TString rule)
51{
52 TObject *obj = new MDataChain(rule);
53 obj->SetBit(kCanDelete);
54 fList.Add(obj);
55}
56
57MData &MDataArray::operator[](Int_t i) const
58{
59 return (MData&)*((TObjArray)fList)[i];
60}
61
62Double_t MDataArray::operator()(Int_t i)
63{
64 return ((MData*)fList[i])->GetValue();
65}
66
67Bool_t MDataArray::PreProcess(const MParList *plist)
68{
69 if (fList.GetSize()==0)
70 {
71 *fLog << err << "Error - No Column specified... aborting." << endl;
72 return kFALSE;
73 }
74
75 TIter Next(&fList);
76 MData *data = NULL;
77 while ((data=(MData*)Next()))
78 if (!data->PreProcess(plist))
79 return kFALSE;
80
81 return kTRUE;
82}
83
84void MDataArray::Print(Option_t *opt) const
85{
86 Int_t n=0;
87
88 TIter Next(&fList);
89 MData *data = NULL;
90 while ((data=(MData*)Next()))
91 {
92 *fLog << all << " Line " << setw(3) << n++ << ": " << flush;
93 data->Print();
94 *fLog << endl;
95 }
96}
97
98Bool_t MDataArray::AsciiWrite(ostream &out) const
99{
100 ((TObjArray)fList).ForEach(MParContainer, AsciiWrite)(out);
101 return kTRUE;
102}
103
104void MDataArray::StreamPrimitive(ofstream &out) const
105{
106 out << " MDataArray " << GetUniqueName();
107
108 if (fName!=gsDefName)
109 {
110 out << "(\"" << fName << "\"";
111 if (fTitle!=gsDefTitle)
112 out << ", \"" << fTitle << "\")";
113 }
114 out << ";" << endl;
115
116 TIter Next(&fList);
117 MData *data = NULL;
118 while ((data=(MData*)Next()))
119 out << " " << GetUniqueName() << ".AddEntry(\"" << data->GetRule() << "\");" << endl;
120}
Note: See TracBrowser for help on using the repository browser.