{ gROOT->Reset(); // Adding 2D histograms gStyle->SetPalette(51,0); //TCanvas *cn1 = new TCanvas("cn1","ROOT",10,10,700,700); //cn1->Size(60,60); TCanvas *c = new TCanvas("c","example",0,0,600,800); c->Divide(1,2); c->cd(1); TFile *f1 = new TFile ("tof_Ar8_N2_multi_20040927_withbin_histo1.root"); TFile *f2 = new TFile ("tof_Ar8_N2_multi_20040927_withbin_histo2.root"); TH2F *h_2_1 = (TH2F*)f1 -> Get("h"); TH2F *h_2_2 = (TH2F*)f2 -> Get("h"); h_2_1->Add(h_2_2); h_2_1->Draw("colz"); TCutG *cutg = new TCutG("mycut",5); cutg->SetVarX(" multihit (int CFD)"); cutg->SetVarY("Coincidence Map "); cutg->SetTitle("Graph"); cutg->SetFillColor(1); cutg->SetPoint(0,4200.00,7600.00); cutg->SetPoint(1,5400.00,7600.00); cutg->SetPoint(2,5400.00,5900.00); cutg->SetPoint(3,4200.00,5900.00); cutg->SetPoint(4,4200.00,7600.00); cutg->Draw("l"); c->cd(2); TH1D *hpp = h_2_1->ProjectionX("",1,1500,"[mycut]"); hpp->Draw(); // Writing the bin content of each channel in ASCII format to a file // For 1D histogram only FILE *f11; f11 = fopen ("projection.dat", "w"); int i; for (i=1; i<=1500; i++) fprintf (f11,"%g\n",hpp->GetBinContent(i)); fclose (f11); }