source: trunk/MagicSoft/Mars/mdata/MDataElement.cc@ 2098

Last change on this file since 2098 was 2098, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.4 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 04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MDataElement
28//
29// This MData class is used for accessing a column of an MHMatrix object.
30// eg. MDataElement("Matrix", 5)
31// will return the 5th column of the MHMatrix object called Matrix.
32//
33// The row which is accessed must be set before by using
34// MHMatrix::SetNumRow. If you want to loop through a matrix use
35// MMatrixLoop.
36//
37/////////////////////////////////////////////////////////////////////////////
38#include "MDataElement.h"
39
40#include <fstream.h>
41
42#include "MHMatrix.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MParList.h"
48
49ClassImp(MDataElement);
50
51// --------------------------------------------------------------------------
52//
53// Specify the name of the MHMatrix-object and the column you want to
54// access.
55//
56MDataElement::MDataElement(const char *member, Int_t col)
57 : fMatrixName(member), fNumCol(col), fMatrix(NULL)
58{
59}
60
61// --------------------------------------------------------------------------
62//
63// Specify the pointer of the MHMatrix-object and the column you want to
64// access.
65//
66MDataElement::MDataElement(MHMatrix *mat, Int_t col)
67 : fMatrixName(mat->GetName()), fNumCol(col), fMatrix(mat)
68{
69}
70
71// --------------------------------------------------------------------------
72//
73// returns the value you requested
74//
75Double_t MDataElement::GetValue() const
76{
77 return fMatrix ? (*fMatrix)[fNumCol] : 0;
78}
79
80// --------------------------------------------------------------------------
81//
82// If the pointer to the MHMatrix isn't yet set search for it in the
83// parameter list.
84//
85Bool_t MDataElement::PreProcess(const MParList *plist)
86{
87 if (fMatrix)
88 return kTRUE;
89
90 fMatrix = (MHMatrix*)plist->FindObject(fMatrixName, "MHMatrix");
91 if (!fMatrix)
92 {
93 *fLog << err << "MHMatrix '" << fMatrixName << "' not in parameter list... aborting." << endl;
94 return kFALSE;
95 }
96
97 return kTRUE;
98}
99
100// --------------------------------------------------------------------------
101//
102// Returns the ready-to-save flag of the data member container
103//
104Bool_t MDataElement::IsReadyToSave() const
105{
106 return IsValid() ? fMatrix->IsReadyToSave() : kFALSE;
107}
108
109// --------------------------------------------------------------------------
110//
111// Return the rule used to identify this object in a datachain
112//
113TString MDataElement::GetRule() const
114{
115 TString rule = fMatrixName + "[";
116 rule += fNumCol;
117 rule += "]";
118 return rule;
119}
Note: See TracBrowser for help on using the repository browser.