#include #include #include "TH1F.h" #include "TCanvas.h" #include "TStyle.h" #include "TMath.h" #include "TROOT.h" #include #include #include #include #include "TFile.h" #include "TRandom.h" class Common_Data { public: Int_t a1; Float_t b1; TH1F **histo1; }; Common_Data *my_class = new Common_Data; void DoSomething(){ int a2=100; float b2=100.11; TH1F *histo[3]; histo[0] = new TH1F("h1","h1",100,-1.0,1.0); histo[1] = new TH1F("h1","h1",100,-1.0,1.0); histo[2] = new TH1F("h1","h1",100,-1.0,1.0); for(int i=0;i<100000;i++){ histo[0]->Fill(gRandom->Gaus(-1,1.5)); histo[1]->Fill(gRandom->Gaus(-1,1.5)); histo[2]->Fill(gRandom->Gaus(-1,1.5)); } my_class->a1=a2; my_class->b1=b2; my_class->histo1=histo; cout << " " << a2 << " " << b2 << " " << histo[0]-> GetMean() ; cout << " " << histo[1]-> GetMean() << " " << histo[2]-> GetMean() << endl; } void Save_data(){ cout << my_class->a1 << " " << my_class->b1 << endl; TFile *my_own_file =new TFile ("histo.root", "RECREATE"); my_own_file->cd(); for (int i= 0;i<3;i++) { cout << " " << i << " " << my_class->histo1[i]->GetMean() << endl; my_class->histo1[i]->Write(); } my_own_file->Close(); }