# Efficiency of storing invariant mass in vector of vectors

Dear Rooters,

I am trying to store all the muon invariant mass combinations per event into a vector<vector >*.

``````//event loop
for (int i=0; i<entries; i++){
massCB->clear();
massCB->reserve(mu_muid_n);
//muon loop
for (int j=0; j<mu_muid_n; j++){
massCB_one.clear();
size_t nPermMuMu =  TMath::Binomial(mu_muid_n,2);
massCB_one.reserve(nPermMuMu);
pt[j] = mu_muid_pt[j]/1000. ;
eta[j] = mu_muid_eta[j];
phi[j] = mu_muid_phi[j];
for(int k=j+1;k<mu_muid_n; k++){
float chargeTemp1 = mu_muid_charge[j];
float chargeTemp2 = mu_muid_charge[k];
TLorentzVector vMu1; vMu1.SetPtEtaPhiM(pt[j],eta[j],phi[j],0.1057);
float pt2 = mu_muid_pt[k]/1000. ;
float eta2 = mu_muid_eta[k];
float phi2 = mu_muid_phi[k];
TLorentzVector vMu2; vMu2.SetPtEtaPhiM(pt2,eta2,phi2,0.1057) ;
TLorentzVector vMuSum = vMu1+vMu2 ;
float invMass = vMuSum.M();
massCB_one.push_back(invMass);
}
}
}``````

However, when running over events the macro is extremely slow. I thought calling vector::reserve() would help, but it doesnâ€™t seem to do anything. Any suggestions?