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

Last change on this file since 7460 was 7413, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 3.6 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(const TMatrix &m, MDataArray *arr, const char *name=NULL, const char *title=NULL);
66 ~MHMatrix();
67
68 static void CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows);
69
70 void Lock() { SetBit(kIsLocked); }
71 void Unlock() { ResetBit(kIsLocked); }
72
73 Int_t AddColumn(const char *name);
74 void AddColumns(MDataArray *mat);
75 void AddColumns(const TCollection &list);
76
77 //MDataArray *GetColumns() { return fData; }
78 const MDataArray *GetColumns() const { return fData; }
79 MDataArray *GetColumns() { return fData; }
80
81 const TMatrix &GetM() const { return fM; }
82
83 Bool_t IsValid() const { return IsValid(fM); }
84 Int_t GetNumRows() const { return fM.GetNrows(); }
85
86 //void Draw(Option_t *opt=NULL);
87 //TObject *DrawClone(Option_t *opt=NULL) const;
88
89 void Print(Option_t *) const;
90
91 const TMatrix *InvertPosDef();
92
93 Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
94 Double_t CalcDist(const TVector &v, Int_t num = 25);
95
96 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
97
98 void Reassign();
99
100 const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
101 void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
102
103 Bool_t SetNumRow(Int_t row);
104
105 Int_t GetNumRow() const { return fRow; };
106 Double_t operator[](Int_t col) { return fM(fRow, col); }
107
108 void GetRow(TVector &v) const;
109 void operator>>(TVector &v) const
110 {
111 GetRow(v);
112 }
113
114 Bool_t Fill(MParList *plist, MTask *read, MFilter *filter=NULL);
115
116 TString GetDataMember() const;
117
118 void ReduceNumberOfRows(UInt_t numrows, const TString opt);
119 Bool_t RemoveInvalidRows();
120
121 Int_t Read(const char *name);
122
123 Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
124 Int_t nmaxevts=0, TMatrix *mrest=NULL);
125 Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
126
127 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
128
129 void ShuffleRows(UInt_t seed);
130 void ReduceRows(UInt_t num);
131
132 ClassDef(MHMatrix, 1) // Multidimensional Matrix (TMatrix) to store events
133};
134
135#endif
136
137
Note: See TracBrowser for help on using the repository browser.