/* ======================================================================== *\ ! ! * ! * This file is part of MARS, the MAGIC Analysis and Reconstruction ! * Software. It is distributed to you in the hope that it can be a useful ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. ! * It is distributed WITHOUT ANY WARRANTY. ! * ! * Permission to use, copy, modify and distribute this software and its ! * documentation for any purpose is hereby granted without fee, ! * provided that the above copyright notice appear in all copies and ! * that both that copyright notice and this permission notice appear ! * in supporting documentation. It is provided "as is" without express ! * or implied warranty. ! * ! ! ! Author(s): Thomas Bretz 07/2001 ! ! Copyright: MAGIC Software Development, 2000-2001 ! ! \* ======================================================================== */ ////////////////////////////////////////////////////////////////////////////// // // // MH // // // // This is a base tasks for mars histograms. It defines a common interface // // for filling the histograms with data (MH::Fill) which is used by a // // common 'filler' (s. MFillH) // // // // If you want to create your own histogram class the new class must be // // derived from MH (instead of the base MParContainer) and you must // // the fill function of MH. This is the function which is called to fill // // the histogram(s) by the data of a corresponding parameter container. // // // ////////////////////////////////////////////////////////////////////////////// #include "MH.h" #include ClassImp(MH); // -------------------------------------------------------------------------- // // Default Constructor. It sets name and title only. Typically you won't // need to change this. // MH::MH(const char *name, const char *title) { // // set the name and title of this object // fName = name ? name : "MH" ; fTitle = title ? title : "Base class for Mars histograms" ; } // -------------------------------------------------------------------------- // // This is a function which should replace the creation of default // canvases like root does. Because this is inconvinient in some aspects. // need to change this. // You can specify a name for the default canvas and a title. Also // width and height can be given. // MakeDefCanvas looks for a canvas with the given name. If now name is // given the DefCanvasName of root is used. If no such canvas is existing // it is created and returned. If such a canvas already exists a new canvas // with a name plus anumber is created (the number is calculated by the // number of all existing canvases plus one) // TCanvas *MH::MakeDefCanvas(const char *name, const char *title, const UInt_t w, const UInt_t h) { const TList *list = (TList*)gROOT->GetListOfCanvases(); const char *def = name ? name : gROOT->GetDefCanvasName(); TCanvas *c; if (list->FindObject(def)) { const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1)); c = new TCanvas(n, title, w, h); delete [] n; } else c = new TCanvas(def, title, w, h); return c; } // -------------------------------------------------------------------------- // // This function works like MakeDefCanvas(name, title, w, h) but name // and title are retrieved from the given TObject. // TCanvas *MH::MakeDefCanvas(const TObject *obj, const UInt_t w, const UInt_t h) { return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h); }