Home | News | Documentation | Download

How to Initialize Muon Vectors

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


#include “classes/DelphesClasses.h”

#include “external/ExRootAnalysis/ExRootTreeReader.h”

#include “external/ExRootAnalysis/ExRootResult.h”


class ExRootTreeReader;

class ExRootResult;




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;




//-------------------------------------Looking at Leptons -----------------------------------------

void selectMuon(const char *inputFile)



// Create chain of root trees

TChain chain(“Delphes”);


// 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



// 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);



// - - - - - - - - - - - - - - Drawing the Histograms - - - - - - - - - - - - - - - - - - - - - -

} // end of event for loop



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

Additional variables should be added at that step I guess: is creation time.

I dont think there is any documentation on that suggestion. Are you familiar with the process?

Not really as you are using an external tool (Madgraph) to generate your TTree. May be you should contact the Madgraph support or the author of the program you are using.

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