Problem to superimpose 2 contour

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?


  // 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->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;
    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]);
  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);

      nGraphs ++;

      curv = (TGraph*)contLevel->After(curv); // Get Next graph 

Can you send a running example ? when I run your macro I get:

Warning: Unknown type 'par' in function argument handled as int tamu.C:3:
Limitation: Statement too long tamu.C:53:
cint: Security mode 0x7:0x2 *** Fatal error in interpreter... restarting interpreter ***
*** Fatal error in interpreter... restarting interpreter ***

thank for reply

I just post part of my code. Sorry for confusion. My code is based on the one of the tutorial codes. This one should run in your machine.


This macro returns a collection of graphs (for each contours). You really need that ? if yes, when you have the graphs you can plot them on top of each others. You draw the first one with option A and the others without.

I think I got it
thank you