Skip to content

Commit

Permalink
adc to energy using map
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Oct 28, 2024
1 parent fe9e8b9 commit b448c30
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/TRestRawPeaksFinderProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,37 @@ TRestEvent* TRestRawPeaksFinderProcess::ProcessEvent(TRestEvent* inputEvent) {
SetObservableValue("peaksTime", peaksTimePhysical);
}

if (fADCtoEnergyFactor != 0.0 || !fChannelIDToADCtoEnergyFactor.empty()) {
vector<Double_t> peaksEnergyPhysical(peaksAmplitude.size(), 0.0);
Double_t peaksEnergySum = 0.0;

if (fADCtoEnergyFactor != 0.0) {
// same factor for all peaks
for (size_t i = 0; i < peaksAmplitude.size(); i++) {
peaksEnergyPhysical[i] = peaksAmplitude[i] * fADCtoEnergyFactor;
peaksEnergySum += peaksEnergyPhysical[i];
}
} else {
// use map to get factor for each channel
for (size_t i = 0; i < peaksAmplitude.size(); i++) {
const auto channelId = peaksChannelId[i];
// check if the channel is in the map
if (fChannelIDToADCtoEnergyFactor.find(channelId) == fChannelIDToADCtoEnergyFactor.end()) {
cerr << "TRestRawPeaksFinderProcess::ProcessEvent: channel id " << channelId
<< " not found in the map of ADC to energy factors" << endl;
exit(1);
}
const auto factor = fChannelIDToADCtoEnergyFactor[channelId];

peaksEnergyPhysical[i] = peaksAmplitude[i] * factor;
peaksEnergySum += peaksEnergyPhysical[i];
}
}

SetObservableValue("peaksEnergy", peaksEnergyPhysical);
SetObservableValue("peaksEnergySum", peaksEnergySum);
}

// Remove peak-less veto signals after the peak finding if chosen
if (fRemovePeaklessVetoes && !fRemoveAllVetoes) {
set<UShort_t> peakSignalIds;
Expand Down

0 comments on commit b448c30

Please sign in to comment.