Trouble running the Macro in ROOT

I am having trouble running this macro. Can someone help me with this?

extractSpectra_new.C (3.1 KB)

When I am using the exactSpectra function inside my main function it is having trouble. I don’t know how to use this function to get the histograms from the root files and how to save those histograms.

extractSpectra_new.C (3.4 KB)