Hi, ROOT people
I need to superimpose 2 contours in one canvas. How can I superimpose 2 contours if I create a contour in the folloring way?
thank
masaki
// loop to fill up TH2D histogram
TH1D *exp_hist;
for (par[0] = min[0]; par[0] <= max[0]; par[0] += err[0]) {
for (par[1] = min[1]; par[1] <= max[1]; par[1] += err[1]) {
exp_hist = new TH1D("exp_hist", "Expected E_{#nu}", nbin, xbin);
chi2 = calculate_chi2(par, exp_hist);
delta_chi2 = chi2 - chi2_bf;
contour->Fill(par[0], par[1], delta_chi2);
delete exp_hist;
}
}
// to extract the CL lines
Double_t confidence_limit[4];
confidence_limit[0] = 1.0; // 68.5% CL
confidence_limit[1] = 1.645*1.645; // 90.0% CL
confidence_limit[2] = 4.0; // 95.4% CL
confidence_limit[3] = 9.0; // 99.7% CL
contour->SetContour(4, confidence_limit);
// Draw contours as filled regions, and Save points
contour->SetStats(kFALSE);
contour->Draw("contz, list");
contour_canvas->Update(); // Needed to force the plotting and retrieve the contours in TGraphs
// Get Contours
TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
TList* contLevel = NULL;
TGraph* curv = NULL;
Int_t nGraphs = 0;
Int_t TotalConts = 0;
if (conts == NULL){
printf("*** No Contours Were Extracted!\n");
TotalConts = 0;
return;
}
else
TotalConts = conts->GetSize();
printf("Total contours = %d\n", TotalConts);
for(Int_t i = 0; i < TotalConts; i++){
contLevel = (TList*)conts->At(i);
printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
nGraphs += contLevel->GetSize();
}
string str_hr = "Oscillation Contour for E^{" + opt_spectrum + "}_{#nu} Spectrum";
TH2D *hr = new TH2D("hr", str_hr.c_str(), Int_t(nbin0), min[0], max[0], Int_t(nbin1), min[1], max[1]);
hr->GetXaxis()->SetTitle(scale_name[0].c_str());
hr->GetYaxis()->SetTitle(scale_name[1].c_str());
hr->SetStats(kFALSE);
hr->Draw();
//contour_canvas->cd();
Double_t x0, y0, z0;
for(Int_t i = 0; i < TotalConts; i++){
contLevel = (TList*)conts->At(i);
z0 = confidence_limit[i];
// Get first graph from list on curves on this level
curv = (TGraph*)contLevel->First();
for(Int_t j = 0; j < contLevel->GetSize(); j++){
curv->GetPoint(0, x0, y0);
curv->SetLineColor(i+2);
nGraphs ++;
curv->Draw("C");
curv = (TGraph*)contLevel->After(curv); // Get Next graph
}
}