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

Last change on this file since 6240 was 5832, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 3.2 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
47 Bool_t SetupFill(const MParList *pList);
48
49 Bool_t Fill(const MParContainer *par, const Stat_t w=1);
50 Bool_t Finalize();
51
52 void DrawDefRefInfo(const TH1 &hth, const TH1 &hthd, const TH1 &thsh, Int_t refcolumn);
53 void GetRandomArrayI(TArrayI &ind) const;
54
55 void StreamPrimitive(ofstream &out) const;
56
57public:
58 MHMatrix(const char *name=NULL, const char *title=NULL);
59 MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
60 MHMatrix(const TMatrix &m, const char *name=NULL, const char *title=NULL);
61 ~MHMatrix();
62
63 static void CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows);
64
65 void Lock() { SetBit(kIsLocked); }
66 void Unlock() { ResetBit(kIsLocked); }
67
68 Int_t AddColumn(const char *name);
69 void AddColumns(MDataArray *mat);
70
71 MDataArray *GetColumns() { return fData; }
72
73 const TMatrix &GetM() const { return fM; }
74
75 Bool_t IsValid() const { return fM.IsValid(); }
76 Int_t GetNumRows() const { return fM.GetNrows(); }
77
78 //void Draw(Option_t *opt=NULL);
79 //TObject *DrawClone(Option_t *opt=NULL) const;
80
81 void Print(Option_t *) const;
82
83 const TMatrix *InvertPosDef();
84
85 Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
86 Double_t CalcDist(const TVector &v, Int_t num = 25);
87
88 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
89
90 void Reassign();
91
92 const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
93 void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
94
95 Bool_t SetNumRow(Int_t row);
96
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, MFilter *filter=NULL);
101
102 TString GetDataMember() const;
103
104 void ReduceNumberOfRows(UInt_t numrows, const TString opt);
105 Bool_t RemoveInvalidRows();
106
107 Int_t Read(const char *name);
108
109 Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
110 Int_t nmaxevts=0, TMatrix *mrest=NULL);
111 Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
112
113 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
114
115 void ShuffleRows(UInt_t seed);
116 void ReduceRows(UInt_t num);
117
118 ClassDef(MHMatrix, 1) // Multidimensional Matrix (TMatrix) to store events
119};
120
121#endif
122
123
Note: See TracBrowser for help on using the repository browser.