Changeset 7401
- Timestamp:
- 11/15/05 11:36:17 (19 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7400 r7401 18 18 19 19 -*-*- END OF LINE -*-*- 20 2005/11/15 Thomas Bretz 21 22 * macros/optim/optimdisp.C, macros/optim/optimenergy.C, 23 macros/optim/rfenergyest.C: 24 - added some more comments 25 - updated 26 27 * mtools/MTFillMatrix.[h,cc]: 28 - added the possibility to use PreCuts like in MJOptim 29 30 31 20 32 2005/11/14 Daniela Dorner 21 33 -
trunk/MagicSoft/Mars/macros/optim/optimdisp.C
r7153 r7401 1 /* More explanations at the end of the file */ 1 2 void optimdisp() 2 3 { 3 MJOptimizeDisp opt; 4 opt.SetDebug(2); 5 opt.SetOptimizer(MJOptimize::k Simplex);6 opt.EnableTestTrain(); 4 MJOptimizeDisp opt; // Initialize optimization class 5 opt.SetDebug(2); // Choose the level of output 6 opt.SetOptimizer(MJOptimize::kMigrad); // Choose the fit algorithm (see MJOptimize) 7 opt.EnableTestTrain(); // Split sample into test and train 7 8 8 9 // -------------------- Setup ---------------------------- 9 //opt.AddParameter("1-(MHillas.fWidth/MHillas.fLength)"); 10 opt.AddParameter("atan(1./(1-(MHillas.fWidth/MHillas.fLength)))"); 11 //opt.AddParameter("log10(MNewImagePar.fLeakage1+1)"); 10 opt.AddParameter("1-(MHillas.fWidth/MHillas.fLength)"); // M[0] 11 opt.AddParameter("log10(MNewImagePar.fLeakage1+1)"); // M[1] 12 12 13 opt. FixParameter(0, 0.743871, 0, 2); //0.56267614 opt. FixParameter(1, 0.329471, 0, 2); //0.31731515 opt. FixParameter(2, 1.500002, 0, 10); //1.5575413 opt.SetParameter(0, 1.30871); // Setup [0] 14 opt.SetParameter(1, 5.81119); // Setup [1] 15 opt.SetParameter(2, 0.763486); // Setup [2] 16 16 17 // Leakage==0: RMS = 0.030 18 // Leakage>0: RMS = 0.010 19 20 // all: 0.029 (0.605991, 0.332266, 1.50825) 21 22 //char *r = "([0]+(pow(M[1],[1])*[2]))/M[0]"; 23 //char *r = "([0]+(pow(M[1],[1])*[2]))*M[0]"; 24 //char *r = "[0]*M[0]"; 25 char *r = "[0]/M[0]"; 17 char *r = "([0]+([1]*pow(M[1], [2])))*M[0]"; // Rule to calc Disp 26 18 27 19 // -------------------- Run ---------------------------- … … 30 22 opt.SetDisplay(d); 31 23 32 opt.AddPreCut("MNewImagePar.fLeakage1<0.0001"); 24 /* 25 -------------------- Magic-Cuts ---------------------- 26 MFMagicCuts cuts; 27 cuts.SetHadronnessCut(MFMagicCuts::kArea); 28 cuts.SetThetaCut(MFMagicCuts::kOn); 29 30 TArrayD arr(10); 31 arr[0]= 1.3245; 32 arr[1]= 0.208700; 33 arr[2]= 0.229200; 34 arr[3]= 5.305200; 35 arr[4]= 0.098930; 36 arr[5]= -0.082950; 37 arr[6]= 8.2957; 38 arr[7]= 0.8677; 39 40 cuts.SetVariables(arr); 41 42 opt.AddPreCut(&cuts); 43 44 -------------------- Other cuts ---------------------- 45 opt.AddPreCut("MNewImagePar.fLeakage1<0.0001"); 46 */ 47 33 48 opt.RunDisp("ganymedmcpart.root", r); 34 49 } 50 51 /* ------------------ Good strategy ------------------- 52 1) first fix parameters: 53 opt.FixParameter(1, 0); 54 opt.FixParameter(2, 1); 55 and process only showers without leakage 56 opt.AddPreCut("MNewImagePar.fLeakage1<0.0001"); 57 2) release parameters 1 and 2 and fix 0 to the result of 1) 58 opt.FixParameter(0, 0.8362); 59 opt.SetParameter(1, 2.0); 60 opt.SetParameter(2, 0.8); 61 and process only showers with leakage 62 opt.AddPreCut("MNewImagePar.fLeakage1>0.0001"); 63 3) release all parameters and start with the result of 1) and 2) 64 opt.SetParameter(0, 0.8362); 65 opt.SetParameter(1, 5.84); 66 opt.SetParameter(2, 0.76); 67 and process all showers. (Comment out opt.PreCuts()) 68 */ -
trunk/MagicSoft/Mars/macros/optim/optimenergy.C
r7170 r7401 18 18 opt.SetDisplay(d); 19 19 20 //opt.AddPreCut("MNewImagePar.fLeakage1<0.0001"); 20 /* 21 -------------------- Magic-Cuts ---------------------- 22 MFMagicCuts cuts; 23 cuts.SetHadronnessCut(MFMagicCuts::kArea); 24 cuts.SetThetaCut(MFMagicCuts::kOn); 25 26 TArrayD arr(10); 27 arr[0]= 1.3245; 28 arr[1]= 0.208700; 29 arr[2]= 0.229200; 30 arr[3]= 5.305200; 31 arr[4]= 0.098930; 32 arr[5]= -0.082950; 33 arr[6]= 8.2957; 34 arr[7]= 0.8677; 35 36 cuts.SetVariables(arr); 37 38 opt.AddPreCut(&cuts); 39 40 -------------------- Other cuts ---------------------- 41 opt.AddPreCut("MPointingPos.fZd<7"); 42 */ 43 21 44 opt.RunEnergy("ganymedmcpart.root", r); 22 45 } -
trunk/MagicSoft/Mars/macros/optim/rfenergyest.C
r7396 r7401 1 1 void rfenergyest() 2 2 { 3 MSequence seqtst("~/Software/ Mars/mranforest/sequencemc-test.txt");4 MSequence seqtrn("~/Software/ Mars/mranforest/sequencemc-train.txt");3 MSequence seqtst("~/Software/mc/sequencemc-test.txt"); 4 MSequence seqtrn("~/Software/mc/sequencemc-train.txt"); 5 5 6 6 if (!seqtst.IsValid()) … … 22 22 23 23 MDirIter iter, iter2; 24 seqtrn.SetupDatRuns(iter, MSequence::kImages, "~/Software/mc ");25 seqtst.SetupDatRuns(iter2, MSequence::kImages, "~/Software/mc ");24 seqtrn.SetupDatRuns(iter, MSequence::kImages, "~/Software/mc/img-abs"); 25 seqtst.SetupDatRuns(iter2, MSequence::kImages, "~/Software/mc/img-abs"); 26 26 27 27 read.AddFiles(iter); … … 60 60 fill.SetReader(&read); 61 61 62 /* ---------- It doesn't seem to improve anything ---------- 63 MFMagicCuts cuts; 64 65 cuts.SetHadronnessCut(MFMagicCuts::kArea); 66 cuts.SetThetaCut(MFMagicCuts::kOn); 67 68 TArrayD arr(10); 69 arr[0]= 1.3245; 70 arr[1]= 0.208700; 71 arr[2]= 0.229200; 72 arr[3]= 5.305200; 73 arr[4]= 0.098930; 74 arr[5]= -0.082950; 75 arr[6]= 8.2957; 76 arr[7]= 0.8677; 77 78 cuts.SetVariables(arr); 79 80 fill.AddPreCut(&cuts); 81 82 --------------- Use the cuts also in test-loop ---------------- 83 */ 84 62 85 if (!fill.Process()) 63 86 return; … … 71 94 MBinning b(32, 10, 100000, "BinningEnergyEst", "log"); 72 95 /* 73 if (!rf.TrainMultiRF(train, b.GetEdgesD())) // classification 96 if (!rf.TrainMultiRF(train, b.GetEdgesD())) // classification with one tree per bin 74 97 return; 75 98 76 if (!rf.TrainSingleRF(train, b.GetEdgesD())) // classification 99 if (!rf.TrainSingleRF(train, b.GetEdgesD())) // classification into different bins 77 100 return; 78 101 */ 79 if (!rf.TrainSingleRF(train)) // regression 102 if (!rf.TrainSingleRF(train)) // regression (best choice) 80 103 return; 81 104 … … 90 113 91 114 MHEnergyEst hist; 115 //MContinue cont(&cuts); 116 //cont.SetInverted(); 92 117 MFillH fillh(&hist); 93 118 94 119 tlist.AddToList(&read2); 120 //tlist.AddToList(&cont); 95 121 tlist.AddToList(&rf); 96 122 tlist.AddToList(&fillh); -
trunk/MagicSoft/Mars/mtools/MTFillMatrix.cc
r7130 r7401 18 18 ! Author(s): Thomas Bretz, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 81 81 #include <TFile.h> 82 82 83 // environment 83 84 #include "MHMatrix.h" 84 85 … … 86 87 #include "MLogManip.h" 87 88 89 // eventloop 88 90 #include "MParList.h" 89 91 #include "MTaskList.h" 90 92 #include "MEvtLoop.h" 91 93 94 // tasks 92 95 #include "MRead.h" 93 96 #include "MFillH.h" 94 97 #include "MContinue.h" 98 99 // filters 100 #include "MF.h" 95 101 #include "MFilterList.h" 96 102 #include "MFEventSelector.h" … … 174 180 delete fReference; 175 181 } 182 183 //------------------------------------------------------------------------ 184 // 185 // Add a cut which is used to fill the matrix, eg "MMcEvt.fOartId<1.5" 186 // (The rule is applied, nit inverted: The matrix is filled with 187 // the events fullfilling the condition) 188 // 189 void MTFillMatrix::AddPreCut(const char *rule) 190 { 191 MFilter *f = new MF(rule); 192 f->SetBit(kCanDelete); 193 AddPreCut(f); 194 } 195 196 //------------------------------------------------------------------------ 197 // 198 // Add a cut which is used to fill the matrix. If kCanDelete is set 199 // MJOptimize takes the ownership. 200 // 201 void MTFillMatrix::AddPreCut(MFilter *f) 202 { 203 fPreCuts.Add(f); 204 } 205 176 206 177 207 // -------------------------------------------------------------------------- … … 236 266 237 267 // 268 // Continue for PreCuts 269 // 270 MFilterList list; 271 list.SetName("PreCuts"); 272 if (!list.AddToList(fPreCuts)) 273 *fLog << err << "ERROR - Calling MFilterList::AddToList for fPreCuts failed!" << endl; 274 275 MContinue cont0(&list); 276 cont0.SetInverted(); 277 278 // 238 279 // Continue for all events which are not (SetInverted()) 239 280 // selected by the 'selector' … … 268 309 // entries in MTaskList 269 310 tlist.AddToList(fReader); // Read events 311 if (fPreCuts.GetEntries()>0) 312 tlist.AddToList(&cont0); // PreCuts 270 313 if (fReference && selector) 271 314 tlist.AddToList(&cont); // select a sample of events
Note:
See TracChangeset
for help on using the changeset viewer.