I am trying to make two separate TLorentz Vectors for -kaon(pdgcode=-321) and pion(pdgcode=211) so that I can add them and extract the mass to D0. But I am not able to do so because the arrays are involved.
However, I have managed to get the histograms for the momenta and energy for the kaon and the pion. I am using this file: reconstruct_D0.C (3.4 KB). and here’s a the root file: FileName.root
Hi,
This sounds like you’d be better off getting some input / help from your supervisor rather than at the ROOT forum, to understand how to write the analysis. Let us know if there’s something ROOT specific that we can help with!
Cheers, Axel.
Here also, I want to do a similar thing. The only difference is that in the above code I am not dealing with TTreeReaderArrays. I wanted some help in dealing with the looping for the TTreereader arrays. So that I can make two separate TLorentx vectors like:
Hi @sanjeeda ,
I don’t quite understand the question but trying to guess I think the problem might be that you have 4 TTreeReaderArrays containing a list of px, py, pz and E values and you want to build a TLorentzVector for each of them?
You can do it with a loop:
std::vector<TLorentzVector> lorentzvectors;
for (int i = 0; i < px.GetSize(); ++i)
lorentzvectors.emplace_back(px[i], py[i], pz[i], E[i]);
Hi @sanjeeda ,
this is a normal C++ compilation error. You are trying to call the method Mag on lorentzvectors, which is of type std::vector<TLorentzVector>, and the compiler complains that std::vector does not have that method.
If you want to call Mag on an element of the vector you have to access that element first, e.g. lorentzvectors[i].Mag() where i is the index of the element you want.
Processing: test.tar.xz…
Hi
Let me explain the problem in detail what sanjeeda and me are facing more clearly
We are reading the px, py, pz and Energy values from Treereader from input root file (attached)
we want to make a Lorentzvector from these values.
So far, we are able to read the values from input file, but here we face issues while making Lorentz vector inorder to get the mass of particle.
We tried your method as you suggested, but it gives the mass values: nan, inf or zero (see below)
====================== Run time output (cout statement)=========
I am not sure if we are setting up the lorentz vector correctly here.
Can you please have a look on code script and input root file attached in this link
(inputfile – Google Drive)and suggest us for correct solution.