Changeset 2862 for trunk/MagicSoft/Mars
- Timestamp:
- 01/20/04 17:49:06 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2861 r2862 4 4 5 5 -*-*- END OF LINE -*-*- 6 7 2004/01/20: Thomas Hengstebeck 8 9 * mranforest/MRanForestCalc.[h,cc] 10 - Added member functions Grow (training of RF) and Fill (reading in 11 trained forest from file) which simplify macros. 12 One just needs to call them instead of using MRanForestGrow and 13 MRanForestFill (and the related training and fill loops) in a 14 macro. 6 15 7 16 2004/01/20: Abelardo moralejo -
trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
r2296 r2862 49 49 #include "MHadronness.h" 50 50 51 #include "MEvtLoop.h" 52 #include "MTaskList.h" 53 #include "MFillH.h" 54 #include "MStatusDisplay.h" 55 #include "MRanForestGrow.h" 56 #include "MRanForestFill.h" 57 58 #include "MWriteRootFile.h" 59 #include "MReadTree.h" 60 51 61 ClassImp(MRanForestCalc); 52 62 … … 149 159 } 150 160 161 Bool_t MRanForestCalc::Grow(MHMatrix *matrixg,MHMatrix *matrixh,Int_t ntree, 162 Int_t numtry,Int_t ndsize,const char* treefile=0, 163 const char* treename=0,const char* contname=0, 164 const char* hgininame=0) 165 { 166 167 treename = treename ? treename : "Tree"; 168 contname = contname ? contname : "MRanTree"; 169 hgininame = hgininame ? hgininame : "MHRanForestGini"; 170 171 if (!matrixg->IsValid()) 172 { 173 *fLog << err << dbginf << " MRanForestCalc::Grow - ERROR: matrixg not valid." << endl; 174 return kFALSE; 175 } 176 if(!matrixh->IsValid()) 177 { 178 *fLog << err << dbginf << " MRanForestCalc::Grow - ERROR: matrixh not valid." << endl; 179 return kFALSE; 180 } 181 182 MEvtLoop run(GetName()); 183 MTaskList tlist; 184 MParList plist; 185 plist.AddToList(&tlist); 186 plist.AddToList(matrixg); 187 plist.AddToList(matrixh); 188 189 // creating training task and setting parameters 190 MRanForestGrow rfgrow; 191 rfgrow.SetNumTrees(ntree); // number of trees 192 rfgrow.SetNumTry(numtry); // number of trials in random split selection 193 rfgrow.SetNdSize(ndsize); // limit for nodesize 194 tlist.AddToList(&rfgrow); 195 196 if(treefile){ 197 MWriteRootFile rfwrite(treefile); 198 rfwrite.AddContainer(contname,treename); 199 tlist.AddToList(&rfwrite); 200 } 201 202 MFillH fillh(hgininame); 203 tlist.AddToList(&fillh); 204 205 run.SetParList(&plist); 206 207 // Execute tree growing 208 if (!run.Eventloop()) 209 { 210 *fLog << err << dbginf << "Evtloop in MRanForestCalc::Grow failed." << endl; 211 return kFALSE; 212 } 213 tlist.PrintStatistics(0, kTRUE); 214 215 if (TestBit(kEnableGraphicalOutput)) 216 plist.FindObject(hgininame)->DrawClone(); 217 218 return kTRUE; 219 } 220 221 Bool_t MRanForestCalc::Fill(Int_t ntree,const char* treefile=0,const char* treename=0) 222 { 223 treefile = treefile ? treefile : "RF.root"; 224 treename = treename ? treename : "Tree"; 225 226 MParList plist; 227 228 MTaskList tlist; 229 plist.AddToList(&tlist); 230 231 MReadTree read(treename,treefile); 232 read.DisableAutoScheme(); 233 234 MRanForestFill rffill; 235 rffill.SetNumTrees(ntree); 236 237 tlist.AddToList(&read); 238 tlist.AddToList(&rffill); 239 240 MEvtLoop run(GetName()); 241 run.SetParList(&plist); 242 243 // 244 // Execute tree reading 245 // 246 if (!run.Eventloop()) 247 { 248 *fLog << err << dbginf << "Evtloop in MRanForestCalc::Fill failed." << endl; 249 return kFALSE; 250 } 251 tlist.PrintStatistics(0, kTRUE); 252 253 return kTRUE; 254 } -
trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h
r2207 r2862 4 4 #ifndef MARS_MTask 5 5 #include "MTask.h" 6 #endif 7 8 #ifndef MARS_MHMatrix 9 #include "MHMatrix.h" 6 10 #endif 7 11 … … 36 40 void SetUseNumTrees(UShort_t n=100) { fNum = n; } 37 41 42 Bool_t Grow(MHMatrix *matrixg,MHMatrix *matrixh,Int_t ntree, 43 Int_t numtry,Int_t ndsize,const char* treefile=0, 44 const char* treename=0,const char* contname=0, 45 const char* hgininame=0); 46 47 Bool_t Fill(Int_t ntree,const char* treefile=0,const char* treename=0); 48 49 38 50 ClassDef(MRanForestCalc, 0) // Task 39 51 }; -
trunk/MagicSoft/Mars/mranforest/Makefile
r2800 r2862 22 22 # connect the include files defined in the config.mk file 23 23 # 24 INCLUDES = -I. -I../mbase -I../mhbase -I../mdata -I../manalysis -I../mmc 24 INCLUDES = -I. -I../mbase -I../mhbase -I../mdata -I../manalysis -I../mmc -I../mfileio 25 25 # MParContainer MH MDataArray MHadronness MMcEvt 26 27 26 #------------------------------------------------------------------------------ 28 27
Note:
See TracChangeset
for help on using the changeset viewer.