About TH1::GetAsymmetry

Dear Rooters,

This is just a suggestion.

I was making a asymmetry plot of two distributions, say dist1 and dist2 whose asymmetry is distAsy. I wrote those histograms on a root file. After opening the root file, I could not find distAsy, but I found two dist1. Actual code is a bit longer. I spend hours to find the reason. And the reason is: when you take the asymmetry of two histograms, it overwrites the name of the distAsy to be name of dist1. Here is an example code:

TH1D *dist1 = new TH1D("dist1", "dist1", 50, 0.0, 1.0);
TH1D *dist2 = new TH1D("dist2", "dist2", 50, 0.0, 1.0);
TH1D *distAsy = new TH1D("distAsy", "distAsy", 50, 0.0, 1.0);

for(int i=0; i<40000; i++) {
    ...... do some thing
     dist1->Fill(x);
     dist2->Fill(y);
}

distAsy = (TH1D*) dist1->GetAsymmetry(dist2);

After this, name of distAsy will be “dist1”, which is kind of confusing. Isn’t it good not to overwrite the name by default?

Just a thought.
Thanks,

Hi,

This should be now fixed in the ROOT trunk version (revision 45815), by given a different name for the asymmetry histogram depending on the h1 and h2 name

Thank you for reporting this and sorry for the late reply

Lorenzo