Changeset 7710 for trunk/MagicSoft


Ignore:
Timestamp:
05/18/06 14:01:43 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7709 r7710  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2006/05/18 Thomas Bretz
     22
     23   * mhflux/MAlphaFitter.h:
     24     - added Getter for ScaleMode
     25
     26   * mhflux/MHThetaSq.[h,cc]:
     27     - removed obsolete data-member fThetaSq
     28
     29   * mjtrain/MJTrainRanForest.cc, mranforest/MRanForestCalc.cc:
     30     - fixed a typo in a comment
     31
     32   * mranforest/MRanTree.cc:
     33     - added a lot of comments in the code
     34
     35
    2036
    2137 2006/05/18 Daniela Dorner
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h

    r7618 r7710  
    169169    Double_t GetMinimizationValue() const;
    170170
     171    ScaleMode_t GetScaleMode() const       { return fScaleMode; }
     172
    171173    Double_t GetGausSigma() const          { return fCoefficients[2]; }
    172174    Double_t GetGausMu() const             { return fCoefficients[1]; }
  • trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc

    r7194 r7710  
    6262//
    6363MHThetaSq::MHThetaSq(const char *name, const char *title)
    64     : MHAlpha(name, title), fThetaSq(0), fNumBinsSignal(3), fNumBinsTotal(75)
     64    : MHAlpha(name, title), fNumBinsSignal(3), fNumBinsTotal(75)
    6565{
    6666    //
  • trunk/MagicSoft/Mars/mhflux/MHThetaSq.h

    r7151 r7710  
    1111{
    1212private:
    13     MParameterD  *fThetaSq; //!
    14 
    1513    UInt_t fNumBinsSignal;
    1614    UInt_t fNumBinsTotal;
  • trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc

    r7697 r7710  
    9090//   Int_t idx = AddParameter("log10(MHillas.fSize)");
    9191//
    92 // The indices area starting with 0 always.
     92// The indices are starting with 0 always.
    9393//
    9494Int_t MJTrainRanForest::AddParameter(const char *rule)
  • trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc

    r7687 r7710  
    1 /* ======================================================================== *\
     1/* ================================q======================================== *\
    22!
    33! *
     
    3232#include "MRanForestCalc.h"
    3333
     34#include <TF1.h>
     35#include <TGraph.h>
    3436#include <TVector.h>
    3537
     
    279281    }
    280282
    281     // Maybe fEForests[0].fRules yould be used instead?
    282 
     283    // Maybe fEForests[0].fRules could be used instead?
    283284    if (fData->Read("rules")<=0)
    284285    {
     
    322323}
    323324
    324 #include <TGraph.h>
    325 #include <TF1.h>
    326325Int_t MRanForestCalc::Process()
    327326{
  • trunk/MagicSoft/Mars/mranforest/MRanTree.cc

    r7697 r7710  
    4141#include "MArrayF.h"
    4242
     43#include "MMath.h"
     44
    4345#include "MLog.h"
    4446#include "MLogManip.h"
     
    176178    Double_t pdo=0;
    177179
    178     for (Int_t j=0; j<nclass; j++)
     180    // tclasspop: sum of weights for events in class
     181    for (Int_t j=0; j<nclass; j++) // loop over number of classes to classifiy
    179182    {
    180183        pno+=tclasspop[j]*tclasspop[j];
     
    182185    }
    183186
    184     const Double_t crit0=pno/pdo;
     187    const Double_t crit0=pno/pdo;  // weighted mean of weights
    185188
    186189    // start main loop through variables to find best split,
     
    190193
    191194    // random split selection, number of trials = fNumTry
    192     for (Int_t mt=0; mt<fNumTry; mt++)
     195    for (Int_t mt=0; mt<fNumTry; mt++) // we could try ALL variables???
    193196    {
    194197        const Int_t mvar= gRandom->Integer(mdim);
     
    212215
    213216            // do classification, Gini index as split rule
    214             rln+=u*( 2*wl[k]+u);
    215             rrn+=u*(-2*wr[k]+u);
    216 
    217             rld+=u;
    218             rrd-=u;
    219 
    220             wl[k]+=u;
    221             wr[k]-=u;
    222 
     217            rln   +=u*(2*wl[k]+u);  // += u*(wl[k]{i-1} + wl[k]{i-1}+u{i})
     218            rld   +=u;   // sum of weights left  from cut total
     219            wl[k] +=u;   // sum of weights left  from cut for class k
     220
     221            rrn   -=u*(2*wr[k]-u);  // -= u*(wr[k]{i-1} + wr[k]{i-1}-u{i})
     222            //  rr0=0; rr0+=u*2*tclasspop[k]
     223            //  rrn = pno - rr0 + rln
     224            rrd   -=u;   // sum of weights right from cut total
     225            wr[k] -=u;   // sum of weights right from cut for class k
     226
     227            // REPLACE BY?
     228            // rr0   = 0
     229            // rr0  += u*2*tclasspop[k]
     230            // rrn   = pno - rr0 + rln
     231            // rrd   = pdo - rld
     232            // wr[k] = tclasspop[k] - wl[k]
     233
     234            // crit = (rln*(pdo - rld + 1) + pno - rr0) / rld*(pdo - rld)
     235
     236            /*
     237             if (k==background)
     238                continue;
     239             crit = TMath::Max(MMath::SignificanceLiMa(rld, rld-wl[k]),
     240                               MMath::SignificanceLiMa(rrd, rrd-wr[k]))
     241             */
     242
     243            // This condition is in fact a == (> cannot happen at all)
     244            // This is because we cannot set the cut between two identical values
     245            //if (datarang[mn+datasort[mn+nsp]]>=datarang[mn+datasort[mn+nsp+1]])
    223246            if (datarang[mn+nc]>=datarang[mn+datasort[mn+nsp+1]])
    224247                continue;
    225248
    226             if (TMath::Min(rrd,rld)<=1.0e-5)
     249            // If crit starts to become pretty large do WHAT???
     250            if (TMath::Min(rrd,rld)<=1.0e-5) // FIXME: CHECKIT FOR WEIGHTS!
    227251                continue;
    228252
    229253            const Double_t crit=(rln/rld)+(rrn/rrd);
    230254
     255            // Search for the highest value of crit
    231256            if (crit<=critvar) continue;
    232257
     258            // store the highest crit value and the corresponding event to cut at
    233259            nbestvar=nsp;
    234260            critvar=crit;
     
    237263        if (critvar<=critmax) continue;
    238264
    239         msplit=mvar;
    240         nbest=nbestvar;
     265        msplit=mvar;      // Variable in which to split
     266        nbest=nbestvar;   // event at which the best split was found
    241267        critmax=critvar;
    242268    }
    243269
     270    // crit0 = MMath::SignificanceLiMa(pdo, pdo-tclasspop[0])
     271    // mean increase of sensitivity
     272    // decsplit = sqrt(critmax/crit0)
    244273    decsplit=critmax-crit0;
    245274
     
    299328        const Int_t mn  = mvar*numdata;
    300329
    301         Double_t rrn=0, rrd=0, rln=0, rld=0;
    302 
    303330        Double_t esumr =mean;
    304331        Double_t e2sumr=square;
     
    316343            const Float_t &u=winbag[nc];
    317344
    318             e2sumr-=u*f*f;
    319             esumr -=u*f;
    320             wr    -=u;
    321 
    322             //-------------------------------------------
    323             // resolution
    324             //rrn=(wr*e2sumr-esumr*esumr)*wr;
    325             //rrd=(wr-1.)*esumr*esumr;
    326 
    327             // resolution times n
    328             //rrn=(wr*e2sumr-esumr*esumr)*wr;
    329             //rrd=esumr*esumr;
    330 
    331             // sigma
    332             //rrn=(e2sumr-esumr*esumr/wr);
    333             //rrd=(wr-1.);
    334 
    335             // sigma times n
    336             rrn=(e2sumr-esumr*esumr/wr);
    337             rrd=1.;
    338 
    339             // 1./(n*variance)
    340             //rrn=1.;
    341             //rrd=(e2sumr-esumr*esumr/wr);
    342             //-------------------------------------------
    343 
    344345            e2suml+=u*f*f;
    345346            esuml +=u*f;
     
    348349            //-------------------------------------------
    349350            // resolution
    350             //rln=(wl*e2suml-esuml*esuml)*wl;
    351             //rld=(wl-1.)*esuml*esuml;
     351            //const Double_t rln=(wl*e2suml-esuml*esuml)*wl;
     352            //const Double_t rld=(wl-1.)*esuml*esuml;
    352353
    353354            // resolution times n
    354             //rln=(wl*e2suml-esuml*esuml)*wl;
    355             //rld=esuml*esuml;
     355            //const Double_t rln=(wl*e2suml-esuml*esuml)*wl;
     356            //const Double_t rld=esuml*esuml;
    356357
    357358            // sigma
    358             //rln=(e2suml-esuml*esuml/wl);
    359             //rld=(wl-1.);
     359            //const Double_t rln=(e2suml-esuml*esuml/wl);
     360            //const Double_t rld=(wl-1.);
    360361
    361362            // sigma times n
    362             rln=(e2suml-esuml*esuml/wl);
    363             rld=1.;
     363            Double_t rln=(e2suml-esuml*esuml/wl);
     364            Double_t rld=1.;
    364365
    365366            // 1./(n*variance)
    366             //rln=1.;
    367             //rld=(e2suml-esuml*esuml/wl);
     367            //const Double_t rln=1.;
     368            //const Double_t rld=(e2suml-esuml*esuml/wl);
     369            //-------------------------------------------
     370
     371            // REPLACE BY???
     372            e2sumr-=u*f*f;   // e2sumr = square       - e2suml
     373            esumr -=u*f;     // esumr  = mean         - esuml
     374            wr    -=u;       // wr     = tclasspop[0] - wl
     375
     376            //-------------------------------------------
     377            // resolution
     378            //const Double_t rrn=(wr*e2sumr-esumr*esumr)*wr;
     379            //const Double_t rrd=(wr-1.)*esumr*esumr;
     380
     381            // resolution times n
     382            //const Double_t rrn=(wr*e2sumr-esumr*esumr)*wr;
     383            //const Double_t rrd=esumr*esumr;
     384
     385            // sigma
     386            //const Double_t rrn=(e2sumr-esumr*esumr/wr);
     387            //const Double_t rrd=(wr-1.);
     388
     389            // sigma times n
     390            const Double_t rrn=(e2sumr-esumr*esumr/wr);
     391            const Double_t rrd=1.;
     392
     393            // 1./(n*variance)
     394            //const Double_t rrn=1.;
     395            //const Double_t rrd=(e2sumr-esumr*esumr/wr);
    368396            //-------------------------------------------
    369397
     
    538566              const int j=idclass[nc];
    539567                   
     568              // statistics left from cut
    540569              mean[ncur+1]+=hadtrue[nc]*winbag[nc];
    541570              square[ncur+1]+=hadtrue[nc]*hadtrue[nc]*winbag[nc];
    542571
     572              // sum of weights left from cut
    543573              classpop[j*nrnodes+ncur+1]+=winbag[nc];
    544574          }
     
    549579              const int j=idclass[nc];
    550580
     581              // statistics right from cut
    551582              mean[ncur+2]  +=hadtrue[nc]*winbag[nc];
    552583              square[ncur+2]+=hadtrue[nc]*hadtrue[nc]*winbag[nc];
    553584
     585              // sum of weights right from cut
    554586              classpop[j*nrnodes+ncur+2]+=winbag[nc];
    555587          }
Note: See TracChangeset for help on using the changeset viewer.