Problem returning a TTree pointer

Hello Root-users!
I’m going to explain you my problem.

I’ve a generic class in which I’ve defined this two methods

[quote]class Instrument {

public:
virtual Int_t getNumber() = 0;
virtual TTree *getData(Double_t RUN, Int_t Inst_Number){};
virtual void plotChannel(TTree *T, Int_t Number)=0;
};
[/quote]

After this definition, there’s another class derivated from Instrument. This class overrides the method getData in this way.

This is the class

[quote]class Instrument2:public Instrument
{
private:
Int_t Instrument_Number = 0;

public:
Instrument2();
Instrument2(Int_t Number);
Int_t getNumber() { return this->Instrument_Number; }
void setNumber(Int_t Number) { this->Instrument_Number = Number; }
virtual getData(Double_t RUN, Int_t Inst_Number);
virtual void plotChannel(TTree *T, Int_t Number);

};[/quote]
And this is the getData method override:

[quote]Instrument2::getData(Double_t RUN, Int_t Instr_Number)
{

TFile f(Form("blabla%f.root", RUN));
TTree *inTree = (TTree*)f.Get("GenInfos");
TTree *Tpoint = (TTree*)f.Get(Form("LS_%i", Instr_Number));
return Tpoint;

};[/quote]

When i test this derivate class in a void Instrument2 class

[quote]void Instrument2(){
Instrument *a = new Instrument2(12);
TTree *T1=a->getData( 3.0, 12);
T1->Show(3);

}
[/quote]

CINT says that there’s a wrong assignment in T1. ‘int’ type. I’ve tryed also a (TTree*) casting before a->getData but nothing.

Any ideas?
Thanks
Salvatore Uttaro

Hi Salvatore,

one of your snippets might have a typo:

class Instrument2:public Instrument
{
private:
Int_t Instrument_Number = 0;

public:
Instrument2();
Instrument2(Int_t Number);
Int_t getNumber() { return this->Instrument_Number; }
void setNumber(Int_t Number) { this->Instrument_Number = Number; }
virtual getData(Double_t RUN, Int_t Inst_Number);
virtual void plotChannel(TTree *T, Int_t Number);
};

They return type of getData is not specified: this should not compile.
I think I need more info to help you:

  1. Can you clarify the remark above?
  2. Can you compile this code with a compiler? What happens?
  3. Does the error persist when using ROOT6?

Danilo

Ya Danilio you’re right. I’ve specified the type (TTree type) but nothing changes. Always a wrong type assignment (‘int’). And this sounds REALLY strange.

Unfortunally right now i cannot access to a compiler and a root 6 version…I will give you more details when I do it.