source: trunk/MagicSoft/Mars/mhbase/MHMatrix.h@ 7189

Last change on this file since 7189 was 7130, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 3.5 KB
Line 
1#ifndef MARS_MHMatrix
2#define MARS_MHMatrix
3
4#ifdef MARS_MLogManip
5#error Please make ensure that MLogManip.h are included _after_ MHMatrix.h
6#endif
7
8#ifndef ROOT_TMatrix
9#include <TMatrix.h>
10#endif
11#ifndef MARS_MH
12#include "MH.h"
13#endif
14
15class TArrayI;
16class TArrayF;
17class TVector;
18class TH1F;
19
20class MTask;
21class MParList;
22class MDataArray;
23class MFilter;
24
25class MHMatrix : public MH
26{
27private:
28 static const TString gsDefName; //! Default Name
29 static const TString gsDefTitle; //! Default Title
30
31 Int_t fNumRows; //! Number of rows filled into the matrix (this is NOT the number of rows of the matrix!)
32 Int_t fRow; //! Present row
33 TMatrix fM; // Matrix to be filled
34
35 TMatrix fM2; //! Covariance Matrix
36
37 MDataArray *fData; // List of data members (columns)
38
39
40 enum {
41 kIsOwner = BIT(14),
42 kIsLocked = BIT(17)
43 };
44
45 void AddRow();
46 Bool_t IsValid(const TMatrix &m) const
47 {
48 return m.GetNrows()>0 && m.IsValid();
49 }
50
51 Bool_t SetupFill(const MParList *pList);
52
53 Bool_t Fill(const MParContainer *par, const Stat_t w=1);
54 Bool_t Finalize();
55
56 void DrawDefRefInfo(const TH1 &hth, const TH1 &hthd, const TH1 &thsh, Int_t refcolumn);
57 void GetRandomArrayI(TArrayI &ind) const;
58
59 void StreamPrimitive(ofstream &out) const;
60
61public:
62 MHMatrix(const char *name=NULL, const char *title=NULL);
63 MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
64 MHMatrix(const TMatrix &m, const char *name=NULL, const char *title=NULL);
65 ~MHMatrix();
66
67 static void CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows);
68
69 void Lock() { SetBit(kIsLocked); }
70 void Unlock() { ResetBit(kIsLocked); }
71
72 Int_t AddColumn(const char *name);
73 void AddColumns(MDataArray *mat);
74
75 //MDataArray *GetColumns() { return fData; }
76 const MDataArray *GetColumns() const { return fData; }
77 MDataArray *GetColumns() { return fData; }
78
79 const TMatrix &GetM() const { return fM; }
80
81 Bool_t IsValid() const { return IsValid(fM); }
82 Int_t GetNumRows() const { return fM.GetNrows(); }
83
84 //void Draw(Option_t *opt=NULL);
85 //TObject *DrawClone(Option_t *opt=NULL) const;
86
87 void Print(Option_t *) const;
88
89 const TMatrix *InvertPosDef();
90
91 Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
92 Double_t CalcDist(const TVector &v, Int_t num = 25);
93
94 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
95
96 void Reassign();
97
98 const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
99 void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
100
101 Bool_t SetNumRow(Int_t row);
102
103 Int_t GetNumRow() const { return fRow; };
104 Double_t operator[](Int_t col) { return fM(fRow, col); }
105
106 void GetRow(TVector &v) const;
107 void operator>>(TVector &v) const
108 {
109 GetRow(v);
110 }
111
112 Bool_t Fill(MParList *plist, MTask *read, MFilter *filter=NULL);
113
114 TString GetDataMember() const;
115
116 void ReduceNumberOfRows(UInt_t numrows, const TString opt);
117 Bool_t RemoveInvalidRows();
118
119 Int_t Read(const char *name);
120
121 Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
122 Int_t nmaxevts=0, TMatrix *mrest=NULL);
123 Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
124
125 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
126
127 void ShuffleRows(UInt_t seed);
128 void ReduceRows(UInt_t num);
129
130 ClassDef(MHMatrix, 1) // Multidimensional Matrix (TMatrix) to store events
131};
132
133#endif
134
135
Note: See TracBrowser for help on using the repository browser.