Changeset 1840
- Timestamp:
- 03/19/03 16:29:30 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1837 r1840 7 7 root CT1 Monte Carlo file from Wolfgang). 8 8 9 10 9 11 2003/03/19: Robert Wagner 10 12 … … 14 16 15 17 18 16 19 2003/03/19: Thomas Bretz 17 20 … … 25 28 meventdisp/MReadMarsFile.cc: 26 29 - changed MReadTree::GetEventNum to MReadTree::GetNumEntry 30 31 * macros/estfit.C: 32 - adopted to new MChisqEval 33 34 * mtools/MChisqEval.[h,cc]: 35 - added 36 37 * mtools/Makefile, mtools/ToolsLinkDef.h: 38 - added MChisqEval 27 39 28 40 -
trunk/MagicSoft/Mars/macros/estfit.C
r1633 r1840 1 #include <fstream.h> 1 #include <TStopwatch.h> 2 #include <TMinuit.h> 2 3 3 #include "MTask.h"4 4 #include "MParList.h" 5 #include "MTaskList.h" 6 #include "MEvtLoop.h" 5 7 6 #include "MDataChain.h" 7 8 class MChisqEval : public MTask 9 { 10 private: 11 static const TString gsDefName; 12 static const TString gsDefTitle; 13 14 Double_t fChisq; //! Evaluated chi square 15 16 MData *fData0; // Data Member one (monte carlo data or chisq function) 17 MData *fData1; // Data Member two (measured data) 18 19 // -------------------------------------------------------------------------- 20 // 21 // Implementation of SavePrimitive. Used to write the call to a constructor 22 // to a macro. In the original root implementation it is used to write 23 // gui elements to a macro-file. 24 // 25 void StreamPrimitive(ofstream &out) const 26 { 27 out << " MChisqEval " << GetUniqueName() << ";"; 28 if (fData0) 29 out << " " << GetUniqueName() << ".SetY1(\"" << fData0->GetRule() << "\");" << endl; 30 if (fData1) 31 out << " " << GetUniqueName() << ".SetY1(\"" << fData1->GetRule() << "\");" << endl; 32 } 33 34 enum { kIsOwner = BIT(14) }; 35 36 public: 37 MChisqEval(const char *name=NULL, const char *title=NULL) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale) 38 { 39 fName = name ? name : gsDefName.Data(); 40 fTitle = title ? title : gsDefTitle.Data(); 41 } 42 43 MChisqEval(MData *y1, const char *name=NULL, const char *title=NULL) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale) 44 { 45 fName = name ? name : gsDefName.Data(); 46 fTitle = title ? title : gsDefTitle.Data(); 47 SetY1(y1); 48 } 49 MChisqEval(MData *y1, MData *y2, const char *name=NULL, const char *title=NULL) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale) 50 { 51 fName = name ? name : gsDefName.Data(); 52 fTitle = title ? title : gsDefTitle.Data(); 53 SetY1(y1); 54 SetY2(y2); 55 } 56 ~MChisqEval() 57 { 58 if (fData0 && (fData0->TestBit(kCanDelete) || TestBit(kIsOwner))) 59 delete fData0; 60 61 if (fData1 && (fData1->TestBit(kCanDelete) || TestBit(kIsOwner))) 62 delete fData1; 63 } 64 65 void SetY1(MData *data) 66 { 67 // Set MC value 68 if (fData0 && (fData0->TestBit(kCanDelete) || TestBit(kIsOwner))) 69 delete fData0; 70 fData0 = data; 71 fData0->SetBit(kCanDelete); 72 AddToBranchList(fData0->GetDataMember()); 73 } 74 void SetY2(MData *data) 75 { 76 // Set measured/estimated value 77 if (fData1 && (fData1->TestBit(kCanDelete) || TestBit(kIsOwner))) 78 delete fData1; 79 fData1 = data; 80 fData1->SetBit(kCanDelete); 81 AddToBranchList(fData1->GetDataMember()); 82 } 83 void SetY1(const TString data) { SetY1(new MDataChain(data)); } 84 void SetY2(const TString data) { SetY2(new MDataChain(data)); } 85 86 void SetOwner(Bool_t o=kTRUE) { o ? SetBit(kIsOwner) : ResetBit(kIsOwner); } 87 88 Bool_t PreProcess(MParList *plist) 89 { 90 fChisq = 0; 91 92 if (!fData0) 93 return kFALSE; 94 95 if (!fData0->PreProcess(plist)) 96 return kFALSE; 97 98 if (fData1) 99 if (!fData1->PreProcess(plist)) 100 return kFALSE; 101 102 return kTRUE; 103 } 104 105 Bool_t Process() 106 { 107 const Double_t y1 = fData0->GetValue(); 108 const Double_t y2 = fData1 ? fData1->GetValue() : 0; 109 110 const Double_t dy = y2-y1; 111 const Double_t err = fData1 ? y1*y1 : 1; 112 113 fChisq += dy*dy/err; 114 return kTRUE; 115 } 116 117 Bool_t PostProcess() 118 { 119 fChisq /= GetNumExecutions(); 120 return kTRUE; 121 } 122 123 Double_t GetChisq() const { return fChisq; } 124 125 ClassDef(MChisqEval, 0) 126 }; 127 128 ClassImp(MChisqEval); 129 130 const TString MChisqEval::gsDefName = "MChisqEval"; 131 const TString MChisqEval::gsDefTitle = "Evaluate a chisq"; 8 #include "MReadTree.h" 9 #include "MHMatrix.h" 10 #include "MChisqEval.h" 11 #include "MMatrixLoop.h" 12 #include "MDataMember.h" 13 #include "MDataElement.h" 14 #include "MEnergyEstParam.h" 132 15 133 16 // -------------------------------------------------------------------------- 134 135 #include <TMinuit.h>136 137 #include "MEvtLoop.h"138 #include "MTaskList.h"139 #include "MEnergyEstParam.h"140 17 141 18 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag) … … 156 33 157 34 // -------------------------------------------------------------------------- 158 #include <TStopwatch.h>159 160 #include "MHMatrix.h"161 #include "MEnergyEst.h"162 163 #include "MDataMember.h"164 #include "MDataElement.h"165 166 #include "MReadTree.h"167 #include "MMatrixLoop.h"168 35 169 36 void estfit(Bool_t evalenergy=kFALSE) … … 177 44 Int_t col = matrix.AddColumn(evalenergy?"MMcEvt.fEnergy":"MMcEvt.fImpact"); 178 45 179 MEnergyEstParam eest ;180 eest.Add(" MHillasSrc");46 MEnergyEstParam eest("Hillas"); 47 eest.Add("HillasSrc"); 181 48 eest.InitMapping(&matrix); 182 49 183 MReadTree read("Events", " gammas.root");50 MReadTree read("Events", "~/ct1/MC_ON2.root"); 184 51 read.DisableAutoScheme(); 185 52 … … 211 78 // 212 79 TMinuit minuit(12); 80 minuit.SetPrintLevel(-1); 213 81 minuit.SetFCN(fcn); 214 82 … … 224 92 // 225 93 TArrayD fA(5); 226 fA[0] = -2539; // [cm]227 fA[1] = 900; // [cm]228 fA[2] = 17.5; // [cm]229 fA[3] = 1;// 4;230 fA[4] = 58.3;94 fA[0] = -3907.74; //4916.4; //-2414.75; 95 fA[1] = 1162.3; //149.549; // 1134.28; 96 fA[2] = 199.351; //-558.209; // 132.932; 97 fA[3] = 0.403192; //0.270725; //0.292845; 98 fA[4] = 121.921; //107.001; // 107.001; 231 99 232 100 TArrayD fB(7); 233 fB[0] = -8.64; // [GeV]234 fB[1] = -0.069; // [GeV]235 fB[2] = 0.00066; // [GeV]236 fB[3] = 0.033; // [GeV]237 fB[4] = 0.000226; // [GeV]238 fB[5] = 4.14e-8; // [GeV]239 fB[6] = -0.06;101 fB[0] = -100; 102 fB[1] = 10; 103 fB[2] = 0.1; 104 fB[3] = 10; 105 fB[4] = -1; 106 fB[5] = -0.1; 107 fB[6] = -0.1; 240 108 241 109 // Set starting values and step sizes for parameters -
trunk/MagicSoft/Mars/mtools/Makefile
r1439 r1840 22 22 # connect the include files defined in the config.mk file 23 23 # 24 INCLUDES = -I. -I../mbase -I../mgui -I../mgeom 24 INCLUDES = -I. -I../mbase -I../mgui -I../mgeom -I../mdata 25 25 26 26 #------------------------------------------------------------------------------ … … 28 28 .SUFFIXES: .c .cc .cxx .h .hxx .o 29 29 30 SRCFILES = MagicSnake.cc \ 30 SRCFILES = MChisqEval.cc \ 31 Magic5Wins.cc \ 32 MagicSnake.cc \ 31 33 MagicShow.cc \ 32 34 MagicDomino.cc \ -
trunk/MagicSoft/Mars/mtools/ToolsLinkDef.h
r1435 r1840 5 5 #pragma link off all functions; 6 6 7 #pragma link C++ class MChisqEval+; 7 8 #pragma link C++ class MineSweeper+; 9 #pragma link C++ class Magic5Wins+; 10 // #pragma link C++ class MagicReversi+; 8 11 #pragma link C++ class MagicSnake+; 9 12 #pragma link C++ class MagicShow+;
Note:
See TracChangeset
for help on using the changeset viewer.