| 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 |
|
|---|
| 17 | class TArrayI;
|
|---|
| 18 | class TArrayF;
|
|---|
| 19 |
|
|---|
| 20 | class TH1F;
|
|---|
| 21 | class MTask;
|
|---|
| 22 | class MParList;
|
|---|
| 23 | class MDataArray;
|
|---|
| 24 | class MFilter;
|
|---|
| 25 |
|
|---|
| 26 | class MHMatrix : public MH
|
|---|
| 27 | {
|
|---|
| 28 | private:
|
|---|
| 29 | static const TString gsDefName; //! Default Name
|
|---|
| 30 | static const TString gsDefTitle; //! Default Title
|
|---|
| 31 |
|
|---|
| 32 | Int_t fNumRows; //! Number of rows filled into the matrix (this is NOT the number of rows of the matrix!)
|
|---|
| 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, const Stat_t w=1);
|
|---|
| 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 |
|
|---|
| 58 | public:
|
|---|
| 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 fM.GetNrows(); }
|
|---|
| 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);
|
|---|
| 97 |
|
|---|
| 98 | Int_t GetNumRow() const { return fRow; };
|
|---|
| 99 | Double_t operator[](Int_t col) { return fM(fRow, col); }
|
|---|
| 100 |
|
|---|
| 101 | Bool_t Fill(MParList *plist, MTask *read, MFilter *filter=NULL);
|
|---|
| 102 |
|
|---|
| 103 | TString GetDataMember() const;
|
|---|
| 104 |
|
|---|
| 105 | void ReduceNumberOfRows(UInt_t numrows, const TString opt);
|
|---|
| 106 | Bool_t RemoveInvalidRows();
|
|---|
| 107 |
|
|---|
| 108 | Int_t Read(const char *name);
|
|---|
| 109 |
|
|---|
| 110 | Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
|
|---|
| 111 | Int_t nmaxevts=0, TMatrix *mrest=NULL);
|
|---|
| 112 | Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
|
|---|
| 113 |
|
|---|
| 114 | Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
|
|---|
| 115 |
|
|---|
| 116 | void ShuffleRows(UInt_t seed);
|
|---|
| 117 | void ReduceRows(UInt_t num);
|
|---|
| 118 |
|
|---|
| 119 | ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
|
|---|
| 120 | };
|
|---|
| 121 |
|
|---|
| 122 | #endif
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|