figSpectraDiff.cxx 2.08 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
//#include "TFile.h"
//#include "TCanvas.h"
//#include "TH1F.h"

void figSpectraDiff()
{

//	TFile *fr = new TFile("figures/PRCspectra15MeV.root", "READ");
	TFile *fr = new TFile("figures/PRCspectra1MeV.root", "READ");

//	fr->ls();

	TH1F *hExp[4];
	TH1F *hSim[4];

	TH1F *hCurr = 0;

	TString heName;
	TString hsName;

	hCurr = (TH1F*)fr->Get("heSpectrum4560");
	hExp[0] = new TH1F(*hCurr);
	hCurr = (TH1F*)fr->Get("heSpectrum6075");
	hExp[1] = new TH1F(*hCurr);
	hCurr = (TH1F*)fr->Get("heSpectrum7590");
	hExp[2] = new TH1F(*hCurr);
	hCurr = (TH1F*)fr->Get("heSpectrum90120");
	hExp[3] = new TH1F(*hCurr);


	hCurr = (TH1F*)fr->Get("hsSpectrum4560");
	hSim[0] = new TH1F(*hCurr);
	hCurr = (TH1F*)fr->Get("hsSpectrum6075");
	hSim[1] = new TH1F(*hCurr);
	hCurr = (TH1F*)fr->Get("hsSpectrum7590");
	hSim[2] = new TH1F(*hCurr);
	hCurr = (TH1F*)fr->Get("hsSpectrum90120");
	hSim[3] = new TH1F(*hCurr);



	/*TCanvas *c1 = new TCanvas();
	c1->ToggleEditor();
//	c1->SetWindowSize(800, 1200);
	c1->SetWindowSize(800, 800);
	c1->Divide(2, 2, .001, .001);


	for (Int_t i = 0; i < 4; i++) {
		c1->cd(i+1);

		hExp[i]->SetTitle("");
		hSim[i]->SetTitle("");

		hSim[i]->Draw("");
		hExp[i]->Draw("E same");

		TLine *l[4];
		TLine *l[0] = new TLine(1.4, 0., 1.4, 40000);
		TLine *l[1] = new TLine(1.9, 0., 1.9, 40000);
		TLine *l[2] = new TLine(2.5, 0., 2.5, 40000);
		TLine *l[3] = new TLine(3.1, 0., 3.1, 40000);

		for (Int_t j = 0; j < 4; j++) {
			l[j]->SetLineColor(kRed);
			l[j]->SetLineWidth(2);
			l[j]->Draw("same");
		}

	}*/

//	c1->SaveAs("figures/spectra.eps");


	TCanvas *c2 = new TCanvas();
	c2->ToggleEditor();
	c2->SetWindowSize(800, 800);
	c2->Divide(2, 2, .001, .001);

	TH1F *diff[4];

	for (Int_t i = 0; i < 4; i++) {
		c2->cd(i+1);

		diff[i] = new TH1F(*hExp[i]);
		diff[i]->Add(hSim[i], -1);
		diff[i]->Draw("");
		diff[i]->SetTitle("");
		diff[i]->GetXaxis()->SetTitle("");
		diff[i]->GetYaxis()->SetTitle("");
		diff[i]->GetYaxis()->SetLabelSize(0.06);
//		Double_t max = diff[i]->GetYaxis()->GetXmax();
//		diff[i]->GetYaxis()->SetRangeUser(-100, 3500);
	}

	c2->SaveAs("figures/spectraDiff1.eps");

}