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

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