TProfile and ProfileY()

From: Nevzat Guler <nguler_at_jlab.org>
Date: Mon, 6 Nov 2006 16:50:49 -0500 (EST)

	Hello All,
	I am getting a ProfileY() from a two dimensional histogram. It
gives me a nice plot with a line fit. I have two questions: Profile plot always comes with black points and black line fit. Is there any way to color it. (I tried SetLineColor but it only colors the error bars on the points..)

If coloring is possible, I want to superimpose two ProfileY plots on the same pad. I tried Draw("same") but it always replaces the previous plot.

Below is a segment of my long program to give you some idea what I am doing:
Thank you very much..

	for(i=0;i<=5;i++){
	sprintf(strTitle,"DP.phi RAW S%d",i+1);
	DeltaPRAW[i] = new TH2F(strTitle,"",500,-0.05,0.05,10,-30,30);
	}
	for(i=0;i<=5;i++){
	sprintf(strTitle,"DP.phi COR S%d",i+1);
	DeltaPCORR[i] = new TH2F(strTitle,"",500,-0.05,0.05,10,-30,30);
	}

// reading the data and filling the histograms defined above.
// Then defining the canvas and doing the rest below:

TCanvas *c1 = new TCanvas("c1","c1",0,0,1900,620); c1->Divide(6,2);
gStyle->SetOptFit(0111);
gPad->SetGrid();
gStyle->SetStatW(0.21);

// here I am drawing the first 2D histogram and
// getting the ProfileY
// then plotting it to pads 1 to 6

	for(i=0;i<=5;i++){
		DeltaPRAW[i]->SetMarkerStyle(20);
		DeltaPRAW[i]->SetXTitle("PhiDC");
		DeltaPRAW[i]->SetYTitle("delta_p/p");
		c1->cd(i+1);
		gPad->SetGrid();
		DeltaPRAW[i]->Draw("colz");
 		TProfile *prof = DeltaPRAW[i]->ProfileY();
		prof->SetLineColor(kBlue);
		prof->Fit("pol1","R","",-20.,20.);
		prof->SetAxisRange(-0.03,0.03,"Y");
		prof->SetXTitle("PhiDC");
		prof->SetYTitle("delta_p/p");
		prof->GetYaxis()->CenterTitle(true);
		prof->Draw("same");

	}

// here I am drawing the second 2D histogram and
// getting the ProfileY
// then plotting it to pads 7 to 12
// BUT I ACTUALLY WANT TO PLOT THESE PROFILES TO THE SAME PADS ABOVE
// AND SUPERIMPOSE TWO PLOTS
// SO I WON'T NEED 12 PADS BUT ONLY 6 PADS

   	for(i=0;i<=5;i++){
		DeltaPCORR[i]->SetMarkerStyle(20);
		DeltaPCORR[i]->SetXTitle("PhiDC");
		DeltaPCORR[i]->SetYTitle("delta_p/p");
		c1->cd(i+1+6);
		gPad->SetGrid();
		DeltaPCORR[i]->Draw("colz");
		TProfile *prof = DeltaPCORR[i]->ProfileY();
		prof->SetLineColor(kBlue);
		prof->Fit("pol1","R","",-20.,20.);
		prof->SetAxisRange(-0.03,0.03,"Y");
		prof->SetXTitle("PhiDC");
		prof->SetYTitle("delta_p/p");
		prof->GetYaxis()->CenterTitle(true);
		prof->Draw("same");
	}


				Nevzat Guler
Received on Mon Nov 06 2006 - 22:50:57 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET