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 |
|
---|
15 | #include <TArrayF.h>
|
---|
16 |
|
---|
17 | class TArrayI;
|
---|
18 | class TArrayF;
|
---|
19 |
|
---|
20 | class TH1F;
|
---|
21 | class MTask;
|
---|
22 | class MParList;
|
---|
23 | class MDataArray;
|
---|
24 |
|
---|
25 | class MHMatrix : public MH
|
---|
26 | {
|
---|
27 | private:
|
---|
28 | static const TString gsDefName; //! Default Name
|
---|
29 | static const TString gsDefTitle; //! Default Title
|
---|
30 |
|
---|
31 | Int_t fNumRow; //! Number of dimensions of histogram
|
---|
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(16)
|
---|
43 | };
|
---|
44 |
|
---|
45 | void AddRow();
|
---|
46 |
|
---|
47 | Bool_t SetupFill(const MParList *pList);
|
---|
48 |
|
---|
49 | Bool_t Fill(const MParContainer *par);
|
---|
50 | Bool_t Finalize();
|
---|
51 |
|
---|
52 | void StreamPrimitive(ofstream &out) const;
|
---|
53 |
|
---|
54 | public:
|
---|
55 | MHMatrix(const char *name=NULL, const char *title=NULL);
|
---|
56 | MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
|
---|
57 | MHMatrix(const TMatrix &m, const char *name=NULL, const char *title=NULL);
|
---|
58 | ~MHMatrix();
|
---|
59 |
|
---|
60 | void Lock() { SetBit(kIsLocked); }
|
---|
61 | void Unlock() { ResetBit(kIsLocked); }
|
---|
62 |
|
---|
63 | Int_t AddColumn(const char *name);
|
---|
64 | void AddColumns(MDataArray *mat);
|
---|
65 |
|
---|
66 | MDataArray *GetColumns() { return fData; }
|
---|
67 |
|
---|
68 | const TMatrix &GetM() const { return fM; }
|
---|
69 |
|
---|
70 | Bool_t IsValid() const { return fM.IsValid(); }
|
---|
71 | Int_t GetNumRows() const { return fNumRow; }
|
---|
72 |
|
---|
73 | //void Draw(Option_t *opt=NULL);
|
---|
74 | //TObject *DrawClone(Option_t *opt=NULL) const;
|
---|
75 |
|
---|
76 | void Print(Option_t *) const;
|
---|
77 |
|
---|
78 | const TMatrix *InvertPosDef();
|
---|
79 |
|
---|
80 | Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
|
---|
81 | Double_t CalcDist(const TVector &v, Int_t num = 25);
|
---|
82 |
|
---|
83 | void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
|
---|
84 |
|
---|
85 | void Reassign();
|
---|
86 |
|
---|
87 | const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
|
---|
88 | void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
|
---|
89 |
|
---|
90 | Bool_t SetNumRow(Int_t row) { if (row>=fNumRow || row<0) return kFALSE; fRow = row; return kTRUE; }
|
---|
91 | Int_t GetNumRow() const { return fRow; };
|
---|
92 | Double_t operator[](Int_t col) { return fM(fRow, col); }
|
---|
93 |
|
---|
94 | Bool_t Fill(MParList *plist, MTask *read);
|
---|
95 |
|
---|
96 | TString GetDataMember() const;
|
---|
97 |
|
---|
98 | void ReduceNumberOfRows(UInt_t numrows, const TString opt);
|
---|
99 |
|
---|
100 | Int_t Read(const char *name);
|
---|
101 |
|
---|
102 | Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
|
---|
103 | Int_t nmaxevts=0, TMatrix *mrest=NULL);
|
---|
104 | Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
|
---|
105 |
|
---|
106 | ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
|
---|
107 | };
|
---|
108 |
|
---|
109 | #endif
|
---|
110 |
|
---|
111 |
|
---|