Addition of two TLorentz Vectors to get mass


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi Everyone !
I have one root file and there I have six different trees. Each tree contains each and individual particle’s four momentum. I want to add all six TLorentz Vectors to get one particle’s mass. Can you please give me a skeleton code of it ?

Thanks in Advance.

Souvik

Hi,

         TLorentzVector p1, p2;
// Here fill the vectors
         const auto this_mass = (p1 + p2).M();

Cheers,
D

Thank you very much for your reply. Now I have one tree in a root file. There I want calculate mass from the four vector so I use the similar command attached below. But the plot is coming out to be empty. Can you please check it.

TFile* f2= new TFile("/home/souvik/root_work/lfv1.root");
TTree* t2=(TTree*)f2->Get(“dklfv”);
float pd3[4];
t2->SetBranchAddress(“D0_P4”, &pd3);

TH1F *hist2 = new TH1F("", " ", 50, 0, 10);
Int_t n_tot2 = (Int_t)t2->GetEntries();
TLorentzVector D0_fvec(pd3);
float fMomentum = D0_fvec.M();
for (int i=0;i<n_tot2; i++)

{
  t2->GetEntry(i);

  {

hist2->Fill(fMomentum);
cout<< i << " "<< fMomentum <<endl;
}
}
hist2->Draw();
1

Hi,

you do not specify what ROOT version you are using: I assume 6.14/06.
In this case, you can simply do:

ROOT::RDataFrame df("dklfv", "/home/souvik/root_work/lfv1.root");
auto massHisto = df.Define("m", "TLorentzVector(D0_P4.data()).M()").Histo1D("m");
massHisto.Draw();

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.