Ignore:
Timestamp:
07/20/01 16:44:11 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
2 deleted
2 edited

Legend:

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

    r867 r891  
    3333#include "MHMcEnergy.h"
    3434
     35#include <stdlib.h>
    3536#include <iostream.h>
    3637
     
    4647//  Default Constructor.
    4748//
    48 MHMcEnergy::MHMcEnergy(const UInt_t idx, const char *name, const char *title)
     49MHMcEnergy::MHMcEnergy(const char *name, const char *title)
    4950{
    50     char aux[15]="MHMcEnergy";
    51 
    52     if (idx>0)
    53         sprintf(aux+strlen(aux), ";%i", idx);
    54 
    55     *fName  = name  ? name  : aux;
    56     *fTitle = title ? title : "Container for an energy distribution histogram" ;
     51    *fTitle = title ? title : "Container for an energy distribution histogram";
    5752
    5853    //  - we initialize the histogram
     
    6055    //    root don't allow us to have diferent histograms with the same name
    6156
     57    fHist = new TH1F("", "", 40, 0.5, 4.5);
     58    fHist->SetXTitle("log(E/GeV)");
     59    fHist->SetYTitle("dN/dE");
     60
     61    SetName(name ? name : "MHMcEnergy");
     62}
     63
     64// -------------------------------------------------------------------------
     65//
     66//  This doesn't only set the name. It tries to get the number from the
     67//  name and creates also name and title of the histogram.
     68//
     69//  This is necessary for example if a list of such MHMcEnergy histograms
     70//  is created (s. MParList::CreateObjList)
     71//
     72void MHMcEnergy::SetName(const char *name)
     73{
     74    TString cname(name);
     75    const char *semicolon = strrchr(cname, ';');
     76
     77    UInt_t idx = semicolon ? atoi(semicolon+1) : 0;
     78
     79    *fName = cname;
     80
    6281    char text[256];
    63     sprintf(text, "Energy Distribution for trigger condition #%i", idx);
    64 
     82    if (idx>0)
     83        sprintf(text, "Energy Distribution for trigger condition #%i", idx);
     84    else
     85        sprintf(text, "Energy Distribution");
     86
     87    char aux[256];
    6588    strcpy(aux, "log(E)");
     89
    6690    if (idx>0)
    6791        sprintf(aux+strlen(aux), " #%i", idx);
    68     fHist = new TH1F(aux, text, 40, 0.5, 4.5);
    69     fHist->SetXTitle("log(E/GeV)");
    70     fHist->SetYTitle("dN/dE");
     92
     93    fHist->SetName(aux);
     94    fHist->SetTitle(text);
    7195}
    7296
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.h

    r867 r891  
    3131public:
    3232
    33     MHMcEnergy(const UInt_t idx=0, const char *name=NULL, const char *title=NULL);
     33    MHMcEnergy(const char *name=NULL, const char *title=NULL);
    3434    ~MHMcEnergy();
     35
     36    void SetName(const char *name);
    3537
    3638    Float_t GetThreshold() const { return fThreshold; }
Note: See TracChangeset for help on using the changeset viewer.