Adding root files from a .txt file

Dear All,

I have a list of root histograms in a .txt file but I would like to merge these root histograms into one file:

I know the hadd -f < new filename> .

I do not know the command to use in this case with the histograms been inside of a .txt file.

Kindly assist.
Priya

Dear Priya,

When you say your histograms are in a .txt file, you mean the names of the histograms?

Do you have the real histograms stored somewhere in a .root file?

Dear etejdor,

In the .txt file are copies of the real histograms having the entire path. I do have real histograms them stored however this .txt file contains the sample (good runs)from those real histograms that I want now analyze.

Can you post here a sample of the contents of this .txt file?

The .txt file contains root histograms with path directory and has ending “number.root”
TH2D h2emctow;1 h2emctow
TH1F hemcdz;1 hemcdz
TH1F hdep;1 hdep
TH1F hpt;1 hpt
TH1F hpemcphi;1 pemcphi

So you have on the one hand a .txt file where each line has a type and name of a histogram. The last line of this .txt file is “number.root”.

And then in “number.root” you have the real histograms stored.

Is this correct so far? Or the histograms are stored in multiple .root files that you want to hadd?

Thank you so much etejedor,

I am use to only hadd from directory but I now know how to hadd from a file.

Cheers

You need to provide to hadd the files you want to merge:

https://root.cern.ch/how/how-merge-histogram-files

Therefore, I am not sure what you want to do with your .txt file, since it contains histogram names, not file names.

Hadd merges .root files which have histograms inside. It will merge histograms with the same name in all the files.

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