Changeset 3788 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
04/21/04 15:38:08 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3787 r3788  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20 2004/04/21: Thomas Bretz
     21
     22   * mbase/MTask.cc,  mbase/MTaskList.cc:
     23     - let MTask in list fTaskProcess to be used as a counter
     24
     25   * mdata/MDataChain.[h,cc]:
     26     - added some treatments for combinations of +/- signs
     27
     28   * mfbase/MFilterList.[h,cc]:
     29     - added a new constructor to simplyfy filter-inversions
     30
     31   * mfileio/MReadReports.cc:
     32     - added comment
     33
     34   * mhbase/MBinning.[h,cc]:
     35     - added new constructor to simplify calls in macros
     36
     37   * mhbase/MFillH.[h,cc]:
     38     - added fDrawOption to be used in MStatusDisplay
     39
     40   * mhist/MHFalseSource.cc:
     41     - added comment
     42
     43
     44
    2045 2004/04/20: Thomas Bretz
    2146
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r3666 r3788  
    7777//                     etc. PostProcess is only executed in case of
    7878//                     PreProcess was successfull (returned kTRUE)
     79//
     80//
     81//  Remark: Using a MTask in your tasklist doesn't make much sense,
     82//          because it is doing nothing. However it is a nice tool
     83//          to count something (exspecially if used together with a
     84//          filter)
     85//
    7986//
    8087//  Version 1:
     
    391398void MTask::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
    392399{
    393     if (!OverwritesProcess())
     400    if (!OverwritesProcess() && IsA()!=MTask::Class())
    394401        return;
    395402
     
    447454    // Check whether we reached the base class MTask
    448455    //
    449     if (TString(cls->GetName())=="MTask")
     456    if (cls==MTask::Class())
    450457        return kFALSE;
    451458
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r3666 r3788  
    4343// from the list.
    4444//
     45// Remark: The Process function is only executed if the class of your task
     46//         overloads Process() or if the task itself is a MTask. This
     47//         means if you have a task without Process() (only PreProcess
     48//         and PostProcess no time is lost during execution)
     49//
    4550// Warning:
    4651//  Be carefull if you are writing your tasklist
     
    300305// --------------------------------------------------------------------------
    301306//
     307//  removes a task from the list (used in PreProcess).
     308//  if kIsOwner is set the task is deleted. (see SetOwner())
     309//
     310void MTaskList::Remove(MTask *task)
     311{
     312    TObject *obj = fTasks->Remove(task);
     313
     314    if (TestBit(kIsOwner))
     315        delete obj;
     316}
     317
     318// --------------------------------------------------------------------------
     319//
     320//  do pre processing (before eventloop) of all tasks in the task-list
     321//  Only if a task overwrites the Process function the task is
     322//  added to the fTaskProcess-List. This makes the execution of the
     323//  tasklist a little bit (only a little bit) faster, bacause tasks
     324//  doing no Processing are not Processed.
     325//
     326Int_t MTaskList::PreProcess(MParList *pList)
     327{
     328    *fLog << all << "Preprocessing... " << flush;
     329    if (fDisplay)
     330    {
     331        // Set status lines
     332        fDisplay->SetStatusLine1("PreProcessing...");
     333        fDisplay->SetStatusLine2("");
     334    }
     335
     336    fParList = pList;
     337
     338    //
     339    // Make sure, that the ReadyToSave flag is not reset from a tasklist
     340    // running as a task in another tasklist.
     341    //
     342    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
     343    if (!noreset)
     344        fParList->SetBit(MParList::kDoNotReset);
     345
     346    //
     347    //  create the Iterator over the tasklist
     348    //
     349    TIter Next(fTasks);
     350
     351    MTask *task=NULL;
     352
     353    //
     354    // loop over all tasks for preproccesing
     355    //
     356    while ((task=(MTask*)Next()))
     357    {
     358        //
     359        // PreProcess the task and check for it's return value.
     360        //
     361        switch (task->CallPreProcess(fParList))
     362        {
     363        case kFALSE:
     364            return kFALSE;
     365
     366        case kTRUE:
     367            // Handle GUI events (display changes, mouse clicks)
     368            if (fDisplay)
     369                gSystem->ProcessEvents();
     370            continue;
     371
     372        case kSKIP:
     373            Remove(task);
     374            continue;
     375        }
     376
     377        *fLog << err << dbginf << "PreProcess of " << task->GetDescriptor();
     378        *fLog << " returned an unknown value... aborting." << endl;
     379        return kFALSE;
     380    }
     381
     382    *fLog << all << endl;
     383
     384    //
     385    // Reset the ReadyToSave flag.
     386    //
     387    if (!noreset)
     388    {
     389        fParList->SetReadyToSave(kFALSE);
     390        fParList->ResetBit(MParList::kDoNotReset);
     391    }
     392
     393    //
     394    // loop over all tasks to fill fTasksProcess
     395    //
     396    Next.Reset();
     397    fTasksProcess.Clear();
     398    while ((task=(MTask*)Next()))
     399        if (task->IsA()==MTask::Class() || task->OverwritesProcess())
     400            fTasksProcess.Add(task);
     401
     402    return kTRUE;
     403}
     404
     405// --------------------------------------------------------------------------
     406//
    302407//  do reinit of all tasks in the task-list
    303408//
     
    348453        pList->ResetBit(MParList::kDoNotReset);
    349454    }
    350 
    351     return kTRUE;
    352 }
    353 
    354 // --------------------------------------------------------------------------
    355 //
    356 //  removes a task from the list (used in PreProcess).
    357 //  if kIsOwner is set the task is deleted. (see SetOwner())
    358 //
    359 void MTaskList::Remove(MTask *task)
    360 {
    361     TObject *obj = fTasks->Remove(task);
    362 
    363     if (TestBit(kIsOwner))
    364         delete obj;
    365 }
    366 
    367 // --------------------------------------------------------------------------
    368 //
    369 //  do pre processing (before eventloop) of all tasks in the task-list
    370 //  Only if a task overwrites the Process function the task is
    371 //  added to the fTaskProcess-List. This makes the execution of the
    372 //  tasklist a little bit (only a little bit) faster, bacause tasks
    373 //  doing no Processing are not Processed.
    374 //
    375 Int_t MTaskList::PreProcess(MParList *pList)
    376 {
    377     *fLog << all << "Preprocessing... " << flush;
    378     if (fDisplay)
    379     {
    380         // Set status lines
    381         fDisplay->SetStatusLine1("PreProcessing...");
    382         fDisplay->SetStatusLine2("");
    383     }
    384 
    385     fParList = pList;
    386 
    387     //
    388     // Make sure, that the ReadyToSave flag is not reset from a tasklist
    389     // running as a task in another tasklist.
    390     //
    391     const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
    392     if (!noreset)
    393         fParList->SetBit(MParList::kDoNotReset);
    394 
    395     //
    396     //  create the Iterator over the tasklist
    397     //
    398     TIter Next(fTasks);
    399 
    400     MTask *task=NULL;
    401 
    402     //
    403     // loop over all tasks for preproccesing
    404     //
    405     while ((task=(MTask*)Next()))
    406     {
    407         //
    408         // PreProcess the task and check for it's return value.
    409         //
    410         switch (task->CallPreProcess(fParList))
    411         {
    412         case kFALSE:
    413             return kFALSE;
    414 
    415         case kTRUE:
    416             // Handle GUI events (display changes, mouse clicks)
    417             if (fDisplay)
    418                 gSystem->ProcessEvents();
    419             continue;
    420 
    421         case kSKIP:
    422             Remove(task);
    423             continue;
    424         }
    425 
    426         *fLog << err << dbginf << "PreProcess of " << task->GetDescriptor();
    427         *fLog << " returned an unknown value... aborting." << endl;
    428         return kFALSE;
    429     }
    430 
    431     *fLog << all << endl;
    432 
    433     //
    434     // Reset the ReadyToSave flag.
    435     //
    436     if (!noreset)
    437     {
    438         fParList->SetReadyToSave(kFALSE);
    439         fParList->ResetBit(MParList::kDoNotReset);
    440     }
    441 
    442     //
    443     // loop over all tasks to fill fTasksProcess
    444     //
    445     Next.Reset();
    446     fTasksProcess.Clear();
    447     while ((task=(MTask*)Next()))
    448         if (task->OverwritesProcess())
    449             fTasksProcess.Add(task);
    450455
    451456    return kTRUE;
  • trunk/MagicSoft/Mars/mdata/MDataChain.cc

    r3666 r3788  
    4545//   "MCameraLV.fPowerSupplyA.fVoltagePos5V"
    4646//
    47 // You can also use brackets:
     47// You can also use parantheses:
    4848//   "HillasDource.fDist / (MHillas.fLength + MHillas.fWidth)"
    4949//
     
    5757// While a^b returns a to the power of b
    5858//
    59 // Warning: There is no priority rule build in. So better use brackets
     59// Warning: There is no priority rule build in. So better use parantheses
    6060//   to get correct results. The rule is parsed/evaluated from the left
    6161//   to the right, which means:
     
    158158//  - The possibility to use other objects inheriting from MData
    159159//    is missing.
    160 //  - By automatic pre-adding brackets to the rule it would be possible
     160//  - By automatic pre-adding parantheses to the rule it would be possible
    161161//    to implement priorities for operators.
    162162//
     
    365365}
    366366
     367void MDataChain::SimplifyString(TString &txt) const
     368{
     369    while (txt.First("--")>=0 || txt.First("++")>=0 ||
     370           txt.First("+-")>=0 || txt.First("-+")>=0)
     371    {
     372        txt.ReplaceAll("--", "+");
     373        txt.ReplaceAll("++", "+");
     374        txt.ReplaceAll("-+", "-");
     375        txt.ReplaceAll("+-", "-");
     376    }
     377}
     378
    367379// --------------------------------------------------------------------------
    368380//
     
    371383MData *MDataChain::ParseString(TString txt, Int_t level)
    372384{
     385    if (level==0)
     386        SimplifyString(txt);
     387
    373388    MData *member0=NULL;
    374389
     
    387402            {
    388403                //
    389                 // Search for the corresponding bracket
    390                 //
    391                 Int_t first=GetBracket(txt, '(', ')');
    392 
     404                // Search for the corresponding parantheses
     405                //
     406                const Int_t first=GetBracket(txt, '(', ')');
    393407                if (first==txt.Length())
    394408                {
     
    400414
    401415                //
    402                 // Make a copy of the 'interieur' and delete the substringä
     416                // Make a copy of the 'interieur' and delete the substring
    403417                // including the brackets
    404418                //
     
    462476            if (txt[0]!='-' && txt[0]!='+')
    463477            {
    464                 *fLog << err << dbginf << "Syntax Error: First argument of symbol '";
    465                 *fLog << txt[0] << "' missing." << endl;
     478                *fLog << err << dbginf << "Syntax Error: First argument of '";
     479                *fLog << txt[0] << "' opartor missing." << endl;
    466480                if (member0)
    467481                    delete member0;
  • trunk/MagicSoft/Mars/mdata/MDataChain.h

    r3666 r3788  
    4444    Int_t GetBracket(TString txt, char open, char close);
    4545
     46    void   SimplifyString(TString &txt) const;
    4647    MData *ParseString(TString txt, Int_t level);
    4748    MData *ParseDataMember(TString txt);
  • trunk/MagicSoft/Mars/mfbase/MFilterList.cc

    r3682 r3788  
    3838// invert the meaning of a filter, by eg:
    3939//
    40 //   MF anyfilter("MHillas.fAlpha");
    41 //
    42 //   MFilterList alist;
    43 //   alist.AddToList(&anyfilter);
    44 //
    45 //   alist.SetInverted();
     40//    MF anyfilter("MHillas.fAlpha");
     41//
     42//    MFilterList alist;
     43//    alist.AddToList(&anyfilter);
     44//
     45//    alist.SetInverted();
     46//
     47//  or do
     48//
     49//    MFilterList alist(&anyfilter);
     50//
    4651//
    4752// Adding the filterlist to the eventloop will process all contained filters.
     
    7277// --------------------------------------------------------------------------
    7378//
    74 //   Constructor.
     79// Wrapper to simplify constructors.
     80//
     81void MFilterList::Init(const char *name, const char *title)
     82{
     83    fName  = name  ? name  : gsDefName.Data();
     84    fTitle = title ? title : gsDefTitle.Data();
     85
     86    gROOT->GetListOfCleanups()->Add(&fFilters);
     87    fFilters.SetBit(kMustCleanup);
     88
     89    fFilterType = kEAnd;
     90}
     91
     92// --------------------------------------------------------------------------
     93//
     94//   Default Constructor.
    7595//
    7696//   Specify the boolean operation which is used to evaluate the
     
    91111MFilterList::MFilterList(const char *type, const char *name, const char *title)
    92112{
    93     fName  = name  ? name  : gsDefName.Data();
    94     fTitle = title ? title : gsDefTitle.Data();
    95 
    96     gROOT->GetListOfCleanups()->Add(&fFilters);
    97     fFilters.SetBit(kMustCleanup);
    98 
    99     fFilterType = kEAnd;
     113    Init(name, title);
    100114
    101115    TString str(type);
     
    113127// --------------------------------------------------------------------------
    114128//
     129//   Constructor.
     130//
     131// Setup an '&&' filter list, adds the filter to the list and
     132// call MFilterList::SetInverted()
     133//
     134// To be used as a logical NOT.
     135//
     136MFilterList::MFilterList(MFilter *f, const char *name, const char *title)
     137{
     138    Init(name, title);
     139
     140    SetInverted();
     141    AddToList(f);
     142}
     143
     144// --------------------------------------------------------------------------
     145//
    115146//   CopyConstructor
    116147//
  • trunk/MagicSoft/Mars/mfbase/MFilterList.h

    r3573 r3788  
    3131    void StreamPrimitive(ofstream &out) const;
    3232
     33    void Init(const char *name, const char *title);
     34
    3335public:
    3436    MFilterList(const char *type="&&", const char *name=NULL, const char *title=NULL);
     37    MFilterList(MFilter *f, const char *name=NULL, const char *title=NULL);
    3538    MFilterList(MFilterList &ts);
    3639    ~MFilterList()
  • trunk/MagicSoft/Mars/mfileio/MReadReports.cc

    r3497 r3788  
    127127// All calls to AddTree _must_ be BEFORE the calls to AddFile!
    128128//
     129// To be done: A flag(?) telling whether the headers can be skipped.
     130//
    129131void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)
    130132{
  • trunk/MagicSoft/Mars/mhbase/MBinning.cc

    r2735 r3788  
    6161
    6262    SetEdges(10, 0, 1);
    63 
    6463    fType = kIsDefault;
    6564}
    6665
     66MBinning::MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt="", const char *title=NULL)
     67{
     68    fName  = name  ? name  : gsDefName.Data();
     69    fTitle = title ? title : gsDefTitle.Data();
     70
     71    SetEdges(nbins, lo, hi, opt);
     72
     73}
    6774void MBinning::SetEdges(const TAxis &axe)
    6875{
     
    110117
    111118    fType = kIsLinear;
     119}
     120
     121// --------------------------------------------------------------------------
     122//
     123// Calls SetEdgesLog if opt contains "log"
     124// Calls SetEdgesCos if opt contains "cos"
     125// Calls SetEdges in all other cases
     126//
     127void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up, const char *opt)
     128{
     129    const TString o(opt);
     130    if (o.Contains("log", TString::kIgnoreCase))
     131    {
     132        SetEdgesLog(nbins, lo, up);
     133        return;
     134    }
     135    if (o.Contains("cos", TString::kIgnoreCase))
     136    {
     137        SetEdgesCos(nbins, lo, up);
     138        return;
     139    }
     140    SetEdges(nbins, lo, up);
    112141}
    113142
  • trunk/MagicSoft/Mars/mhbase/MBinning.h

    r2735 r3788  
    3232public:
    3333    MBinning(const char *name=NULL, const char *title=NULL);
     34    MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt="", const char *title=NULL);
    3435
    3536    void SetEdges(const TArrayD &arr)
     
    4243    void SetEdges(const TH1 &h, const Char_t axis='x');
    4344    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
     45    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up, const char *opt);
    4446    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
    4547    void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up);
  • trunk/MagicSoft/Mars/mhbase/MFillH.cc

    r3500 r3788  
    340340// --------------------------------------------------------------------------
    341341//
     342// Use this to set a draw option used when drawing automatically to the
     343// status display.
     344//
     345void MFillH::SetDrawOption(Option_t *option="")
     346{
     347    fDrawOption = option;
     348}
     349
     350// --------------------------------------------------------------------------
     351//
    342352// Creates a new tab in a status display with the name of the MH class,
    343353// if fDisplay is set and the MH-class overwrites the Draw function
     
    357367
    358368    fCanvas = &fDisplay->AddTab(fNameTab.IsNull() ? fH->GetName() : fNameTab.Data());
    359     fH->Draw();
     369    fH->Draw(fDrawOption);
    360370
    361371    return kTRUE;
     
    549559    if (fDisplay && fDisplay->HasCanvas(fCanvas))
    550560    {
     561        const TString opt(Form("nonew %s", fDrawOption));
    551562        fCanvas->cd();
    552         fH->DrawClone("nonew");
     563        fH->DrawClone(opt);
    553564        fCanvas->Modified();
    554565        fCanvas->Update();
  • trunk/MagicSoft/Mars/mhbase/MFillH.h

    r3500 r3788  
    3838    TCanvas *fCanvas;             //! Canvas used to update a MStatusDisplay at the end of a loop
    3939
     40    TString fDrawOption;          // Draw option for status display
     41
    4042    TString ExtractName(const char *name) const;
    4143    TString ExtractClass(const char *name) const;
     
    6365    void SetWeight(const char *name) { fWeightName = name; }
    6466
     67    void      SetDrawOption(Option_t *option="");
     68    Option_t *GetDrawOption() const { return fDrawOption; }
     69
    6570    Int_t  PreProcess(MParList *pList);
    6671    Bool_t ReInit(MParList *pList);
  • trunk/MagicSoft/Mars/mhist/MHFalseSource.cc

    r3682 r3788  
    107107//  - currently a constant pointing position is assumed in Fill()
    108108//  - the center of rotation need not to be the camera center
     109//  - ERRORS on each alpha bin to estimate the chi^2 correctly!
     110//    (sqrt(N)/binwidth) needed for WOlfgangs proposed caluclation
     111//    of alpha(Li/Ma)
    109112//
    110113//////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.