Hello,
I am using ROOT 6.12/04 version for overlaying two TGraphAsymmError plots from two files. I cannot see the X and Y axis and the title of the final histogram.
I am trying the following lines, but the macro crashes.
TCanvas* c1 = new TCanvas("c1","c1",800,600);
TFile *f0 = TFile::Open("/Users/shreya/Lead_Si_d0_track/Lead_Si_nod0_noTrack.root");
TFile *f1 = TFile::Open("/Users/shreya/Lead_Si_d0_track/Lead_Si_d0_Track.root");
TDirectory *d0 = nullptr;
TString tdir = "PassTrackQuality_veryloose20170713";
f0->GetObject(tdir, d0);
for (TObject* keyAsObj : *(d0->GetListOfKeys())){
auto key = dynamic_cast<TKey*>(keyAsObj);
if((TString)key->GetClassName() == "TH2D") continue;
TGraphAsymmErrors * h_10 = (TGraphAsymmErrors*) key->ReadObj();
TString histName = TString(key->GetName());
TGraphAsymmErrors *h_20 = (TGraphAsymmErrors*)f1->Get(tdir+"/"+ histName );
TString append = "";
if(histName.Contains("et4")) append = ", 4 < E_{T} < 7 GeV";
TString title = "";
if(histName.Contains("eta0.00")) title = TString("0 < |#eta| < 0.6") + append;
h_10->Draw("AP");
h_20->Draw("P SAME");
h_10-> GetXaxis()->SetTitle("LH discriminant");
h_10->GetYaxis()->SetTitle("Fraction of events");
}
It crashes at GetXAxis
[/Applications/root_v6.12.04/lib/libHist.so] TGraph::GetXaxis() const (no debug info)
The TString append also does not work, which is used to write some text in the plot.
Is there something I am missing here, the code works for histograms but not from TGraphAsymmErrors…
Any help is appreciated !
Thank you