Changeset 8698 for trunk/MagicSoft/Mars/mranforest
- Timestamp:
- 08/23/07 11:26:38 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mranforest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
r8646 r8698 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.2 7 2007-07-26 11:13:00tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.28 2007-08-23 10:25:08 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 66 66 67 67 MRanForestCalc::MRanForestCalc(const char *name, const char *title) 68 : fData(0), fRFOut(0), fTestMatrix(0), 68 : fData(0), fRFOut(0), fTestMatrix(0), fFunc("Function", "x"), 69 69 fNumTrees(-1), fNumTry(-1), fNdSize(-1), fNumObsoleteVariables(1), 70 70 fLastDataColumnHasWeights(kFALSE), … … 73 73 fName = name ? name : gsDefName.Data(); 74 74 fTitle = title ? title : gsDefTitle.Data(); 75 76 gROOT->GetListOfFunctions()->Remove(&fFunc); 75 77 76 78 // FIXME: … … 83 85 { 84 86 fEForests.Delete(); 87 } 88 89 // -------------------------------------------------------------------------- 90 // 91 // Set a function which is applied to the output of the random forest 92 // 93 Bool_t MRanForestCalc::SetFunction(const char *func) 94 { 95 return !fFunc.Compile(func); 85 96 } 86 97 … … 291 302 } 292 303 304 if (fileRF.GetListOfKeys()->FindObject("Function")) 305 fFunc.Read("Function"); 306 293 307 return kTRUE; 294 308 } … … 326 340 } 327 341 328 Int_t MRanForestCalc::Process() 342 Double_t MRanForestCalc::Eval() const 329 343 { 330 344 TVector event; … … 338 352 { 339 353 MRanForest *rf = static_cast<MRanForest*>(fEForests.UncheckedAt(0)); 340 fRFOut->SetVal(rf->CalcHadroness(event)); 341 fRFOut->SetReadyToSave(); 342 343 return kTRUE; 354 return rf->CalcHadroness(event); 344 355 } 345 356 … … 383 394 { 384 395 case kMean: 385 fRFOut->SetVal(pow(10, sume/sumh)); 386 break; 396 return sume/sumh; 387 397 case kMaximum: 388 fRFOut->SetVal(pow(10, maxe)); 389 break; 398 return maxe; 390 399 case kFit: 391 400 f1.SetParameter(0, maxh); … … 393 402 f1.SetParameter(2, 0.125); 394 403 g.Fit(&f1, "Q0N"); 395 fRFOut->SetVal(pow(10, f1.GetParameter(1))); 396 break; 397 } 398 404 return f1.GetParameter(1); 405 } 406 407 return 0; 408 } 409 410 Int_t MRanForestCalc::Process() 411 { 412 const Double_t val = Eval(); 413 414 fRFOut->SetVal(fFunc.Eval(val)); 399 415 fRFOut->SetReadyToSave(); 400 416 -
trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h
r7687 r8698 12 12 #ifndef ROOT_TArrayD 13 13 #include <TArrayD.h> 14 #endif 15 16 #ifndef ROOT_TF1 17 #include <TF1.h> 14 18 #endif 15 19 … … 36 40 MParameterD *fRFOut; //! Used to store result 37 41 MHMatrix *fTestMatrix; //! Test Matrix used in Process (together with MMatrixLoop) 42 TF1 fFunc; //! Function to apply to the result 38 43 39 44 TObjArray fEForests; //! List of forests read or to be written … … 60 65 // MRanForestCalc 61 66 Int_t ReadForests(MParList &plist); 67 Double_t Eval() const; 62 68 63 69 // MParContainer … … 84 90 void SetNumTry(UShort_t n=0) { fNumTry = n; } 85 91 void SetDebug(Bool_t b=kTRUE) { fDebug = b; } 92 93 Bool_t SetFunction(const char *name="x"); 86 94 87 95 void SetNumObsoleteVariables(Int_t n=1) { fNumObsoleteVariables = n; }
Note:
See TracChangeset
for help on using the changeset viewer.