Changeset 8679 for trunk/MagicSoft/Mars/mtools
- Timestamp:
- 08/19/07 22:40:04 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mtools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/MagicSoft/Mars/mtools/MChisqEval.cc ¶
r8074 r8679 49 49 const TString MChisqEval::gsDefTitle = "Evaluate a chisq"; 50 50 51 MChisqEval::MChisqEval(const char *name, const char *title) : fData0(NULL), fData1(NULL), fNameResult("MinimizationValue") 51 MChisqEval::MChisqEval(const char *name, const char *title) 52 : fData0(NULL), fData1(NULL), fWeight(NULL), fNameResult("MinimizationValue") 52 53 { 53 54 fName = name ? name : gsDefName.Data(); … … 55 56 } 56 57 57 MChisqEval::MChisqEval(MData *y1, const char *name, const char *title) : fData0(NULL), fData1(NULL), fNameResult("MinimizationValue") 58 MChisqEval::MChisqEval(MData *y1, const char *name, const char *title) 59 : fData0(NULL), fData1(NULL), fWeight(NULL), fNameResult("MinimizationValue") 58 60 { 59 61 fName = name ? name : gsDefName.Data(); … … 62 64 } 63 65 64 MChisqEval::MChisqEval(MData *y1, MData *y2, const char *name, const char *title) : fData0(NULL), fData1(NULL), fNameResult("MinimizationValue") 66 MChisqEval::MChisqEval(MData *y1, MData *y2, const char *name, const char *title) 67 : fData0(NULL), fData1(NULL), fWeight(NULL), fNameResult("MinimizationValue") 65 68 { 66 69 fName = name ? name : gsDefName.Data(); … … 112 115 { 113 116 fChisq = 0; 117 fSumW = 0; 114 118 115 119 if (!fData0) … … 122 126 if (!fData1->PreProcess(plist)) 123 127 return kFALSE; 128 129 if (!fNameWeight.IsNull()) 130 { 131 fWeight = (MParameterD*)plist->FindObject(fNameWeight, "MParameterD"); 132 if (!fWeight) 133 return kFALSE; 134 } 124 135 125 136 fResult = (MParameterD*)plist->FindCreateObj("MParameterD", fNameResult); … … 138 149 const Double_t err = fData1 ? y1*y2 : 1; 139 150 140 fChisq += dy*dy/err; 151 const Double_t w = fWeight ? fWeight->GetVal() : 1; 152 153 fChisq += w*dy*dy/err; 154 fSumW += w; 155 141 156 return kTRUE; 142 157 } … … 145 160 { 146 161 if (GetNumExecutions()>0) 147 fChisq /= GetNumExecutions();162 fChisq /= fSumW; 148 163 149 164 fResult->SetVal(fChisq); -
TabularUnified trunk/MagicSoft/Mars/mtools/MChisqEval.h ¶
r7804 r8679 15 15 static const TString gsDefTitle; 16 16 17 Double_t fChisq; //! Evaluated chi square18 MParameterD *fResult; //! Storage for result19 20 17 MData *fData0; // Data Member one (monte carlo data or chisq function) 21 18 MData *fData1; // Data Member two (measured data) 22 19 20 MParameterD *fWeight; //! Storage for weight 21 MParameterD *fResult; //! Storage for result 22 23 23 TString fNameResult; 24 TString fNameWeight; 25 26 Double_t fChisq; //! Evaluated chi square 27 Double_t fSumW; //! Sum of weights 24 28 25 29 void StreamPrimitive(ostream &out) const; … … 43 47 44 48 void SetOwner(Bool_t o=kTRUE) { o ? SetBit(kIsOwner) : ResetBit(kIsOwner); } 49 void SetNameWeight(TString w="MWeight") { fNameWeight=w; } 45 50 46 51 Double_t GetChisq() const { return fChisq; }
Note:
See TracChangeset
for help on using the changeset viewer.