| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz 07/2001 (tbretz@uni-sw.gwdg.de)
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MH //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is a base tasks for mars histograms. It defines a common interface //
|
|---|
| 30 | // for filling the histograms with data (MH::Fill) which is used by a //
|
|---|
| 31 | // common 'filler' (s. MFillH) //
|
|---|
| 32 | // //
|
|---|
| 33 | // If you want to create your own histogram class the new class must be //
|
|---|
| 34 | // derived from MH (instead of the base MParContainer) and you must //
|
|---|
| 35 | // the fill function of MH. This is the function which is called to fill //
|
|---|
| 36 | // the histogram(s) by the data of a corresponding parameter container. //
|
|---|
| 37 | // //
|
|---|
| 38 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 39 |
|
|---|
| 40 | #include "MH.h"
|
|---|
| 41 |
|
|---|
| 42 | #include <TCanvas.h>
|
|---|
| 43 |
|
|---|
| 44 | ClassImp(MH);
|
|---|
| 45 |
|
|---|
| 46 | // --------------------------------------------------------------------------
|
|---|
| 47 | //
|
|---|
| 48 | // Default Constructor. It sets name and title only. Typically you won't
|
|---|
| 49 | // need to change this.
|
|---|
| 50 | //
|
|---|
| 51 | MH::MH(const char *name, const char *title)
|
|---|
| 52 | {
|
|---|
| 53 | //
|
|---|
| 54 | // set the name and title of this object
|
|---|
| 55 | //
|
|---|
| 56 | fName = name ? name : "MH" ;
|
|---|
| 57 | fTitle = title ? title : "Base class for Mars histograms" ;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | TCanvas *MH::MakeDefCanvas(const char *name, const char *title,
|
|---|
| 61 | const UInt_t w, const UInt_t h)
|
|---|
| 62 | {
|
|---|
| 63 | const TList *list = (TList*)gROOT->GetListOfCanvases();
|
|---|
| 64 |
|
|---|
| 65 | const char *def = name ? name : gROOT->GetDefCanvasName();
|
|---|
| 66 |
|
|---|
| 67 | TCanvas *c;
|
|---|
| 68 | if (list->FindObject(def))
|
|---|
| 69 | {
|
|---|
| 70 | const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1));
|
|---|
| 71 | c = new TCanvas(n, title, w, h);
|
|---|
| 72 | delete [] n;
|
|---|
| 73 | }
|
|---|
| 74 | else
|
|---|
| 75 | c = new TCanvas(def, title, w, h);
|
|---|
| 76 |
|
|---|
| 77 | return c;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | TCanvas *MH::MakeDefCanvas(const TObject *obj,
|
|---|
| 81 | const UInt_t w, const UInt_t h)
|
|---|
| 82 | {
|
|---|
| 83 | return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h);
|
|---|
| 84 | }
|
|---|