source: trunk/Mars/mhbase/MHMatrix.h@ 15789

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