Changeset 7169 for trunk/MagicSoft/Mars/mranforest
- Timestamp:
- 06/17/05 13:33:56 (19 years ago)
- Location:
- trunk/MagicSoft/Mars/mranforest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.cc
r7142 r7169 70 70 MRFEnergyEst::MRFEnergyEst(const char *name, const char *title) 71 71 : fNumTrees(-1), fNumTry(-1), fNdSize(-1), fDebug(kFALSE), 72 fData(0), fEnergyEst(0), fTestMatrix(0) 72 fData(0), fEnergyEst(0), fTestMatrix(0), fEstimationMode(kMean) 73 73 { 74 74 fName = name ? name : gsDefName.Data(); … … 91 91 } 92 92 93 const TMatrix &m = matrixtrain.GetM(); 94 95 const Int_t ncols = m.GetNcols(); 96 const Int_t nrows = m.GetNrows(); 93 const Int_t ncols = matrixtrain.GetM().GetNcols(); 94 const Int_t nrows = matrixtrain.GetM().GetNrows(); 97 95 if (ncols<=0 || nrows <=0) 98 96 { … … 132 130 Int_t irow0=0; 133 131 132 const TMatrix &m = matrixtrain.GetM(); 134 133 for (Int_t j=0; j<nrows; j++) 135 134 { … … 165 164 MHMatrix matrix0(mat0, "MatrixGammas"); 166 165 167 matrix1.AddColumns(&usedrules);168 matrix0.AddColumns(&usedrules);166 //matrix1.AddColumns(&usedrules); 167 //matrix0.AddColumns(&usedrules); 169 168 170 169 // training of RF … … 186 185 evtloop.SetParList(&plist); 187 186 187 if (!evtloop.Eventloop()) 188 return kFALSE; 189 188 190 if (fDebug) 189 191 gLog.SetNullOutput(kFALSE); 190 191 if (!evtloop.Eventloop())192 return kFALSE;193 192 194 193 const Double_t E = (log10(grid[ie])+log10(grid[ie+1]))/2; … … 220 219 fEForests.Delete(); 221 220 221 Int_t i=0; 222 222 223 TIter Next(fileRF.GetListOfKeys()); 223 224 TObject *o=0; … … 231 232 forest->SetTitle(o->GetTitle()); 232 233 forest->SetBit(kCanDelete); 234 235 fBinning.Set(i+1); 236 fBinning[i++] = atof(o->GetTitle()); 233 237 234 238 fEForests.Add(forest); … … 289 293 Double_t eest = 0; 290 294 Double_t hsum = 0; 295 Double_t maxh = 0; 296 Double_t maxe = 0; 297 298 Int_t i=0; 291 299 292 300 TIter Next(&fEForests); … … 295 303 { 296 304 const Double_t h = rf->CalcHadroness(event); 297 const Double_t e = atof(rf->GetTitle());305 const Double_t e = fBinning[i++]; 298 306 299 307 hsum += h; 300 308 eest += e*h; 301 } 302 303 fEnergyEst->SetVal(pow(10, eest/hsum)); 309 if (h>maxh) 310 { 311 maxh = h; 312 maxe = e; 313 } 314 } 315 316 switch (fEstimationMode) 317 { 318 case kMean: 319 fEnergyEst->SetVal(pow(10, eest/hsum)); 320 break; 321 case kMaximum: 322 fEnergyEst->SetVal(pow(10, maxe)); 323 break; 324 } 304 325 fEnergyEst->SetReadyToSave(); 305 326 … … 323 344 SetDebug(GetEnvValue(env, prefix, "Debug", fDebug)); 324 345 } 346 if (IsEnvDefined(env, prefix, "EstimationMode", print)) 347 { 348 TString txt = GetEnvValue(env, prefix, "EstimationMode", ""); 349 txt = txt.Strip(TString::kBoth); 350 txt.ToLower(); 351 if (txt==(TString)"mean") 352 fEstimationMode = kMean; 353 if (txt==(TString)"maximum") 354 fEstimationMode = kMaximum; 355 rc = kTRUE; 356 } 325 357 return rc; 326 358 } -
trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.h
r7142 r7169 9 9 #include <TObjArray.h> 10 10 #endif 11 12 class TArrayD; 11 #ifndef ROOT_TArrayD 12 #include <TArrayD.h> 13 #endif 13 14 14 15 class MHMatrix; … … 18 19 class MRFEnergyEst : public MTask 19 20 { 21 public: 22 enum EstimationMode_t 23 { 24 kMean, 25 kMaximum 26 }; 20 27 private: 21 28 Int_t fNumTrees; // Training parameters … … 32 39 33 40 MHMatrix *fTestMatrix; 41 42 TArrayD fBinning; 43 44 EstimationMode_t fEstimationMode; 34 45 35 46 Int_t PreProcess(MParList *plist); … … 52 63 void InitMapping(MHMatrix *m=0) { fTestMatrix=m; } 53 64 54 void SetDebug(Bool_t b=kTRUE) { fDebug = b; } 65 void SetDebug(Bool_t b=kTRUE) { fDebug = b; } 66 67 void SetEstimationMode(EstimationMode_t op) { fEstimationMode = op; } 55 68 56 69 Int_t Train(const MHMatrix &n, const TArrayD &grid);
Note:
See TracChangeset
for help on using the changeset viewer.