I was pleasantly surprised that it was feasible to use TTree::Draw to make use of
member functions of things like TLorentzVector.
For example with a TLorentzVector Pgen
Now, I’m trying to port the analysis of this tree to a TTree::MakeClass like main loop
(along the lines of good old nt/loop …) but with the advantages of the object interface.
I want the flexibility of access to each individual event variable for doing more complex stuff than
is comfortable with the TTree::Draw interface.
Initially I had issues with non-unique identifiers but I fixed this
when spotting the need for the dot as a result of identical branch names
associated with the sub-branches.
EvtTree->Branch(“Pgen”,&Pgen); // not good
EvtTree->Branch(“Pgen.”,&Pgen); // works
But when generating the MyClass.h and MyClass.C files with MakeClass
the structure seems OK, but there is no automatic configuration of
the underlying TLorentzVector.
The individual components are there OK, namely
Pgen_fP_fX,Pgen_fP_fY,Pgen_fP_fZ,Pgen_fE of type Double_t, but no Pgen TLorentzVector.
I added code like
TLorentzVector Pgen = TLorentzVector(Pgen_fP_fX,Pgen_fP_fY,Pgen_fP_fZ,Pgen_fE);
cout << "Pgen " << Pgen.Px() << " " << Pgen.Py() << " " << Pgen.Pz() << " " << Pgen.E()
<< " " << Pgen.CosTheta() << " " << Pgen.Phi() << endl;
and the corresponding TLorentzVector.h header file and this manual method worked, but this is
pretty clunky and error prone if used for many such objects.
Is this not something that one should expect to be supported automatically if the TTree is meant to
be able to store an object in a flexible manner ?
Or is there some other more suitable way to accomplish what I want to do ?
thanks Graham Wilson