How can I find Magnitude of Lorentz vector v(Px, Py, Pz, E )

I want to find the magnitude of Lorentz vector v(Px, Py, Pz, E).

TLorentzVector lorentzvectors_K(K_px[i], K_py[i], K_pz[i], K_energy[i]);
What is the command to find that?

ROOT Version: 6.24/00
Platform: Ubuntu 18.04 LTS

Check out the documentation for TLorentzVector:
https://root.cern/doc/master/classTLorentzVector.html

Thank you for your reply @dastudillo ,

My root code is,

#include "TLorentzVector.h"
#include <iostream>	
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TCanvas.h"
#include "TTree.h"
using namespace std;

void reconstruct_D0mass()
  
{
	TFile *file0 = new TFile("rootfille.root");
TTreeReader reader("events;1", file0);
  
  TTreeReaderArray<Float_t> pxArray(reader, "Reconstruct.p.x");
  TTreeReaderArray<Float_t> pyArray(reader, "Reconstruct.p.y");
  TTreeReaderArray<Float_t> pzArray(reader, "Reconstruct.p.z");
  TTreeReaderArray<Float_t> energyArray(reader, "Reconstructenergy");
  TTreeReaderArray<Int_t> pdgArray(reader, "Reconstructs.pid");

Int_t n = 70000;
  Double_t K_px[n];
  Double_t K_py[n];
  Double_t K_pz[n];
  Double_t K_energy[n];
  Double_t K_M;

  Double_t pi_px[n];
  Double_t pi_py[n];
  Double_t pi_pz[n];
  Double_t pi_energy[n];
  Double_t pi_M;
  Double_t Dz_M;

  Double_t K_px_new1[n];
  Double_t K_py_new1[n];
  Double_t K_pz_new1[n];
  Double_t K_energy_new1[n];

// for K
  TLorentzVector lorentzvectors_K[n];
   for (int i = 0; i < pxArray.GetSize(); ++i)
    {
      TLorentzVector lorentzvectors_K(K_px[i], K_py[i], K_pz[i], K_energy[i]); //.emplace_back
    }
  
// for Pi
  TLorentzVector lorentzvectors_pi[n];
    for (int i = 0; i < pxArray.GetSize(); ++i)
    {
      TLorentzVector lorentzvectors_pi(pi_px[i], pi_py[i], pi_pz[i], pi_energy[i]);  //.emplace_back
    }
  
// for D
 TLorentzVector lorentzvectors_Dz[n];
       
  while (reader.Next())
    {

      for (auto pdg: pdgArray)
      {
	  if(pdg==-321)
	    {      
	      Double_t K_M;
	      //std::vector<TLorentzVector> lorentzvectors_K;
	      for (int i = 0; i < pxArray.GetSize(); ++i)
		{
		  //put PDG condition for pion and kaon inside the px array size loop
		  K_px[i] = pxArray[i];
		  K_py[i] = pyArray[i];
		  K_pz[i] = pzArray[i];
		  K_energy[i] = energyArray[i];
		  //cout<<"K_px[i] = "<<K_py[i]<<endl;
		  //L_k = TLorentzVector(K_px[i], K_py[i], K_pz[i], K_energy[i]);
		  TLorentzVector lorentzvectors_K(K_px[i], K_py[i], K_pz[i], K_energy[i]);  // .emplace_back
		  K_M = lorentzvectors_K[i].Mag();
		  //cout << " kaon_mass = " << K_M << endl;
		  //h9->Fill(K_M);
		}
	    }
	  cout << "1" << endl;
	/*  

      if(pdg==211)
	{ 
	  for (auto pi_px_new: pxArray)
	    //h5->Fill(pi_px_new);

	  for (auto pi_py_new: pyArray)
	    //h6->Fill(pi_py_new);

	  for (auto pi_pz_new: pzArray)
	    //h7->Fill(pi_pz_new);

	  for (auto pi_energy_new: energyArray)
	    //h8->Fill(pi_energy_new);

	  
	  Double_t pi_M;
	  //std::vector<TLorentzVector> lorentzvectors_pi;
	  for (int i = 0; i < pxArray.GetSize(); ++i)
	    {
	      pi_px[i] = pxArray[i];
	      pi_py[i] = pyArray[i];
	      pi_pz[i] = pzArray[i];
	      pi_energy[i] = energyArray[i];
	      //cout<<"pi_px[i] ="<<pi_py[i]<<endl;

	      TLorentzVector lorentzvectors_pi(pi_px[i], pi_py[i], pi_pz[i], pi_energy[i]); //.emplace_back
              pi_M = lorentzvectors_pi[i].Mag();
	      //cout << " pion_mass = " << pi_M << endl;
              //h10->Fill(pi_M);
	    }

	}
}

I am getting this error.

 error: member reference base type 'Double_t' (aka 'double') is not a structure or union
                  K_M = lorentzvectors_K[i].Mag();
                        ~~~~~~~~~~~~~~~~~~~^~~~

What to do now? How can i troubleshoot this error?

In the place where you call “Mag”, the “lorentzvectors_K” is an ordinary local variable (created just in the previous line) and not an array (i.e., “[i]” makes no sense there, if you want to get its “Mag”).