sfAngInt_cosThetaYk.cxx 3.02 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
{

	TCanvas *cThetaY[nointervals];
	for (Int_t i = 0; i<nointervals; i++) {	//energy intervals (canvases)

	TH1F *hscoskY[nointervals][6];
	TH1F *hecoskY[nointervals][6];
	TH1F *hicoskY[nointervals][6];

		if (cosThetaY[i]) {

			cThetaY[i] = new TCanvas();

			canvasTitle.Form("cos thetak in %s Y-system;\t(%d,%d) degrees", (const char*)cBeE[i], kMinAngle, kMaxAngle);
			cThetaY[i]->SetTitle(canvasTitle.Data());
			cThetaY[i]->Divide(2, 3);

			che->SetLineColor(kBlack);
			for (Int_t j = 0; j < 6; j++) {	//different files
				cThetaY[i]->cd(j+1);
				chs[j]->SetLineColor(kGray+1);
				chs[j]->SetFillColor(kGray+1);
				hsName.Form("hscoskY%d_%d", i, j);
				drawCommand.Form("fCosThetaYk>>%s(50,-1,1)", hsName.Data());
				chs[j]->Draw(drawCommand.Data(), cQ && crBeE[i] && crAngles && sRatio[j], "", sEvents[j]);
				TH1F *hscoskY[i][j] = (TH1F*)gPad->FindObject(hsName.Data());
				heName.Form("hecoskY%d_%d", i, j);
				drawCommand.Form("fCosThetaYk>>%s(50,-1,1)", heName.Data());
				che->Draw(drawCommand.Data(), cQ && cBeE[i] && cAngles, "E same", eEvents[j]);
				TH1F *hecoskY[i][j] = (TH1F*)gPad->FindObject(heName.Data());

				hscoskY[i][j]->Draw();
//				hscoskY[i][j]->GetYaxis()->SetRangeUser(0, coskYRange[i][j]);
				hecoskY[i][j]->Draw("E same");
				if (kAutoRange) {
					Float_t leftMaxMC = kRangeProportion*hecoskY[i][j]->GetMaximum();
					Float_t leftMaxE = kRangeProportion*hscoskY[i][j]->GetMaximum();
					hscoskY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
					leftMaxMC > leftMaxE ? hscoskY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hscoskY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
				}
				else {
					hscoskY[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]);
				}



				cThetaY[i]->Update();

				hiName.Form("hicoskY%d_%d", i, j);
				drawCommand.Form("sCosThetaYk>>%s", hiName.Data());
				ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same");
				TH1F *hicoskY[i][j] = (TH1F*)gPad->FindObject(hiName.Data());
				Float_t rightmax = 1.1*hicoskY[i][j]->GetMaximum();
				Float_t scale = cThetaY[i]->GetPad(j+1)->GetUymax()/rightmax;
				hicoskY[i][j]->SetLineColor(kRed);
				hicoskY[i][j]->Scale(scale);

				//draw an axis on the right side
				TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
						gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
				axis->SetLineColor(kRed);
				axis->SetLabelColor(kRed);
				axis->Draw();

				cThetaY[i]->Update();

				if (kVerbose) {
					Info("sfAngInt_cosThetaYk.cxx", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f",
							i, j, hecoskY[i][j]->Integral(0,hecoskY[i][j]->GetNbinsX()),
							hscoskY[i][j]->Integral(0,hscoskY[i][j]->GetNbinsX()),
							hecoskY[i][j]->Integral(0,hecoskY[i][j]->GetNbinsX())/hscoskY[i][j]->Integral(0,hscoskY[i][j]->GetNbinsX()) );
				}


			}//for j
			if (savePictures) {
				canvasName.Form("%sfig%dcosThetakY:%s%s", ppath.Data(), i, configuration.Data(), pictFormat.Data());
				cThetaY[i]->SaveAs(canvasName.Data());
				cThetaY[i]->cd();
				cThetaY[i]->Close();
			}
		}//if
	}//for i

	sw.Print();
	sw.Continue();
}