Changeset 2114


Ignore:
Timestamp:
05/13/03 15:16:54 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2111 r2114  
    11                                                 -*-*- 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
    228 2003/05/12: Abelardo Moralejo
    329
    430   * mhistmc/MHMcEnergyMigration.cc
    531     - Draw(): fixed axis label in one plot.
     32
     33
    634
    735 2003/05/12: Thomas Bretz
  • trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc

    r1954 r2114  
    172172Bool_t MMultiDimDistCalc::Process()
    173173{
    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;
    188177
    189178    Double_t numg = fNum;
  • trunk/MagicSoft/Mars/mdata/MDataArray.cc

    r2109 r2114  
    3535#include <fstream.h>
    3636
     37#include <TVector.h>
     38
    3739#include "MLog.h"
    3840#include "MLogManip.h"
     
    8991// Return the data value of the i-th entry
    9092//
    91 Double_t MDataArray::operator()(Int_t i)
    92 {
    93     return ((MData*)fList[i])->GetValue();
     93Double_t MDataArray::operator()(Int_t i) const
     94{
     95    return (*this)[i].GetValue();
    9496}
    9597
     
    189191    return str;
    190192}
     193
     194void 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  
    1414#include <TObjArray.h>
    1515#endif
     16
     17class TVector;
    1618
    1719class MData;
     
    3133
    3234    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    }
    3443
    3544    TString GetRule(int i) const;
  • trunk/MagicSoft/Mars/mranforest/MRanForest.cc

    r2071 r2114  
    8585void MRanForest::SetPriors(Float_t prior_had, Float_t prior_gam)
    8686{
    87     Float_t sum;
    88 
    89     sum=prior_gam+prior_had;
     87    const Float_t sum=prior_gam+prior_had;
    9088
    9189    prior_gam/=sum;
     
    9896}
    9997
    100 Double_t MRanForest::CalcHadroness(TVector &event)
     98Double_t MRanForest::CalcHadroness(const TVector &event)
    10199{
    102100    Double_t hadroness=0;
    103101    Int_t ntree=0;
     102
     103    TIter forest(fForest);
     104
    104105    MRanTree *tree;
    105 
    106     TIter forest(fForest);
    107     forest.Reset();
    108 
    109106    while ((tree=(MRanTree*)forest.Next()))
    110107    {
  • trunk/MagicSoft/Mars/mranforest/MRanForest.h

    r2071 r2114  
    9696 
    9797    // use forest to calculate hadronness of event
    98     Double_t CalcHadroness(TVector &event);
     98    Double_t CalcHadroness(const TVector &event);
    9999
    100100    Bool_t AsciiWrite(ostream &out) const;
  • trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc

    r2071 r2114  
    137137Bool_t MRanForestCalc::Process()
    138138{
    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;
    144142
    145143    Double_t hadroness=fRanForest->CalcHadroness(event);
  • trunk/MagicSoft/Mars/mranforest/MRanTree.cc

    r2071 r2114  
    178178    // (Gini-index as criterium crit)
    179179
    180     critmax=-1.0e20;
     180    critmax=-1.0e20;  // FIXME: Replace by a constant from limits.h
    181181
    182182    // random split selection, number of trials = fNumTry
     
    301301    for(Int_t n=ndstart;n<=ndend;n++)
    302302        ncase[n]=datasort[msplit*numdata+n];
    303 
    304     return;
    305303}
    306304
     
    459457            fBestSplit[kn]/=(classpop[0*nrnodes+kn]+classpop[1*nrnodes+kn]);
    460458        }
    461 
    462     return;
    463459}
    464460
     
    468464}
    469465
    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 
     466Double_t MRanTree::TreeHad(const TVector &event)
     467{
    502468    Int_t kt=0;
    503469    // to optimize on storage space node status and node class
     
    513479            break;
    514480
    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];
    522484    }
    523485
    524486    return fBestSplit[kt];
     487}
     488
     489Double_t MRanTree::TreeHad()
     490{
     491    TVector event;
     492    *fData >> event;
     493
     494    return TreeHad(event);
    525495}
    526496
  • trunk/MagicSoft/Mars/mranforest/MRanTree.h

    r2071 r2114  
    8181                   TArrayF &wl,Int_t ninbag);
    8282
    83     Double_t TreeHad(TVector &event);
     83    Double_t TreeHad(const TVector &event);
    8484    Double_t TreeHad();
    8585
Note: See TracChangeset for help on using the changeset viewer.