"Incorrect referencing" error

Hello,

I am trying to read back in ROOT an object that I have previously created and saved in a file. The header file from the object is below

[code]#ifndef RTCALIB_HH
#define RTCALIB_HH

#include “TNamed.h”
#include
#include
using namespace std;

class T0Result;
class AthIndex;

class RTCalib : public TNamed {
public:
RTCalib();
virtual ~RTCalib();

T0Result& getT0Fit(const AthIndex& index);
T0Result& getT0Fit(const string& index);
double driftTime(const AthIndex& index, double rawdt);
double radius(const AthIndex& index, double rawdt);

T0Result* getT0FitUnSafe(const AthIndex& index);
T0Result* getT0FitUnSafe(const string& index);

private:

map<string,T0Result*> _t0res;

ClassDef(RTCalib,1) // container and calculator of the RT calibrations
};
#endif
[/code]

My program basically writes this object to a file by doing the following:

TFile* f = TFile::Open("tmp.root", "recreate"); calib->Write(); f->Close();

After that, I try to read back the object in a root session interactively:

[code]$ root tmp.root


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 4.03/02 14 March 2005 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      http://root.cern.ch            *
    
  •                                     *
    

FreeType Engine v2.1.3 used to render TrueType fonts.
Compiled for linuxdeb with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.159, Nov 14 2004
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Attaching file tmp.root as _file0…
root [1] .ls
TFile** tmp.root
TFile* tmp.root
KEY: RTCalib calib;1 RT Calibrations
KEY: TH1F caldrt;1 caldrt
root [2] calib
Error: Incorrect referencing of $calib FILE:(tmpfile) LINE:1
(class RTCalib*)0x8cdaeb8
*** Interpreter error recovered ***
[/code]

I have no idea what this error means: could you help me understanding what is wrong?

I can post more information from my code if what I have given isn’t enough

Thanks

Pierre-François Giraud

To investigate the problem, set the debug option active
root > gDebug = 2
root > calib

My guess is that your class has a bad default constructor where your map
object is not initialized.

Rene

Dear René,

Thanks very much for the advice, however it does not solve my problem.

I cannot find anything relevant in the debug dump (I am attaching it to this mail for reference)

My default constructor for RTCalib does essentially nothing, apart from calling map’s default constructor

[code]RTCalib::RTCalib() {

}
[/code]

What else should be there?

Thanks

Pierre-François Giraud
AthIndex.h (795 Bytes)
T0Result.h (752 Bytes)
debug.dump.txt (33.7 KB)

Could you run under gdb and send the traceback when it crashes
gdb root.exe
gdb > r
root > gDebug=2
root > calib
crash
gdb > bt

Rene

René,

root does not crash when this happens. I can even use the calib object without errors after the problem occurs, though I am not sure that its data is correct

Pierre-François Giraud

I think I have found the source of my problems.

I had a LinkDef.h file which contained the following line:

#pragma link C++ class RTCalib+;

I replaced it with:

#pragma link C++ class RTCalib;

And the problem (seems to) goes away completely.

Now I am deeply frustrated because I have no idea of what I am doing, and what is happening to my class when changing this LinkDef option…

Pierre-François Giraud

Hi,

This a problem is CINT (I am trying to find a solution).
You should keep the ‘+’ in the linkdef but you should use the following code

to access the object.

Cheers,
Philippe.

The fix for this problem should be uploaded in CVS shortly.

Cheers,
Philippe.