If I have a for loop that reads from a data file and each time I have a varible number of variables, say jet1_emfr, jet2_emfr, ..., if N is the number of these variables, I used something like
vector<double> jet_emfr;
osstringstream oss;
for( int i = 0; i < N; i++ ){
oss << "jet" << i << "_emfr";
jet_emf.push_back(oss.str());
oss.str("");
}
to store them, is it the best way? And What if I want to associate the name of the variable to its value, I mean, I created a map
map<string,TLorentzVector> map_jets;
map_jets["jet1"] = jet1_mom;
map_jets["jet2"] = jet2_mom;
map_jets["jet3"] = jet3_mom;
...
and used a vector<pair<string,double> > jets_pt to associate jet1 to a value given by jet1_mom.Pt(), now I need to impose a condition that whenever jet_emfr[i] < 0.4 i have to erase (or not store) the value of the corresponding jet?_mom.Pt() in (from) jets_pt.
I don’t see anything wrong with the data structures you used.
Using a std::vector to hold your double values is definitely a good way to go.
And using an std::map to associate your data with a string is also a good way to store the association.