Re: Crash:illegal pointer to class object (not happened before!)

From: Eduard Avetisyan <Eduard.Avetisyan_at_desy.de>
Date: Tue, 21 Apr 2009 12:34:06 +0200

Hi,

On Tue, 21 Apr 2009, Axel Naumann wrote:

> Hi Deepak,
>
> sorry, I meant
>
> TFile *f= new TFile("gen.root");
> f->cd("Ana/dyjet/Hist");
> f->ls()
>
> But anyway - I believe you have given me the answer nevertheless :-) There
> seems to be no directory "Ana" in your file gen.root. The TProfile seems not
> to be in a subdirectory, so you should call
> gDirectory->Get("dyjet_Pnchg5pairpt2"); - and maybe the same for the other
> TProfile.

Maybe the easiest way to check that all would be via TBrowser.

Cheers

        Eduard

>
> Cheers, Axel.
>
> Deepak Kar wrote on 04/21/2009 10:43 AM:
> > Hi Axel,
> >
> > Thanks for your comment.
> > Here is what I get:
> >
> > root [0] TFile *f= new TFile("gen.root");
> > root [1] f->cd("Ana/dyjet/Hist/dyjet_Pnchg5pairpt2");
> > Error in <TFile::cd>: Object Ana is not a directory (I am not sure if
> > this was an error before or a warning)
> > root [2] f->ls()
> > OBJ: TProfile dyjet_Pnchg5pairpt2 dyjet: TRV - <No of Charged> vs
> > Lepton Pair PT (Z Range) : 0 at: 0x8cf7270
> > (...and my other histograms with similar lines)
> >
> > Regards,
> > Deepak
> >
> > On Tue, Apr 21, 2009 at 8:54 AM, Axel Naumann <Axel.Naumann_at_cern.ch> wrote:
> > > Hi Deepak,
> > >
> > > CINT claims hist2 is NULL, which means that gen.root does not contain
> > > Ana/dyjet/Hist/dyjet_Pnchg5pairpt2. Could you send the output of
> > >
> > > TFile *f= new TFile("gen.root");
> > > f->cd("Ana/dyjet/Hist/dyjet_Pnchg5pairpt2");
> > > f->ls()
> > >
> > > Cheers, Axel.
> > >
> > > Deepak Kar wrote on 04/21/2009 01:22 AM:
> > > > Hello folks!
> > > >
> > > > I am sure I am missing something trivial here. I had a bunch of codes
> > > > before, and they ran fine. After a while I am trying to run them,
> > > > without changing anything to my knowledge. They are all crashing with
> > > > the same error, and this just a simple example.
> > > >
> > > > {
> > > > gROOT->Reset();
> > > >
> > > > TFile *f= new TFile("gen.root");
> > > > TProfile *hist2=(TProfile*)
> > > > gDirectory->Get("Ana/dyjet/Hist/dyjet_Pnchg5pairpt2");
> > > >
> > > > TFile *f=new TFile("ze_tlt.root");
> > > > TProfile *hist3=(TProfile*)
> > > > gDirectory->Get("Ana/dyjet/Hist/dyjet_Pnchg5pairpt2");
> > > >
> > > >
> > > > for(i=1;i<=31;i++){
> > > > xbin1= hist2->GetBinCenter(i);
> > > > gen = hist2->GetBinContent(i);
> > > > sim = hist3->GetBinContent(i);
> > > > printf("MC bin, Gen/SIM = %f, %f,\n",gen/sim);
> > > > }
> >>> }
> > > >
> > > > It crashes with:
> > > >
> > > > Warning: Automatic variable i is allocated draw_ratio.C:19:
> > > > Error: illegal pointer to class object hist2 0x0 1046 draw_ratio.C:20:
> > > > Warning: Automatic variable xbin1 is allocated draw_ratio.C:20:
> > > > Error: Undeclared variable xbin1 draw_ratio.C:20:
> > > > *** Interpreter error recovered ***
> > > >
> > > > The .root files are all there, so are the histograms in that path.
> > > >
> > > > Thanks a lot for any input.
> > > >
> > > > Deepak
> > > >
> > > >
> >
>
>
Received on Tue Apr 21 2009 - 12:34:12 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 21 2009 - 17:50:01 CEST