Problem with MakeClass generated code

Hi,

I have the following two branches in a ROOT tree:

cloneGenParticle = new TClonesArray("GenParticle"); tree->Branch("GenParticle", &cloneGenParticle, 32000, 2); tree->Branch("nGenParticle", &fnGenParticle, "fnGenParticle/I");

where GenParticle is declared as:

[code]class GenParticle: public TObject {
public:
GenParticle();
~GenParticle() {}

double eta;
double phi;
double p;
double px;
double py;
double pz;
double pt;
double energy;
int pdgId;
double vx;
double vy;
double vz;
int status;
int numDaught;
int numMother;
int motherIndex;
std::vector motherIndices;
std::vector daughtIndices;

ClassDef(GenParticle,3)
};[/code]

Afterwards when I use TTree::MakeClass to create the code skeleton, I cannot correctly access the two vectors in the above class. TTree::MakeClass generates the following code for the two vectors:

vector<int> GenParticle_motherIndices[kMaxGenParticle]; vector<int> GenParticle_daughtIndices[kMaxGenParticle];

TBranch *b_GenParticle_motherIndices; //! TBranch *b_GenParticle_daughtIndices; //!

and

fChain->SetBranchAddress("GenParticle.motherIndices", GenParticle_motherIndices, &b_GenParticle_motherIndices); fChain->SetBranchAddress("GenParticle.daughtIndices", GenParticle_daughtIndices, &b_GenParticle_daughtIndices);

So I suppose the above is not the right way to do the job. Where am I going wrong here?

Thanks,

  • Subir

Hi,

Which version of ROOT are you using?

Philippe.

Hi Philippe,

I’m using ROOT Version 5.27/06b (more specifically 5.27.06b-cms21)

Thanks,

  • Subir

Hi,

MakeClass creates a skeleton that (tries to) decompose the object in its component and explicitly does not support any objects. In particular this precludes the use of nested non split object (like the vector).

To solve the problem either load the shared library that defines GenParticle and replaces all the data members by the single TClonesArray and the setting of the branch by a single branch and remove the call to SetMakeClass.

Alternatively, you can use TTree::MakeProxy instead of MakeClass.

Cheers,
Philippe.

Hi Phillipe,

Thanks. I shall follow your suggestion.

Regards,

  • Subir