Changeset 2114
- Timestamp:
- 05/13/03 15:16:54 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2111 r2114 1 1 -*-*- END OF LINE -*-*- 2 2003/05/13: Thomas Bretz 3 4 * mdata/MDataArray.[h,cc]: 5 - addeed GetData and >>-operator to fill a TVector from the array 6 7 * manalysis/MMultiDimDistCalc.cc: 8 - use new >>-operator from MDataArray 9 10 * mranforest/MRanForest.[h,cc]: 11 - TVector& in CalcHadronness declared const 12 - added a const qualifier to 'Float_t sum' 13 - removed Reset() from a TIter declaration (done by the TIter 14 constructor) 15 16 * mranforest/MRanForestCalc.cc: 17 - fill TVector with new >>-operator of MDataArray 18 19 * mranforest/MRanTree.[h,cc]: 20 - removed obsolete returns at the end of some functions 21 - TVector& in TreeHad declared const 22 - changed if to ?:-operator in TreeHad 23 - TreeHad() calls TreeHad(const TVector &) now (code is not 24 implemented twice) 25 26 27 2 28 2003/05/12: Abelardo Moralejo 3 29 4 30 * mhistmc/MHMcEnergyMigration.cc 5 31 - Draw(): fixed axis label in one plot. 32 33 6 34 7 35 2003/05/12: Thomas Bretz -
trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc
r1954 r2114 172 172 Bool_t MMultiDimDistCalc::Process() 173 173 { 174 const Double_t ncols = fMGammas->GetM().GetNcols(); 175 176 TVector event(ncols); 177 178 for (int i=0; i<fData->GetNumEntries(); i++) 179 event(i) = (*fData)(i); 180 181 /* 182 Int_t n=0; 183 TIter Next(fData); 184 MData *data = NULL; 185 while ((data=(MData*)Next())) 186 event(n++) = data->GetValue(); 187 */ 174 // first copy the data from the data array to a vector event 175 TVector event; 176 *fData >> event; 188 177 189 178 Double_t numg = fNum; -
trunk/MagicSoft/Mars/mdata/MDataArray.cc
r2109 r2114 35 35 #include <fstream.h> 36 36 37 #include <TVector.h> 38 37 39 #include "MLog.h" 38 40 #include "MLogManip.h" … … 89 91 // Return the data value of the i-th entry 90 92 // 91 Double_t MDataArray::operator()(Int_t i) 92 { 93 return ( (MData*)fList[i])->GetValue();93 Double_t MDataArray::operator()(Int_t i) const 94 { 95 return (*this)[i].GetValue(); 94 96 } 95 97 … … 189 191 return str; 190 192 } 193 194 void MDataArray::GetData(TVector &v) const 195 { 196 Double_t ncols = GetNumEntries(); 197 198 v.ResizeTo(ncols); 199 200 // same as: for (int i=0; i<ncols; i++) <should be faster> 201 while (ncols--) 202 v(ncols) = (*this)(ncols); 203 } -
trunk/MagicSoft/Mars/mdata/MDataArray.h
r2109 r2114 14 14 #include <TObjArray.h> 15 15 #endif 16 17 class TVector; 16 18 17 19 class MData; … … 31 33 32 34 MData &operator[](Int_t i) const; 33 Double_t operator()(Int_t i); 35 Double_t operator()(Int_t i) const; 36 37 void GetData(TVector &v) const; 38 39 void operator>>(TVector &v) const 40 { 41 GetData(v); 42 } 34 43 35 44 TString GetRule(int i) const; -
trunk/MagicSoft/Mars/mranforest/MRanForest.cc
r2071 r2114 85 85 void MRanForest::SetPriors(Float_t prior_had, Float_t prior_gam) 86 86 { 87 Float_t sum; 88 89 sum=prior_gam+prior_had; 87 const Float_t sum=prior_gam+prior_had; 90 88 91 89 prior_gam/=sum; … … 98 96 } 99 97 100 Double_t MRanForest::CalcHadroness( TVector &event)98 Double_t MRanForest::CalcHadroness(const TVector &event) 101 99 { 102 100 Double_t hadroness=0; 103 101 Int_t ntree=0; 102 103 TIter forest(fForest); 104 104 105 MRanTree *tree; 105 106 TIter forest(fForest);107 forest.Reset();108 109 106 while ((tree=(MRanTree*)forest.Next())) 110 107 { -
trunk/MagicSoft/Mars/mranforest/MRanForest.h
r2071 r2114 96 96 97 97 // use forest to calculate hadronness of event 98 Double_t CalcHadroness( TVector &event);98 Double_t CalcHadroness(const TVector &event); 99 99 100 100 Bool_t AsciiWrite(ostream &out) const; -
trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
r2071 r2114 137 137 Bool_t MRanForestCalc::Process() 138 138 { 139 const Double_t ncols = fData->GetNumEntries(); 140 TVector event(ncols); 141 142 for (int i=0; i<fData->GetNumEntries(); i++) 143 event(i) = (*fData)(i); 139 // first copy the data from the data array to a vector event 140 TVector event; 141 *fData >> event; 144 142 145 143 Double_t hadroness=fRanForest->CalcHadroness(event); -
trunk/MagicSoft/Mars/mranforest/MRanTree.cc
r2071 r2114 178 178 // (Gini-index as criterium crit) 179 179 180 critmax=-1.0e20; 180 critmax=-1.0e20; // FIXME: Replace by a constant from limits.h 181 181 182 182 // random split selection, number of trials = fNumTry … … 301 301 for(Int_t n=ndstart;n<=ndend;n++) 302 302 ncase[n]=datasort[msplit*numdata+n]; 303 304 return;305 303 } 306 304 … … 459 457 fBestSplit[kn]/=(classpop[0*nrnodes+kn]+classpop[1*nrnodes+kn]); 460 458 } 461 462 return;463 459 } 464 460 … … 468 464 } 469 465 470 Double_t MRanTree::TreeHad(TVector &event) 471 { 472 Int_t kt=0; 473 // to optimize on storage space node status and node class 474 // are coded into fBestVar: 475 // status of node kt = TMath::Sign(1,fBestVar[kt]) 476 // hadronness assigned to node kt = fBestSplit[kt] 477 478 for (Int_t k=0;k<fNumNodes;k++) 479 { 480 if (fBestVar[kt]<0) 481 break; 482 483 Int_t m=fBestVar[kt]; 484 485 if (event(m)<=fBestSplit[kt]) 486 kt=fTreeMap1[kt]; 487 else 488 kt=fTreeMap2[kt]; 489 } 490 491 return fBestSplit[kt]; 492 } 493 494 Double_t MRanTree::TreeHad() 495 { 496 const Double_t ncols = fData->GetNumEntries(); 497 TVector event(ncols); 498 499 for (int i=0; i<fData->GetNumEntries(); i++) 500 event(i) = (*fData)(i); 501 466 Double_t MRanTree::TreeHad(const TVector &event) 467 { 502 468 Int_t kt=0; 503 469 // to optimize on storage space node status and node class … … 513 479 break; 514 480 515 Int_t m=fBestVar[kt]; 516 517 if (event(m)<=fBestSplit[kt]) 518 kt=fTreeMap1[kt]; 519 else 520 kt=fTreeMap2[kt]; 521 481 const Int_t m=fBestVar[kt]; 482 483 kt = event(m)<=fBestSplit[kt] ? fTreeMap1[kt] : fTreeMap2[kt]; 522 484 } 523 485 524 486 return fBestSplit[kt]; 487 } 488 489 Double_t MRanTree::TreeHad() 490 { 491 TVector event; 492 *fData >> event; 493 494 return TreeHad(event); 525 495 } 526 496 -
trunk/MagicSoft/Mars/mranforest/MRanTree.h
r2071 r2114 81 81 TArrayF &wl,Int_t ninbag); 82 82 83 Double_t TreeHad( TVector &event);83 Double_t TreeHad(const TVector &event); 84 84 Double_t TreeHad(); 85 85
Note:
See TracChangeset
for help on using the changeset viewer.