but I receive the error:
‘Error in TTree::SetBranchAddress: unknown branch -> McEventCollection_p5_GEN_EVENT/m_genParticles/m_px’.
I’m aware the SetBranchAddress line is incorrect in formalism (I don’t think you can / separate the branches) but I’m not sure what the correct form should be. Is there a simple way around this?
[quote]I’m aware the SetBranchAddress line is incorrect in formalism (I don’t think you can / separate the branches)[/quote]This is not accurate. Please review the User’s Guide chapter on TTree and reading data out of it or check the result of TTree::MakeClass, MakeSelector and MakeProxy.
"McEventCollection_p5_GEN_EVENT/m_genParticles/m_px"This is unlikely to be the correct branch name. How did you derive this name?
Since there is a trailing ‘s’ in the name of the data member I am guessing this is actually a collection. You will get more than one float per entry. I.e. you need to pass an array rather than a single variable.
Also how did you derive that m_px was of type ‘float’, this is unusual (but possible). We most often see ‘double’.
I am guessing something like this might work for you …
inputTree->SetMakeClass(true);
const int kMaxNumberOfGenParticles = .....;
Double_t px[kMaxNumberOfGenParticles]
inputTree->SetBranchAddress("McEventCollection_p5_GEN_EVENT.m_genParticles.m_px", &(px[0]));
Or you may want to investigate using the TTreeReader instead.
Thanks for the suggestions. I’ve tried the following code:
TFile* inputFile = new TFile("/afs/cern.ch/user/a/afray/public/PhD/SpuriousSignalSyst/JIRA_v2_copy/pool.root", "READ");
TTree* inputTree = (TTree*)inputFile->Get("CollectionTree");
inputTree->SetMakeClass(true);
const int kMaxNumberOfGenParticles = 1000;
Double_t px[kMaxNumberOfGenParticles];
inputTree->SetBranchAddress("McEventCollection_p5_GEN_EVENT.m_genParticle.m_px", &(px[0]));
but I receive the error
Error in TTree::SetBranchAddress: unknown branch -> McEventCollection_p5_GEN_EVENT.m_genParticles.m_px
I’m not sure why the branches are named as such. It’s an output file from running a command needed to validate a job option file for an MC production request via JIRA.
But to clarify, the file is structured such that:
CollectionTree (Tree) -> McEventCollection_p5_GEN_EVENT (Branch) -> m_genParticles (SubBranch of previous) -> m_px (Leaf variable of interest).
m_px being a float was purely a guess, using a double in retrospect is a better choice.
I will read up on TTreeReader and look at the User’s Guide TTree section, unless you have any other ideas.
Error in TTree::SetBranchAddress: unknown branch -> McEventCollection_p5_GEN_EVENT.m_genParticles.m_px[/quote]The name I used was just a guess. See the result of TTree::Print or TTree::MakeSelector to have a better idea of the actual branch names. (and if m_genParticles is not split, you will need to either use the original shared library or the result of MakeProxy (or the TTreeReader might also work).