Sum root files

Hello, I’ve a macro to open root file created by compass, find coincidences and save a new root file.

Now we set the autosave in compass then compass autosaves root files based on the maximum file size.

Then, I’ve to implement the possibility to merge the root files created by compass.

compass saves in this way:

  1. The first file is called SDataR_run_RUNNUMBER.root
  2. The other files are called SDataR_run_RUNNUMBER_1.root, SDataR_run_RUNNUMBER_2.root, SDataR_run_RUNNUMBER_3.root
    etc

Obviously the number of files is variable. Then, the macro should

  1. Look for the first file SDataR_run_RUNNUMBER.root, then look for other files.
    If there is only SDataR_run_RUNNUMBER.root it can use it. If there are also SDataR_run_RUNNUMBER_*.root files, the macro should firstly sum all the root files SDataR_run_RUNNUMBER.root + SDataR_run_RUNNUMBER_1.root + SDataR_run_RUNNUMBER_2.root… SDataR_run_RUNNUMBER_N.root

how should I do that?

I guess @pcanal can help you.

Hi @couet thank you…but I solve my self using the “hadd” function of root!

1 Like

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