- Timestamp:
- 04/30/06 14:15:49 (19 years ago)
- Location:
- trunk/MagicSoft/Mars/mjtrain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
r7654 r7664 86 86 g.SetMarkerColor(kGreen); 87 87 88 TH2D res1(g); 89 TH2D res2(g); 90 91 res1.SetTitle("Significance Li/Ma"); 92 res2.SetTitle("Significance Li/Ma * log_{10}(excess)"); 93 88 94 const Int_t nx = h.GetNbinsX(); 89 95 const Int_t ny = h.GetNbinsY(); … … 106 112 const Float_t s = gx->Integral(1, y+1); 107 113 const Float_t b = hx->Integral(1, y+1); 108 const Float_t sig1 = MMath::SignificanceLiMa (s+b, b);109 const Float_t sig2 = s<1 ? 0 : MMath::SignificanceLiMa (s+b, b)*TMath::Log10(s);114 const Float_t sig1 = MMath::SignificanceLiMaSigned(s+b, b); 115 const Float_t sig2 = s<1 ? 0 : MMath::SignificanceLiMaSigned(s+b, b)*TMath::Log10(s); 110 116 if (sig1>max1) 111 117 { … … 118 124 max2 = sig2; 119 125 } 126 127 res1.SetBinContent(x+1, y+1, sig1); 128 res2.SetBinContent(x+1, y+1, sig2); 120 129 } 121 130 … … 127 136 } 128 137 129 fDisplay->AddTab("OptCut"); 138 TCanvas &c = fDisplay->AddTab("OptCut"); 139 c.Divide(2,2); 140 141 c.cd(1); 130 142 gPad->SetLogx(); 131 143 h.DrawCopy(); … … 136 148 gr2.SetMarkerStyle(kFullDotMedium); 137 149 gr2.DrawClone("LP")->SetBit(kCanDelete); 150 151 c.cd(2); 152 gPad->SetLogx(); 153 MH::SetPalette("pretty"); 154 res1.DrawCopy("colz"); 155 156 c.cd(4); 157 gPad->SetLogx(); 158 MH::SetPalette("pretty"); 159 res2.DrawCopy("colz"); 138 160 } 139 161 … … 457 479 return kFALSE; 458 480 481 const Int_t numgammas = train.GetNumRows(); 482 459 483 // Set classifier for hadrons 460 484 had.SetVal(1); … … 464 488 if (!fill.Process(plistx)) 465 489 return kFALSE; 490 491 const Int_t numbackgrnd = train.GetNumRows()-numgammas; 466 492 467 493 // ------------------------ Train RF -------------------------- … … 478 504 rf.SetNameOutput("MHadronness"); 479 505 480 //MBinning b(2, -0.5, 1.5, "BinningHadronness", "lin"); 506 if (fUseRegression) 507 { 508 if (!rf.TrainSingleRF(train)) // regression 509 return kFALSE; 510 } 511 else 512 { 513 MBinning b(2, -0.5, 1.5, "BinningHadronness", "lin"); 514 if (!rf.TrainSingleRF(train, b.GetEdgesD())) // classification 515 return; 516 } 481 517 482 518 //if (!rf.TrainMultiRF(train, b.GetEdgesD())) // classification 483 519 // return; 484 520 485 //if (!rf.TrainSingleRF(train, b.GetEdgesD())) // classification486 // return;487 488 if (!rf.TrainSingleRF(train)) // regression489 return kFALSE;490 491 521 //fDisplay = rf.GetDisplay(); 492 522 523 524 *fLog << all; 525 fLog->Separator(); 526 527 *fLog << "Training method:" << endl; 528 *fLog << " * " << (fUseRegression?"regression":"classification") << endl; 529 *fLog << endl; 530 *fLog << "Events used for training:" << endl; 531 *fLog << " * Gammas: " << numgammas << endl; 532 *fLog << " * Background: " << numbackgrnd << endl; 533 534 if (!fDataSetTest.IsValid()) 535 return kTRUE; 536 493 537 // --------------------- Display result ---------------------- 494 gLog.Separator("Test");538 fLog->Separator("Test"); 495 539 496 540 MParList plist; -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.h
r7652 r7664 25 25 26 26 Bool_t fAutoTrain; 27 Bool_t fUseRegression; 27 28 28 29 void DisplayResult(MH3 &h31, MH3 &h32); … … 36 37 fNumTrainOn((UInt_t)-1), fNumTrainOff((UInt_t)-1), 37 38 fNumTestOn((UInt_t)-1), fNumTestOff((UInt_t)-1), 38 fAutoTrain(kFALSE) 39 fAutoTrain(kFALSE), fUseRegression(kTRUE) 39 40 { } 40 41 … … 42 43 { 43 44 ds.Copy(fDataSetTrain); 45 46 fDataSet.SetNumAnalysis(1); 47 44 48 fNumTrainOn = non; 45 49 fNumTrainOff = noff; … … 48 52 { 49 53 ds.Copy(fDataSetTest); 54 55 fDataSet.SetNumAnalysis(1); 56 50 57 fNumTestOn = non; 51 58 fNumTestOff = noff; 52 59 } 53 60 54 void EnableAutoTrain(Bool_t b=kTRUE) { fAutoTrain = b; } 61 void EnableAutoTrain(Bool_t b=kTRUE) { fAutoTrain = b; } 62 void EnableRegression(Bool_t b=kTRUE) { fUseRegression = b; } 63 void EnableClassification(Bool_t b=kTRUE) { fUseRegression = !b; } 55 64 56 65 Bool_t Train(const char *out);
Note:
See TracChangeset
for help on using the changeset viewer.