Re: [ROOT] TGraphSmooth

From: Federico Roncarolo (Federico.Roncarolo@cern.ch)
Date: Thu Mar 21 2002 - 11:04:11 MET


Hello,

please find below a simple example concerning my problem.
I never get errors in compiling with gmake (I also put the Makefile
below). 
While executing sometimes it is working, often I get the message

pure virtual method called
Abort (core dumped)

depending if I include the lines 

TGraph *grout=new TGraph(20);
TGraphSmooth *gs1 = new TGraphSmooth("g");	

in the source.
I don't have a real c++ backgound... maybe I miss something basilar, like
calling a destructor or something like that...

At the moment I wrote a .C version of my complete code, I use .L file.C
and it works always... but I would like to implement it in the more
flexible way where I can compile with gmake...

Thanks a lot, Federico

//File: my_test.cxx:

#include <iostream.h>
#include "TCanvas.h"
#include "TGraph.h"
#include "TGraphSmooth.h"
#include "TStyle.h"
#include "G__ci.h"
#include "TObject.h"
#include "TApplication.h"


//___________________________________
int main(int argc, char **argv)
{ 

    
  TApplication theApp("App", &argc, argv);

  TCanvas *MyC = new TCanvas("test","test",0);

  
  MyC->Divide(1,2);
  MyC->cd(1);
  Int_t n=20;
  Float_t x[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  Float_t y[20]={-2.1,-1.6,-2.2,1.4,-1.0,.1,.9,.5,1.1,1.5,
		 .8,1.2,1.8,2.2,1.6,1.1,1.3,.7,.3,0.0};

  TGraph *grq1 = new TGraph(n,x,y);
  
  grq1->Print();
  grq1->Draw("ALP");
  
  TGraph *grout=new TGraph(20);
  TGraphSmooth *gs1 = new TGraphSmooth("g");
    
  grout = gs1->Approx(grq1,"linear",40);
  MyC->cd(2);
  
  grout->Draw("ALP");
    
     
  theApp.Run(); 
  gApplication->Terminate(); 
}

//Makefile:
ARCH          = linuxegcs

CXX           =
ObjSuf        = o
SrcSuf        = cxx
ExeSuf        =
DllSuf        = so
OutPutOpt     = -o 

EVENTLIB      = $(EVENTSO)

ROOTCFLAGS   := $(shell root-config --cflags)
ROOTLIBS     := $(shell root-config --libs)
ROOTGLIBS    := $(shell root-config --glibs)


ifeq ($(ARCH),linuxegcs)
# Linux with egcs (>= RedHat 5.2)
CXX           = g++
CXXFLAGS      = -O -Wall -fPIC
LD            = g++
LDFLAGS       = -O
SOFLAGS       = -shared
endif

#_____________________________________________________________________________

ifeq ($(CXX),)
$(error $(ARCH) invalid architecture)
endif

CXXFLAGS     += $(ROOTCFLAGS)
LIBS          = $(ROOTLIBS) $(SYSLIBS)
GLIBS         = $(ROOTGLIBS) $(SYSLIBS)

#------------------------------------------------------------------------------

FIT_Q_VERO    = fit_q_ver.$(ObjSuf)
FIT_Q_VERS    = fit_q_ver.$(SrcSuf)
FIT_Q_VER     = fit_q_ver$(ExeSuf)

MY_TESTO      = my_test.$(ObjSuf)
MY_TESTS      = my_test.$(SrcSuf)
MY_TEST       = my_test$(ExeSuf)



OBJS          = $(FIT_Q_VERO) $(MY_TESTO)

PROGRAMS      = $(FIT_Q_VER) $(MY_TEST)

#------------------------------------------------------------------------------

.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
.PHONY:

all:            $(PROGRAMS)

		@echo "$@ done"

$(FIT_Q_VER):      $(FIT_Q_VERO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		@echo "$@ done fit_q_ver"

$(MY_TEST):      $(MY_TESTO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		@echo "$@ done my_test"

clean:
		@rm -f $(OBJS) core

distclean:      clean
		@rm -f $(PROGRAMS) $(EVENTSO) $(EVENTLIB) *Dict.* *.def
*.exp \
		   *.root *.ps *.so .def so_locations
		@rm -rf cxx_repository

.SUFFIXES: .$(SrcSuf)

###

.$(SrcSuf).$(ObjSuf):
	$(CXX) $(CXXFLAGS) -c $<

//_______________________________________________________________________


 __________________________________________________
Federico Roncarolo     federico.roncarolo@cern.ch       
                            alchemist@infinito.it     
CERN SL/BI 865 1-A27

Tel:
+41.(0)22.76.75611	Work 
+41.(0)79.6982190 	GSM                              
+33.(0)4.50.40.82.67 	Home
__________________________________________________

On Wed, 20 Mar 2002, Rene Brun wrote:

> Hi Federico,
> 
> Impossible to come with a diagnostic with only these few lines.
> Could you provide a short example that we can use to understand your problem?
> 
> Rene Brun
> 
> Federico Roncarolo wrote:
> > 
> > Hello,
> > 
> > I'm trying to interpolate a graph with TGraphSmooth,
> > I'm working in linux, my makefile looks to compile properly the file .cxx
> > in which I put:
> > 
> >         .....
> >         .....
> >         TGraph *grq1 = new TGraph(ncycles,vtime,vmax);// properly drawn
> > 
> >         TGraph *grout=new TGraph(ncycles+12);
> >         TGraphSmooth *gs1 = new TGraphSmooth();
> > 
> >         Double_t xout[12];
> >         Int_t add;
> >         Double_t dt=90e-3;
> >         Double_t t0=784e-3;
> > 
> >         for(add=0;add<12;add++) xout[add]=t0+add*dt;
> > 
> >         grout = gs1->Approx(grq1,"linear",ncycles+12,xout,0,2);
> >         //the program clearly
> >         //stops at this line
> >         .....
> >         .....
> > 
> > but while executing I get the message
> > 
> >         pure virtual method called
> >         Abort (core dumped)
> > 
> > what's wrong?
> > 
> > Thanks a lot,
> > Federico
> > 
> > __________________________________________________
> > Federico Roncarolo     federico.roncarolo@cern.ch
> >                             alchemist@infinito.it
> > CERN SL/BI 865 1-A27
> > 
> > Tel:
> > +41.(0)22.76.75611      Work
> > +41.(0)79.6982190       GSM
> > +33.(0)4.50.40.82.67    Home
> > __________________________________________________
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET