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 | class TArrayI;
|
---|
16 | class TArrayF;
|
---|
17 |
|
---|
18 | class TH1F;
|
---|
19 | class MTask;
|
---|
20 | class MParList;
|
---|
21 | class MDataArray;
|
---|
22 | class MFilter;
|
---|
23 |
|
---|
24 | class MHMatrix : public MH
|
---|
25 | {
|
---|
26 | private:
|
---|
27 | static const TString gsDefName; //! Default Name
|
---|
28 | static const TString gsDefTitle; //! Default Title
|
---|
29 |
|
---|
30 | Int_t fNumRows; //! Number of rows filled into the matrix (this is NOT the number of rows of the matrix!)
|
---|
31 | Int_t fRow; //! Present row
|
---|
32 | TMatrix fM; // Matrix to be filled
|
---|
33 |
|
---|
34 | TMatrix fM2; //! Covariance Matrix
|
---|
35 |
|
---|
36 | MDataArray *fData; // List of data members (columns)
|
---|
37 |
|
---|
38 |
|
---|
39 | enum {
|
---|
40 | kIsOwner = BIT(14),
|
---|
41 | kIsLocked = BIT(17)
|
---|
42 | };
|
---|
43 |
|
---|
44 | void AddRow();
|
---|
45 |
|
---|
46 | Bool_t SetupFill(const MParList *pList);
|
---|
47 |
|
---|
48 | Bool_t Fill(const MParContainer *par, const Stat_t w=1);
|
---|
49 | Bool_t Finalize();
|
---|
50 |
|
---|
51 | void DrawDefRefInfo(const TH1 &hth, const TH1 &hthd, const TH1 &thsh, Int_t refcolumn);
|
---|
52 | void GetRandomArrayI(TArrayI &ind) const;
|
---|
53 |
|
---|
54 | void StreamPrimitive(ofstream &out) const;
|
---|
55 |
|
---|
56 | public:
|
---|
57 | MHMatrix(const char *name=NULL, const char *title=NULL);
|
---|
58 | MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
|
---|
59 | MHMatrix(const TMatrix &m, const char *name=NULL, const char *title=NULL);
|
---|
60 | ~MHMatrix();
|
---|
61 |
|
---|
62 | static void CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows);
|
---|
63 |
|
---|
64 | void Lock() { SetBit(kIsLocked); }
|
---|
65 | void Unlock() { ResetBit(kIsLocked); }
|
---|
66 |
|
---|
67 | Int_t AddColumn(const char *name);
|
---|
68 | void AddColumns(MDataArray *mat);
|
---|
69 |
|
---|
70 | MDataArray *GetColumns() { return fData; }
|
---|
71 |
|
---|
72 | const TMatrix &GetM() const { return fM; }
|
---|
73 |
|
---|
74 | Bool_t IsValid() const { return fM.IsValid(); }
|
---|
75 | Int_t GetNumRows() const { return fM.GetNrows(); }
|
---|
76 |
|
---|
77 | //void Draw(Option_t *opt=NULL);
|
---|
78 | //TObject *DrawClone(Option_t *opt=NULL) const;
|
---|
79 |
|
---|
80 | void Print(Option_t *) const;
|
---|
81 |
|
---|
82 | const TMatrix *InvertPosDef();
|
---|
83 |
|
---|
84 | Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
|
---|
85 | Double_t CalcDist(const TVector &v, Int_t num = 25);
|
---|
86 |
|
---|
87 | void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
|
---|
88 |
|
---|
89 | void Reassign();
|
---|
90 |
|
---|
91 | const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
|
---|
92 | void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
|
---|
93 |
|
---|
94 | Bool_t SetNumRow(Int_t row);
|
---|
95 |
|
---|
96 | Int_t GetNumRow() const { return fRow; };
|
---|
97 | Double_t operator[](Int_t col) { return fM(fRow, col); }
|
---|
98 |
|
---|
99 | Bool_t Fill(MParList *plist, MTask *read, MFilter *filter=NULL);
|
---|
100 |
|
---|
101 | TString GetDataMember() const;
|
---|
102 |
|
---|
103 | void ReduceNumberOfRows(UInt_t numrows, const TString opt);
|
---|
104 | Bool_t RemoveInvalidRows();
|
---|
105 |
|
---|
106 | Int_t Read(const char *name);
|
---|
107 |
|
---|
108 | Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
|
---|
109 | Int_t nmaxevts=0, TMatrix *mrest=NULL);
|
---|
110 | Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
|
---|
111 |
|
---|
112 | Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
|
---|
113 |
|
---|
114 | void ShuffleRows(UInt_t seed);
|
---|
115 | void ReduceRows(UInt_t num);
|
---|
116 |
|
---|
117 | ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
|
---|
118 | };
|
---|
119 |
|
---|
120 | #endif
|
---|
121 |
|
---|
122 |
|
---|