Commit 50aa1d63 authored by vpalladi's avatar vpalladi

interface/triggerCell.hh method isNeighbour modified in order to handle the...

interface/triggerCell.hh method isNeighbour modified in order to handle the exception due to the std::map. Accessing an element using [] that does not exist generate a new element of the map, this was creating a memory leak. Using instead the at() method does not create new elements but rises exception. Try-catch construct has been used to avoid the problem.
parent 56a842ec
......@@ -37,7 +37,7 @@ public:
hgcTriggerCell(int Id, int waferId) { this->setId(Id); this->setWaferId(waferId); }
void setNormId(pair<int,int> normId) { fNormId = normId; }
pair<int,int> setNormId() { return fNormId; }
pair<int,int> getNormId() { return fNormId; }
void addNeighbour(int waferId, int triggerCellId) { fNeighbours[waferId].push_back(triggerCellId); }
void addNeighbours(vector< pair<int,int> > n) {
......@@ -49,11 +49,16 @@ public:
return fNeighbours;
}
bool isNeigbour(int waferId, int triggerCellId) {
if( find(fNeighbours[waferId].begin(), fNeighbours[waferId].end(), triggerCellId) != fNeighbours[waferId].end() )
return true;
try{
if( find(fNeighbours.at(waferId).begin(), fNeighbours.at(waferId).end(), triggerCellId) != fNeighbours.at(waferId).end() )
return true;
}
catch(const std::out_of_range& oor){
return false;
}
return false;
}
void addCorners(vector< pair<float,float> > corners){
fCorners = corners;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment