I am trying to apply 2D maps to my code for matching entries in multiple maps.
std::map<Float_t,std::map<Float_t,std::Int_t>> map1;
Int_t nrows1 = Space1->GetEntries();
for (Int_t irow1=0; irow1 < nrows1; ++irow1 ) {
Space1->GetEntry(irow1);
Float_t key1 = x1;
Float_t keyA = y1;
map1[key1][keyA] = irow1;
}
std::map<Float_t,std::map<Float_t,std::Int_t>> map2;
Int_t nrows2 = Space2->GetEntries();
for (Int_t irow2=0; irow2 < nrows2; ++irow2 ) {
Space2->GetEntry(irow2);
Float_t key2 = x2;
Float_t keyB = y2;
map1[key2][keyB] = irow2;
}
for (Int_t ientry1=0; ientry1<Space1->GetEntries(); ientry1++) {
Space1->GetEntry(ientry1);
Float_t key1 = x1;
Float_t keyA = y1;
if(!map1.count(key1) && !map1.count(keyA)) continue;
if(!map2.count(key1) && !map2.count(keyA)) continue;
Int_t entry1 = map1[key1][keyA];
Int_t entry2 = map2[key1][keyA];
Space1->GetEntry(entry1);
Space2->GetEntry(entry2);
//more happens after.
}
Example table with x and y values
I am having the problem that it will match X when x=4 then when Y when y=1. I only want entries from Space 1 and Space 2 when both x and y match like entry 4 from Space 1 and entry 5 from Space 2.