Ignore:
Timestamp:
11/28/03 08:08:53 (21 years ago)
Author:
wittek
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.cc

    r2408 r2574  
    5858#include "MFillH.h"
    5959//#include "MGeomCamCT1Daniel.h"
     60#include "MFRandomSplit.h"
    6061#include "MGeomCamCT1.h"
    6162#include "MH3.h"
     
    246247    fTitle = title ? title : "Optimizer of the supercuts";
    247248
     249    fUseOrigDistribution = kFALSE;
     250
    248251    //---------------------------
    249252    // camera geometry is needed for conversion mm ==> degree
     
    277280}
    278281
     282
     283// --------------------------------------------------------------------------
     284//
     285//
     286//
     287void MCT1FindSupercuts::SetUseOrigDistribution(Bool_t b)
     288{
     289  fUseOrigDistribution = b;
     290
     291  *fLog << "MCT1FindSupercuts : when defining training and test matrices use the original distribution"
     292        << endl;
     293}
     294
    279295// --------------------------------------------------------------------------
    280296//
     
    285301//
    286302//
    287 Bool_t MCT1FindSupercuts::DefineTrainMatrix(const TString &nametrain,
    288                           const Int_t howmanytrain, MH3 &hreftrain,
    289                           const TString &filetrain)
     303Bool_t MCT1FindSupercuts::DefineTrainMatrix(
     304                          const TString &nametrain, MH3 &hreftrain,
     305                          const Int_t howmanytrain, const TString &filetrain)
    290306{
    291307    if (nametrain.IsNull() || howmanytrain <= 0)
     
    295311    *fLog << "fill training matrix from file '" << nametrain
    296312          << "',   select " << howmanytrain
    297           << " events according to a distribution given by the MH3 object '"
    298           << hreftrain.GetName() << "'" << endl;
     313          << " events " << endl;
     314    if (!fUseOrigDistribution)
     315    {
     316      *fLog << "     according to a distribution given by the MH3 object '"
     317            << hreftrain.GetName() << "'" << endl;
     318    }
     319    else
     320    {
     321      *fLog << "     randomly" << endl;
     322    }
    299323
    300324
     
    305329    read.DisableAutoScheme();
    306330
    307     //MFEventSelector2 seltrain(hreftrain);
    308     //seltrain.SetNumMax(howmanytrain);
    309     MFEventSelector seltrain;
    310     seltrain.SetNumSelectEvts(howmanytrain);
     331    MFEventSelector2 seltrain(hreftrain);
     332    seltrain.SetNumMax(howmanytrain);
     333    seltrain.SetName("selectTrain");
     334    if (fUseOrigDistribution)
     335      seltrain.SetUseOrigDistribution(kTRUE);
    311336
    312337    MFillH filltrain(fMatrixTrain);
    313338    filltrain.SetFilter(&seltrain);
     339    filltrain.SetName("fillMatrixTrain");
    314340
    315341    //******************************
     
    379405//
    380406//
    381 Bool_t MCT1FindSupercuts::DefineTestMatrix(const TString &nametest,
    382                           const Int_t howmanytest, MH3 &hreftest,
    383                           const TString &filetest)
     407Bool_t MCT1FindSupercuts::DefineTestMatrix(
     408                          const TString &nametest, MH3 &hreftest,
     409                          const Int_t howmanytest, const TString &filetest)
    384410{
    385411    if (nametest.IsNull() || howmanytest<=0)
     
    389415    *fLog << "fill test matrix from file '" << nametest
    390416          << "',   select " << howmanytest
    391           << " events according to a distribution given by the MH3 object '"
    392           << hreftest.GetName() << "'" << endl;
     417          << " events " << endl;
     418    if (!fUseOrigDistribution)
     419    {
     420      *fLog << "     according to a distribution given by the MH3 object '"
     421            << hreftest.GetName() << "'" << endl;
     422    }
     423    else
     424    {
     425      *fLog << "     randomly" << endl;
     426    }
    393427
    394428
     
    399433    read.DisableAutoScheme();
    400434
    401     //MFEventSelector2 seltest(hreftest);
    402     //seltest.SetNumMax(howmanytest);
    403     MFEventSelector seltest;
    404     seltest.SetNumSelectEvts(howmanytest);
    405 
     435    MFEventSelector2 seltest(hreftest);
     436    seltest.SetNumMax(howmanytest);
     437    seltest.SetName("selectTest");
     438    if (fUseOrigDistribution)
     439      seltest.SetUseOrigDistribution(kTRUE);
     440 
    406441    MFillH filltest(fMatrixTest);
    407442    filltest.SetFilter(&seltest);
     
    471506//
    472507Bool_t MCT1FindSupercuts::DefineTrainTestMatrix(
    473                           const TString &name,
    474                           const Int_t howmanytrain, MH3 &hreftrain,
    475                           const Int_t howmanytest,  MH3 &hreftest,
     508                          const TString &name, MH3 &href,
     509                          const Int_t howmanytrain, const Int_t howmanytest,
    476510                          const TString &filetrain, const TString &filetest)
    477511{
    478512    *fLog << "=============================================" << endl;
    479     *fLog << "fill training matrix from file '" << name
    480           << "',   select " << howmanytrain
    481           << " events for the training according to a distribution given by the MH3 object '"
    482           << hreftrain.GetName() << "'" << endl;
    483 
    484     *fLog << "fill test matrix from the same file '" << name
    485           << "',   select " << howmanytest
    486           << " events for the training according to a distribution given by the MH3 object '"
    487           << hreftest.GetName() << "'" << endl;
     513    *fLog << "fill training and test matrix from file '" << name
     514          << "',   select "   << howmanytrain
     515          << " training and " << howmanytest << " test events " << endl;
     516    if (!fUseOrigDistribution)
     517    {
     518      *fLog << "     according to a distribution given by the MH3 object '"
     519            << href.GetName() << "'" << endl;
     520    }
     521    else
     522    {
     523      *fLog << "     randomly" << endl;
     524    }
    488525
    489526
     
    494531    read.DisableAutoScheme();
    495532
    496     //MFEventSelector2 seltrain(hreftrain);
    497     //seltrain.SetNumMax(howmanytrain);
    498     MFEventSelector seltrain;
    499     seltrain.SetName("SelTrain");
    500     seltrain.SetNumSelectEvts(howmanytrain);
     533    MFEventSelector2 selector(href);
     534    selector.SetNumMax(howmanytrain+howmanytest);
     535    selector.SetName("selectTrainTest");
     536    selector.SetInverted();
     537    if (fUseOrigDistribution)
     538      selector.SetUseOrigDistribution(kTRUE);
     539
     540    MContinue cont(&selector);
     541    cont.SetName("ContTrainTest");
     542
     543    Double_t prob =  ( (Double_t) howmanytrain )
     544                   / ( (Double_t)(howmanytrain+howmanytest) );
     545    MFRandomSplit split(prob);
    501546
    502547    MFillH filltrain(fMatrixTrain);
     548    filltrain.SetFilter(&split);
    503549    filltrain.SetName("fillMatrixTrain");
    504     filltrain.SetFilter(&seltrain);
     550
    505551
    506552    // consider this event as candidate for a test event
    507553    // only if event was not accepted as a training event
    508     MContinue cont(&seltrain);
    509 
    510     const Float_t fcorr = (Float_t)read.GetEntries() / (read.GetEntries()-howmanytrain);
    511 
    512     *fLog << "entries, howmanytrain, fcorr = " << read.GetEntries()
    513           << ",  " << howmanytrain << ",  " << fcorr << endl;
    514 
    515     //MFEventSelector2 seltest(hreftest);
    516     //seltrain.SetNumMax(howmanytest*fcorr);
    517     MFEventSelector seltest;
    518     seltest.SetName("SelTest");
    519     seltest.SetNumSelectEvts((Int_t)(fcorr*howmanytest));
     554
     555    MContinue conttrain(&split);
     556    conttrain.SetName("ContTrain");
    520557
    521558    MFillH filltest(fMatrixTest);
    522559    filltest.SetName("fillMatrixTest");
    523     filltest.SetFilter(&seltest);
     560
    524561
    525562    //******************************
     
    535572
    536573    tlist.AddToList(&read);
    537     tlist.AddToList(&seltrain);
     574    tlist.AddToList(&cont);
     575
     576    tlist.AddToList(&split);
    538577    tlist.AddToList(&filltrain);
    539 
    540     tlist.AddToList(&cont);
    541 
    542     tlist.AddToList(&seltest);
     578    tlist.AddToList(&conttrain);
     579
    543580    tlist.AddToList(&filltest);
    544581
  • trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.h

    r2357 r2574  
    3737  Int_t   fHowManyTrain;
    3838  Int_t   fHowManyTest;
     39
     40  Bool_t  fUseOrigDistribution;
    3941
    4042  TString  fFilenameParam;
     
    8890  void SetMatrixFilter(MFilter *filter)          {fMatrixFilter = filter;}
    8991
    90   Bool_t DefineTrainMatrix(const TString &name, const Int_t howmany,
    91                            MH3 &href, const TString &filetrain);
     92  Bool_t DefineTrainMatrix(const TString &name, MH3 &href,
     93                           const Int_t howmany, const TString &filetrain);
    9294
    93   Bool_t DefineTestMatrix(const TString &name, const Int_t howmany,
    94                           MH3 &href, const TString &filetest);
     95  Bool_t DefineTestMatrix(const TString &name, MH3 &href,
     96                          const Int_t howmany, const TString &filetest);
    9597
    96   Bool_t DefineTrainTestMatrix(const TString &name,
    97                          const Int_t howmanytrain, MH3 &hreftrain,
    98                          const Int_t howmanytest,  MH3 &hreftest,
     98  Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href,
     99                         const Int_t howmanytrain, const Int_t howmanytest,
    99100                         const TString &filetrain, const TString &filetest);
     101
     102  void SetUseOrigDistribution(Bool_t b);
    100103
    101104  MHMatrix *GetMatrixTrain() { return fMatrixTrain; }
Note: See TracChangeset for help on using the changeset viewer.