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

Last change on this file since 6948 was 6890, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 3.3 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
77 const TMatrix &GetM() const { return fM; }
78
79 Bool_t IsValid() const { return IsValid(fM); }
80 Int_t GetNumRows() const { return fM.GetNrows(); }
81
82 //void Draw(Option_t *opt=NULL);
83 //TObject *DrawClone(Option_t *opt=NULL) const;
84
85 void Print(Option_t *) const;
86
87 const TMatrix *InvertPosDef();
88
89 Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
90 Double_t CalcDist(const TVector &v, Int_t num = 25);
91
92 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
93
94 void Reassign();
95
96 const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
97 void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
98
99 Bool_t SetNumRow(Int_t row);
100
101 Int_t GetNumRow() const { return fRow; };
102 Double_t operator[](Int_t col) { return fM(fRow, col); }
103
104 Bool_t Fill(MParList *plist, MTask *read, MFilter *filter=NULL);
105
106 TString GetDataMember() const;
107
108 void ReduceNumberOfRows(UInt_t numrows, const TString opt);
109 Bool_t RemoveInvalidRows();
110
111 Int_t Read(const char *name);
112
113 Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
114 Int_t nmaxevts=0, TMatrix *mrest=NULL);
115 Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
116
117 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
118
119 void ShuffleRows(UInt_t seed);
120 void ReduceRows(UInt_t num);
121
122 ClassDef(MHMatrix, 1) // Multidimensional Matrix (TMatrix) to store events
123};
124
125#endif
126
127
Note: See TracBrowser for help on using the repository browser.