source: trunk/MagicSoft/Mars/mhist/MHMatrix.h@ 1942

Last change on this file since 1942 was 1891, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.1 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
15#include <TArrayF.h>
16
17class TArrayI;
18class TArrayF;
19
20class TH1F;
21class MTask;
22class MParList;
23class MDataArray;
24class MF;
25
26class MHMatrix : public MH
27{
28private:
29 static const TString gsDefName; //! Default Name
30 static const TString gsDefTitle; //! Default Title
31
32 Int_t fNumRow; //! Number of dimensions of histogram
33 Int_t fRow; //! Present row
34 TMatrix fM; // Matrix to be filled
35
36 TMatrix fM2; //! Covariance Matrix
37
38 MDataArray *fData; // List of data members (columns)
39
40
41 enum {
42 kIsOwner = BIT(14),
43 kIsLocked = BIT(17)
44 };
45
46 void AddRow();
47
48 Bool_t SetupFill(const MParList *pList);
49
50 Bool_t Fill(const MParContainer *par);
51 Bool_t Finalize();
52
53 void DrawDefRefInfo(const TH1 &hth, const TH1 &hthd, const TH1 &thsh, Int_t refcolumn);
54 void GetRandomArrayI(TArrayI &ind) const;
55
56 void StreamPrimitive(ofstream &out) const;
57
58public:
59 MHMatrix(const char *name=NULL, const char *title=NULL);
60 MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
61 MHMatrix(const TMatrix &m, const char *name=NULL, const char *title=NULL);
62 ~MHMatrix();
63
64 static void CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows);
65
66 void Lock() { SetBit(kIsLocked); }
67 void Unlock() { ResetBit(kIsLocked); }
68
69 Int_t AddColumn(const char *name);
70 void AddColumns(MDataArray *mat);
71
72 MDataArray *GetColumns() { return fData; }
73
74 const TMatrix &GetM() const { return fM; }
75
76 Bool_t IsValid() const { return fM.IsValid(); }
77 Int_t GetNumRows() const { return fNumRow; }
78
79 //void Draw(Option_t *opt=NULL);
80 //TObject *DrawClone(Option_t *opt=NULL) const;
81
82 void Print(Option_t *) const;
83
84 const TMatrix *InvertPosDef();
85
86 Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
87 Double_t CalcDist(const TVector &v, Int_t num = 25);
88
89 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
90
91 void Reassign();
92
93 const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
94 void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
95
96 Bool_t SetNumRow(Int_t row) { if (row>=fNumRow || row<0) return kFALSE; fRow = row; return kTRUE; }
97 Int_t GetNumRow() const { return fRow; };
98 Double_t operator[](Int_t col) { return fM(fRow, col); }
99
100 Bool_t Fill(MParList *plist, MTask *read, MF *filter=NULL);
101
102 TString GetDataMember() const;
103
104 void ReduceNumberOfRows(UInt_t numrows, const TString opt);
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 Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
113
114 ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
115};
116
117#endif
118
119
Note: See TracBrowser for help on using the repository browser.