Addition and Subtraction of TLorentzVector


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


Hi Everyone,
I have five TLorentzVectors. I want to do the following mathematical operation but sometimes it is giving me plot but sometimes the plot is coming out to be empty. Please check the following code.
mathematical operation is something like this: p1 - p2 -p3 -p4 - p5 - p6.
I use ROOT6.14.
Need help to write it.
“”""""""""""""""""""""""""""""

void lfv2()
{
  TFile* f3= new TFile("/home/souvik/root_work/lfv2.root");
  TTree* t3=(TTree*)f3->Get("tree");
  float pd1[4];
  float pd3[4];
  float pd4[4];
  float pd5[4];
  float pd6[4];

  t3->SetBranchAddress("Upsilon4S_P4", &pd1);
  t3->SetBranchAddress("Upsilon4S_D0_P4", &pd3);
  t3->SetBranchAddress("Upsilon4S_pi_P4", &pd4);
  t3->SetBranchAddress("Upsilon4S_K_S0_P4", &pd3);
  t3->SetBranchAddress("Upsilon4S_gamma_P4", &pd4);


  TH1F *hist3 = new TH1F("", "Adding two four momenta ", 50, 1.7, 3.5);
  TCanvas* c2 = new TCanvas();
  c2->cd();
  Int_t n_tot3 = (Int_t)t3->GetEntries();
  for (int i=0; i<n_tot3 ;i++)

    {
      t3->GetEntry(i);
      TLorentzVector lv_B_pi0(pd1);
      TLorentzVector lv_B_pi1(pd3);
      TLorentzVector lv_B_pi2(pd4);
      TLorentzVector lv_B_pi3(pd5);
      TLorentzVector lv_B_pi4(pd6);
      const auto this_mass =(lv_B_pi0- lv_B_pi1-lv_B_pi2-lv_B_pi3-lv_B_pi4).Mag();

      {
                                                                                                                                                                                         
        hist3->Fill(this_mass);
                                                                                                                                          
      }
    }
      hist3->Draw();
}

Thanks and Regards

Maybe:

  t3->SetBranchAddress("Upsilon4S_K_S0_P4", &pd5);
  t3->SetBranchAddress("Upsilon4S_gamma_P4", &pd6);

And remove “const”.

BTW. When you post “source code” or “output” here, do remember to enclose them into two lines which contain just three characters ``` (see how your post has been edited above).

Thanks for the reply. I will keep in mind that.
It is giving me a line around zero. If I plot one single variable(i.e lv_B_pi0.Mag() ), it is giving correct plot. But when I am adding them then it is creating problem.

Need Suggestions
Thanks

Hi,

Can you

  • post the actual, current code, e.g. as attachment
  • copy & paste the output of t3->Scan()
  • copy & paste the output of t3->Print()

Finally, please add the line

std::cout << "DEBUG: " << pd1[0] << ',' << pd1[1] << ',' << pd1[2] << ',' << pd1[3] << '\n';

after the the t3->GetEntry(i) and copy & paste the output.

And we ask you to provide the ROOT version and platform for a reason :slight_smile: Could you please state it?

Cheers, Axel.

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