Ignore:
Timestamp:
12/22/03 20:35:39 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtools/MChisqEval.cc

    r2208 r2744  
    3232
    3333#include "MDataChain.h"
     34#include "MParameters.h" // MParameterD
     35
     36#include "MParList.h"
    3437
    3538ClassImp(MChisqEval);
     
    120123            return kFALSE;
    121124
     125    fResult = (MParameterD*)plist->FindCreateObj("MParameterD", "MFitResult");
     126    if (!fResult)
     127        return kFALSE;
     128
    122129    return kTRUE;
    123130}
     
    138145{
    139146    fChisq /= GetNumExecutions();
     147
     148    fResult->SetVal(fChisq);
     149
    140150    return kTRUE;
    141151}
  • trunk/MagicSoft/Mars/mtools/MChisqEval.h

    r2208 r2744  
    77
    88class MData;
     9class MParameterD;
    910
    1011class MChisqEval : public MTask
     
    1415    static const TString gsDefTitle;
    1516
    16     Double_t fChisq; //! Evaluated chi square
     17    Double_t     fChisq;  //! Evaluated chi square
     18    MParameterD *fResult; //! Storage for result
    1719
    1820    MData   *fData0; // Data Member one (monte carlo data or chisq function)
  • trunk/MagicSoft/Mars/mtools/MTFillMatrix.cc

    r2711 r2744  
    3535// reference histogram.
    3636//
     37// If no reference histogram is available the number of events are
     38// randomly choosen from the sample with a probability which fits
     39// the total destination number of events.
    3740//
    3841// Here is an example of how to choose 1000 events somehow distributed in
     
    4952// read.DisableAutoScheme();           // make sure everything is read
    5053//
    51 // MTFillMatrix fill(ref);             // setup MTFillMatrix
     54// MTFillMatrix fill(&ref);            // setup MTFillMatrix
    5255// fill.SetNumDestEvents1(1000);       // setup number of events to select
    5356// fill.SetDestMatrix1(&matrix1);      // setup destination matrix
     
    9194#include "MContinue.h"
    9295#include "MFilterList.h"
    93 #include "MFRandomSplit.h"
     96#include "MFEventSelector.h"
    9497#include "MFEventSelector2.h"
    9598
     
    151154// at MFEventSelector2 which is used to select the events.
    152155//
    153 // FIXME: Make a copy of ref.
    154 //
    155 MTFillMatrix::MTFillMatrix(const MH3 &ref)
    156 : fReference(ref), fReader(0), fDestMatrix1(0),
    157 fDestMatrix2(0), fNumDestEvents1(0), fNumDestEvents2(0),
    158 fWriteFile1(0), fWriteFile2(0)
     156// If no MH3 *ref is given the events are randomly selected from the
     157// total sample - this may result in samples which don't have exactly
     158// the predefined size, but it is much faster.
     159//
     160MTFillMatrix::MTFillMatrix(const MH3 *ref)
     161: fReference(0), fReader(0), fDestMatrix1(0), fDestMatrix2(0),
     162  fNumDestEvents1(0), fNumDestEvents2(0), fWriteFile1(0), fWriteFile2(0)
    159163{
    160164    fName  = "MFillMatrix";
    161165    fTitle = "Tool to fill MHMatrix from file";
     166
     167    if (ref)
     168        fReference = (MH3*)ref->Clone();
     169}
     170
     171MTFillMatrix::~MTFillMatrix()
     172{
     173    if (fReference)
     174        delete fReference;
    162175}
    163176
     
    178191    *fLog << "Fill " << fDestMatrix1->GetDescriptor() << " with " << fNumDestEvents1 << endl;
    179192    *fLog << "Fill " << fDestMatrix2->GetDescriptor() << " with " << fNumDestEvents2 << endl;
    180         *fLog << "Distribution choosen ";
    181     if (fReference.GetHist().GetEntries()>0)
    182         *fLog << "from " << fReference.GetDescriptor();
     193    *fLog << "Distribution choosen ";
     194    if (fReference && fReference->GetHist().GetEntries()>0)
     195        *fLog << "from " << fReference->GetDescriptor();
    183196    else
    184197        *fLog << "randomly";
     
    195208    // A selector to select a given number of events from a sample
    196209    //
    197     MFEventSelector2 selector(fReference);
    198     selector.SetNumMax(fNumDestEvents1+fNumDestEvents2);
    199     selector.SetInverted();
     210    // FIXME: Merge MFEventSelector and MFEventSelector2
     211    MFilter *selector=0;
     212    if (fReference)
     213    {
     214        // Case of a reference/nominal distribution
     215        // The events must be read before selection
     216        MFEventSelector2 *sel = new MFEventSelector2(*fReference);
     217        sel->SetNumMax(fNumDestEvents1+fNumDestEvents2);
     218        sel->SetInverted();
     219
     220        selector = sel;
     221    }
     222    else
     223    {
     224        // Case of a random distribution
     225        // The events can be selected before reading
     226        MFEventSelector *sel = new MFEventSelector;
     227        sel->SetNumSelectEvts(fNumDestEvents1+fNumDestEvents2);
     228        fReader->SetSelector(sel);
     229
     230        selector = sel;
     231    }
    200232
    201233    //
     
    203235    // selected by the 'selector'
    204236    //
    205     MContinue cont(&selector);
     237    MContinue cont(selector);
    206238
    207239    //
     
    209241    //
    210242    const Double_t prob = (Double_t)fNumDestEvents1/(fNumDestEvents1+fNumDestEvents2);
    211     MFRandomSplit split(prob);
     243    MFEventSelector split;
     244    split.SetSelectionRatio(prob);
    212245
    213246    //
     
    227260
    228261    // entries in MTaskList
    229     tlist.AddToList(fReader);    // Read events
    230     tlist.AddToList(&cont);      // select a sample of events
    231     tlist.AddToList(&invsplit);  // process invsplit (which implicitly processes split)
     262    tlist.AddToList(fReader);        // Read events
     263    if (fReference)
     264        tlist.AddToList(&cont);      // select a sample of events
     265    tlist.AddToList(&invsplit);      // process invsplit (which implicitly processes split)
    232266    if (fDestMatrix1 && fNumDestEvents1>0)
    233         tlist.AddToList(&fill1); // fill matrix 1
     267        tlist.AddToList(&fill1);     // fill matrix 1
    234268    if (fDestMatrix2 && fNumDestEvents2>0)
    235         tlist.AddToList(&fill2); // fill matrix 2
     269        tlist.AddToList(&fill2);     // fill matrix 2
    236270    if (fWriteFile1)
    237271    {
     
    252286    evtloop.SetDisplay(fDisplay);
    253287    evtloop.SetLogStream(fLog);
    254     if (!evtloop.Eventloop())
     288
     289    const Bool_t rc = evtloop.Eventloop();
     290
     291    // Print execution statistics of the tasklist
     292    if (rc)
     293        tlist.PrintStatistics();
     294
     295    delete selector;
     296
     297    if (!rc)
    255298    {
    256299        *fLog << err << GetDescriptor() << ": Failed." << endl;
    257300        return kFALSE;
    258301    }
    259 
    260     // Print execution statistics of the tasklist
    261     tlist.PrintStatistics();
    262302
    263303    // Check the result of filling...
  • trunk/MagicSoft/Mars/mtools/MTFillMatrix.h

    r2712 r2744  
    1313{
    1414private:
    15     MH3       fReference;
     15    MH3      *fReference;
    1616    MRead    *fReader;
    1717    MHMatrix *fDestMatrix1;
     
    2626
    2727public:
    28     MTFillMatrix(const MH3 &ref);
     28    MTFillMatrix(const MH3 *ref=NULL);
     29    ~MTFillMatrix();
    2930
    3031    void SetDestMatrix1(MHMatrix *matrix, UInt_t num=0)
Note: See TracChangeset for help on using the changeset viewer.