Problem with splitting a ROOT class

I have a TObject defined below

class Muon_Track : public TObject {
public:
    Int_t n = 0;
    Double_t *X;      //[n]
    TFitResult fit[3];

    Double_t chi2[3]; 
    TVector3 v;        
    TVector3 r0;       
    TVector3 vError; 
    TVector3 r0Error; 
	
    Muon_Track();
    ~Muon_Track();
    
    void Fit(); // sets fit, chi2, v,r0,vError,r0Error

private:
    Color_t markerColour = kBlue+2; //!
    Color_t lineColour = kBlue+2;   //!
    Style_t markerStyle = 20;       //!
    
    ClassDef(Muon_Track,1)
};

And I’m trying to write to it using the following

// File and Tree for output
TFile fOut(output.c_str(), "recreate");
TTree tOut("t", "Muon Track Tree");

Muon_Track* M = new Muon_Track();
M->X = new Double_t[MAXN];

tOut.Branch("M","Muon_Track",&M,8000,1);

...
std::vector<Double_t> X_vec;
...
X_vec.push_back(some_value);
...
M->X = X_vec.data();
tOut.Fill();

When I try to run the executable I get the following output

Warning in <TTree::Bronch>: Muon_Track cannot be split, resetting splitlevel to 0

It works just fine with the root interpreter though

Makefile.txt (1.1 KB)

Did you use

#pragma link C++ class  Muon_Track+;

(note the trailing +) in the LinkDef.h file?

No, LinkDef.h looks like:

#ifdef __CINT__
#pragma link C++ class Muon_Track;
#endif

This is the problem. Without the +, this request the old style I/O for that class and that does not support splitting.
Add the + and regenerate the dictionary and it should work as expected.

Cheers,
Philippe.

That worked, thankyou!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.