Home | News | Documentation | Download

Using CopyFiles.C

I want to copy the histograms from one file into a new one, with one additional branch included. There are no TDirectories and no trees, only histograms in the file. I copied and pasted into my macro the syntax from the tutorial CopyFiles.C (https://root.cern.ch/doc/v608/copyFiles_8C_source.html)

CopyFile calls CopyDir, and when the macro reaches line 29 it outputs the error:
Error in TFile::GetObjectChecked: The provided key name is invalid.

Followed quickly by *** Break *** segmentation violation.

What is the name it is trying to get from the source file? There are so many histograms in there, what would make one of those names invalid?

Thanks for any help! :slight_smile:

Please read tips for efficient and successful posting and posting code

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


What does

with one additional branch included

Did you try rootcp? It’s a command line tool (like ls or root). Does that help? If that crashes, too, then we need to dig deeper :slight_smile:

Cheers, Axel.

Hi! The additional branch is just one the rest of my macro is adding. rootcp does work. Actually I’m not sure if there’s something wrong with the root files I’m trying to copy, when I try to add a new branch to some of them I get
Error in TFile::WriteTObject: Directory Test/JZ12_MergedPythiaWithTrackSystematics_user.krybacki.23163599._000001.hist-output.root is not writable
Even though I’ve done chmod +x ./* in the directory, and rootcp works on this file.

Edit: sorry that last thing is just me incorrectly using ‘read’ not ‘recreate’ on the file!

So - everything solved? :slight_smile: I’m a bit lost with where we are…

Yes, all sorted, thank you! :smiley:

1 Like