Re: Error: illegal pointer to class object (fwd)

From: Olivier Couet <couet_at_mail.cern.ch>
Date: Fri, 1 Jul 2005 14:24:06 +0200 (CEST)

Hi,

I do not have the file ../rootfiles/bu-jpsik-BDStest.root. Can you send a RUNNING macro reproducing the problem ?

Cheers,

   O.Couet

> ---------- Forwarded message ----------
> Date: Fri, 01 Jul 2005 11:13:25 +0200
> From: Gian Piero Di Giovanni <digiovan_at_fnal.gov>
> To: roottalk_at_pcroot.cern.ch
> Subject: [ROOT] Error: illegal pointer to class object
>
> Hi,
>
> I'm using the version 4.02/00 on Fedora Core 3.
> This is the following script "test.C".
> Using root I get:
>
> root [0] .L test.C
> root [1] test()
> ===============================
> TRACK_ALL
> dilptRel_ALL
> dilplRel_ALL
> dilpt_ALL
> ===============================
> ../rootfiles/bu-jpsik-BDStest.root:/TRACK_ALL
> Error: illegal pointer to class object graph_data 0x0 634 FILE:test.C LINE:82
> *** Interpreter error recovered ***
>
> This is strange for me because the values of TString are also printed on the
> screen.
> Can someone help me?
>
> Thank you a lot,
>
> Gian Piero.
>
> 1 int test(int Ntrk=0)
> 2 {
> 3
> 4 gROOT->Reset();
> 5
> 6 // gStyle->SetOptStat(111111);
> 7 // gStyle->SetOptFit(1111);
> 8
> 9
> 10 TObjArray Data;
> 11
> 12 TString folder = "TRACK_";
> 13 TString dilptRel = "dilptRel_";
> 14 TString dilplRel = "dilplRel_";
> 15 TString dilpt = "dilpt_";
> 16
> 17
> 18 if (Ntrk != 0) {
> 19
> 20 folder += Ntrk;
> 21 dilptRel += Ntrk;
> 22 dilplRel += Ntrk;
> 23 dilpt += Ntrk;
> 24
> 25 }else{
> 26
> 27 folder.Append("ALL");
> 28 dilptRel.Append("ALL");
> 29 dilplRel.Append("ALL");
> 30 dilpt.Append("ALL");
> 31 }
> 32
> 33
> 34 TString graphs[3]={dilptRel, dilplRel, dilpt};
> 35 cout << "===============================\n";
> 36 cout << folder << endl;
> 37 cout << graphs[0] << endl;
> 38 cout << graphs[1] << endl;
> 39 cout << graphs[2] << endl;
> 40 cout << "===============================\n";
> 41
> 42
> 43 //----- Taking DATA -----
> 44 TFile* file = new TFile("../rootfiles/bu-jpsik-BDStest.root");
> 45 TDirectory* dir= (TDirectory*) file->Get(folder);
> 46 dir->pwd();
> 47 dir->cd();
> 48
> 49 for (int i=0;i<3;i++)
> 50 {
> 51
> 52 TGraphErrors* graph= (TGraphErrors*) file->Get(graphs[i]);
> 53 Data.Add(graph);
> 54
> 55 }
> 56
> 57
> 58 file->Close();
> 59
> 60 TCanvas* CANVAS1 = new TCanvas("CANVAS1","CANVAS1",950,750);
> 61 CANVAS1->Divide(2,2,0,0);
> 62
> 63
> 64
> 65 for (int i=1;i<4;i++)
> 66 {
> 67
> 68 CANVAS1->cd(i);
> 69
> 70 char PadName[200];
> 71 sprintf(PadName,"%s_%d",CANVAS1->GetName(),i);
> 72
> 73
> 74 TPad* pad = (TPad*) CANVAS1->FindObject(PadName);
> 75 pad->SetGridx();
> 76 pad->SetGridy();
> 77
> 78
> 79 TGraphErrors* graph_data= (TGraphErrors*) Data[i-1];
> 80
> 81
> 82 graph_data->SetMarkerColor(2);
> 83 graph_data->SetFillColor(1);
> 84 graph_data->GetXaxis()->SetTitle("Pt Cut (GeV)");
> 85 //graph_data->GetYaxis()->SetTitle("Dilution");
> 86 //graph_data->GetYaxis()->SetTitleOffset(1.5);
> 87 graph_data->SetMarkerSize(1.0);
> 88 graph_data->SetMarkerStyle(8);
> 89 graph_data->SetMinimum(-0.15);
> 90 graph_data->SetMaximum(0.28);
> 91
> 92 graph_data->Draw("AP");
> 93
> 94
> 95 pad->SetFillColor(0);
> 96 pad->Update();
> 97 TPaveText* text = (TPaveText*) pad->FindObject("title");
> 98 text->SetFillColor(0);
> 99 pad->Update();
> 100 }
> 101
> 102 return 0;
> 103 }
>
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Fri Jul 01 2005 - 14:27:52 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:10 MET