void all2daq(const char *rootfilename1,const char *rootfilename2)
{
TFile *file1 = new TFile(rootfilename1,"READ");//"RECREATE" "READ"
if(!file1->IsOpen())
{
std::cout<<"Can't open root file"<<std::endl;
}
TH2I *matrix1 = (TH2I*)file1->Get("matrix");
TFile *file2 = new TFile(rootfilename2,"READ");//"RECREATE" "READ"
if(!file2->IsOpen())
{
std::cout<<"Can't open root file"<<std::endl;
}
TH2I *matrix2 = (TH2I*)file2->Get("matrix");
TFile *file3 = new TFile("all2daq.root","RECREATE");
TH2I *matrix3= new TH2I("matrix3","",4096,0,4096,4096,0,4096);
matrix3->Add(matrix1,matrix2,1,1);
file3->cd();
matrix3->Write();
file3->Close();
file1->Close();
file2->Close();
}
编译方式:
root
.L all2daq.C
all2daq("rootname1","rootname2")