Macro on a Histogram File

Hi,

I have a histogram file, and I’m trying to run a normalization on all the histograms in it.
How do you go about this? Currently, I have code that works, but its very inefficient:

//////////////////////////////////////////////////////////
TFile *a = new TFile(“JPsiData.root”)

void Normalize();

int Normalize()
{
Double_t scale = 1 / Data1->Integral();
Data1 -> Scale(scale);

 scale = 1 / Data2->Integral();
 Data2 -> Scale(scale);

 ...
 ...
  
 scale = 1 / Data66 -> Integral();
 Data 66 -> Scale(scale);

 return 0;

}
////////////////////////////////////////////////////////////////

This program is unnecessarily long :-/ . I guess the more general question is:
how do you perform a macro on a large number of histograms (normalization,
error bars, setting style options, etc.)?

Thanks,
Ning

Hi,

Take a look at $ROOTSYS/tutorials/hadd.C for an example looping over the content of a file.

Cheers,
Philippe.

great, thanks!