Re: [ROOT] histogram identifier

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Aug 23 2002 - 16:07:14 MEST


Hi Andreas,

The solution to your first problem is to use an array of pointers, eg
  TH1F *h[10000];
See an example in $ROOTSYS/tutorials/dirs.C (2-d array)
This is far more efficient than the Hbook way. Note that if you want
to mimic Hbook identifiers, have a look at the two functions in TH1
   extern TH1 *R__H(Int_t hid);
   extern TH1 *R__H(const char *hname);
the implementation is doing;

TH1 *R__H(Int_t hid)
{
   //return pointer to histogram with name
   //   hid if id >=0
   //   h_id if id <0

   char hname[20];
   if(hid >= 0) sprintf(hname,"h%d",hid);
   else         sprintf(hname,"h_%d",hid);
   return (TH1*)gDirectory->Get(hname);
}
_
TH1 *R__H(const char * hname)
{
   //return pointer to histogram with name hname

   return (TH1*)gDirectory->Get(hname);
}
Note that I do not recommend this procedure at all.

Concerning your second problem, SetLabelFont should be taken into account.
Could you send an example where it does not work?

Rene Brun


On Fri, 23 Aug 2002, Andreas Salzburger wrote:

> dear root talk members,
> 
> i've got a question concerning histogram identifiers.
> i try to fill various histos (e.g.) dependent on a specific value.
> im paw this was possible by calculating the histogram identifier from this
> value and then fill f.e. HBOOK(i) and so on.
> But as in root the histograms carry names i just managed to do the same by
> a switch syntax. but when there are more and more histos i'd rather like
> to stick to the old possibility. a second trial by making a vector of
> histograms and then filling the one at vector position (i) failed...
> 
> does someone have an advice for me in this case?
> 
> 
> 
> btw. a second, not very urgent question. i designed a histogramstyle for
> me and tried to use gROOT -> ForceStyle() which works (for most of the
> values set by the style except f.e. style->SetLabelFont(42) which is
> totally ignored) for the first
> histogram, but when i redo the macro, the style gets crazy, even if i make
> gROOT -> Reset() before.
> 
> 
> thanks,
> andreas
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:05 MET