Skip to content

Commit

Permalink
Merge pull request #134 from JamesJieranShen/pr/fix-pmt-waveform-memleak
Browse files Browse the repository at this point in the history
Memory Leak in the PMTWaveformGenerator code.
  • Loading branch information
tannerbk authored May 22, 2024
2 parents 0c4ebc6 + deef9a7 commit 0fb67b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/daq/include/RAT/PMTWaveform.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PMTWaveform {
virtual ~PMTWaveform();
virtual double GetHeight(double time);

std::vector<PMTPulse *> fPulse;
std::vector<PMTPulse> fPulse;
};

} // namespace RAT
Expand Down
4 changes: 2 additions & 2 deletions src/daq/src/PMTWaveform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ PMTWaveform::~PMTWaveform() {}

double PMTWaveform::GetHeight(double currenttime) {
double height = 0.;
for (unsigned int i = 0; i < fPulse.size() && fPulse[i]->GetPulseStartTime() <= currenttime; i++) {
height += fPulse[i]->GetPulseHeight(currenttime);
for (unsigned int i = 0; i < fPulse.size() && fPulse[i].GetPulseStartTime() <= currenttime; i++) {
height += fPulse[i].GetPulseHeight(currenttime);
}
return height;
}
Expand Down
5 changes: 2 additions & 3 deletions src/daq/src/PMTWaveformGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ PMTWaveform PMTWaveformGenerator::GenerateWaveforms(DS::MCPMT *mcpmt, double tri
for (int iph = 0; iph < mcpmt->GetMCPhotonCount(); iph++) {
DS::MCPhoton *mcpe = mcpmt->GetMCPhoton(iph);

PMTPulse *pmtpulse = new PMTPulse(fPMTPulseType, fPMTPulseShape);
pmtwf.fPulse.push_back(PMTPulse(fPMTPulseType, fPMTPulseShape));
PMTPulse *pmtpulse = &pmtwf.fPulse.back();
pmtpulse->SetPulseCharge(mcpe->GetCharge() * fTerminationOhms);
pmtpulse->SetPulseMin(fPMTPulseMin);
pmtpulse->SetPulseOffset(fPMTPulseOffset);
Expand All @@ -81,8 +82,6 @@ PMTWaveform PMTWaveformGenerator::GenerateWaveforms(DS::MCPMT *mcpmt, double tri

pmtpulse->SetPulseTimes(fPMTPulseShapeTimes);
pmtpulse->SetPulseValues(fPMTPulseShapeValues);

pmtwf.fPulse.push_back(pmtpulse);
}

return pmtwf;
Expand Down

0 comments on commit 0fb67b7

Please sign in to comment.