MakeClass not initializing branches containing arrays

I have a chain of trees and I use MakeClass to get the skeleton for the analysis. The problem is that the branches that contain arrays are not initialized in the header file. My guess is that is because the size of the array can’t be determined. In the part // Fixed size dimensions of array or collections stored in the TTree if any. no variables are declared. How can I get around this problem?

I checked and the problem persists even if the files are not chained. Attached is one of the files I’m using.

I am using Root version 6.06/02.

Thanks!

Andrea
BHWide_LER_12thCamp.root (1.55 MB)

Your “ECLData” tree does not have any “branches that contain arrays”. Try:
ECLData->Print();

BTW. I tried ROOT 5.34/36 and 6.06/04 and MakeClass seems to generate its files fine.

My bad, the branches I’m referring to are vectors. If you open the file in browser, I’m interested in the leaves CrystalHitPosition->fX, fY, fZ.

With the old version of the same file, the .h file contained

// Fixed size dimensions of array or collections stored in the TTree if any. const Int_t kMaxCrystalHitPosition = 1992;

Int_t CrystalHitPosition_; UInt_t CrystalHitPosition_fUniqueID[kMaxCrystalHitPosition]; //[CrystalHitPosition_] UInt_t CrystalHitPosition_fBits[kMaxCrystalHitPosition]; //[CrystalHitPosition_] Double_t CrystalHitPosition_fX[kMaxCrystalHitPosition]; //[CrystalHitPosition_] Double_t CrystalHitPosition_fY[kMaxCrystalHitPosition]; //[CrystalHitPosition_] Double_t CrystalHitPosition_fZ[kMaxCrystalHitPosition]; //[CrystalHitPosition_]
… and later the branch addresses were set. But I’m assuming I can’t just simply copy/paste from the old file because the kMaxCrystalHitPosition would be different. But in the new version, this is missing.

Since I also want to do this for a chain, how do I get around this problem?

Looks like the one who produces your ROOT files changed the “splitlevel” (or maybe switched from “TCLonesArray” to “vector”).
You can ask him/her to generate new ROOT files for you (with the old “splitlevel”), but I think you should start to use the existing “vectors”.

Ok, thanks!
Can you please tell me how do I access the leaves I need (fX, fY, fZ) in that case?

Hi,

I recommend you regenerate your MakeClass or better yet generate a MakeSelector instead. In v6, the MakeSelector will use the TTreeReader which make those use case a bit easier.

Cheers,
Philippe.

In the “Loop()” method generated by MakeClass, try something like: if (CrystalHitPosition) { // vector<TVector3> *CrystalHitPosition; for (unsigned int i = 0; i < CrystalHitPosition->size(); i++) { TVector3 &v = CrystalHitPosition->at(i); std::cout << jentry << " : " << i << " : " << v.x() << " " << v.y() << " " << v.z() << std::endl; } }

Thanks a lot to both of you for your suggestions!