Changeset 2744 for trunk/MagicSoft/Mars


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2743 r2744  
    2020   * mfilter/MFEventSelector2.[h,cc]:
    2121     - added some comments
     22
     23   * macros/dohtml.C, macros/rootlogon.C:
     24     - added mcalib
     25     - added mhbase
     26     
     27   * macros/estfit.C:
     28     - get chisq from MParameterD
     29     
     30   * manalysis/MEventRateCalc.cc:
     31     - added comments
     32     
     33   * mbase/MParContainer.h:
     34     - added a comment
     35     
     36   * mhist/MHCamera.h:
     37     - added default argument for DrawClone
     38     
     39   * mmontecarlo/MMcEnergyEst.cc:
     40     - use an MParameterD instead of accessing MChisqEval
     41     
     42   * mtools/MChisqEval.[h,cc]:
     43     - write result to an MParameterD
     44
     45   * mtools/MTFillMatrix.[h,cc]:
     46     - some more features
    2247
    2348
  • trunk/MagicSoft/Mars/macros/dohtml.C

    r2503 r2744  
    3838    sourcedir += "manalysis:";
    3939    sourcedir += "mbase:";
     40    sourcedir += "mcalib:";
    4041    sourcedir += "mdata:";
    4142    sourcedir += "mfileio:";
     
    4344    sourcedir += "mgeom:";
    4445    sourcedir += "mgui:";
     46    sourcedir += "mhbase:";
    4547    sourcedir += "mhist:";
    4648    sourcedir += "mhistmc:";
  • trunk/MagicSoft/Mars/macros/estfit.C

    r2124 r2744  
    1010#include "MChisqEval.h"
    1111#include "MMatrixLoop.h"
     12#include "MParameterD.h"
    1213#include "MDataMember.h"
    1314#include "MDataElement.h"
     
    2021    MEvtLoop *evtloop = (MEvtLoop*)gMinuit->GetObjectFit();
    2122
    22     MTaskList *tlist  = (MTaskList*)evtloop->GetParList()->FindObject("MTaskList"); //GetTaskList();
    23 
    24     MChisqEval      *eval = (MChisqEval*)     tlist->FindObject("MChisqEval");
     23    MParList  *plist  = evtloop->GetParList();
     24    MTaskList *tlist  = evtloop->GetTaskList();
     25
     26    MChisqEval      *eval = (MChisqEval*)     plist->FindObject("MFitResult", "MParameterD");
    2527    MEnergyEstParam *eest = (MEnergyEstParam*)tlist->FindObject("MEnergyEstParam");
    2628
     
    2931    evtloop->Eventloop();
    3032
    31     f = eval->GetChisq();
     33    f = eval->GetVal();
    3234}
    3335
  • trunk/MagicSoft/Mars/macros/rootlogon.C

    r2558 r2744  
    100100    gInterpreter->AddIncludePath(dir+"manalysis");
    101101    gInterpreter->AddIncludePath(dir+"mbase");
     102    gInterpreter->AddIncludePath(dir+"mcalib");
    102103    gInterpreter->AddIncludePath(dir+"mdata");
    103104    gInterpreter->AddIncludePath(dir+"mfileio");
     
    105106    gInterpreter->AddIncludePath(dir+"mgeom");
    106107    gInterpreter->AddIncludePath(dir+"mgui");
     108    gInterpreter->AddIncludePath(dir+"mhbase");
    107109    gInterpreter->AddIncludePath(dir+"mhist");
    108110    gInterpreter->AddIncludePath(dir+"mhistmc");
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc

    r2678 r2744  
    2929//  This task calculates the event rates from the event times and numbers.
    3030//
    31 //  It is under construction: More information comming soon....
    32 //
     31//  The algorithm is explained in Process()
    3332//
    3433//  Input Containers:
     
    3837//    MEventRate
    3938//    MTimeRate [MTime] (missing)
     39//
     40//  FIXME: For convinience we could implement a mode which always takes
     41//         n events to calculate the event rate and sets the corresponding
     42//         time. This mode could be used to UPADTE files with the event
     43//         rate.
    4044//
    4145//////////////////////////////////////////////////////////////////////////////
     
    6872//
    6973// The PreProcess searches for the following input containers:
    70 //  ...
     74//   MTime
     75//
     76// The PreProcess searches for the following input containers:
     77//   MEventRate
     78//
     79// Reset all times in the buffer
    7180//
    7281Int_t MEventRateCalc::PreProcess(MParList *pList)
     
    9099// --------------------------------------------------------------------------
    91100//
     101// Calculate the events rate as (t1-t0)/n while t1 is the n-th event after
     102// t0. If there are not yet enough events in the buffer n is the number
     103// of available events. Otherwise the number setup in SetNumEvents.
    92104//
    93105Int_t MEventRateCalc::Process()
     
    109121    fRate->SetReadyToSave();
    110122
    111     // *fLog << inf << "   ---   Event Rate [Hz]: " << rate << "  (" << cnt << ")" << endl;
    112 
    113123    return kTRUE;
    114124}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r2490 r2744  
    5252    Bool_t  fReadyToSave; // should be set to true if the contents of the container is changed somehow
    5353
     54    // FIXME: Change to ostream!
    5455    virtual void StreamPrimitive(ofstream &out) const;
    5556
  • trunk/MagicSoft/Mars/mhist/MHCamera.h

    r2698 r2744  
    159159    void     Paint(Option_t *option="");
    160160    void     Draw(Option_t *option="");
    161     TObject *DrawClone(Option_t *option) const;
     161    TObject *DrawClone(Option_t *option="") const;
    162162    void     SavePrimitive(ofstream &out, Option_t *);
    163163    Int_t    DistancetoPrimitive(Int_t px, Int_t py);
  • trunk/MagicSoft/Mars/mmontecarlo/MMcEnergyEst.cc

    r2728 r2744  
    6060#include "MLog.h"
    6161#include "MLogManip.h"
     62#include "MParameters.h"
    6263
    6364ClassImp(MMcEnergyEst);
     
    7172static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
    7273{
    73   MEvtLoop *evtloop = (MEvtLoop*)gMinuit->GetObjectFit();
    74  
    75   MTaskList *tlist  = (MTaskList*)evtloop->GetParList()->FindObject("MTaskList"); // GetTaskList();
    76 
    77   MChisqEval      *eval = (MChisqEval*)     tlist->FindObject("MChisqEval");
    78   MEnergyEstParam *eest = (MEnergyEstParam*)tlist->FindObject("MEnergyEstParam");
    79 
    80   eest->SetCoeff(TArrayD(eest->GetNumCoeff(), par));
    81 
    82   evtloop->Eventloop();
    83 
    84   f = eval->GetChisq();
     74    MEvtLoop *evtloop = (MEvtLoop*)gMinuit->GetObjectFit();
     75
     76    MParList  *plist  = evtloop->GetParList();
     77    MTaskList *tlist  = evtloop->GetTaskList();
     78
     79    MParameterD     *eval = (MParameterD*)    plist->FindObject("MFitResult", "MParameterD");
     80    MEnergyEstParam *eest = (MEnergyEstParam*)tlist->FindObject("MEnergyEstParam");
     81
     82    eest->SetCoeff(TArrayD(eest->GetNumCoeff(), par));
     83
     84    evtloop->Eventloop();
     85
     86    f = eval->GetVal();
    8587}
    8688
     
    340342
    341343}
    342 
    343 
  • 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.