85 return static_cast<Float_t
>(
static_cast<Int_t
>(
TDetectorHit::GetCfd()) & 0x3fffff) +
static_cast<Float_t
>(gRandom->Uniform());
113 std::ostringstream str;
114 str <<
"Descant Detector: " <<
GetDetector() << std::endl;
115 str <<
"Descant hit energy: " <<
GetEnergy() << std::endl;
116 str <<
"Descant hit time: " <<
GetTime() << std::endl;
127 std::vector<Int_t> baselineCorrections(8, 0);
128 std::vector<Short_t> newWaveform;
132 unsigned int interpolationSteps = 256;
134 double attenuation = 24. / 64.;
135 int halfSmoothingWindow = 0;
138 for(
size_t i = 0; i < 8 && i <
WaveSize(); ++i) {
141 for(
size_t i = 8; i < 16 && i <
WaveSize(); ++i) {
142 baselineCorrections[i - 8] =
143 ((baselineCorrections[i - 8] +
GetWaveform()->at(i)) + ((baselineCorrections[i - 8] +
GetWaveform()->at(i)) > 0 ? 1 : -1)) >>
146 for(
size_t i = 0; i <
WaveSize(); ++i) {
147 newWaveform[i] -= baselineCorrections[i % 8];
155 double fraction = 0.90;
169 unsigned int interpolation_steps)
172 std::vector<Short_t> monitor;
178 unsigned int interpolationSteps, std::vector<Short_t>& monitor)
181 Short_t monitormax = 0;
188 std::vector<Short_t> smoothedWaveform;
191 if(halfSmoothingWindow > 0) {
198 monitor.resize(smoothedWaveform.size() - delay);
199 monitor[0] =
static_cast<Short_t
>(attenuation * smoothedWaveform[delay] - smoothedWaveform[0]);
200 if(monitor[0] > monitormax) {
202 monitormax = monitor[0];
205 for(
size_t i = delay + 1; i < smoothedWaveform.size(); ++i) {
206 monitor[i - delay] =
static_cast<Short_t
>(attenuation * smoothedWaveform[i] - smoothedWaveform[i - delay]);
207 if(monitor[i - delay] > monitormax) {
209 monitormax = monitor[i - delay];
211 if(armed && monitor[i - delay] < 0) {
213 if(monitor[i - delay - 1] - monitor[i - delay] != 0) {
215 cfd = (i - delay - 1) * interpolationSteps +
216 (monitor[i - delay - 1] * interpolationSteps) / (monitor[i - delay - 1] - monitor[i - delay]);
246 std::vector<Short_t> smoothedWaveform(std::max((
static_cast<size_t>(0)),
WaveSize() - 2 * halfSmoothingWindow),
249 for(
size_t i = halfSmoothingWindow; i <
WaveSize() - halfSmoothingWindow; ++i) {
250 for(
int j = -
static_cast<int>(halfSmoothingWindow); j <= static_cast<int>(halfSmoothingWindow); ++j) {
251 smoothedWaveform[i - halfSmoothingWindow] +=
GetWaveform()->at(i + j);
255 return smoothedWaveform;
259 unsigned int halfSmoothingWindow)
264 std::vector<Short_t> smoothedWaveform;
266 if(halfSmoothingWindow > 0) {
272 std::vector<Short_t> monitor(std::max((
static_cast<size_t>(0)), smoothedWaveform.size() - delay), 0);
274 for(
size_t i = delay; i <
WaveSize(); ++i) {
275 monitor[i - delay] =
static_cast<Short_t
>(attenuation * smoothedWaveform[i] - smoothedWaveform[i - delay]);
287 std::vector<Int_t> partialSums(
WaveSize(), 0);
290 for(
size_t i = 1; i <
WaveSize(); ++i) {
291 partialSums[i] = partialSums[i - 1] +
GetWaveform()->at(i);
303 std::vector<Int_t> partialSums;
309 std::vector<Int_t>& partialSums)
314 if(partialSums.empty()) {
317 int totalSum = partialSums.back();
320 if(partialSums[0] < fraction * totalSum) {
321 for(
size_t i = 1; i < partialSums.size(); ++i) {
322 if(partialSums[i] >= fraction * totalSum) {
323 psd =
static_cast<Int_t
>(
static_cast<double>(i * interpolationSteps) - ((partialSums[i] - fraction * totalSum) * interpolationSteps) /
GetWaveform()->at(i));
std::vector< int > fPartialSum
std::vector< Short_t > CalculateCfdMonitor(double attenuation, unsigned int delay, unsigned int halfSmoothingWindow)
!
void SetCcLong(const int &x)
!
void SetCcShort(const int &x)
!
Int_t CalculatePsd(double fraction, unsigned int interpolationSteps)
!
Int_t CalculatePsdAndPartialSums(double fraction, unsigned int interpolationSteps, std::vector< Int_t > &partialSums)
!
std::vector< Int_t > CalculatePartialSum()
!
void Print(Option_t *opt="") const override
!
void Clear(Option_t *opt="") override
!
std::vector< int16_t > fCfdMonitor
Int_t CalculateCfdAndMonitor(double attenuation, unsigned int delay, int halfSmoothingWindow, unsigned int interpolationSteps, std::vector< Short_t > &monitor)
!
Int_t GetRemainder() const
void SetPsd(const int &x)
!
void Copy(TObject &) const override
!
TVector3 GetPosition() const override
!
Double_t GetDefaultDistance() const
std::vector< Short_t > CalculateSmoothedWaveform(unsigned int halfSmoothingWindow)
!
Int_t CalculateCfd(double attenuation, unsigned int delay, int halfsmoothingwindow, unsigned int interpolation_steps)
!
Float_t GetCfd() const override
!
void SetZc(const int &x)
!
static TVector3 GetPosition(int DetNbr, double dist=222)
!
virtual void SetCfd(const Float_t &val)
!
virtual double GetEnergy(Option_t *opt="") const
void SetWaveform(const std::vector< Short_t > &val)
!
const std::vector< Short_t > * GetWaveform() const
!
void SetCharge(const Float_t &temp_charge)
!
void Clear(Option_t *opt="") override
!
virtual Int_t GetDetector() const
!
virtual Float_t GetCfd() const
!
void Copy(TObject &) const override
!
virtual Double_t GetTime(const ETimeFlag &correct_flag=ETimeFlag::kAll, Option_t *opt="") const
Returns a time value to the nearest nanosecond!
virtual bool HasWave() const
!
virtual size_t WaveSize() const
!
virtual void CopyWave(TObject &) const
!
static TGRSIOptions * Get(int argc=0, char **argv=nullptr)
Do not use!