source: trunk/MagicSoft/Mars/mhist/MH.cc@ 1091

Last change on this file since 1091 was 1082, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.0 KB
Line 
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 <mailto: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
44ClassImp(MH);
45
46// --------------------------------------------------------------------------
47//
48// Default Constructor. It sets name and title only. Typically you won't
49// need to change this.
50//
51MH::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// --------------------------------------------------------------------------
61//
62// This is a function which should replace the creation of default
63// canvases like root does. Because this is inconvinient in some aspects.
64// need to change this.
65// You can specify a name for the default canvas and a title. Also
66// width and height can be given.
67// MakeDefCanvas looks for a canvas with the given name. If now name is
68// given the DefCanvasName of root is used. If no such canvas is existing
69// it is created and returned. If such a canvas already exists a new canvas
70// with a name plus anumber is created (the number is calculated by the
71// number of all existing canvases plus one)
72//
73TCanvas *MH::MakeDefCanvas(const char *name, const char *title,
74 const UInt_t w, const UInt_t h)
75{
76 const TList *list = (TList*)gROOT->GetListOfCanvases();
77
78 const char *def = name ? name : gROOT->GetDefCanvasName();
79
80 TCanvas *c;
81 if (list->FindObject(def))
82 {
83 const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1));
84 c = new TCanvas(n, title, w, h);
85 delete [] n;
86 }
87 else
88 c = new TCanvas(def, title, w, h);
89
90 return c;
91}
92
93// --------------------------------------------------------------------------
94//
95// This function works like MakeDefCanvas(name, title, w, h) but name
96// and title are retrieved from the given TObject.
97//
98TCanvas *MH::MakeDefCanvas(const TObject *obj,
99 const UInt_t w, const UInt_t h)
100{
101 return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h);
102}
Note: See TracBrowser for help on using the repository browser.