Hello,
I have a problem while analysis of long Double data type with TTree. I want to analyse following data as:
Time_(s) s0
0.00000E+000 0.00000E+000
5.09966E-002 0.00000E+000
6.62959E-001 0.00000E+000
2.09959E+000 0.00000E+000
4.38372E+000 0.00000E+000
7.62890E+000 0.00000E+000
1.17973E+001 0.00000E+000
1.69840E+001 0.00000E+000
2.31787E+001 0.00000E+000
3.04986E+001 0.00000E+000
3.90199E+001 1.04312E+003
4.88280E+001 6.56040E+003
5.99976E+001 1.70816E+004
7.26286E+001 2.81410E+004
For this my code is as follows:
void Analyse() {
//DecIaration of Ieaves types
long double time, s0;
FILE *fp = fopen("C:/Analyse.data", "r");
char line[128];
//create the file, the Tree and a few branches
TFile *rootf = new TFile("Analyse.root", "RECREATE");
TTree *tree = new TTree("tree","Tree");
tree->Branch("time",&time,"time/D");
tree->Branch("s0",&s0,"s0/D");
while (fgets(&line[0],127,fp)) {
sscanf(&line[0],"%lf%lf",&zeit,&s0);
tree->Fill();
}
tree->Print();
tree->Write();
fclose(fp);
rootf->Write();
//Analysis
TFile *f1 = TFile::Open("Analyse.root");
//read a tree from a root file
TTree *T1 = (TTree*)f1->Get("tree");
TCanvas *c = new TCanvas("c", "c", 0, 0, 1000, 1000);
T1->Draw("s0:time");
gPad->Modified();
gPad->Update();
TGraph *gr = (TGraph *)gPad->GetPrimitive("Graph")->Clone();
TGraph *gr = new TGraph(T1->GetSelectedRows(),T1->GetV2(), T1->GetV1());
gr->Draw("AC"); [color=#FF0000]//Here I am not getting a proper curve as I expected for analysis. I want a proper Curve for analysis and for fitting a function[/color]
gr->SetMarkerStyle(2);
gr->SetLineColor(16);
}
what is going wrong? Is there other way to analyse long double data type? Please guide me.