Changeset 8644 for trunk/MagicSoft/Mars/mjtrain
- Timestamp:
- 07/24/07 14:36:39 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mjtrain
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
r8643 r8644 18 18 ! Author(s): Thomas Bretz 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2005 20 ! Copyright: MAGIC Software Development, 2005-2007 21 21 ! 22 22 ! … … 55 55 #include "MJTrainDisp.h" 56 56 57 #include <TLine.h> 58 #include <TCanvas.h> 59 57 60 #include "MHMatrix.h" 58 61 … … 64 67 #include "MTFillMatrix.h" 65 68 #include "MChisqEval.h" 69 #include "MStatusDisplay.h" 66 70 67 71 // eventloop … … 92 96 using namespace std; 93 97 98 const TString MJTrainDisp::fgTrainParameter = "MHillasSrc.fDist*MGeomCam.fConvMm2Deg"; 99 100 // -------------------------------------------------------------------------- 101 // 102 // Display a result histogram either vs. size or energy 103 // FIXME: Could be moved into a new histogram class. 104 // 105 void MJTrainDisp::DisplayHist(TCanvas &c, Int_t i, MH3 &mh3) const 106 { 107 MH::SetPalette("pretty"); 108 109 TH1 &hist = *(TH1*)mh3.GetHist().Clone(); 110 hist.SetBit(TH1::kNoStats); 111 hist.SetDirectory(0); 112 113 TLine line; 114 line.SetLineStyle(kDashed); 115 line.SetLineWidth(1); 116 117 c.cd(i); 118 gPad->SetBorderMode(0); 119 gPad->SetFrameBorderMode(0); 120 //gPad->SetFillColor(kWhite); 121 gPad->SetLogx(); 122 gPad->SetGridx(); 123 gPad->SetGridy(); 124 //gPad->SetLeftMargin(0.12); 125 //gPad->SetRightMargin(0.12); 126 127 for (int x=0; x<=hist.GetNbinsX(); x++) 128 { 129 Float_t n = 0; 130 for (int y=1; y<=2; y++) 131 n += hist.GetBinContent(x,y); 132 133 if (n==0) 134 continue; 135 136 for (int y=0; y<=hist.GetNbinsY(); y++) 137 hist.SetBinContent(x, y, 200*hist.GetBinContent(x,y)/n); 138 } 139 140 hist.SetMaximum(100); 141 hist.DrawCopy("colz"); 142 143 line.DrawLine(10, 0.04, 31623, 0.04); 144 145 c.cd(i+2); 146 gPad->SetBorderMode(0); 147 gPad->SetFrameBorderMode(0); 148 //gPad->SetFillColor(kWhite); 149 gPad->SetLogx(); 150 gPad->SetGridx(); 151 gPad->SetGridy(); 152 //gPad->SetLeftMargin(0.12); 153 //gPad->SetRightMargin(0.12); 154 155 for (int x=0; x<=hist.GetNbinsX(); x++) 156 { 157 Float_t n = 0; 158 for (int y=0; y<=hist.GetNbinsY(); y++) 159 n += hist.GetBinContent(x,y); 160 161 if (n==0) 162 continue; 163 164 for (int y=0; y<=hist.GetNbinsY(); y++) 165 hist.SetBinContent(x, y, 100*hist.GetBinContent(x,y)/n); 166 } 167 168 hist.SetMaximum(25); 169 hist.DrawCopy("colz"); 170 171 line.DrawLine(10, 0.04, 31623, 0.04); 172 } 173 174 // -------------------------------------------------------------------------- 175 // 176 // Display the result histograms in a new tab. 177 // 178 void MJTrainDisp::DisplayResult(MH3 &hsize, MH3 &henergy) 179 { 180 TCanvas &c = fDisplay->AddTab("Disp"); 181 c.Divide(2,2); 182 183 DisplayHist(c, 1, hsize); 184 DisplayHist(c, 2, henergy); 185 } 186 187 // -------------------------------------------------------------------------- 188 // 189 // Run Disp optimization 190 // 94 191 Bool_t MJTrainDisp::Train(const char *out, const MDataSet &set, Int_t num) 95 192 { 193 SetTitle(Form("TrainDisp: %s", out)); 194 195 if (fDisplay) 196 fDisplay->SetTitle(fTitle); 197 96 198 if (!set.IsValid()) 97 199 { … … 99 201 return kFALSE; 100 202 } 203 204 if (!HasWritePermission(out)) 205 return kFALSE; 101 206 102 207 *fLog << inf; … … 119 224 if (fEnableWeights) 120 225 train.AddColumn("MWeight.fVal"); 121 train.AddColumn("MHillasSrc.fDist*MGeomCam.fConvMm2Deg"); 122 //train.AddColumn("TMath::Hypot(MHillasSrc.fDCA, MHillasSrc.fDist)*MGeomCam.fConvMm2Deg"); 226 train.AddColumn(fgTrainParameter); 123 227 124 228 // ----------------------- Fill Matrix RF ---------------------- 125 MTFillMatrix fill ;229 MTFillMatrix fill(fTitle); 126 230 fill.SetDisplay(fDisplay); 127 231 fill.SetLogStream(fLog); … … 136 240 137 241 // ------------------------ Train RF -------------------------- 138 MRanForestCalc rf ;242 MRanForestCalc rf(fTitle); 139 243 rf.SetNumTrees(fNumTrees); 140 244 rf.SetNdSize(fNdSize); … … 212 316 eval.SetY1("sqrt(ThetaSquared.fVal)"); 213 317 214 MH3 hdisp1("MHillas.fSize", " sqrt(ThetaSquared.fVal)");215 MH3 hdisp2("MMcEvt.fEnergy", " sqrt(ThetaSquared.fVal)");318 MH3 hdisp1("MHillas.fSize", "ThetaSquared.fVal"); 319 MH3 hdisp2("MMcEvt.fEnergy", "ThetaSquared.fVal"); 216 320 hdisp1.SetTitle("\\vartheta distribution vs. Size:Size [phe]:\\vartheta [\\circ]"); 217 321 hdisp2.SetTitle("\\vartheta distribution vs. Energy:Enerhy [GeV]:\\vartheta [\\circ]"); 218 322 219 MBinning binsx( 50, 10, 100000, "BinningMH3X", "log");220 MBinning binsy( 50, 0, 1,"BinningMH3Y", "lin");323 MBinning binsx( 70, 10, 31623, "BinningMH3X", "log"); 324 MBinning binsy( 75, 0, 0.3, "BinningMH3Y", "lin"); 221 325 222 326 plist.AddToList(&binsx); … … 239 343 tlist.AddToList(&eval); 240 344 241 MEvtLoop loop ;345 MEvtLoop loop(fTitle); 242 346 loop.SetLogStream(fLog); 243 347 loop.SetDisplay(fDisplay); 244 348 loop.SetParList(&plist); 349 //if (!SetupEnv(loop)) 350 // return kFALSE; 245 351 246 352 if (!loop.Eventloop()) … … 251 357 hist.GetAlphaFitter().Print("result"); 252 358 253 if (!WriteDisplay(out, "UPDATE")) 359 DisplayResult(hdisp1, hdisp2); 360 361 SetPathOut(out); 362 if (!WriteDisplay(0, "UPDATE")) 254 363 return kFALSE; 255 364 -
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.h
r7412 r8644 6 6 #endif 7 7 8 class TCanvas; 9 10 class MH3; 8 11 class MDataSet; 9 12 10 13 class MJTrainDisp : public MJTrainRanForest 11 14 { 15 private: 16 static const TString fgTrainParameter; 17 18 TString fTrainParameter; 19 20 void DisplayHist(TCanvas &c, Int_t i, MH3 &mh3) const; 21 void DisplayResult(MH3 &hsize, MH3 &henergy); 22 12 23 public: 13 MJTrainDisp() { } 24 MJTrainDisp() : fTrainParameter(fgTrainParameter) { } 25 26 void SetTrainParameter(const char *txt) { fTrainParameter=txt; } 27 14 28 Bool_t Train(const char *out, const MDataSet &set, Int_t num); 15 29 -
trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc
r8643 r8644 62 62 #include "MDataSet.h" 63 63 #include "MTFillMatrix.h" 64 #include "MStatusDisplay.h" 64 65 65 66 // eventloop … … 86 87 Bool_t MJTrainEnergy::Train(const char *out, const MDataSet &set, Int_t num) 87 88 { 89 SetTitle(Form("TrainEnergy: %s", out)); 90 91 if (fDisplay) 92 fDisplay->SetTitle(fTitle); 93 88 94 if (!set.IsValid()) 89 95 { … … 91 97 return kFALSE; 92 98 } 99 100 if (!HasWritePermission(out)) 101 return kFALSE; 93 102 94 103 *fLog << inf; … … 102 111 103 112 if (!set.AddFilesOn(readtrn)) 104 return kFALSE; 113 { 114 *fLog << err << "ERROR - Adding SequencesOn." << endl; 115 return kFALSE; 116 } 105 117 if (!set.AddFilesOff(readtst)) 106 return kFALSE; 118 { 119 *fLog << err << "ERROR - Adding SequencesOff." << endl; 120 return kFALSE; 121 } 107 122 108 123 // ----------------------- Setup Matrix ------------------ … … 117 132 118 133 // ----------------------- Fill Matrix RF ---------------------- 119 MTFillMatrix fill ;134 MTFillMatrix fill(fTitle); 120 135 fill.SetDisplay(fDisplay); 121 136 fill.SetLogStream(fLog); … … 130 145 131 146 // ------------------------ Train RF -------------------------- 132 MRanForestCalc rf ;147 MRanForestCalc rf(fTitle); 133 148 rf.SetNumTrees(fNumTrees); 134 149 rf.SetNdSize(fNdSize); … … 185 200 tlist.AddToList(&fillh); 186 201 187 MEvtLoop loop ;202 MEvtLoop loop(fTitle); 188 203 loop.SetLogStream(fLog); 189 204 loop.SetDisplay(fDisplay); 190 205 loop.SetParList(&plist); 206 //if (!SetupEnv(loop)) 207 // return kFALSE; 191 208 192 209 if (!loop.Eventloop()) 193 210 return kFALSE; 194 211 195 if (!WriteDisplay(out, "UPDATE")) 212 SetPathOut(out); 213 if (!WriteDisplay(0, "UPDATE")) 196 214 return kFALSE; 197 215 -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
r8643 r8644 589 589 Bool_t MJTrainSeparation::Train(const char *out) 590 590 { 591 if (fDisplay) 592 fDisplay->SetTitle(out); 593 591 594 if (!fDataSetTrain.IsValid()) 592 595 { … … 606 609 } 607 610 608 TStopwatch clock; 611 if (!HasWritePermission(out)) 612 return kFALSE; 613 614 TStopwatch clock; 609 615 clock.Start(); 610 616 … … 939 945 loop.SetLogStream(fLog); 940 946 loop.SetParList(&plist); 947 //if (!SetupEnv(loop)) 948 // return kFALSE; 941 949 942 950 wgt.SetVal(1); … … 1039 1047 1040 1048 // Write the display 1041 if (!WriteDisplay(out, "UPDATE")) 1049 SetPathOut(out); 1050 if (!WriteDisplay(0, "UPDATE")) 1042 1051 return kFALSE; 1043 1052
Note:
See TracChangeset
for help on using the changeset viewer.