Ignore:
Timestamp:
03/31/03 15:17:50 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHArray.cc

    r1833 r1883  
    182182};
    183183
     184void MHArray::Init(const char *name)
     185{
     186    fName  = name  ? name  : "MHArray";
     187
     188    fMapIdx = new MMap;
     189
     190    fArray = new TList;
     191    fArray->SetOwner();
     192}
     193
     194// --------------------------------------------------------------------------
     195//
     196// Can replace a constructor. Use the default constructor and afterwards
     197// the Set function of your need.
     198//
     199void MHArray::Set(const TString hname, Bool_t istempl)
     200{
     201    if (fTemplate || fClass || fTemplateName!="<dummy>")
     202    {
     203        *fLog << warn << "WARNING - MHArray already setup... Set ignored." << endl;
     204        return;
     205    }
     206
     207    if (istempl)
     208    {
     209        fTemplateName = hname;
     210        return;
     211    }
     212
     213    //
     214    // try to get class from root environment
     215    //
     216    fClass = gROOT->GetClass(hname);
     217    if (!fClass)
     218    {
     219        //
     220        // if class is not existing in the root environment
     221        //
     222        *fLog << err << dbginf << "Class '" << hname << "' not existing in dictionary." << endl;
     223    }
     224
     225    //
     226    // check for ineritance from MH
     227    //
     228    if (!fClass->InheritsFrom(MH::Class()))
     229    {
     230        //
     231        // if class doesn't inherit from MH --> error
     232        //
     233        *fLog << err << dbginf << "Class '" << hname << "' doesn't inherit from MH." << endl;
     234        fClass = NULL;
     235    }
     236}
     237
     238// --------------------------------------------------------------------------
     239//
     240// Can replace a constructor. Use the default constructor and afterwards
     241// the Set function of your need.
     242//
     243void MHArray::Set(const MH *hist)
     244{
     245    fIdx=0;
     246    fClass=NULL;
     247    fTemplate=hist;
     248    fTemplateName="<dummy>";
     249}
     250
     251
    184252// --------------------------------------------------------------------------
    185253//
     
    200268    //   set the name and title of this object
    201269    //
    202     fName  = name  ? name  : "MHArray";
     270    Init(name);
    203271    fTitle = title ? TString(title) : (TString("Base class for Mars histogram arrays:") + hname);
    204272
    205     fMapIdx = new MMap;
    206 
    207     fArray = new TList;
    208     fArray->SetOwner();
    209 
    210     if (istempl)
    211     {
    212         fTemplateName = hname;
    213         return;
    214     }
    215 
    216     //
    217     // try to get class from root environment
    218     //
    219     fClass = gROOT->GetClass(hname);
    220     if (!fClass)
    221     {
    222         //
    223         // if class is not existing in the root environment
    224         //
    225         *fLog << err << dbginf << "Class '" << hname << "' not existing in dictionary." << endl;
    226     }
    227 
    228     //
    229     // check for ineritance from MH
    230     //
    231     if (!fClass->InheritsFrom(MH::Class()))
    232     {
    233         //
    234         // if class doesn't inherit from MH --> error
    235         //
    236         *fLog << err << dbginf << "Class '" << hname << "' doesn't inherit from MH." << endl;
    237         fClass = NULL;
    238     }
    239 }
    240 
    241 // --------------------------------------------------------------------------
    242 //
    243 // Default Constructor. hname is the name of the histogram class which
    244 // is in the array.
     273    Set(hname, istempl);
     274}
     275
     276// --------------------------------------------------------------------------
     277//
     278// Default constructor. Use MHArray::Set to setup the MHArray afterwards
     279//
     280MHArray::MHArray(const char *name=NULL, const char *title=NULL)
     281    : fIdx(0), fClass(NULL), fTemplate(NULL), fTemplateName("<dummy>")
     282{
     283    //
     284    //   set the name and title of this object
     285    //
     286    Init(name);
     287    fTitle = title ? title : "A Mars histogram array";
     288}
     289
     290// --------------------------------------------------------------------------
     291//
     292// hname is the name of the histogram class which is in the array.
    245293//
    246294// istempl=kTRUE tells MHArray to use the first histogram retrieved from the
     
    258306    //   set the name and title of this object
    259307    //
    260     fName  = name  ? name  : "MHArray";
     308    Init(name);
    261309    fTitle = title ? TString(title) : (TString("Base class for Mars histogram arrays:") + hist->GetName());
    262 
    263     fMapIdx = new MMap;
    264 
    265     fArray = new TList;
    266     fArray->SetOwner();
    267310}
    268311
Note: See TracChangeset for help on using the changeset viewer.