Scale a root file event by event

Dear Experts,

I have a root file, say yyy.root and I want to scale it down event by event 1/6 times and create a new root file with same tree and branches as the previous file.

While plotting a histogram, I know, I have to scale it, something like,
Double_t scale = 1.0/6.0;
hist1=Scale(scale);

I want to do the same thing and write it to a new root file.
Can someone help me!

Thank you in advance,
C.S


ROOT Version: 6.14
Platform: Not Provided
Compiler: Not Provided


I guess you just want to scale one value (one branch), right? You have to do it manually: open your file, loop over the entries, scale the value (branch) you wand to scale down, and write the tree to a new file.

Hi bellenot,

Thank you for your quick response.
Basically, I want to scale the entire tree (all branches). Is it possible to do so?
Can you please share a sample code, if possible?

Thank you,
C.S

Then you have to read all branches, scale all values, and write to another tree. You could get inspiration form the copytree3.C tutorial

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.