TFile *f1 = new TFile("/afs/cern.ch/user/e/evgenia/testarea/12.0.6/PhysicsAnalysis/AnalysisCommon/UserAnalysis/run/tt1.root");
TFile *f2 = new TFile("/afs/cern.ch/user/e/evgenia/testarea/12.0.6/PhysicsAnalysis/AnalysisCommon/UserAnalysis/run/tt2.root");
Use a named macro - it allows you to have multiple functions in one file; see the users guide for names vs. unnamed macros. You cannot declare a function inside another function. You cannot re-declare a class’s (TH1 in your case) function, or declare a new one (please read a book on C++, you need to understand the basics of C++ before you can use ROOT). The users guide also shows how to save a histogram: just call TH1::Write().
If option = NEW or CREATE create a new file and open it for writing,
if the file already exists the file is
not opened.
= RECREATE create a new file, if the file already
exists it will be overwritten.
= UPDATE open an existing file for writing.
if no file exists, it is created.
= READ open an existing file for reading (default).
= NET used by derived remote file access
classes, not a user callable option
= WEB used by derived remote http access
class, not a user callable option
If option = "" (default), READ is assumed.