Difference ROOT5.34 & ROOT6.04.16

Here is a corrected version of your macro:

appearance_nu_mode_0.cc (2.3 KB)

Hello everyone!
I made a loop on theta23 in TGraph*pchisq2, My problem that I want to find the point where the chisquare is equal to 1. I think I will get Eval for each theta23’s point, if the returned value is close to 1 (or 1 +/- 1e-5) then that values will be printed. How will I do? How can I fix the code?Example.zip (12.4 KB)

I ran you macro. I get the following plot:


I am not sure what is your problem exactly. May be @moneta has an idea.

Right. I mean from this plot, What command I can use to know at what value in x-axis is correspond to the value of y=1

plot_theta13_proj.C (4.0 KB)

root [0] 
Processing plot_theta13_proj.C...
The mean value of chisq is 3.1245e-05 and2 2.56002e-05
0.05 0.12
x = 0.09445
x = 0.10495

In the macro I sent you you can change dx to have a better precision. For instance double dx = (x1-x0)/100000.; gives:

x = 0.0945137
x = 0.105003
{
  const char *f = "theta13_proj_reactor_6.dat";
  TGraph *pchisq = new TGraph(f, "%lg %lg %*s"); pchisq->Sort();
  TGraph *pchisq2 = new TGraph(f, "%lg %*s %lg"); pchisq2->Sort();
  Int_t n = pchisq->GetN();
  Double_t xmin = pchisq->GetX()[0];
  Double_t xmax = pchisq->GetX()[(n - 1)];
  TF1 *fq =
    new TF1("fq",
            [=](double *x, double */*p*/){return pchisq->Eval(x[0], 0, "S");},
            xmin, xmax, 0);
  fq->SetNpx(n * 3);
  Double_t yminq = fq->GetMinimum();
  Double_t xminq = fq->GetMinimumX();
  std::cout << "chisq ... " << fq->GetX(1. + yminq, xmin, xminq)
            << " ... " << xminq << " (" << yminq << ")"
            << " ... " << fq->GetX(1. + yminq, xminq, xmax)
            << std::endl;
  TF1 *fq2 =
    new TF1("fq2",
            [=](double *x, double */*p*/){return pchisq2->Eval(x[0], 0, "S");},
            xmin, xmax, 0);
  fq2->SetNpx(n * 3);
  Double_t yminq2 = fq2->GetMinimum();
  Double_t xminq2 = fq2->GetMinimumX();
  std::cout << "chisq2 ... " << fq2->GetX(1. + yminq2, xmin, xminq2)
            << " ... " << xminq2 << " (" << yminq2 << ")"
            << " ... " << fq2->GetX(1. + yminq2, xminq2, xmax)
            << std::endl;
}

Hi couet!
I made errors when I run your code. I used root version 6.10.04

It seems you have y0 already defined elsewhere in your code.
The code I added is:

   double x0 = atheta13[0];
   double x1 = atheta13[TotalLine-1];
   printf("%g %g\n",x0,x1);
   double dx = (x1-x0)/100000.;
   double y  = 1.;
   double y0, y1;
   TLine *l = new TLine();
   l->SetLineStyle(2);
   for (double x=x0; x<x1; x = x+dx) {
      y0 = pchisq2->Eval(x);
      y1 = pchisq2->Eval(x+dx);
      if (y0<=y) {
         if (y1>=y) {
            printf("x = %g\n", x);
            l->DrawLine(x,0.,x,y);
         }
      }
      if (y0>=y) {
         if (y1<=y) {
            printf("x = %g\n", x);
            l->DrawLine(x,0.,x,y);
         }
      }
   }

In that code change y0 to something else not clashing with other declaration in your code.

I didn’t use y0 before. plot_theta13_proj.C (4.0 KB)

Can you send me the macro you are running ? I do not see the error with the macro I sent you …

This is my code and the errors. Example (1).zip (6.0 KB)

search forum -> “mathcalls”

Try this one:
plot_theta13_proj.C (4.1 KB)

Okay, I can run it. Thank you very much

Right in the beginning of your “storeHKTDRinfo.C” macro, add:

#include "TFile.h"
#include "TH1.h"
#include "TGraph.h"
#include <cstdio>
#include <iostream>

Then fix all errors and warnings reported by:
root [0] .L storeHKTDRinfo.C++

Hi,

I have the commands below:
TFile* f1 = new TFile(disapp.root");
TH2D* h2d = (TH2D*)f1->Get(“hdm_proj”);
h2d->ProjectionX(“h1x”, 0, 1);
h2d->ProjectionY(“h1y”, 0, 1);
int nbinx = h1x->GetNbinsX();
int nbiny = h1y->GetNbinsX();
TH1F* h_th23 = new TH1F(“th23”, “”, nbinx, h1x->GetBinCenter(1), h1x->GetBinCenter(nbinx)); …

and when I run my macro I get an error :

What am i doing wrong?

h2d->ProjectionX("h1x", 0, 1);
TH1D *h1x = (TH1D*)gROOT->FindObject("h1x");
h2d->ProjectionY("h1y", 0, 1);
TH1D *h1y = (TH1D*)gROOT->FindObject("h1y");

Okay, Thanks Wile_E_Coyote

A post was split to a new topic: Projection on a axis from TH2D