Changeset 8643
- Timestamp:
- 07/19/07 19:59:27 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8642 r8643 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 22 2007/07/19 Thomas Bretz 23 24 * mjobs/MJCut.cc: 25 - added a sanity check for one off-position in on/off-mode 26 27 * mjoptim/MJOptimize.[h,cc]: 28 - moved the functions and data-members to set cuts etc to new 29 base class 30 - added setting of pre- and post-tasks to reading the data 31 32 * mjoptim/Makefile, mjoptim/OptimLinkDef.h: 33 - added new MJOptimizeBase 34 35 * mjtrain/MJTrainDisp.cc, mjtrain/MJTrainEnergy.cc, 36 mjtrain/MJTrainSeparation.cc: 37 - changed to use fDebug and WriteDisplay from the new base class 38 39 * mjtrain/MJTrainRanForest.[h,cc]: 40 - moved all data members and setting of pre-/posttasks/-cuts 41 to new base class 42 43 * mjtrain/Makefile: 44 - added include of mjoptim for new base class 45 46 * mjoptim/MJOptimizeBase.[h,cc]: 47 - new base class for optimization and training classes 48 49 20 50 21 51 -
trunk/MagicSoft/Mars/mjoptim/MJOptimize.cc
r8244 r8643 111 111 #include "MMatrixLoop.h" 112 112 #include "MFillH.h" 113 #include "MParameterCalc.h" 114 #include "MContinue.h" 113 115 114 116 // filters … … 225 227 } 226 228 227 MJOptimize::MJOptimize() : fDebug(-1),fNumEvents(0), fType(kSimplex), fNumMaxCalls(0), fTolerance(0), fTestTrain(0), fNameMinimizationValue("MinimizationValue")229 MJOptimize::MJOptimize() : /*fDebug(-1),*/ fNumEvents(0), fType(kSimplex), fNumMaxCalls(0), fTolerance(0), fTestTrain(0), fNameMinimizationValue("MinimizationValue") 228 230 { 229 231 fRules.SetOwner(); … … 287 289 } 288 290 289 //------------------------------------------------------------------------290 //291 // Add a parameter used in your filters (see AddFilter) The parameter292 // index is returned,293 //294 // Int_t idx = AddParameter("log10(MHillas.fSize)");295 //296 // The indices area starting with 0 always.297 //298 Int_t MJOptimize::AddParameter(const char *rule)299 {300 fRules.Add(new TNamed(rule, ""));301 return fRules.GetSize()-1;302 }303 291 304 292 //------------------------------------------------------------------------ … … 319 307 { 320 308 fFilter.Add(new MFDataPhrase(rule)); 321 }322 323 //------------------------------------------------------------------------324 //325 // Add a cut which is used to fill the matrix, eg "MMcEvt.fOartId<1.5"326 // (The rule is applied, nit inverted: The matrix is filled with327 // the events fullfilling the condition)328 //329 void MJOptimize::AddPreCut(const char *rule)330 {331 MFilter *f = new MFDataPhrase(rule);332 f->SetBit(kCanDelete);333 AddPreCut(f);334 }335 336 //------------------------------------------------------------------------337 //338 // Add a cut which is used to fill the matrix. If kCanDelete is set339 // MJOptimize takes the ownership.340 //341 void MJOptimize::AddPreCut(MFilter *f)342 {343 fPreCuts.Add(f);344 309 } 345 310 … … 739 704 m->Print("cols"); 740 705 741 //MParList parlist;742 743 706 // MGeomCamMagic cam; 744 707 // parlist.AddToList(&cam); 745 708 746 MTaskList tlist; 747 parlist.Replace(&tlist); 748 749 MFillH fillh(m); 750 751 tlist.AddToList(&read); 752 709 // Setup filter and apply filter to filling of matrix 753 710 MFilterList list; 754 711 if (!list.AddToList(fPreCuts)) … … 757 714 SetupFilters(list); 758 715 list.SetName("PreCuts"); // reset Name set by SetupFilters 759 list.SetInverted(kFALSE); // reset inversion set by SetupFilters 760 fillh.SetFilter(&list); 761 tlist.AddToList(&list); 762 763 tlist.AddToList(&fillh); 716 list.SetInverted(kTRUE); // reset inversion set by SetupFilters 717 718 MContinue cont(&list); 719 720 // Setup filling of matrix 721 MFillH fillh(m); 722 723 // Setup tasklist 724 MTaskList tlist; 725 parlist.Replace(&tlist); 726 727 // Create task list 728 tlist.AddToList(&read); // read data 729 tlist.AddToList(fPreTasks); // execute pre-filter tasks 730 tlist.AddToList(&cont); // execute filters 731 tlist.AddToList(fPostTasks); // execute post-filter tasks 732 tlist.AddToList(&fillh); // Fill matrix 764 733 765 734 tlist.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime); -
trunk/MagicSoft/Mars/mjoptim/MJOptimize.h
r7152 r8643 2 2 #define MARS_MJOptimize 3 3 4 #ifndef MARS_MJ ob5 #include "MJ ob.h"4 #ifndef MARS_MJOptimizeBase 5 #include "MJOptimizeBase.h" 6 6 #endif 7 7 … … 14 14 class MAlphaFitter; 15 15 16 class MTask; 16 17 class MEvtLoop; 17 18 class MParList; … … 26 27 class MReadTree; 27 28 28 class MJOptimize : public MJ ob29 class MJOptimize : public MJOptimizeBase 29 30 { 30 31 public: … … 41 42 42 43 private: 43 Int_t fDebug; // -1 no output, 0 MJOptimize output, 1 PrintStatistics output44 44 Int_t fNumEvents; 45 45 46 TList fRules;47 46 TList fFilter; 48 47 … … 78 77 79 78 protected: 80 TList fPreCuts;81 82 79 TList fNamesOn; 83 80 TList fNamesOff; … … 100 97 101 98 // Interface for filter cuts 102 Int_t AddParameter(const char *rule);103 99 void AddFilter(const char *rule); 104 void AddPreCut(const char *rule);105 void AddPreCut(MFilter *f);106 100 107 101 // Steering of optimization -
trunk/MagicSoft/Mars/mjoptim/Makefile
r7152 r8643 29 29 # mgeom: MGeomCam 30 30 31 SRCFILES = MJOptimize.cc \ 31 SRCFILES = MJOptimizeBase.cc \ 32 MJOptimize.cc \ 32 33 MJOptimizeCuts.cc \ 33 34 MJOptimizeDisp.cc \ -
trunk/MagicSoft/Mars/mjoptim/OptimLinkDef.h
r7152 r8643 6 6 7 7 #pragma link C++ class MJOptimize+; 8 #pragma link C++ class MJOptimizeBase+; 8 9 #pragma link C++ class MJOptimizeCuts+; 9 10 #pragma link C++ class MJOptimizeDisp+; -
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
r8244 r8643 145 145 rf.SetLogStream(fLog); 146 146 rf.SetFileName(out); 147 rf.SetDebug(fDebug );147 rf.SetDebug(fDebug>1); 148 148 rf.SetNameOutput("Disp"); 149 149 … … 251 251 hist.GetAlphaFitter().Print("result"); 252 252 253 if (!WriteDisplay(out ))253 if (!WriteDisplay(out, "UPDATE")) 254 254 return kFALSE; 255 255 -
trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc
r8636 r8643 139 139 rf.SetLogStream(fLog); 140 140 rf.SetFileName(out); 141 rf.SetDebug(fDebug );141 rf.SetDebug(fDebug>1); 142 142 rf.SetNameOutput("MEnergyEst"); 143 143 … … 193 193 return kFALSE; 194 194 195 if (!WriteDisplay(out ))195 if (!WriteDisplay(out, "UPDATE")) 196 196 return kFALSE; 197 197 -
trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc
r8091 r8643 18 18 ! Author(s): Thomas Bretz 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2005-200 620 ! Copyright: MAGIC Software Development, 2005-2007 21 21 ! 22 22 ! … … 28 28 // 29 29 // Base class for classes training a random forest 30 // 31 // The order when reading a file is: 32 // 1) Execution of PreTasks (set by user) 33 // 2) Execution of PreCuts (set by user) 34 // 3) Selector (calculated from number of requested events) 35 // 4) Splitter (if sample is split automatically in test/train) 36 // 5) PostTasks (set by user) 37 // 38 // The split into Pre- and PostTasks is done for speed reason. So, if 39 // you calculate a vlue which is not needed for your PreCuts, you can 40 // calculate it afterwards, which will speed up execution. 30 41 // 31 42 ///////////////////////////////////////////////////////////////////////////// … … 45 56 46 57 using namespace std; 47 58 /* 48 59 //------------------------------------------------------------------------ 49 60 // … … 120 131 return kTRUE; 121 132 } 133 */ -
trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h
r7697 r8643 2 2 #define MARS_MJTrainRanForest 3 3 4 #ifndef MARS_MJ ob5 #include "MJ ob.h"4 #ifndef MARS_MJOptimizeBase 5 #include "MJOptimizeBase.h" 6 6 #endif 7 7 … … 9 9 class MFilter; 10 10 11 class MJTrainRanForest : public MJ ob11 class MJTrainRanForest : public MJOptimizeBase 12 12 { 13 13 protected: 14 Bool_t fDebug;15 Bool_t fEnableWeights;16 17 TList fRules;18 19 TList fPreCuts;20 TList fTrainCuts;21 TList fTestCuts;22 TList fPreTasks;23 TList fPostTasks;24 25 14 UShort_t fNumTrees; 26 15 UShort_t fNdSize; 27 16 UShort_t fNumTry; 28 17 29 Bool_t WriteDisplay(const char *fname) const;30 31 void AddCut(TList &l, const char *rule);32 void AddPar(TList &l, const char *rule, const char *name);33 void Add(TList &l, MTask *f);34 35 18 public: 36 MJTrainRanForest() : fDebug(kFALSE), fEnableWeights(kFALSE)19 MJTrainRanForest() 37 20 { 38 21 fNumTrees = 100; //100 … … 41 24 } 42 25 43 void AddPreTask(MTask *t) { Add(fPreTasks, t); }44 void AddPreTask(const char *rule,45 const char *name="MWeight") { AddPar(fPreTasks, rule, name); }46 47 void AddPostTask(MTask *t) { Add(fPostTasks, t); }48 void AddPostTask(const char *rule,49 const char *name="MWeight") { AddPar(fPostTasks, rule, name); }50 51 void SetDebug(Bool_t b=kTRUE) { fDebug = b; }52 53 void SetWeights(const char *rule) { if (fEnableWeights) return; fEnableWeights=kTRUE; AddPostTask(rule); }54 void SetWeights(MTask *t) { if (fEnableWeights) return; fEnableWeights=kTRUE; AddPostTask(t); }55 56 void AddPreCut(const char *rule) { AddCut(fPreCuts, rule); }57 void AddPreCut(MFilter *f) { Add(fPreCuts, (MTask*)(f)); }58 59 void AddTrainCut(const char *rule) { AddCut(fTrainCuts, rule); }60 void AddTrainCut(MFilter *f) { Add(fTrainCuts, (MTask*)(f)); }61 62 void AddTestCut(const char *rule) { AddCut(fTestCuts, rule); }63 void AddTestCut(MFilter *f) { Add(fTestCuts, (MTask*)(f)); }64 65 26 void SetNumTrees(UShort_t n=100) { fNumTrees = n; } 66 27 void SetNdSize(UShort_t n=5) { fNdSize = n; } 67 28 void SetNumTry(UShort_t n=0) { fNumTry = n; } 68 69 Int_t AddParameter(const char *rule);70 29 71 30 ClassDef(MJTrainRanForest, 0)//Base class for Random Forest training classes -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
r8223 r8643 802 802 rf.SetNumObsoleteVariables(1); 803 803 rf.SetLastDataColumnHasWeights(fEnableWeights[kTrainOn] || fEnableWeights[kTrainOff]); 804 rf.SetDebug(fDebug );804 rf.SetDebug(fDebug>1); 805 805 rf.SetDisplay(fDisplay); 806 806 rf.SetLogStream(fLog); … … 1039 1039 1040 1040 // Write the display 1041 if (!WriteDisplay(out ))1041 if (!WriteDisplay(out, "UPDATE")) 1042 1042 return kFALSE; 1043 1043 -
trunk/MagicSoft/Mars/mjtrain/Makefile
r7702 r8643 22 22 -I../manalysis -I../mfilter -I../mjobs -I../mtools \ 23 23 -I../mranforest -I../mhflux -I../mmc -I../mhist -I../mpointing \ 24 -I../mimage 24 -I../mimage -I../mjoptim 25 25 26 26 SRCFILES = MJTrainRanForest.cc \
Note:
See TracChangeset
for help on using the changeset viewer.