I keep getting the error where it says:
- could not delete seasondependence.root
- Error cannot call TGraph
A detailed error message is in the attached picture. Can someone please help? I am a newbie. Thanks!
#include “Riostream.h”
void seasondependence() {
TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
dir.ReplaceAll(“seasondependence.C”,"");
dir.ReplaceAll("/./","/");
ifstream file1;
file1.open(Form("%seasondependence.txt",dir.Data()));
Double_t date1,charge1, error1;
Int_t nlines = 0;
TFile *f = new TFile(“seasondependence.root”,“RECREATE”);
TNtuple *ntuple1 = new TNtuple(“ntuple”,“data from ascii file”,“date1:y:z”);
TCanvas *c1 = new TCanvas(“c1”,“A Simple Graph Example”,200,10,700,500);
c1->SetFillColor(kWhite);
c1->SetGrid();
// TCanvas::Update() draws the frame, after which one can change it
c1->Update();
c1->GetFrame()->SetFillColor(kWhite);
c1->GetFrame()->SetBorderSize(12);
c1->Modified();
while (!file1.eof( )) {
file1 >> date1 >> charge1 >> error1;
if (!file1.good()) break;
if (nlines < 5) printf(“DateofYear1=%8f, charge(fC)=%8f, error=%8f\n”,date1,charge1,error1);
gr1 = new TGraph(date1,charge1,error1);
gr1->SetLineColor(kRed);
gr1->SetLineWidth(4);
gr1->SetMarkerColor(kRed);
gr1->SetMarkerStyle(21);
gr1->SetTitle(“a simple graph”);
gr1->GetXaxis()->SetTitle(“Days”);
gr1->GetYaxis()->SetTitle(“Charge Values (fC)”);
gr1->Draw(“ACP”);
ntuple->Fill(date1,charge1,error1);
nlines++;
}
printf(" found %d points\n",nlines);
in.close();
f->Write();
f->delete();
}