Changeset 4891


Ignore:
Timestamp:
09/09/04 10:51:39 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4889 r4891  
    1919
    2020                                                 -*-*- END OF LINE -*-*-
     21
     22 2004/09/09: Thomas Bretz
     23
     24  * mhvstime/MHPixVsTime.[h,cc], mhvstime/MHVsTime.[h,cc],
     25    mhvstime/MHSectorVsTime.[h,cc], mhbase/MH3.[h,cc]:
     26    - changed such that the axis titles can be set via the
     27      title
     28
     29
    2130
    2231 2004/09/08: Thomas Bretz
  • trunk/MagicSoft/Mars/mhbase/MBinning.cc

    r4840 r4891  
    4444using namespace std;
    4545
    46 static const TString gsDefName  = "MBinning";
    47 static const TString gsDefTitle = "Container describing the binning of an axis";
     46const TString MBinning::gsDefName  = "MBinning";
     47const TString MBinning::gsDefTitle = "Container describing the binning of an axis";
    4848
    4949// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mhbase/MBinning.h

    r4840 r4891  
    1515class MBinning : public MParContainer
    1616{
     17public:
     18    static const TString gsDefName;
     19    static const TString gsDefTitle;
     20
    1721private:
     22
    1823    TArrayD fEdges;
    1924
     
    8085    Bool_t IsUserArray() const { return fType==kIsUserArray; }
    8186
     87    Bool_t HasTitle() const { return gsDefTitle!=fTitle; }
     88
    8289    void Apply(TH1 &) const;
    8390
  • 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
  • trunk/MagicSoft/Mars/mhbase/MH3.h

    r4828 r4891  
    1515class MH3 : public MH
    1616{
     17private:
     18    static const TString gsDefName;
     19    static const TString gsDefTitle;
     20
    1721protected:
    1822    // Could be const but root < 3.02/06 doesn't like this...
  • trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.cc

    r4889 r4891  
    1818!   Author(s): Thomas Bretz, 12/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    2828//
    2929// Display the pixel content versus time or event number
     30//
     31// Axis titles
     32// ===========
     33//
     34// 1) If no other title is given the rule for the y-axis is used.
     35// 2) If the MH3 has a non-default title (MH3::SetTitle called)
     36//    this title is set as the histogram title. It can be used to overwrite
     37//    the axis titles. For more information see TH1::SetTitle, eg.
     38//       SetTitle("MyGraph;;Counts");
     39//    The title for the x-axis is ignored and set automatically (MAKE SURE
     40//    YOU HAVE TWO SEMICOLON!)
    3041//
    3142/////////////////////////////////////////////////////////////////////////////
     
    4859
    4960using namespace std;
     61
     62const TString MHPixVsTime::gsDefName  = "MHPixVsTime";
     63const TString MHPixVsTime::gsDefTitle = "Graph of pixel content vs. time";
    5064
    5165// --------------------------------------------------------------------------
     
    5973    //   set the name and title of this object
    6074    //
    61     fName  = name  ? name  : "MHPixVsTime";
    62     fTitle = title ? title : "Average of MPixVsTimes";
     75    fName  = name  ? name  : gsDefName.Data();
     76    fTitle = title ? title : gsDefTitle.Data();
    6377
    6478    TString t("Pixel Index #");
     
    7791MHPixVsTime::~MHPixVsTime()
    7892{
    79   if(fGraph)
    80     delete fGraph;
     93    if (fGraph)
     94        delete fGraph;
     95}
     96
     97// --------------------------------------------------------------------------
     98//
     99// Set the name of the TGraph and the MHPixVsTime container
     100//
     101void MHPixVsTime::SetName(const char *name)
     102{
     103    fGraph->SetName(name);
     104    MParContainer::SetName(name);
     105}
     106
     107// --------------------------------------------------------------------------
     108//
     109// Set the title of the TGraph and the MHPixVsTime container
     110//
     111void MHPixVsTime::SetTitle(const char *title)
     112{
     113    fGraph->SetTitle(title);
     114    MParContainer::SetTitle(title);
    81115}
    82116
     
    124158    }
    125159
     160    if (fTitle!=gsDefTitle)
     161        fGraph->SetTitle(fTitle);
     162
    126163    return kTRUE;
    127164}
     
    190227
    191228    h->SetXTitle("Time");
    192     h->SetYTitle("");
    193229    if (!fNameTime.IsNull())
    194230    {
  • trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.h

    r3394 r4891  
    2020{
    2121private:
     22    static const TString gsDefName;
     23    static const TString gsDefTitle;
     24
    2225    TGraphErrors *fGraph;
    2326    Int_t fIndex;
     
    4649    void SetType(Int_t type, Int_t e=-1) { fType = type; fTypeErr=e; }
    4750
     51    void SetName(const char *name);
     52    void SetTitle(const char *title);
     53
    4854    TH1 *GetHistByName(const TString name="");
    4955    TGraph *GetGraph() { return fGraph; }
  • trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc

    r4889 r4891  
    3030// single sector
    3131//
     32// 1) If no other title is given the rule for the y-axis is used.
     33// 2) If the MH3 has a non-default title (MH3::SetTitle called)
     34//    this title is set as the histogram title. It can be used to overwrite
     35//    the axis titles. For more information see TH1::SetTitle, eg.
     36//       SetTitle("MyGraph;;Counts");
     37//    The title for the x-axis is ignored and set automatically (MAKE SURE
     38//    YOU HAVE TWO SEMICOLON!)
     39//
    3240/////////////////////////////////////////////////////////////////////////////
    3341#include "MHSectorVsTime.h"
     
    5058
    5159using namespace std;
     60
     61const TString MHSectorVsTime::gsDefName  = "MSectorHVsTime";
     62const TString MHSectorVsTime::gsDefTitle = "Graph of sector mean vs. time";
    5263
    5364// --------------------------------------------------------------------------
     
    6273    //   set the name and title of this object
    6374    //
    64     fName  = name  ? name  : "MHSectorVsTime";
    65     fTitle = title ? title : "Sector mean vs time";
     75    fName  = name  ? name  : gsDefName.Data();
     76    fTitle = title ? title : gsDefTitle.Data();
    6677}
    6778
     
    7586        delete fGraph;
    7687}
     88
     89// --------------------------------------------------------------------------
     90//
     91// Set the name of the TGraph and the MHVsTime container
     92//
     93void MHSectorVsTime::SetName(const char *name)
     94{
     95    fGraph->SetName(name);
     96    MParContainer::SetName(name);
     97}
     98
     99// --------------------------------------------------------------------------
     100//
     101// Set the title of the TGraph and the MHVsTime container
     102//
     103void MHSectorVsTime::SetTitle(const char *title)
     104{
     105    fGraph->SetTitle(title);
     106    MParContainer::SetTitle(title);
     107}
     108
    77109
    78110// --------------------------------------------------------------------------
     
    127159    fGraph = fTypeErr<0 ? new TGraph : new TGraphErrors;
    128160    fGraph->SetName(fEvt ? dynamic_cast<TObject*>(fEvt)->GetName() : "MCamEvent");
    129     fGraph->SetTitle("Camera");
     161    fGraph->SetTitle(fTitle==gsDefTitle?"Camera":fTitle);
    130162
    131163    fMin =  FLT_MAX;
     
    206238void MHSectorVsTime::Draw(Option_t *opt)
    207239{
    208     /*
     240    if (!fGraph)
     241        return;
     242
    209243    if (fGraph->GetN()==0)
    210244        return;
    211         */
    212 
    213     if (fGraph->GetN()==0)
    214         return;
    215245
    216246    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
     
    220250
    221251    TString str(opt);
    222     /*
    223     fGraph->GetHistogram()->SetXTitle("Time");
    224     fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
    225     fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
    226     fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
    227 
    228     fGraph->GetHistogram()->SetYTitle("");
    229      */
     252
    230253    if (!str.Contains("A"))
    231254        str += "A";
     
    242265
    243266    h->SetXTitle("Time");
    244     h->SetYTitle("");
    245267
    246268    if (!fNameTime.IsNull())
     
    252274    }
    253275
    254     *fLog << dbg << "Draw: " << str << endl;
    255276    fGraph->Draw(str);
    256 /*
    257     str.ReplaceAll("same", "");
    258     str.ReplaceAll("A", "");
    259 
    260     Int_t i=-1;
    261     Int_t col=kRed;
    262     while ((g=(TGraphErrors*)Next()))
    263     {
    264         i++;
    265         *fLog << dbg << "Check" << i << ": " << str << endl;
    266 
    267         while ((fMinSector>=0 && i<fMinSector) || (fMaxSector>=0 && i>fMaxSector))
    268             i++;
    269 
    270         h = g->GetHistogram();
    271         g->SetLineColor(col++);
    272 
    273         *fLog << dbg << "Draw" << i << ": " << g->GetTitle() << endl;
    274         g->Draw(str);
    275 
    276     }
    277 
    278     pad->Modified();
    279     pad->Update();*/
    280 }
     277}
  • trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.h

    r3394 r4891  
    2020class MHSectorVsTime : public MH
    2121{
     22private:
     23    static const TString gsDefName;
     24    static const TString gsDefTitle;
     25
    2226private:
    2327    TGraph *fGraph;
     
    5155    ~MHSectorVsTime();
    5256
     57    void SetName(const char *name);
     58    void SetTitle(const char *title);
     59
    5360    void SetNameEvt(const TString name)  { fNameEvt = name; }
    5461    void SetNameTime(const TString name) { fNameTime = name; }
  • trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc

    r4889 r4891  
    2929// Use this class if you want to display any rule vs time (or event number)
    3030//
     31// Axis titles
     32// ===========
     33//
     34// 1) If no other title is given the rule for the y-axis is used.
     35// 2) If the MH3 has a non-default title (MH3::SetTitle called)
     36//    this title is set as the histogram title. It can be used to overwrite
     37//    the axis titles. For more information see TH1::SetTitle, eg.
     38//       SetTitle("MyGraph;;Counts");
     39//    The title for the x-axis is ignored and set automatically (MAKE SURE
     40//    YOU HAVE TWO SEMICOLON!)
     41//
    3142// eg.
    3243//       MHVsTime hist("MHillas.fAlpha");
     
    6374using namespace std;
    6475
    65 static const TString gsDefName  = "MHVsTime";
    66 static const TString gsDefTitle = "Container for a graph vs time/evtnumber";
     76const TString MHVsTime::gsDefName  = "MHVsTime";
     77const TString MHVsTime::gsDefTitle = "Container for a graph vs time/evtnumber";
    6778
    6879// --------------------------------------------------------------------------
     
    89100    fGraph->SetPoint(0, 0, 0); // Dummy point!
    90101    fGraph->SetEditable();     // Used as flag: First point? yes/no
     102    fGraph->SetMarkerStyle(kFullDotMedium);
    91103}
    92104
     
    137149    fGraph->SetEditable();     // Used as flag: First point? yes/no
    138150
    139     TString title(fData ? GetRule() : (TString)"Histogram");
     151
     152    TString title(fData ? GetRule() : (TString)"Graph");
    140153    title += " vs ";
    141154    title += fUseEventNumber ? "Event Number" : "Time";
    142155
    143     fGraph->SetNameTitle(fName, title);
     156    fGraph->SetNameTitle(fName, fTitle==gsDefTitle?title:fTitle);
    144157
    145158    fMean = 0;
     
    245258    }
    246259
    247     fGraph->GetHistogram()->SetMarkerStyle(kFullDotMedium);
    248     fGraph->GetHistogram()->SetYTitle(fAxisTitle.IsNull() ? GetRule() : fAxisTitle);
    249     if (fTitle!=gsDefTitle)
    250         fGraph->GetHistogram()->SetTitle(fTitle);
    251 
    252260    if (TestBit(kIsLogy))
    253261        gPad->SetLogy();
  • trunk/MagicSoft/Mars/mhvstime/MHVsTime.h

    r4889 r4891  
    1515class MHVsTime : public MH
    1616{
     17private:
     18    static const TString gsDefName;
     19    static const TString gsDefTitle;
     20
    1721protected:
    1822    // Could be const but root < 3.02/06 doesn't like this...
     
    2933    Int_t       fN;         //! Number of entries in fMean
    3034    MTime       fLast;      //! For checks
    31 
    32     TString     fAxisTitle;
    3335
    3436    enum {
     
    5052
    5153    void SetLogy(Bool_t b=kTRUE) { b ? SetBit(kIsLogy) : ResetBit(kIsLogy); }
    52     void SetAxisTitle(const char *y) { fAxisTitle=y; }
    5354
    5455    Bool_t SetupFill(const MParList *pList);
Note: See TracChangeset for help on using the changeset viewer.