Ignore:
Timestamp:
09/09/04 10:51:39 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhbase/MH3.cc

    r4829 r4891  
    4848// SetScaleY and SetScaleZ.
    4949//
     50//
     51// Axis titles
     52// ===========
     53//
     54// 1) If no other title is given the rule for this axis is used.
     55// 2) If the MBinning used for this axis has a non-default Title
     56//    (MBinning::HasTitle) this title is used for the corresponding axis
     57// 3) If the MH3 has a non-default title (MH3::SetTitle called)
     58//    this title is set as the histogram title. It can be used to overwrite
     59//    the axis titles. For more information see TH1::SetTitle, eg.
     60//       SetTitle("MyHist;x[mm];y[cm];Counts");
     61//
    5062// For example:
    5163//   MH3 myhist("MHillas.fLength");
     
    8395using namespace std;
    8496
    85 static const TString gsDefName  = "MH3";
    86 static const TString gsDefTitle = "Container for a %dD Mars Histogram";
     97const TString MH3::gsDefName  = "MH3";
     98const TString MH3::gsDefTitle = "Container for a n-D Mars Histogram";
    8799
    88100// --------------------------------------------------------------------------
     
    113125
    114126    fName  = gsDefName;
    115     fTitle = Form(gsDefTitle.Data(), fDimension);
     127    fTitle = gsDefTitle;
    116128
    117129    if (fHist)
     
    141153
    142154    fName  = gsDefName;
    143     fTitle = Form(gsDefTitle.Data(), 1);
     155    fTitle = gsDefTitle;
    144156
    145157    fHist->UseCurrentStyle();
     
    168180
    169181    fName  = gsDefName;
    170     fTitle = Form(gsDefTitle.Data(), 2);
     182    fTitle = gsDefTitle;
    171183
    172184    fHist->UseCurrentStyle();
     
    195207
    196208    fName  = gsDefName;
    197     fTitle = Form(gsDefTitle.Data(), 3);
     209    fTitle = gsDefTitle;
    198210
    199211    fHist->UseCurrentStyle();
     
    266278            return kFALSE;
    267279        }
     280        if (fData[2] && !fData[2]->PreProcess(plist))
     281            return kFALSE;
     282        if (fData[2])
     283            fHist->SetZTitle(fData[2]->GetTitle());
     284        if (binsz->HasTitle())
     285            fHist->SetZTitle(binsz->GetTitle());
    268286        if (binsz->IsLogarithmic())
    269287            fHist->SetBit(kIsLogz);
    270         if (fData[2]) fHist->SetZTitle(fData[2]->GetTitle());
    271         if (fData[2] && !fData[2]->PreProcess(plist))
    272             return kFALSE;
    273288    case 2:
    274289        binsy = (MBinning*)plist->FindObject(bname+"Y", "MBinning");
     
    278293            return kFALSE;
    279294        }
     295        if (fData[1] && !fData[1]->PreProcess(plist))
     296            return kFALSE;
     297        if (fData[1])
     298            fHist->SetYTitle(fData[1]->GetTitle());
     299        if (binsy->HasTitle())
     300            fHist->SetYTitle(binsy->GetTitle());
    280301        if (binsy->IsLogarithmic())
    281302            fHist->SetBit(kIsLogy);
    282         if (fData[1]) fHist->SetYTitle(fData[1]->GetTitle());
    283         if (fData[1] && !fData[1]->PreProcess(plist))
    284             return kFALSE;
    285303    case 1:
    286304        binsx = (MBinning*)plist->FindObject(bname+"X", "MBinning");
     
    297315
    298316        }
     317        if (fData[0] && !fData[0]->PreProcess(plist))
     318            return kFALSE;
     319        if (fData[0]!=NULL)
     320            fHist->SetXTitle(fData[0]->GetTitle());
     321        if (binsx->HasTitle())
     322            fHist->SetXTitle(binsx->GetTitle());
    299323        if (binsx->IsLogarithmic())
    300324            fHist->SetBit(kIsLogx);
    301 
    302       if (fData[0]!=NULL)  fHist->SetXTitle(fData[0]->GetTitle());
    303         if (fData[0] && !fData[0]->PreProcess(plist))
    304             return kFALSE;
    305325    }
    306326
    307327    fHist->SetName(fName);
     328    fHist->SetDirectory(0);
     329
     330    if (fTitle!=gsDefTitle)
     331    {
     332        fHist->SetTitle(fTitle);
     333        return kTRUE;
     334    }
    308335
    309336    TString title("Histogram for ");
     
    325352        return kTRUE;
    326353    }
    327     cout << "Still alive...?" << endl;
    328     return kTRUE;
     354
     355    *fLog << err << "ERROR - MH3 has " << fDimension << " dimensions!" << endl;
     356    return kFALSE;
    329357}
    330358
     
    335363void MH3::SetName(const char *name)
    336364{
    337     fHist->SetName(name);
     365    if (fHist)
     366    {
     367        fHist->SetName(name);
     368        fHist->SetDirectory(0);
     369    }
    338370    MParContainer::SetName(name);
    339371}
     
    345377void MH3::SetTitle(const char *title)
    346378{
    347     fHist->SetTitle(title);
     379    if (fHist)
     380        fHist->SetTitle(title);
    348381    MParContainer::SetTitle(title);
    349382}
     
    644677        out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
    645678
    646     if (fTitle!=Form(gsDefTitle.Data(), fDimension))
     679    if (fTitle!=gsDefTitle)
    647680        out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
    648681
Note: See TracChangeset for help on using the changeset viewer.