Changeset 7420 for trunk/MagicSoft/Mars/mjtrain
- Timestamp:
- 11/22/05 11:06:56 (19 years ago)
- Location:
- trunk/MagicSoft/Mars/mjtrain
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
r7412 r7420 115 115 MHMatrix train("Train"); 116 116 train.AddColumns(fRules); 117 //train.AddColumn("MHillasSrc.fDist*MGeomCam.fConvMm2Deg");118 train.AddColumn("TMath::Hypot(MHillasSrc.fDCA, MHillasSrc.fDist)*MGeomCam.fConvMm2Deg");117 train.AddColumn("MHillasSrc.fDist*MGeomCam.fConvMm2Deg"); 118 //train.AddColumn("TMath::Hypot(MHillasSrc.fDCA, MHillasSrc.fDist)*MGeomCam.fConvMm2Deg"); 119 119 120 120 // ----------------------- Fill Matrix RF ---------------------- … … 147 147 return; 148 148 */ 149 if (!rf.Train SingleRF(train)) // regression (best choice)149 if (!rf.TrainRegression(train)) // regression (best choice) 150 150 return kFALSE; 151 151 -
trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc
r7412 r7420 141 141 return; 142 142 */ 143 if (!rf.Train SingleRF(train)) // regression (best choice)143 if (!rf.TrainRegression(train)) // regression (best choice) 144 144 return kFALSE; 145 145 -
trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc
r7412 r7420 26 26 // 27 27 // MJTrainRanForest 28 // 29 // Base class for classes training a random forest 28 30 // 29 31 ///////////////////////////////////////////////////////////////////////////// -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
r7412 r7420 30 30 #include "MJTrainSeparation.h" 31 31 32 #include <TH2.h> 33 #include <TGraph.h> 34 #include <TVirtualPad.h> 35 32 36 #include "MHMatrix.h" 33 37 … … 36 40 37 41 // tools 42 #include "MMath.h" 38 43 #include "MDataSet.h" 39 44 #include "MTFillMatrix.h" 40 45 #include "MChisqEval.h" 46 #include "MStatusDisplay.h" 41 47 42 48 // eventloop … … 63 69 // filter 64 70 #include "MF.h" 71 #include "MFEventSelector.h" 65 72 #include "MFilterList.h" 66 73 … … 68 75 69 76 using namespace std; 77 78 void MJTrainSeparation::DisplayResult(MH3 &h31, MH3 &h32) 79 { 80 TH2 &g = (TH2&)h32.GetHist(); 81 TH2 &h = (TH2&)h31.GetHist(); 82 83 h.SetMarkerColor(kRed); 84 g.SetMarkerColor(kGreen); 85 86 const Int_t nx = h.GetNbinsX(); 87 const Int_t ny = h.GetNbinsY(); 88 89 gROOT->SetSelectedPad(NULL); 90 91 TGraph gr1; 92 TGraph gr2; 93 for (int x=0; x<nx; x++) 94 { 95 TH1 *hx = h.ProjectionY("H_py", x+1, x+1); 96 TH1 *gx = g.ProjectionY("G_py", x+1, x+1); 97 98 Double_t max1 = -1; 99 Double_t max2 = -1; 100 Int_t maxy1 = 0; 101 Int_t maxy2 = 0; 102 for (int y=0; y<ny; y++) 103 { 104 const Float_t s = gx->Integral(1, y+1); 105 const Float_t b = hx->Integral(1, y+1); 106 const Float_t sig1 = MMath::SignificanceLiMa(s+b, b); 107 const Float_t sig2 = s<1 ? 0 : MMath::SignificanceLiMa(s+b, b)*TMath::Log10(s); 108 if (sig1>max1) 109 { 110 maxy1 = y; 111 max1 = sig1; 112 } 113 if (sig2>max2) 114 { 115 maxy2 = y; 116 max2 = sig2; 117 } 118 } 119 120 gr1.SetPoint(x, h.GetXaxis()->GetBinCenter(x+1), h.GetYaxis()->GetBinCenter(maxy1+1)); 121 gr2.SetPoint(x, h.GetXaxis()->GetBinCenter(x+1), h.GetYaxis()->GetBinCenter(maxy2+1)); 122 123 delete hx; 124 delete gx; 125 } 126 127 fDisplay->AddTab("OptCut"); 128 gPad->SetLogx(); 129 h.DrawCopy(); 130 g.DrawCopy("same"); 131 gr1.SetMarkerStyle(kFullDotMedium); 132 gr1.DrawClone("LP")->SetBit(kCanDelete); 133 gr2.SetLineColor(kBlue); 134 gr2.SetMarkerStyle(kFullDotMedium); 135 gr2.DrawClone("LP")->SetBit(kCanDelete); 136 } 70 137 71 138 Bool_t MJTrainSeparation::Train(const char *out) … … 83 150 84 151 // --------------------- Setup files -------------------- 85 MReadMarsFile read ("Events");152 MReadMarsFile read1("Events"); 86 153 MReadMarsFile read2("Events"); 87 154 MReadMarsFile read3("Events"); 88 read.DisableAutoScheme(); 155 MReadMarsFile read4("Events"); 156 read1.DisableAutoScheme(); 89 157 read2.DisableAutoScheme(); 90 158 read3.DisableAutoScheme(); 91 92 fDataSetTrain.AddFilesOn(read); 159 read4.DisableAutoScheme(); 160 161 fDataSetTrain.AddFilesOn(read1); 93 162 fDataSetTrain.AddFilesOff(read3); 94 163 95 164 fDataSetTest.AddFilesOff(read2); 96 fDataSetTest.AddFilesOn(read2); 97 98 read2.VetoBranch("MMcTrig"); 99 read2.VetoBranch("MTime"); 100 read2.VetoBranch("MMcRunHeader"); 101 read2.VetoBranch("MMcTrigHeader"); 102 read2.VetoBranch("MMcFadcHeader"); 103 read2.VetoBranch("MMcCorsikaRunHeader"); 104 read2.VetoBranch("MMcConfigRunHeader"); 105 165 fDataSetTest.AddFilesOn(read4); 106 166 107 167 // ----------------------- Setup RF ---------------------- … … 116 176 MParList plistx; 117 177 plistx.AddToList(&had); 178 plistx.AddToList(this); 118 179 119 180 MTFillMatrix fill; … … 127 188 fill.SetName("FillGammas"); 128 189 fill.SetDestMatrix1(&train, fNumTrainOn); 129 fill.SetReader(&read );190 fill.SetReader(&read1); 130 191 if (!fill.Process(plistx)) 131 192 return kFALSE; … … 160 221 return kFALSE; 161 222 223 //fDisplay = rf.GetDisplay(); 224 162 225 // --------------------- Display result ---------------------- 163 164 226 gLog.Separator("Test"); 165 227 … … 172 234 plist.AddToList(&mcevt); 173 235 236 // ----- Setup histograms ----- 174 237 MBinning binsy(100, 0 , 1, "BinningMH3Y", "lin"); 175 MBinning binsx( 100, 10, 100000, "BinningMH3X", "log");238 MBinning binsx( 50, 10, 100000, "BinningMH3X", "log"); 176 239 177 240 plist.AddToList(&binsx); … … 183 246 h32.SetTitle("Background probability vs. Size:Size [phe]:Hadronness"); 184 247 185 MF f("MRawRunHeader.fRunType>255");186 MFilterList list;187 list.SetInverted();188 list.AddToList(&f);189 190 248 MHHadronness hist; 191 249 192 MFillH fillh(&hist, "", "FillHadronness");193 MFillH fillh 1(&h31, "", "FillGammas");194 MFillH fillh 2(&h32, "", "FillBackground");195 fillh1.SetNameTab("Gammas");196 fillh 2.SetNameTab("Background");197 198 fillh 1.SetFilter(&f);199 fillh2.SetFilter(&list); 200 250 // ----- Setup tasks ----- 251 MFillH fillh0(&hist, "", "FillHadronness"); 252 MFillH fillh1(&h31); 253 MFillH fillh2(&h32); 254 fillh1.SetNameTab("Background"); 255 fillh2.SetNameTab("Gammas"); 256 fillh0.SetBit(MFillH::kDoNotDisplay); 257 258 // ----- Setup filter ----- 201 259 MFilterList precuts; 202 260 precuts.AddToList(fPreCuts); … … 204 262 205 263 MContinue c0(&precuts); 264 c0.SetName("PreCuts"); 206 265 c0.SetInverted(); 207 266 267 MFEventSelector sel; 268 sel.SetNumSelectEvts(fNumTestOn); 269 270 MContinue c1(&sel); 271 c1.SetInverted(); 272 273 // ----- Setup tasklist ----- 208 274 tlist.AddToList(&read2); 209 275 tlist.AddToList(&c0); 276 tlist.AddToList(&c1); 210 277 tlist.AddToList(&rf); 211 tlist.AddToList(&fillh); 212 tlist.AddToList(&list); 278 tlist.AddToList(&fillh0); 213 279 tlist.AddToList(&fillh1); 214 tlist.AddToList(&fillh2); 215 280 281 // ----- Run eventloop on gammas ----- 216 282 MEvtLoop loop; 217 283 loop.SetDisplay(fDisplay); … … 222 288 return kFALSE; 223 289 290 // ----- Setup and run eventloop on background ----- 291 sel.SetNumSelectEvts(fNumTestOff); 292 fillh0.ResetBit(MFillH::kDoNotDisplay); 293 294 tlist.Replace(&read4); 295 tlist.Replace(&fillh2); 296 297 if (!loop.Eventloop()) 298 return kFALSE; 299 300 DisplayResult(h31, h32); 301 224 302 if (!WriteDisplay(out)) 225 303 return kFALSE; -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.h
r7412 r7420 10 10 #endif 11 11 12 class MH3; 13 12 14 class MJTrainSeparation : public MJTrainRanForest 13 15 { … … 19 21 UInt_t fNumTrainOff; 20 22 23 UInt_t fNumTestOn; 24 UInt_t fNumTestOff; 25 26 void DisplayResult(MH3 &h31, MH3 &h32); 27 21 28 public: 22 MJTrainSeparation() { } 29 MJTrainSeparation() : 30 fNumTrainOn((UInt_t)-1), fNumTrainOff((UInt_t)-1), fNumTestOn((UInt_t)-1), fNumTestOff((UInt_t)-1) 31 { } 23 32 24 void SetDataSetTrain(const MDataSet &ds, UInt_t non , UInt_t noff)33 void SetDataSetTrain(const MDataSet &ds, UInt_t non=(UInt_t)-1, UInt_t noff=(UInt_t)-1) 25 34 { 26 35 ds.Copy(fDataSetTrain); … … 28 37 fNumTrainOff = noff; 29 38 } 30 void SetDataSetTest(const MDataSet &ds )39 void SetDataSetTest(const MDataSet &ds, UInt_t non=(UInt_t)-1, UInt_t noff=(UInt_t)-1) 31 40 { 32 41 ds.Copy(fDataSetTest); 42 fNumTestOn = non; 43 fNumTestOff = noff; 33 44 } 34 45
Note:
See TracChangeset
for help on using the changeset viewer.