Changeset 2862 for trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
- Timestamp:
- 01/20/04 17:49:06 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.