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>
|
---|
41 |
|
---|
42 | #include "MHMatrix.h"
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MParList.h"
|
---|
48 |
|
---|
49 | ClassImp(MDataElement);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | // --------------------------------------------------------------------------
|
---|
54 | //
|
---|
55 | // Specify the name of the MHMatrix-object and the column you want to
|
---|
56 | // access.
|
---|
57 | //
|
---|
58 | MDataElement::MDataElement(const char *member, Int_t col)
|
---|
59 | : fMatrixName(member), fNumCol(col), fMatrix(NULL)
|
---|
60 | {
|
---|
61 | }
|
---|
62 |
|
---|
63 | // --------------------------------------------------------------------------
|
---|
64 | //
|
---|
65 | // Specify the pointer of the MHMatrix-object and the column you want to
|
---|
66 | // access.
|
---|
67 | //
|
---|
68 | MDataElement::MDataElement(MHMatrix *mat, Int_t col)
|
---|
69 | : fMatrixName(mat->GetName()), fNumCol(col), fMatrix(mat)
|
---|
70 | {
|
---|
71 | }
|
---|
72 |
|
---|
73 | // --------------------------------------------------------------------------
|
---|
74 | //
|
---|
75 | // returns the value you requested
|
---|
76 | //
|
---|
77 | Double_t MDataElement::GetValue() const
|
---|
78 | {
|
---|
79 | return fMatrix ? (*fMatrix)[fNumCol] : 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 | // --------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // If the pointer to the MHMatrix isn't yet set search for it in the
|
---|
85 | // parameter list.
|
---|
86 | //
|
---|
87 | Bool_t MDataElement::PreProcess(const MParList *plist)
|
---|
88 | {
|
---|
89 | if (fMatrix)
|
---|
90 | return kTRUE;
|
---|
91 |
|
---|
92 | fMatrix = (MHMatrix*)plist->FindObject(fMatrixName, "MHMatrix");
|
---|
93 | if (!fMatrix)
|
---|
94 | {
|
---|
95 | *fLog << err << "MHMatrix '" << fMatrixName << "' not in parameter list... aborting." << endl;
|
---|
96 | return kFALSE;
|
---|
97 | }
|
---|
98 |
|
---|
99 | return kTRUE;
|
---|
100 | }
|
---|
101 |
|
---|
102 | // --------------------------------------------------------------------------
|
---|
103 | //
|
---|
104 | // Returns the ready-to-save flag of the data member container
|
---|
105 | //
|
---|
106 | Bool_t MDataElement::IsReadyToSave() const
|
---|
107 | {
|
---|
108 | return IsValid() ? fMatrix->IsReadyToSave() : kFALSE;
|
---|
109 | }
|
---|
110 |
|
---|
111 | // --------------------------------------------------------------------------
|
---|
112 | //
|
---|
113 | // Return the rule used to identify this object in a datachain
|
---|
114 | //
|
---|
115 | TString MDataElement::GetRule() const
|
---|
116 | {
|
---|
117 | TString rule = fMatrixName + "[";
|
---|
118 | rule += fNumCol;
|
---|
119 | rule += "]";
|
---|
120 | return rule;
|
---|
121 | }
|
---|