Skip to content
Snippets Groups Projects
Commit f1fee5de authored by Carl Gwilliam's avatar Carl Gwilliam
Browse files

fix float to int trunncation in digi

parent 15711929
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include <cmath>
CaloWaveformDigiAlg::CaloWaveformDigiAlg(const std::string& name, CaloWaveformDigiAlg::CaloWaveformDigiAlg(const std::string& name,
ISvcLocator* pSvcLocator) ISvcLocator* pSvcLocator)
...@@ -122,8 +123,8 @@ CaloWaveformDigiAlg::execute(const EventContext& ctx) const { ...@@ -122,8 +123,8 @@ CaloWaveformDigiAlg::execute(const EventContext& ctx) const {
// Subtract count from basleine and add result to correct waveform vector // Subtract count from basleine and add result to correct waveform vector
for (const auto& c : counts) { for (const auto& c : counts) {
unsigned int baseline = m_digiTool->generate_baseline(m_base_mean, m_base_rms); double baseline = m_digiTool->generate_baseline(m_base_mean, m_base_rms);
int value = baseline - c.second; int value = std::round(baseline - c.second);
if (value < 0) { if (value < 0) {
ATH_MSG_WARNING("Found pulse " << c.second << " larger than baseline " << c.first); ATH_MSG_WARNING("Found pulse " << c.second << " larger than baseline " << c.first);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "ScintSimEvent/ScintHitIdHelper.h" #include "ScintSimEvent/ScintHitIdHelper.h"
#include <map> #include <map>
#include <cmath>
ScintWaveformDigiAlg::ScintWaveformDigiAlg(const std::string& name, ScintWaveformDigiAlg::ScintWaveformDigiAlg(const std::string& name,
...@@ -170,8 +171,8 @@ ScintWaveformDigiAlg::execute(const EventContext& ctx) const { ...@@ -170,8 +171,8 @@ ScintWaveformDigiAlg::execute(const EventContext& ctx) const {
// Subtract count from basleine and add result to correct waveform vector // Subtract count from basleine and add result to correct waveform vector
for (const auto& c : counts) { for (const auto& c : counts) {
unsigned int baseline = m_digiTool->generate_baseline(m_base_mean, m_base_rms); double baseline = m_digiTool->generate_baseline(m_base_mean, m_base_rms);
int value = baseline - c.second; int value = std::round(baseline - c.second);
if (value < 0) { if (value < 0) {
ATH_MSG_WARNING("Found pulse " << c.second << " larger than baseline " << c.first); ATH_MSG_WARNING("Found pulse " << c.second << " larger than baseline " << c.first);
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
virtual std::vector<float> evaluate_timekernel(TF1* kernel) const = 0; virtual std::vector<float> evaluate_timekernel(TF1* kernel) const = 0;
/// Generate random baseline /// Generate random baseline
virtual unsigned int generate_baseline(int mean, int rms) const = 0; virtual float generate_baseline(float mean, float rms) const = 0;
/// Create structure to store pulse for each channel /// Create structure to store pulse for each channel
template <class T> template <class T>
......
...@@ -41,7 +41,7 @@ WaveformDigitisationTool::evaluate_timekernel(TF1* kernel) const { ...@@ -41,7 +41,7 @@ WaveformDigitisationTool::evaluate_timekernel(TF1* kernel) const {
return timekernel; return timekernel;
} }
unsigned int float
WaveformDigitisationTool::generate_baseline(int mean, int rms) const { WaveformDigitisationTool::generate_baseline(float mean, float rms) const {
return m_random->Gaus(mean, rms); return m_random->Gaus(mean, rms);
} }
...@@ -32,7 +32,7 @@ class WaveformDigitisationTool: public extends<AthAlgTool, IWaveformDigitisation ...@@ -32,7 +32,7 @@ class WaveformDigitisationTool: public extends<AthAlgTool, IWaveformDigitisation
std::vector<float> evaluate_timekernel(TF1* kernel) const; std::vector<float> evaluate_timekernel(TF1* kernel) const;
/// Generate random baseline /// Generate random baseline
unsigned int generate_baseline(int mean, int rms) const; float generate_baseline(float mean, float rms) const;
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment