Hello,
I don’t understand why my program didn’t function.
It is possible to create a graphe with TGraphe with Tree data ?
void OMline()
{
gStyle->SetOptStat(0);
gStyle->SetOptFit(1111);
//gStyle->SetMarkerSize(3);
TCanvas *c1 = new TCanvas("c1","",0,10,0,500000);
TFile *input = new TFile("/home/kdupuy/Documents/fichier_root/valeurspics2.root","READ");
TTree *tree = (TTree*)input->Get("valeurspics2_tree;1");
double Constant1, Mean1, Sigma1, om_number1;
int pics, intensity;
Double_t error1, error2, error3;
Double_t x[6], y[6],ex[6],ey[6];
Int_t n = 6;
tree->SetBranchAddress("om_number1", &om_number1);
tree->SetBranchAddress("Constant1", &Constant1);
tree->SetBranchAddress("Mean1", &Mean1);
tree->SetBranchAddress("Sigma1", &Sigma1);
tree->SetBranchAddress("pics", &pics);
tree->SetBranchAddress("intensity", &intensity);
tree->SetBranchAddress("error1", &error1);
tree->SetBranchAddress("error2", &error2);
tree->SetBranchAddress("error3", &error3);
int entries = tree->GetEntries();
for (int j = 301; j <= 301; j++ )
{
//TH2D *hist7 = new TH2D("hist7", "",1000, 60, 130, 1000, 0, 500000);
TF1 *fit7 = new TF1("fit7", "pol1", 0, 400000);
TGraph* gr = new TGraphErrors(n,x,y,ex,ey);
for(int i=0; i < entries; i++) // rentre les valeurs de la branche dans notre variable
{
tree->GetEntry(i);
if (om_number1 == j)
{
//cout << Mean1 << pics << endl;
//hist7->Fill(intensity,Mean1);
for (Int_t i=0;i<n;i++)
{
cout << intensity << endl;
x[i] = intensity;
y[i] = Mean1;
ex[i] = error2;
ey[i] = 0;
}
}
}
//TGraph* gr = new TGraph(n,x,y,ex,ey);
gr->Draw("");
//gr->Fit("fit7","R");
//hist7->SetErrorX(0.5);
// hist7->SetMarkerStyle(20);
// hist7->GetXaxis()->SetTitle("Intensite LED (U.A)");
// hist7->GetYaxis()->SetTitle("Charge moyenne (U.A)");
// hist7->GetXaxis()->SetTitleSize(0.04);
// hist7->GetYaxis()->SetTitleSize(0.03);
// hist7->GetXaxis()->SetLabelSize(0.05);
// hist7->GetYaxis()->SetLabelSize(0.05);
// hist7->Draw("");
//c1->Print(Form("/home/kdupuy/Documents/Line/%03i1.png", j));
//delete hist7;
}
}
valeurspics2.root (35.7 KB)