Changeset 7724
- Timestamp:
- 05/21/06 16:17:05 (19 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7723 r7724 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2006/05/21 Thomas Bretz 22 23 * mfileio/MReadTree.cc: 24 - show all added files only in debug modes or if wildcards are used 25 26 * mfilter/MFEnergySlope.[h,cc]: 27 - added a third constructor which also allows to set fMcEnergyMin 28 29 * mjtrain/MJTrainSeparation.[h,cc]: 30 - updated text output 31 - improved result display 32 - added possibility to set weights and/or pre/post-tasks for 33 train or test only 34 35 * mranforest/MRanForest.cc: 36 - commented out an obsolete check to check whether TMath::Sort 37 has sorted correctly 38 - added some comments 39 40 20 41 21 42 2006/05/20 Thomas Bretz -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r6932 r7724 395 395 { 396 396 SetBit(kChainWasChanged); 397 *fLog << inf << GetDescriptor() << ": Added " << fname << " <" << numfiles << ">" << endl; 397 if (numfiles>1 || gLog.GetDebugLevel()>4) 398 *fLog << inf << GetDescriptor() << ": Added " << fname << " <" << numfiles << ">" << endl; 398 399 } 399 400 else -
trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc
r7643 r7724 87 87 // -------------------------------------------------------------------------- 88 88 // 89 // Constructor 90 // 91 MFEnergySlope::MFEnergySlope(Float_t slope, Float_t emin, const char *name, const char *title): 92 fNewSlope(TMath::Abs(slope)), fMcMinEnergy(emin), fMcMaxEnergy(-1.) 93 { 94 fName = name ? name : "MFEnergySlope"; 95 fTitle = title ? title : "Filter to select energy with given slope"; 96 } 97 98 // -------------------------------------------------------------------------- 99 // 89 100 // Preprocess 90 101 // -
trunk/MagicSoft/Mars/mfilter/MFEnergySlope.h
r7409 r7724 38 38 MFEnergySlope(const char *name=NULL, const char *title=NULL); 39 39 MFEnergySlope(Float_t slope, const char *name=NULL, const char *title=NULL); 40 MFEnergySlope(Float_t slope, Float_t emin, const char *name=NULL, const char *title=NULL); 40 41 41 42 // Setter -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
r7700 r7724 36 36 #include <TMarker.h> 37 37 #include <TCanvas.h> 38 #include <TStopwatch.h> 38 39 #include <TVirtualPad.h> 39 40 … … 81 82 using namespace std; 82 83 83 void MJTrainSeparation::DisplayResult(MH3 &h31, MH3 &h32 )84 void MJTrainSeparation::DisplayResult(MH3 &h31, MH3 &h32, Float_t ontime) 84 85 { 85 86 TH2D &g = (TH2D&)h32.GetHist(); … … 107 108 gROOT->SetSelectedPad(NULL); 108 109 110 111 Double_t Stot = 0; 112 Double_t Btot = 0; 113 114 Double_t max2 = -1; 115 109 116 TGraph gr1; 110 117 TGraph gr2; 111 for (int x= 0; x<nx; x++)118 for (int x=nx-1; x>=0; x--) 112 119 { 113 120 TH1 *hx = h.ProjectionY("H_py", x+1, x+1); 114 121 TH1 *gx = g.ProjectionY("G_py", x+1, x+1); 115 122 123 Double_t S = 0; 124 Double_t B = 0; 125 116 126 Double_t max1 = -1; 117 Double_t max2 = -1;118 127 Int_t maxy1 = 0; 119 128 Int_t maxy2 = 0; 120 for (int y= 0; y<ny; y++)129 for (int y=ny-1; y>=0; y--) 121 130 { 122 131 const Float_t s = gx->Integral(1, y+1); 123 132 const Float_t b = hx->Integral(1, y+1); 124 133 const Float_t sig1 = MMath::SignificanceLiMa(s+b, b); 125 const Float_t sig2 = s<1 ? 0 : MMath::SignificanceLiMa(s+b, b)*TMath::Log10(s+1);134 const Float_t sig2 = MMath::SignificanceLiMa(s+Stot+b+Btot, b+Btot)*TMath::Log10(s+Stot+1); 126 135 if (sig1>max1) 127 136 { … … 133 142 maxy2 = y; 134 143 max2 = sig2; 144 145 S=s; 146 B=b; 135 147 } 136 148 … … 138 150 } 139 151 152 Stot += S; 153 Btot += B; 154 140 155 gr1.SetPoint(x, h.GetXaxis()->GetBinCenter(x+1), h.GetYaxis()->GetBinCenter(maxy1+1)); 141 156 gr2.SetPoint(x, h.GetXaxis()->GetBinCenter(x+1), h.GetYaxis()->GetBinCenter(maxy2+1)); … … 145 160 } 146 161 162 //cout << "--> " << MMath::SignificanceLiMa(Stot+Btot, Btot) << " "; 163 //cout << Stot << " " << Btot << endl; 164 165 166 Int_t mx1=0; 167 Int_t my1=0; 168 Int_t mx2=0; 169 Int_t my2=0; 170 Int_t s1=0; 171 Int_t b1=0; 172 Int_t s2=0; 173 Int_t b2=0; 174 Double_t sig1=-1; 175 Double_t sig2=-1; 147 176 for (int x=0; x<nx; x++) 148 177 { … … 155 184 const Float_t sig = MMath::SignificanceLiMa(s+b, b); 156 185 res2.SetBinContent(x+1, y+1, sig); 186 187 // Search for top-rightmost maximum 188 if (sig>=sig1) 189 { 190 mx1=x+1; 191 my1=y+1; 192 s1 = TMath::Nint(s); 193 b1 = TMath::Nint(b); 194 sig1=sig; 195 } 196 if (TMath::Log10(s)*sig>=sig2) 197 { 198 mx2=x+1; 199 my2=y+1; 200 s2 = TMath::Nint(s); 201 b2 = TMath::Nint(b); 202 sig2=TMath::Log10(s)*sig; 203 } 157 204 } 158 205 delete hx; … … 179 226 delete gx; 180 227 181 TCanvas &c = fDisplay->AddTab("OptCut"); 182 c.SetBorderMode(0); 183 c.Divide(2,2); 184 185 c.cd(1); 186 gPad->SetBorderMode(0); 187 gPad->SetFrameBorderMode(0); 188 gPad->SetLogx(); 189 gPad->SetGridx(); 190 gPad->SetGridy(); 191 h.DrawCopy(); 192 g.DrawCopy("same"); 193 gr1.SetMarkerStyle(kFullDotMedium); 194 gr1.DrawClone("LP")->SetBit(kCanDelete); 195 gr2.SetLineColor(kBlue); 196 gr2.SetMarkerStyle(kFullDotMedium); 197 gr2.DrawClone("LP")->SetBit(kCanDelete); 198 199 c.cd(3); 200 gPad->SetBorderMode(0); 201 gPad->SetFrameBorderMode(0); 202 gPad->SetGridx(); 203 gPad->SetGridy(); 204 gr4.SetMinimum(0); 205 gr4.SetMarkerStyle(kFullDotMedium); 206 gr4.DrawClone("ALP")->SetBit(kCanDelete); 207 gr3.SetLineColor(kBlue); 208 gr3.SetMarkerStyle(kFullDotMedium); 209 gr3.DrawClone("LP")->SetBit(kCanDelete); 210 211 c.cd(2); 212 gPad->SetBorderMode(0); 213 gPad->SetFrameBorderMode(0); 214 gPad->SetLogx(); 215 gPad->SetGridx(); 216 gPad->SetGridy(); 217 gPad->AddExec("color", "gStyle->SetPalette(1, 0);"); 218 res1.SetMaximum(7); 219 res1.DrawCopy("colz"); 220 221 c.cd(4); 222 gPad->SetBorderMode(0); 223 gPad->SetFrameBorderMode(0); 224 gPad->SetLogx(); 225 gPad->SetGridx(); 226 gPad->SetGridy(); 227 gPad->AddExec("color", "gStyle->SetPalette(1, 0);"); 228 res2.SetMaximum(res2.GetMaximum()*1.05); 229 res2.DrawCopy("colz"); 230 231 Int_t mx, my, mz; 232 res2.GetMaximumBin(mx, my, mz); 233 234 TMarker m; 235 m.SetMarkerStyle(kStar); 236 m.DrawMarker(res2.GetXaxis()->GetBinCenter(mx), res2.GetYaxis()->GetBinCenter(my)); 228 if (fDisplay) 229 { 230 TCanvas &c = fDisplay->AddTab("OptCut"); 231 c.SetBorderMode(0); 232 c.Divide(2,2); 233 234 c.cd(1); 235 gPad->SetBorderMode(0); 236 gPad->SetFrameBorderMode(0); 237 gPad->SetLogx(); 238 gPad->SetGridx(); 239 gPad->SetGridy(); 240 h.DrawCopy(); 241 g.DrawCopy("same"); 242 gr1.SetMarkerStyle(kFullDotMedium); 243 gr1.DrawClone("LP")->SetBit(kCanDelete); 244 gr2.SetLineColor(kBlue); 245 gr2.SetMarkerStyle(kFullDotMedium); 246 gr2.DrawClone("LP")->SetBit(kCanDelete); 247 248 c.cd(3); 249 gPad->SetBorderMode(0); 250 gPad->SetFrameBorderMode(0); 251 gPad->SetGridx(); 252 gPad->SetGridy(); 253 gr4.SetMinimum(0); 254 gr4.SetMarkerStyle(kFullDotMedium); 255 gr4.DrawClone("ALP")->SetBit(kCanDelete); 256 gr3.SetLineColor(kBlue); 257 gr3.SetMarkerStyle(kFullDotMedium); 258 gr3.DrawClone("LP")->SetBit(kCanDelete); 259 260 c.cd(2); 261 gPad->SetBorderMode(0); 262 gPad->SetFrameBorderMode(0); 263 gPad->SetLogx(); 264 gPad->SetGridx(); 265 gPad->SetGridy(); 266 gPad->AddExec("color", "gStyle->SetPalette(1, 0);"); 267 res1.SetMaximum(7); 268 res1.DrawCopy("colz"); 269 270 c.cd(4); 271 gPad->SetBorderMode(0); 272 gPad->SetFrameBorderMode(0); 273 gPad->SetLogx(); 274 gPad->SetGridx(); 275 gPad->SetGridy(); 276 gPad->AddExec("color", "gStyle->SetPalette(1, 0);"); 277 res2.SetMaximum(res2.GetMaximum()*1.05); 278 res2.DrawCopy("colz"); 279 280 // Int_t mx, my, mz; 281 // res2.GetMaximumBin(mx, my, mz); 282 283 TMarker m; 284 m.SetMarkerStyle(kStar); 285 m.DrawMarker(res2.GetXaxis()->GetBinCenter(mx1), res2.GetYaxis()->GetBinCenter(my1)); 286 m.SetMarkerStyle(kPlus); 287 m.DrawMarker(res2.GetXaxis()->GetBinCenter(mx2), res2.GetYaxis()->GetBinCenter(my2)); 288 } 289 290 *fLog << all << "Observation Time: " << TMath::Nint(ontime/60) << "min" << endl; 291 *fLog << "Maximum Significance: " << Form("%.1f", sig1) << " ["; 292 *fLog << Form("%.1f", sig1/TMath::Sqrt(ontime/3600)) << "/sqrt(h)]"; 293 *fLog << endl; 294 295 *fLog << "Significance: S=" << Form("%.1f", sig1) << " E=" << s1 << " B=" << b1 << " h<"; 296 *fLog << Form("%.2f", res2.GetYaxis()->GetBinCenter(my1)) << " s>"; 297 *fLog << Form("%3d", TMath::Nint(res2.GetXaxis()->GetBinCenter(mx1))) << endl; 298 *fLog << "Significance*LogE: S=" << Form("%.1f", sig2/TMath::Log10(s2)) << " E=" << s2 << " B=" << b2 << " h<"; 299 *fLog << Form("%.2f", res2.GetYaxis()->GetBinCenter(my2)) << " s>"; 300 *fLog << Form("%3d", TMath::Nint(res2.GetXaxis()->GetBinCenter(mx2))) << endl; 301 *fLog << endl; 237 302 } 238 303 … … 392 457 } 393 458 394 Bool_t MJTrainSeparation::AutoTrain(MDataSet &set, UInt_t &seton, UInt_t &setoff)459 Float_t MJTrainSeparation::AutoTrain(MDataSet &set, Type_t typon, Type_t typof, Float_t flux) 395 460 { 396 461 Double_t num, min, max; 397 462 if (!GetEventsProduced(set, num, min, max)) 398 return kFALSE;463 return -1; 399 464 400 465 *fLog << inf << "Using build-in radius of 300m to calculate collection area!" << endl; … … 402 467 // Target spectrum 403 468 TF1 flx("Flux", "[0]/1000*(x/1000)^(-2.6)", min, max); 404 flx.SetParameter(0, f Flux);469 flx.SetParameter(0, flux); 405 470 406 471 // Number n0 of events this spectrum would produce per s and m^2 … … 412 477 // Rate R of events this spectrum would produce per s 413 478 const Double_t R = n0*A; //[Hz] 479 480 *fLog << "Source Spectrum: " << flux << " * (E/TeV)^(-2.6) * TeV*m^2*s" << endl; 414 481 415 482 *fLog << "Gamma rate from the source inside the MC production area: " << R << "Hz" << endl; … … 428 495 Double_t data=0; 429 496 const Double_t r = GetDataRate(set, data); //[Hz] 497 Double_t ontime = data/r; 430 498 431 499 *fLog << "Events measured per second effective on time: " << r << "Hz" << endl; 432 *fLog << "Total effective on time: " << data/r<< "s" << endl;433 434 const Double_t ratio = T *r/data;500 *fLog << "Total effective on time: " << ontime << "s" << endl; 501 502 const Double_t ratio = T/ontime; 435 503 *fLog << "Ratio of Monte Carlo to data observation time: " << ratio << endl; 436 504 … … 445 513 446 514 if (r<0) 447 return kFALSE;515 return -1; 448 516 449 517 Double_t nummc = GetNumMC(set); … … 460 528 off = TMath::Nint(data); 461 529 *fLog << warn; 462 *fLog << "Not enough data events available... scaling by " << data/n << endl;530 *fLog << "Not enough data events available... scaling MC to data by " << data/n << endl; 463 531 *fLog << inf; 464 532 } … … 469 537 } 470 538 471 if (seton>0 && seton<on) 472 { 473 setoff = TMath::Nint(off*seton/on); 474 *fLog << "Less MC events requested... scaling by " << seton/on << endl; 539 if (fNum[typon]>0 && fNum[typon]<on) 540 { 541 fNum[typof] = TMath::Nint(off*fNum[typon]/on); 542 ontime *= fNum[typon]/on; 543 *fLog << warn << "Less MC events requested... scaling data to MC by " << fNum[typon]/on << endl; 475 544 } 476 545 else 477 546 { 478 seton = TMath::Nint(on); 479 setoff = TMath::Nint(off); 480 } 481 482 *fLog << "Target number of MC events: " << seton << endl; 483 *fLog << "Target number of data events: " << setoff << endl; 547 fNum[typon] = TMath::Nint(on); 548 fNum[typof] = TMath::Nint(off); 549 } 550 551 *fLog << inf; 552 *fLog << "Target number of MC events: " << fNum[typon] << endl; 553 *fLog << "Target number of data events: " << fNum[typof] << endl; 484 554 485 555 /* … … 498 568 */ 499 569 500 return kTRUE;570 return ontime; 501 571 } 502 572 … … 520 590 } 521 591 592 TStopwatch clock; 593 clock.Start(); 594 522 595 // ----------------------- Auto Train? ---------------------- 523 596 597 Float_t ontime = -1; 524 598 if (fAutoTrain) 525 599 { 526 600 fLog->Separator("Auto-Training -- Train-Data"); 527 if ( !AutoTrain(fDataSetTrain, fNumTrainOn, fNumTrainOff))601 if (AutoTrain(fDataSetTrain, kTrainOn, kTrainOff, fFluxTrain)<0) 528 602 return kFALSE; 529 603 fLog->Separator("Auto-Training -- Test-Data"); 530 if (!AutoTrain(fDataSetTest, fNumTestOn, fNumTestOff)) 604 ontime = AutoTrain(fDataSetTest, kTestOn, kTestOff, fFluxTest); 605 if (ontime<0) 531 606 return kFALSE; 532 607 } … … 552 627 MHMatrix train("Train"); 553 628 train.AddColumns(fRules); 554 if (fEnableWeights On || fEnableWeightsOff)629 if (fEnableWeights[kTrainOn] || fEnableWeights[kTrainOff]) 555 630 train.AddColumn("MWeight.fVal"); 556 631 train.AddColumn("MHadronness.fVal"); … … 565 640 // Add them to the parameter list 566 641 MParList plistx; 642 plistx.AddToList(this); // take care of fDisplay! 567 643 plistx.AddToList(&had); 568 644 plistx.AddToList(&wgt); 569 plistx.AddToList(this);570 645 571 646 // Setup the tool class to fill the matrix … … 582 657 // Setup the tool class to read the gammas and read them 583 658 fill.SetName("FillGammas"); 584 fill.SetDestMatrix1(&train, fNum TrainOn);659 fill.SetDestMatrix1(&train, fNum[kTrainOn]); 585 660 fill.SetReader(&read1); 586 fill.AddPreTasks(fPreTasks On);661 fill.AddPreTasks(fPreTasksSet[kTrainOn]); 587 662 fill.AddPreTasks(fPreTasks); 588 fill.AddPostTasks(fPostTasks On);663 fill.AddPostTasks(fPostTasksSet[kTrainOn]); 589 664 fill.AddPostTasks(fPostTasks); 590 665 if (!fill.Process(plistx)) … … 616 691 if (fDataSetTrain.IsWobbleMode()) 617 692 { 618 fPreTasks Off.AddFirst(&hcalc);619 fPreTasks Off.AddFirst(&srcrndm);693 fPreTasksSet[kTrainOff].AddFirst(&hcalc); 694 fPreTasksSet[kTrainOff].AddFirst(&srcrndm); 620 695 } 621 696 622 697 // Setup the tool class to read the background and read them 623 698 fill.SetName("FillBackground"); 624 fill.SetDestMatrix1(&train, fNum TrainOff);699 fill.SetDestMatrix1(&train, fNum[kTrainOff]); 625 700 fill.SetReader(&read3); 626 fill.AddPreTasks(fPreTasks Off);701 fill.AddPreTasks(fPreTasksSet[kTrainOff]); 627 702 fill.AddPreTasks(fPreTasks); 628 fill.AddPostTasks(fPostTasks Off);703 fill.AddPostTasks(fPostTasksSet[kTrainOff]); 629 704 fill.AddPostTasks(fPostTasks); 630 705 if (!fill.Process(plistx)) … … 646 721 rf.SetNumTry(fNumTry); 647 722 rf.SetNumObsoleteVariables(1); 648 rf.SetLastDataColumnHasWeights(fEnableWeights On || fEnableWeightsOff);723 rf.SetLastDataColumnHasWeights(fEnableWeights[kTrainOn] || fEnableWeights[kTrainOff]); 649 724 rf.SetDebug(fDebug); 650 725 rf.SetDisplay(fDisplay); … … 671 746 *fLog << "Training method:" << endl; 672 747 *fLog << " * " << (fUseRegression?"regression":"classification") << endl; 673 if (fEnableWeights On)748 if (fEnableWeights[kTrainOn]) 674 749 *fLog << " * weights for on-data" << endl; 675 if (fEnableWeights Off)750 if (fEnableWeights[kTrainOff]) 676 751 *fLog << " * weights for off-data" << endl; 677 752 if (fDataSetTrain.IsWobbleMode()) … … 683 758 *fLog << endl; 684 759 *fLog << "Gamma/Background ratio:" << endl; 685 *fLog << " * Requested: " << (float)fNum TrainOn/fNumTrainOff<< endl;760 *fLog << " * Requested: " << (float)fNum[kTrainOn]/fNum[kTrainOff] << endl; 686 761 *fLog << " * Result: " << (float)numgammastrn/numbackgrndtrn << endl; 762 *fLog << endl; 763 *fLog << "Run-Time: " << Form("%.1f", clock.RealTime()/60) << "min (CPU: "; 764 *fLog << Form("%.1f", clock.CpuTime()/60) << "min)" << endl; 687 765 688 766 // Chekc if testing is requested … … 693 771 fLog->Separator("Test"); 694 772 773 clock.Continue(); 774 695 775 // Setup parlist and tasklist for testing 696 776 MParList plist; 697 777 MTaskList tlist; 698 plist.AddToList(this); 778 plist.AddToList(this); // Take care of display 699 779 plist.AddToList(&tlist); 700 780 … … 747 827 748 828 MFEventSelector sel; // FIXME: USING IT (WITH PROB?) in READ will by much faster!!! 749 sel.SetNumSelectEvts(fNum TestOff);829 sel.SetNumSelectEvts(fNum[kTestOff]); 750 830 751 831 MContinue c1(&sel); … … 755 835 tlist.AddToList(&read2); 756 836 tlist.AddToList(&c1); 757 tlist.AddToList(fPreTasks Off);837 tlist.AddToList(fPreTasksSet[kTestOff]); 758 838 tlist.AddToList(fPreTasks); 759 839 tlist.AddToList(&c0); 760 840 tlist.AddToList(&rf); 761 tlist.AddToList(fPostTasks Off);841 tlist.AddToList(fPostTasksSet[kTestOff]); 762 842 tlist.AddToList(fPostTasks); 763 843 tlist.AddToList(&fillh0); … … 776 856 if (!loop.Eventloop()) 777 857 return kFALSE; 778 858 /* 859 if (!loop.GetDisplay()) 860 { 861 gLog << warn << "Display closed by user... execution aborted." << endl << endl; 862 return kFALSE; 863 } 864 */ 779 865 // ----- Setup and run eventloop on gammas ----- 780 sel.SetNumSelectEvts(fNum TestOn);866 sel.SetNumSelectEvts(fNum[kTestOn]); 781 867 fillh0.ResetBit(MFillH::kDoNotDisplay); 782 868 783 869 // Remove PreTasksOff and PostTasksOff from the list 784 tlist.RemoveFromList(fPreTasks Off);785 tlist.RemoveFromList(fPostTasks Off);870 tlist.RemoveFromList(fPreTasksSet[kTestOff]); 871 tlist.RemoveFromList(fPostTasksSet[kTestOff]); 786 872 787 873 // replace the reading task by a new one … … 789 875 790 876 // Add the PreTasksOn directly after the reading task 791 tlist.AddToListAfter(fPreTasks On, &c1);877 tlist.AddToListAfter(fPreTasksSet[kTestOn], &c1); 792 878 793 879 // Add the PostTasksOn after rf 794 tlist.AddToListAfter(fPostTasks On, &rf);880 tlist.AddToListAfter(fPostTasksSet[kTestOn], &rf); 795 881 796 882 // Replace fillh1 by fillh2 … … 805 891 wgt.SetVal(1); 806 892 if (!loop.Eventloop()) 807 return kFALSE;808 809 // Display the result plots810 DisplayResult(h31, h32);811 812 // Write the display813 if (!WriteDisplay(out))814 893 return kFALSE; 815 894 … … 822 901 *fLog << "Test method:" << endl; 823 902 *fLog << " * Random Forest: " << out << endl; 824 if (fEnableWeights On)903 if (fEnableWeights[kTestOn]) 825 904 *fLog << " * weights for on-data" << endl; 826 if (fEnableWeights Off)905 if (fEnableWeights[kTestOff]) 827 906 *fLog << " * weights for off-data" << endl; 828 907 if (fDataSetTrain.IsWobbleMode()) 829 908 *fLog << " * random source position in a distance of 0.4°" << endl; 909 *fLog << endl; 830 910 *fLog << "Events used for test:" << endl; 831 911 *fLog << " * Gammas: " << numgammastst << endl; … … 833 913 *fLog << endl; 834 914 *fLog << "Gamma/Background ratio:" << endl; 835 *fLog << " * Requested: " << (float)fNum TestOn/fNumTestOff<< endl;915 *fLog << " * Requested: " << (float)fNum[kTestOn]/fNum[kTestOff] << endl; 836 916 *fLog << " * Result: " << (float)numgammastst/numbackgrndtst << endl; 917 *fLog << endl; 918 919 // Display the result plots 920 DisplayResult(h31, h32, ontime); 921 922 *fLog << "Total Run-Time: " << Form("%.1f", clock.RealTime()/60) << "min (CPU: "; 923 *fLog << Form("%.1f", clock.CpuTime()/60) << "min)" << endl; 924 fLog->Separator(); 925 926 // Write the display 927 if (!WriteDisplay(out)) 928 return kFALSE; 837 929 838 930 return kTRUE; -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.h
r7701 r7724 14 14 class MJTrainSeparation : public MJTrainRanForest 15 15 { 16 public: 17 enum Type_t { kTrainOn, kTrainOff, kTestOn, kTestOff }; 18 16 19 private: 17 20 MDataSet fDataSetTest; 18 21 MDataSet fDataSetTrain; 19 22 20 UInt_t fNumTrainOn; 21 UInt_t fNumTrainOff; 23 UInt_t fNum[4]; 22 24 23 UInt_t fNumTestOn; 24 UInt_t fNumTestOff; 25 26 TList fPreTasksOn; 27 TList fPreTasksOff; 28 TList fPostTasksOn; 29 TList fPostTasksOff; 25 TList fPreTasksSet[4]; 26 TList fPostTasksSet[4]; 30 27 31 28 Bool_t fAutoTrain; 32 29 Bool_t fUseRegression; 33 Bool_t fEnableWeightsOn;34 Bool_t fEnableWeightsOff;35 30 36 Float_t fFlux;31 Bool_t fEnableWeights[4]; 37 32 38 void DisplayResult(MH3 &h31, MH3 &h32); 33 Float_t fFluxTrain; 34 Float_t fFluxTest; 39 35 36 // Result 37 void DisplayResult(MH3 &h31, MH3 &h32, Float_t ontime); 38 39 // Auto training 40 40 Bool_t GetEventsProduced(MDataSet &set, Double_t &num, Double_t &min, Double_t &max) const; 41 41 Double_t GetDataRate(MDataSet &set, Double_t &num) const; 42 42 Double_t GetNumMC(MDataSet &set) const; 43 Bool_t AutoTrain(MDataSet &set, UInt_t &on, UInt_t &off);43 Float_t AutoTrain(MDataSet &set, Type_t typon, Type_t typoff, Float_t flux); 44 44 45 45 public: 46 46 MJTrainSeparation() : 47 fNumTrainOn((UInt_t)-1), fNumTrainOff((UInt_t)-1),48 fNumTestOn((UInt_t)-1), fNumTestOff((UInt_t)-1),49 47 fAutoTrain(kFALSE), fUseRegression(kFALSE), 50 f EnableWeightsOn(kFALSE), fEnableWeightsOff(kFALSE), fFlux(2e-7)51 { }48 fFluxTrain(2e-7), fFluxTest(2e-7) 49 { for (int i=0; i<4; i++) { fEnableWeights[i]=kFALSE; fNum[i] = (UInt_t)-1; } } 52 50 53 51 void SetDataSetTrain(const MDataSet &ds, UInt_t non=(UInt_t)-1, UInt_t noff=(UInt_t)-1) … … 57 55 fDataSetTrain.SetNumAnalysis(1); 58 56 59 fNum TrainOn= non;60 fNum TrainOff= noff;57 fNum[kTrainOn] = non; 58 fNum[kTrainOff] = noff; 61 59 } 62 60 void SetDataSetTest(const MDataSet &ds, UInt_t non=(UInt_t)-1, UInt_t noff=(UInt_t)-1) … … 66 64 fDataSetTest.SetNumAnalysis(1); 67 65 68 fNum TestOn= non;69 fNum TestOff= noff;66 fNum[kTestOn] = non; 67 fNum[kTestOff] = noff; 70 68 } 71 69 72 void AddPreTaskOn(MTask *t) { Add(fPreTasksOn, t); }73 void AddPreTask On(const char *rule,74 const char *name="MWeight") { AddPar(fPreTasksOn, rule, name); }70 // Deprecated, used for test purpose 71 void AddPreTask(Type_t typ, MTask *t) { Add(fPreTasksSet[typ], t); } 72 void AddPreTask(Type_t typ, const char *rule, const char *name="MWeight") { AddPar(fPreTasksSet[typ], rule, name); } 75 73 76 void AddPreTaskOff(MTask *t) { Add(fPreTasksOff, t); } 77 void AddPreTaskOff(const char *rule, 78 const char *name="MWeight") { AddPar(fPreTasksOff, rule, name); } 74 void AddPostTask(Type_t typ, MTask *t) { Add(fPostTasksSet[typ], t); } 75 void AddPostTask(Type_t typ, const char *rule, const char *name="MWeight") { AddPar(fPostTasksSet[typ], rule, name); } 79 76 80 void AddPostTaskOn(MTask *t) { Add(fPostTasksOn, t); } 81 void AddPostTaskOn(const char *rule, 82 const char *name="MWeight") { AddPar(fPostTasksOn, rule, name); } 77 void SetWeights(Type_t typ, const char *rule) { if (fEnableWeights[typ]) return; fEnableWeights[typ]=kTRUE; AddPostTask(typ, rule); } 78 void SetWeights(Type_t typ, MTask *t) { if (fEnableWeights[typ]) return; fEnableWeights[typ]=kTRUE; AddPostTask(typ, t); } 83 79 84 void AddPostTaskOff(MTask *t) { Add(fPostTasksOff, t); } 85 void AddPostTaskOff(const char *rule, 86 const char *name="MWeight") { AddPar(fPostTasksOff, rule, name); } 80 // Standard user interface 81 void AddPreTaskOn(MTask *t) { AddPreTask(kTrainOn, t); AddPreTask(kTestOn, t); } 82 void AddPreTaskOn(const char *rule, const char *name="MWeight") { AddPreTask(kTrainOn, rule, name); AddPreTask(kTestOn, rule, name); } 83 void AddPreTaskOff(MTask *t) { AddPreTask(kTrainOff, t); AddPreTask(kTestOff, t); } 84 void AddPreTaskOff(const char *rule, const char *name="MWeight") { AddPreTask(kTrainOff, rule, name); AddPreTask(kTestOff, rule, name); } 87 85 88 void SetWeightsOn(const char *rule) { if (fEnableWeightsOn) return; fEnableWeightsOn=kTRUE; AddPostTaskOn(rule); } 89 void SetWeightsOn(MTask *t) { if (fEnableWeightsOn) return; fEnableWeightsOn=kTRUE; AddPostTaskOn(t); } 86 void AddPostTaskOn(MTask *t) { AddPostTask(kTrainOn, t); AddPostTask(kTestOn, t); } 87 void AddPostTaskOn(const char *rule, const char *name="MWeight") { AddPostTask(kTrainOn, rule, name); AddPostTask(kTestOn, rule, name); } 88 void AddPostTaskOff(MTask *t) { AddPostTask(kTrainOff, t); AddPostTask(kTestOff, t); } 89 void AddPostTaskOff(const char *rule, const char *name="MWeight") { AddPostTask(kTrainOff, rule, name); AddPostTask(kTestOff, rule, name); } 90 90 91 void SetWeightsOff(const char *rule) { if (fEnableWeightsOff) return; fEnableWeightsOff=kTRUE; AddPostTaskOff(rule); } 92 void SetWeightsOff(MTask *t) { if (fEnableWeightsOff) return; fEnableWeightsOff=kTRUE; AddPostTaskOff(t); } 91 void SetWeightsOn(const char *rule) { SetWeights(kTrainOn, rule); SetWeights(kTestOn, rule); } 92 void SetWeightsOn(MTask *t) { SetWeights(kTrainOn, t); SetWeights(kTestOn, t); } 93 void SetWeightsOff(const char *rule) { SetWeights(kTrainOff, rule); SetWeights(kTestOff, rule); } 94 void SetWeightsOff(MTask *t) { SetWeights(kTrainOff, t); SetWeights(kTestOff, t); } 93 95 94 void SetFlux(Float_t f) { fFlux = f; } 96 void SetFluxTrain(Float_t f) { fFluxTrain = f; } 97 void SetFluxTest(Float_t f) { fFluxTest = f; } 98 void SetFlux(Float_t f) { SetFluxTrain(f); SetFluxTest(f); } 95 99 96 100 void EnableAutoTrain(Bool_t b=kTRUE) { fAutoTrain = b; } -
trunk/MagicSoft/Mars/mranforest/MRanForest.cc
r7693 r7724 590 590 591 591 // control sorting 592 for(int n=1;n<numdata;n++) 593 if(v[isort[n-1]]>v[isort[n]]) 592 /* 593 for(int n=0;n<numdata-1;n++) 594 if(v[isort[n]]>v[isort[n+1]]) 594 595 { 595 596 *fLog << err <<"Event no. "<<n<<", matrix column no. "<<mvar; … … 597 598 return kFALSE; 598 599 } 599 600 */ 601 602 // DataRang is similar to the isort index starting from 0 it is 603 // increased by one for each event which is greater, but stays 604 // the same for the same value. (So to say it counts how many 605 // different values we have) 600 606 for(Int_t n=0;n<numdata-1;n++) 601 607 { … … 603 609 const Int_t n2=isort[n+1]; 604 610 611 // FIXME: Copying isort[n] to fDataSort[mvar*numdata] can be accelerated! 605 612 fDataSort[mvar*numdata+n]=n1; 606 613 if(n==0) fDataRang[mvar*numdata+n1]=0;
Note:
See TracChangeset
for help on using the changeset viewer.