Hi Ijaz!
I guess it would be good to re-exercise some C and C++.
The message is very clear: getting the object from a file failed,
resulting into a null pointer at that line.
One reason could be that the object is not in that file, check by
browsing the file with
root yourfile.root
TBrowse b
When you get some pointer, it is always your responsibility to check its validity in your code first
TGraphErrors *itsgraph = (TGraphErrors
*)f1.Get(Form("fV%sMeanTPC",labelsTPCITS[axis].Data()));
if (itsgraph) {
// do stuff
} else {
cerr << "ERROR getting graph!" << endl;
return;
}
before you try to access it's methods and properties.
Cheers and good luck,
Jiri
Ijaz Ahmed wrote:
> Hi....
>
> I am getting the following error:
>
> Error: illegal pointer to class object itsgraph 0x0 678 readQAgrid_tracks.C:506:
> *** Interpreter error recovered *
>
> if somebody want to suggest me, here is the function:
> *******************
> void plotVertexTPC(Int_t axis){
>
> TFile f1("RunQA.root");
>
> TString labelsTPCITS[3];
>
> labelsTPCITS[0]="TPC Vertex_x";
>
> labelsTPCITS[1]="TPC Vertex_y";
>
> labelsTPCITS[2]="TPC Vertex_z";
>
>
>
>
>
> TGraphErrors *itsgraph = (TGraphErrors *)f1.Get(Form("fV%sMeanTPC",labelsTPCITS[axis].Data()));
>
>
>
> ---
> line 506
> TCanvas *itstpc = new TCanvas( Form("Vertex_%s",labelsTPCITS[axis].Data()), Form("Vertex_%s",labelsTPCITS[axis].Data()),
>
> 0, 100+axis*50, 820, 620);
>
> if (itsgraph){
> itsgraph->Draw("apl");
>
> itsgraph->GetYaxis()->SetTitle(Form("vertex position in %s (cm)",labels[axis].Data()));
>
> delete itstpc;
> delete itsgraph;
> }
>
> }
>
>
> Ijaz Ahmed
> CIIT, Islamabad
> mob#+923345349527
> URL: http://iahmed.web.cern.ch/iahmed
>
>
-- ------------------------------------------------------------------------ Office: 40-3D-06, Tel. (+41 2276) 73436, Cell +41 76 239 5696 Jiri.Kvita@cern.ch, A1 Rh+, http://qitek.web.cern.ch/qitek/ ------------------------------------------------------------------------Received on Thu Sep 23 2010 - 15:53:11 CEST
This archive was generated by hypermail 2.2.0 : Thu Sep 23 2010 - 23:50:02 CEST