The script didn’t run because another TFile(*.root,“READ”) is inside the Analysis1() function, so it didn’t write into “rootfile.root”.I got an error due to that.
Then, I took it inside AnalysisMain() function ,and then tried to run it. it works now .