Read the data in a TCanvas

ROOT Version: Not Provided
_Platform: Centos 7
Compiler: Not Provided

Sys_Pt_IsoSFNom_All_IsoFCLoose.root (21.8 KB)

There are several OBJ in my root file, and I want to read the data in TGraphAsymmtry. This problem is quite similar with
However, I used the code in the answer like:

(1). TFile *th1 = new TFile("Sys_Pt_IsoSFNom_All_IsoFCLoose.root")
(2).TCanvas *c1 = (TCanvas*)t1->Get("Sys_ p_{T} [GeV]_IsoSFNom_All_IsoFCLoose")
(there is a star before c1 and after TCanvas. It disappeared after I post it)
Canvas Name=Sys_ p_{T} [GeV]_IsoSFNom_All_IsoFCLoose Title=Sys_ p_{T} [GeV]_IsoSFNom_All_IsoFCLoose Option=
 TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= Sys_ p_{T} [GeV]_IsoSFNom_All_IsoFCLoose Title= Sys_ p_{T} [GeV]_IsoSFNom_All_IsoFCLoose Option=
  OBJ: TList	TList	Doubly linked list : 0
   TFrame  X1= 3.000000 Y1=0.001000 X2=500.000000 Y2=1000.000000
   OBJ: TH1F	Nom_ZmumuZmumuTPIsoIsoSFNomIsoFCLooseAllPtOCProbe	Z#rightarrow#mu#mu : 1 at: 0x3ba5ad0
   OBJ: TGraphAsymmErrors		Total : 1 at: 0x3be5010
   OBJ: TGraphAsymmErrors		isolBkg : 1 at: 0x3bebeb0
   OBJ: TGraphAsymmErrors		Statistics : 1 at: 0x3bec550
   OBJ: TGraphAsymmErrors		eta : 1 at: 0x3becbf0
   OBJ: TGraphAsymmErrors		mass : 1 at: 0x3bed290
   OBJ: TGraphAsymmErrors		Statistics (MC) : 1 at: 0x3bed930
   OBJ: TGraphAsymmErrors		tpdR : 1 at: 0x3bedfd0
   OBJ: TGraphAsymmErrors		probeQ : 1 at: 0x3bee670
   OBJ: TGraphAsymmErrors		tagIsol : 1 at: 0x3beed10
   OBJ: TGraphAsymmErrors		dRmuj : 1 at: 0x3bef3b0
   OBJ: TLegend	TPave  	X1= 40.746839 Y1=620.253547 X2=455.962026 Y2=835.443204
   Text  X=0.190000 Y=0.900000 Text=#font[72]{ATLAS} Internal
   Text  X=0.190000 Y=0.850000 Text=#sqrt{s} = 13 TeV, 44.3 fb^{-1}
   Text  X=0.920000 Y=0.900000 Text=IsoFCLoose
   Text  X=0.920000 Y=0.850000 Text=IsoSFNom
   Text  X=0.500000 Y=0.850000 Text=
(4). TH1F *th1 = (TH1F*)c1->GetPrimitive("Total")
(there is a star before th1 and after TH1F. It disappeared after I post it)

and also

TGraphAsymmErrors *tg1 = (TGraphAsymmErrors*)c1->GetPrimitive("Total")

doesn’t work
However, it said: nullptr.

Could you please help me?
I want to read the data in the TGraphAsymmtry objects.

All your graphs have nonempty titles (e.g. “Total”, “isolBkg”) but all names are empty (i.e. "", so that you cannot “find” them):

new TCanvas();

BTW. When you post “source code” or “output” here, do remember to enclose them into two lines which contain just three characters ``` (see how your post has been edited above).

Many thanks Wile. It works well! And thanks for your instruction. This is my first time to post a question.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.