Initializing Muon Vectors: How to

I am trying to reconstruct two Z bosons.
I am using this tutorial as an example. https://root.cern.ch/doc/master/df103__NanoAODHiggsAnalysis_8C.html
However, I am still not familiar in using ROOT data frame and I am writing it in terms of what I am familiar with.

What I do not understand is how can I define i1, i2, and idx that is shown in the ROOT tutorial?

In my tree, I have the BranchMuon and the variables in this branch are called Muon.PT, Muon.Eta, Muon.Phi and Muon.Charge, and Muon.Mass.

My attempt to follow the tutorial is constructing a muon vector and defining the variables (which generates errors but I am still learning how to work with it):

> #ifdef __CLING__
> 
> R__LOAD_LIBRARY(libDelphes)
> 
> #include "classes/DelphesClasses.h"
> 
> #include "external/ExRootAnalysis/ExRootTreeReader.h"
> 
> #include "external/ExRootAnalysis/ExRootResult.h"
> 
> #else
> 
> class ExRootTreeReader;
> 
> class ExRootResult;
> 
> #endif
> 
> #include <vector>
> 
> template<typename T>
> 
> void CollectionFilter(const TClonesArray& inColl ,vector<T*>& outColl, Double_t ptMin=30, Double_t etaMax=2.5)
> 
> {
> 
> const TObject *object;
> 
> for (Int_t i = 0; i < inColl.GetEntriesFast(); i++)
> 
> {
> 
> object = inColl.At(i);
> 
> const T *t = static_cast<const T*>(object);
> 
> if(t->P4().Pt() < ptMin) continue;
> 
> if(TMath::Abs(t->P4().Eta()) > etaMax) continue;
> 
> outColl.push_back(t);
> 
> }
> 
> }
> 
> //-------------------------------------Looking at Leptons -----------------------------------------
> 
> void selectMuon(const char *inputFile)
> 
> {
> 
>   gSystem->Load("libDelphes");
> 
>   // Create chain of root trees
> 
>   TChain chain("Delphes");
> 
>   chain.Add(inputFile);
> 
>   // Create object of class ExRootTreeReader
> 
>   ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
> 
>   Long64_t numberOfEntries = treeReader->GetEntries();
> 
>   // Get pointers to branches used in this analysis
> 
>   TClonesArray *branchMuon = treeReader->UseBranch("Muon");
> 
>   
> 
>   // Book histograms
> 
>  
> 
>   TH1F *histZMass = new TH1F("mass", "M_{inv}(Z[1]); M_inv (GeV/c^2); Events", 50, 0.0, 1500);
> 
>   TH1F *histDiMuonMass = new TH1F("mass", "M_{inv}(Z[3]Z[5]); M_inv (GeV/c^2); Events", 50, 0.0, 1500);
> 
>   
> 
>   // Define variables
> 
>   
> 
>   float_t PT, Eta, Phi, Mass, Charge;  
> 
>  
> 
>   // Initializing the vectors
> 
>   //vector<const Muon*>  *muons = new vector<const Muon*>();;
> 
>   MuonVector muon(PT, Eta, Phi, Mass, Charge);
> 
>      
> 
>   // Loop over all events
> 
>   for(Int_t entry = 0; entry < numberOfEntries; ++entry)
> 
>   {
> 
>     // Load selected branches with data from specified event
> 
>     treeReader->ReadEntry(entry);
> 
>              
> 
>     // Select leptons with pT > 10 GeV and |eta| < 2.5
> 
>     
> 
>     CollectionFilter(*branchMuon, *muons, 10.0, 2.5);
> 
>    
> 
>       muon1 = (*muon)[0];
> 
>       muon2 = (*muon)[1];
> 
>       if(muon1->Charge != muon2->Charge)
> 
>       {
> 
>         ROOT::Math::PtEtaPhiMVector m1(PT[0], Eta[0], Phi[0], Mass[0]);
> 
>         ROOT::Math:PtEtaPhiMVector m2(PT[1], Eta[1], Phi[1], Mass[1]);
> 
>         const mass = (m1 + m2).M();
> 
>       }
> 
>       
> 
>       TLorentzVector dimuon = (muon1 + muon2);
> 
>       histDiMuonMass->Fill(mass);   
> 
>     
> 
>   }
> 
>     
>       
> 
> //  - - - - - - - - - - - - - - Drawing the Histograms - - - - - - - - - - - - - - - - - - - - - -   
> 
>    
> 
>   } // end of event for loop
> 
>   histDiMuonMass->Draw();
> 
>   }

How can I define the two muon vectors? How can I write idx, i1 and i2?

EDIT: Below is my current progress:

I am trying to reconstruct two Z bosons.
I am using this tutorial as an example. https://root.cern.ch/doc/master/df103__NanoAODHiggsAnalysis_8C.html
However, I am still not familiar in using ROOT data frame and I am writing it in terms of what I am familiar with.

What I do not understand is how is i1, i2, and idx that is shown in the ROOT tutorial defined?

In my tree, I have the BranchMuon and the variables in this branch are called Muon.PT, Muon.Eta, Muon.Phi and Muon.Charge, and Muon.Mass.

My attempt to follow the tutorial is constructing a muon vector and defining the variables (which generates errors but I am still learning how to work with it):

#ifdef __CLING__
R__LOAD_LIBRARY(libDelphes)
#include "classes/DelphesClasses.h"
#include "external/ExRootAnalysis/ExRootTreeReader.h"
#include "external/ExRootAnalysis/ExRootResult.h"
#else
class ExRootTreeReader;
class ExRootResult;
#endif
#include <vector>

#include "ROOT/RDataFrame.hxx"
#include "ROOT/RVec.hxx"
#include "ROOT/RDF/RInterface.hxx"
#include "TCanvas.h"
#include "TH1D.h"
#include "TLatex.h"
#include "TLegend.h"
#include "Math/Vector4Dfwd.h"
#include "TStyle.h"
using namespace ROOT::VecOps;
using RNode = ROOT::RDF::RNode;
using rvec_f = const RVec<float> &;
using rvec_i = const RVec<int> &;
const auto z_mass = 91.2;

template<typename T>
void CollectionFilter(const TClonesArray& inColl ,vector<T*>& outColl, Double_t ptMin=30, Double_t etaMax=2.5)
{

const TObject *object;

for (Int_t i = 0; i < inColl.GetEntriesFast(); i++)
{

object = inColl.At(i);
const T *t = static_cast<const T*>(object);

if(t->P4().Pt() < ptMin) continue;
if(TMath::Abs(t->P4().Eta()) > etaMax) continue;

outColl.push_back(t);

}
}



void selectMuon(const char *inputFile)
{
  gSystem->Load("libDelphes");

  // Create chain of root trees
  TChain chain("Delphes");
  chain.Add(inputFile);

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
  Long64_t numberOfEntries = treeReader->GetEntries();

  // Get pointers to branches used in this analysis
  TClonesArray *branchMuon = treeReader->UseBranch("Muon");
  
  // Book histograms
 
  TH1F *histZMass = new TH1F("mass", "M_{inv}(Z[1]); M_inv (GeV/c^2); Events", 50, 0.0, 1500);
  TH1F *histDiMuonMass = new TH1F("mass", "M_{inv}(Z[3]Z[5]); M_inv (GeV/c^2); Events", 50, 0.0, 1500);
  

  // Define variables
  
  float_t PT, Eta, Phi, Mass, Charge;  
 
  // Initializing the vectors
  //vector<const Muon*>  *muons = new vector<const Muon*>();;
  //MuonVector muon(PT, Eta, Phi, Mass, Charge);
  RVec<RVec<size_t>> reco_zz_to_4l(rvec_f PT, rvec_f Eta, rvec_f Phi, rvec_f Mass, rvec_i Charge);
  
    RVec<RVec<size_t>> idx(2);
    idx[0].reserve(2); idx[1].reserve(2);
    auto idx_cmb = Combinations(PT, 2);
    for (size_t i = 0; i < idx_cmb[0].size(); i++)
    {
      const auto i1 = idx_cmb[0][i];
      const auto i2 = idx_cmb[1][i];

      
      if(Charge[i1] != Charge[i2]
      {

      

        ROOT::Math::PtEtaPhiMVector m1(PT[0], Eta[0], Phi[0], Mass[0]);
        ROOT::Math::PtEtaPhiMVector m2(PT[1], Eta[1], Phi[1], Mass[1]);
        const auto mass = (m1 + m2).M();
     }
    }

      histDiMuonMass->Fill(mass);   
    
  
    

   
   // end of event for loop
  histDiMuonMass->Draw();
  
  }

The errors that I am getting is below.

In file included from input_line_188:1:
/mnt/c/1/MG5_aMC_v2_6_6/Delphes/examples/selectMuon.C:89:16: error: subscripted value is not an array, pointer, or vector
      if(Charge[i1] != Charge[i2]
         ~~~~~~^~~
/mnt/c/1/MG5_aMC_v2_6_6/Delphes/examples/selectMuon.C:89:30: error: subscripted value is not an array, pointer, or vector
      if(Charge[i1] != Charge[i2]
                       ~~~~~~^~~
/mnt/c/1/MG5_aMC_v2_6_6/Delphes/examples/selectMuon.C:100:28: error: use of undeclared identifier 'mass'
      histDiMuonMass->Fill(mass);

How can I fix it?
Thank you.
___
Please read tips for efficient and successful posting and posting code

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