I have been using this code to plot the mass, momentum of tauon-antitauon pirs and their mother particle zboson, but the TTree are just blank

//Sorting τ- and τ+ fron Zboson created from pp collision:

#include "Pythia8/Pythia.h"
#include "TLorentzVector.h"
#include "TTree.h"
#include "TFile.h"

using namespace Pythia8;

int main() {
  // Set up Pythia.
  Pythia pythia;

  // Allow no substructure in e+- beams: normal for corrected LEP data.
  // pythia.readString("PDF:lepton = off");
  // Process selection.
  pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
  pythia.readString("WeakZ0:gmZmode = 2");


  // Switch off all Z0 decays and then switch back on those to tauons.
  pythia.readString("23:onMode = off");
  pythia.readString("15:onMode = off");
  pythia.readString("-15:onMode = off");
  pythia.readString("23:onIfAny = 15");
  pythia.readString("23:onIfAny = -15");

  // LEP1 initialization at Z0 mass.
  pythia.readString("Beams:idA =  2212");
  pythia.readString("Beams:idB =  2212");
  double mZ = pythia.particleData.m0(23);
  // pythia.settings.parm("Beams:eCM", mZ);
  pythia.readString("Beams:eCM =  1400");
  pythia.readString("HardQCD:all = off");
  pythia.readString("HadronLevel:Hadronize = off");
  pythia.init();

  // Create the output file and TTrees.
  TFile* output = new TFile("try10.root", "RECREATE");
  TTree* treeTauon = new TTree("treeTauon", "Tauon Branches");
  TTree* treeAntitauon = new TTree("treeAntitauon", "Antitauon Branches");
  TTree* treeZBoson = new TTree("treeZBoson", "ZBoson Branches");

  // Define variables for TTree branches.
  Int_t iEvent, no;
  Float_t m, px, py, pz;

  // Create branches for the Tauon tree.
  treeTauon->Branch("iEvent", &iEvent, "iEvent/I");
  treeTauon->Branch("m", &m, "m/F");
  treeTauon->Branch("no", &no, "no/I");
  treeTauon->Branch("px", &px, "px/F");
  treeTauon->Branch("py", &py, "py/F");
  treeTauon->Branch("pz", &pz, "pz/F");

  // Create branches for the Antitauon tree.
  treeAntitauon->Branch("iEvent", &iEvent, "iEvent/I");
  treeAntitauon->Branch("m", &m, "m/F");
  treeAntitauon->Branch("no", &no, "no/I");
  treeAntitauon->Branch("px", &px, "px/F");
  treeAntitauon->Branch("py", &py, "py/F");
  treeAntitauon->Branch("pz", &pz, "pz/F");

  // Create branches for the Z Boson tree.
  treeZBoson->Branch("iEvent", &iEvent, "iEvent/I");
  treeZBoson->Branch("m", &m, "m/F");
  treeZBoson->Branch("no", &no, "no/I");
  treeZBoson->Branch("px", &px, "px/F");
  treeZBoson->Branch("py", &py, "py/F");
  treeZBoson->Branch("pz", &pz, "pz/F");

  // Begin event loop.
  for (iEvent = 0; iEvent < 10000; ++iEvent) {
    // Generate event.
    pythia.next();

    // Check for events with tauon-antitauon pairs from Z bosons.
    bool hasTauonsFromZ0 = false;
    bool hasAntitauonsFromZ0 = false;
    TLorentzVector tauon;
    TLorentzVector antitauon;

    for (int i = 0; i < pythia.event.size(); ++i) {
      if ((pythia.event[i].id() == 15) && (abs(pythia.event[pythia.event[i].mother1()].id()) == 23) && (pythia.event[i].status() == 1)) {
        hasTauonsFromZ0 = true;
        tauon.SetPxPyPzE(pythia.event[i].px(), pythia.event[i].py(), pythia.event[i].pz(), pythia.event[i].e());

        // Fill tauon branch.
        no = pythia.event[i].id();
        m = pythia.event[i].m() * 1000.0;  // Convert mass from GeV to MeV
        px = pythia.event[i].px();
        py = pythia.event[i].py();
        pz = pythia.event[i].pz();
        treeTauon->Fill();
      }
    }

    for (int i = 0; i < pythia.event.size(); ++i) {
      if ((pythia.event[i].id() == -15) && (abs(pythia.event[pythia.event[i].mother1()].id()) == 23) && (pythia.event[i].status() == 1)) {
        hasAntitauonsFromZ0 = true;
        antitauon.SetPxPyPzE(pythia.event[i].px(), pythia.event[i].py(), pythia.event[i].pz(), pythia.event[i].e());

        // Fill antitauon branch.
        no = pythia.event[i].id();
        m = pythia.event[i].m() * 1000.0;  // Convert mass from GeV to MeV
        px = pythia.event[i].px();
        py = pythia.event[i].py();
        pz = pythia.event[i].pz();
        treeAntitauon->Fill();
      }
    }

    // If both tauon and antitauon are present, construct the Z boson and fill its branch.
    if (hasTauonsFromZ0 && hasAntitauonsFromZ0) {
      // Construct the Z boson from the tauon and antitauon.
      TLorentzVector zBoson = tauon + antitauon;

      // Fill Z boson branch.
      no = 23;
      m = zBoson.M();
      px = zBoson.Px();
      py = zBoson.Py();
      pz = zBoson.Pz();
      treeZBoson->Fill();
    }
  }

  // Write the trees to the output file and close it.
  output->Write();
  output->Close();

  // End of main program.
  return 0;
}

Check whether you are actually reaching the Fill lines, e.g.

// ...
    cout << "Filling Tauon with " << no << " " << m << endl; // etc. (px, py, pz)
    treeTauon->Fill();
// ...

and so on, and see if you get (the expected) output. The ROOT code seems ok, so maybe the problem is with Pythia, or with your cuts.

I think I checked. there were 0 entries. But the pythia Was showing Tauons are getting generated