Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak fixes #2340

Merged
merged 1 commit into from
Feb 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ DTMeantimerPatternReco::reconstruct(const DTSuperLayer* sl,
delete *(cand++); // delete the candidate!
}

for (vector<DTHitPairForFit*>::iterator it = hitsForFit.begin(), ed = hitsForFit.end();
it != ed; ++it) delete *it;

return result;
}

Expand Down
22 changes: 13 additions & 9 deletions RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco4D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ DTMeantimerPatternReco4D::DTMeantimerPatternReco4D(const ParameterSet& pset):
// Get the concrete 2D-segments reconstruction algo from the factory
// For the 2D reco I use this reconstructor!
the2DAlgo = new DTMeantimerPatternReco(pset.getParameter<ParameterSet>("Reco2DAlgoConfig"));

}
}


DTMeantimerPatternReco4D::~DTMeantimerPatternReco4D(){
Expand Down Expand Up @@ -134,7 +133,9 @@ DTMeantimerPatternReco4D::reconstruct(){
cout << "Segments in " << theChamber->id() << endl;
cout << "Reconstructing Phi segments"<<endl;
}
vector<DTSegmentCand*> resultPhi = buildPhiSuperSegmentsCandidates();

vector<DTHitPairForFit*> pairPhiOwned;
vector<DTSegmentCand*> resultPhi = buildPhiSuperSegmentsCandidates(pairPhiOwned);

if (debug) cout << "There are " << resultPhi.size() << " Phi cand" << endl;

Expand All @@ -158,7 +159,7 @@ DTMeantimerPatternReco4D::reconstruct(){
hasZed = theSegments2DTheta.size()>0;
if (debug) cout << "There are " << theSegments2DTheta.size() << " Theta cand" << endl;
} else {
if (debug) cout << "No Theta SL" << endl;
if (debug) cout << "No Theta candidates." << endl;
}

// Now I want to build the concrete DTRecSegment4D.
Expand All @@ -167,9 +168,10 @@ DTMeantimerPatternReco4D::reconstruct(){
for (vector<DTSegmentCand*>::const_iterator phi=resultPhi.begin();
phi!=resultPhi.end(); ++phi) {

DTChamberRecSegment2D* superPhi = (**phi);
std::auto_ptr<DTChamberRecSegment2D> superPhi(**phi);

theUpdator->update(superPhi);
theUpdator->update(superPhi.get());
if(debug) cout << "superPhi: " << *superPhi << endl;

if (hasZed) {

Expand All @@ -195,7 +197,6 @@ DTMeantimerPatternReco4D::reconstruct(){
const LocalVector dirZInCh = theChamber->toLocal( zSL->toGlobal(zed->localDirection()));

DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi,*zed,posZInCh,dirZInCh);
//<<

/// 4d segment: I have the pos along the wire => further update!
theUpdator->update(newSeg);
Expand Down Expand Up @@ -247,13 +248,15 @@ DTMeantimerPatternReco4D::reconstruct(){
// finally delete the candidates!
for (vector<DTSegmentCand*>::iterator phi=resultPhi.begin();
phi!=resultPhi.end(); ++phi) delete *phi;
for (vector<DTHitPairForFit*>::iterator phiPair = pairPhiOwned.begin();
phiPair!=pairPhiOwned.end(); ++phiPair) delete *phiPair;

return result;
}



vector<DTSegmentCand*> DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates(){
vector<DTSegmentCand*> DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates(vector<DTHitPairForFit*> &pairPhiOwned){

DTSuperLayerId slId;

Expand All @@ -276,6 +279,7 @@ vector<DTSegmentCand*> DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates
// copy the pairPhi2 in the pairPhi1 vector
copy(pairPhi2.begin(),pairPhi2.end(),back_inserter(pairPhi1));

pairPhiOwned.swap(pairPhi1);
// Build the segment candidate
return the2DAlgo->buildSegments(sl,pairPhi1);
return the2DAlgo->buildSegments(sl,pairPhiOwned);
}
3 changes: 2 additions & 1 deletion RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco4D.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DTSegmentUpdator;
// ======================================================================
class DTSegmentCand;
class DTMeantimerPatternReco;
class DTHitPairForFit;

// Class DTMeantimerPatternReco4D Interface

Expand Down Expand Up @@ -60,7 +61,7 @@ class DTMeantimerPatternReco4D : public DTRecSegment4DBaseAlgo {
protected:

private:
std::vector<DTSegmentCand*> buildPhiSuperSegmentsCandidates();
std::vector<DTSegmentCand*> buildPhiSuperSegmentsCandidates(std::vector<DTHitPairForFit*> &pairPhiOwned);
DTRecSegment4D* segmentSpecialZed(DTRecSegment4D* seg);


Expand Down