TH1F data rescaling

Hi,

I would like to re scale the graph since the graph data is somewhat overlapped. What should I do for that?

I have
TH1F* pion = new TH1F(…);
TH1F* kaon = new TH1F(…);
TH1F* proton = new TH1F(…);

and I created
TH1F* pion2 = new TH1F(…);
TH1F* kaon2 = new TH1F(…);
TH1F* proton2 = new TH1F(…);

so,
pion2 = TH1F( pion * 1.0 );
kaon2 = TH1F( kaon * 0.1 );
proton2 = TH1F( proton * 0.01);

pion2->Draw();
kaon2->Draw(“same”);
proton2->Draw(“same”);

but it does not work.
Would you tell me how to do that?
Thank you!

see TH1::Scale

Rene

Thank you for the message, and TH1::Scale(factor) works.
I have the other but similar question.

How about TF1 *pionfit = new TF1(…);

I tried

pionfit->TH1::Scale(0.01);

but no error message and it does not change anything.
I know it is a “function” pointer, not a “histogram” pointer.
In this case, what should I do for the scaling?
Thank you!

Change the definition of your function adding a scaling parameter.

Rene

Hi,

and call pionfit->Scale(0.01) (no TH1:: prefix). And please read a book on C++, your problems are caused by extremely basic C++ mistakes. E.g. you need to understand pointers and calls of virtual functions.

Axel.