88 return static_cast<Float_t
>(
static_cast<Int_t
>(
TDetectorHit::GetCfd()) & 0x3fffff) +
static_cast<Float_t
>(gRandom->Uniform());
116 std::ostringstream str;
117 str <<
"Descant Detector: " <<
GetDetector() << std::endl;
118 str <<
"Descant hit energy: " <<
GetEnergy() << std::endl;
119 str <<
"Descant hit time: " <<
GetTime() << std::endl;
130 std::vector<Int_t> baselineCorrections(8, 0);
131 std::vector<Short_t> newWaveform;
135 unsigned int interpolationSteps = 256;
137 double attenuation = 24. / 64.;
138 int halfSmoothingWindow = 0;
141 for(
size_t i = 0; i < 8 && i <
WaveSize(); ++i) {
144 for(
size_t i = 8; i < 16 && i <
WaveSize(); ++i) {
145 baselineCorrections[i - 8] =
146 ((baselineCorrections[i - 8] +
GetWaveform()->at(i)) + ((baselineCorrections[i - 8] +
GetWaveform()->at(i)) > 0 ? 1 : -1)) >>
149 for(
size_t i = 0; i <
WaveSize(); ++i) {
150 newWaveform[i] -= baselineCorrections[i % 8];
158 double fraction = 0.90;
172 unsigned int interpolation_steps)
175 std::vector<Short_t> monitor;
181 unsigned int interpolationSteps, std::vector<Short_t>& monitor)
184 Short_t monitormax = 0;
191 std::vector<Short_t> smoothedWaveform;
194 if(halfSmoothingWindow > 0) {
201 monitor.resize(smoothedWaveform.size() - delay);
202 monitor[0] =
static_cast<Short_t
>(attenuation * smoothedWaveform[delay] - smoothedWaveform[0]);
203 if(monitor[0] > monitormax) {
205 monitormax = monitor[0];
208 for(
size_t i = delay + 1; i < smoothedWaveform.size(); ++i) {
209 monitor[i - delay] =
static_cast<Short_t
>(attenuation * smoothedWaveform[i] - smoothedWaveform[i - delay]);
210 if(monitor[i - delay] > monitormax) {
212 monitormax = monitor[i - delay];
214 if(armed && monitor[i - delay] < 0) {
216 if(monitor[i - delay - 1] - monitor[i - delay] != 0) {
218 cfd = (i - delay - 1) * interpolationSteps +
219 (monitor[i - delay - 1] * interpolationSteps) / (monitor[i - delay - 1] - monitor[i - delay]);
249 std::vector<Short_t> smoothedWaveform(std::max((
static_cast<size_t>(0)),
WaveSize() - 2 * halfSmoothingWindow),
252 for(
size_t i = halfSmoothingWindow; i <
WaveSize() - halfSmoothingWindow; ++i) {
253 for(
int j = -
static_cast<int>(halfSmoothingWindow); j <= static_cast<int>(halfSmoothingWindow); ++j) {
254 smoothedWaveform[i - halfSmoothingWindow] +=
GetWaveform()->at(i + j);
258 return smoothedWaveform;
262 unsigned int halfSmoothingWindow)
267 std::vector<Short_t> smoothedWaveform;
269 if(halfSmoothingWindow > 0) {
275 std::vector<Short_t> monitor(std::max((
static_cast<size_t>(0)), smoothedWaveform.size() - delay), 0);
277 for(
size_t i = delay; i <
WaveSize(); ++i) {
278 monitor[i - delay] =
static_cast<Short_t
>(attenuation * smoothedWaveform[i] - smoothedWaveform[i - delay]);
290 std::vector<Int_t> partialSums(
WaveSize(), 0);
293 for(
size_t i = 1; i <
WaveSize(); ++i) {
294 partialSums[i] = partialSums[i - 1] +
GetWaveform()->at(i);
306 std::vector<Int_t> partialSums;
312 std::vector<Int_t>& partialSums)
317 if(partialSums.empty()) {
320 int totalSum = partialSums.back();
323 if(partialSums[0] < fraction * totalSum) {
324 for(
size_t i = 1; i < partialSums.size(); ++i) {
325 if(partialSums[i] >= fraction * totalSum) {
326 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!