26 namespace ConstantFraction
49 assert(
typeid(Channel::waveform_t::value_type) ==
typeid(T));
53 const double horpos = c.
horpos()*1.e9;
54 const double vGain = c.
gain();
55 const int32_t vOff =
static_cast<int32_t
>(c.
offset() / vGain);
57 const int32_t idxToFiPoint = 0;
59 const size_t wLength = c.
waveform().size();
62 const int32_t delay =
static_cast<int32_t
>(param.
_delay / sampleInterval);
63 const double walk = param.
_walk / vGain;
68 for (
size_t i=delay+1; i<wLength-2;++i)
70 const double fx = Data[i] -
static_cast<double>(vOff);
71 const double fxd = Data[i-delay] -
static_cast<double>(vOff);
72 const double fsx = -fx*fraction + fxd;
74 const double fx_1 = Data[i+1] -
static_cast<double>(vOff);
75 const double fxd_1 = Data[i+1-delay] -
static_cast<double>(vOff);
76 const double fsx_1 = -fx_1*fraction + fxd_1;
79 if (((fsx-walk) * (fsx_1-walk)) <= 0 )
80 if (fabs(fx) > threshold)
85 if (fabs(fsx-fsx_1) < 1e-8)
90 else if ((fsx-walk) == 0)
95 else if ((fsx_1-walk) == 0)
114 const double fx_m1 = Data[i-1] -
static_cast<double>(vOff);
115 const double fxd_m1 = Data[i-1-delay] -
static_cast<double>(vOff);
116 const double fsx_m1 = -fx_m1*fraction + fxd_m1;
118 const double fx_2 = Data[i+2] -
static_cast<double>(vOff);
119 const double fxd_2 = Data[i+2-delay] -
static_cast<double>(vOff);
120 const double fsx_2 = -fx_2*fraction + fxd_2;
124 const double m = fsx_1-fsx;
125 const double xLin = i + (walk - fsx)/m;
128 double mslope,cslope;
129 const double xslope[3] = {
static_cast<double>(i-delay),
130 static_cast<double>(i+1-delay),
131 static_cast<double>(i+2-delay)};
132 const double yslope[3] = {fxd,fxd_1,fxd_2};
133 linearRegression<T>(3,xslope,yslope,mslope,cslope);
137 const double x[4] = {
static_cast<double>(i-1),
138 static_cast<double>(i),
139 static_cast<double>(i+1),
140 static_cast<double>(i+2)};
141 const double y[4] = {fsx_m1,fsx,fsx_1,fsx_2};
142 double coeff[4] = {0,0,0,0};
143 createNewtonPolynomial<T>(
x,
y,coeff);
147 const double xPoly = cass::ACQIRIS::findXForGivenY<T>(
x,coeff,walk,xLin);
148 const double pos = xPoly +
static_cast<double>(idxToFiPoint) + horpos;
154 signal[
time] = pos*sampleInterval;
155 signal[
cfd] = pos*sampleInterval;
158 if (fabs(fsx-fsx_1) < std::sqrt(std::numeric_limits<double>::epsilon()))
175 if(fabs(signal[
polarity]-param.
_polarity) < std::sqrt(std::numeric_limits<double>::epsilon()))
177 for (CFDParameters::timeranges_t::const_iterator it (param.
_timeranges.begin());
181 if(signal[
time] > it->first && signal[
time] < it->second)
184 sig.push_back(signal);
213 instrument = s.
value(
"AcqirisInstrument",0).toInt();
214 channelNbr = s.
value(
"ChannelNumber",0).toInt();
221 for (
int i = 0; i <
size; ++i)
225 s.
value(
"UpperLimit",1000).toDouble()));
238 ConstantFraction::getcfd<char>(*_chan,_parameters,sig);
249 _chan = extactRightChannel<char>(evt,_instrument,_chNbr);
256 ConstantFraction::getcfd<short>(*_chan,_parameters,sig);
267 _chan = extactRightChannel<short>(evt,_instrument,_chNbr);
SignalProducer::signals_t & operator()(SignalProducer::signals_t &sig)
retrieve signals from data
std::vector< int16_t > waveform_t
define the waveform
double _walk
the walk of the cfd (in V)
Event to store all LCLS Data.
double _threshold
the level above which we think this is a signal (in V)
int32_t _delay
the delay of the cfd
std::vector< signal_t > signals_t
waveform_t & waveform()
setter
file contains declaration of the CASSEvent
file contains the classes that describe an acqiris channel
double _fraction
the fraction of the cfd
double & sampleInterval()
setter
things written only at end of run H5Dump ProcessorSummary size
void associate(const CASSEvent &evt)
associate the event with this analyzer
std::vector< double > signal_t
beginReadArray(const QString &prefix)
void loadSettings(CASSSettings &)
load the settings of the extractor
Binary function for thresholding.
timeranges_t _timeranges
the time ranges in which the signals are found
Polarity
the Polarity of a Signal in the waveform (Peak)
file contains functions that help analysing an acqiris waveform
value(const QString &key, const QVariant &defaultValue=QVariant()
A Channel of an Acqiris Instrument.
void loadSettings(CASSSettings &)
load the settings of the extractor
void loadSettings(CASSSettings &s, CFDParameters &p, uint32_t &instrument, size_t &channelNbr)
implementation of loading settings for both CFD classes
file contains specialized class that do the settings for cass
struct to combine the parameters that the Constant Fraction Extractors need
file contains declaration of class that does a constant fraction descrimination like analysis of a wa...
Polarity _polarity
the polarity that the signals have
void getcfd(const Channel &c, const CFDParameters ¶m, SignalProducer::signals_t &sig)
Implematation of Constant Fraction Method.
beginGroup(const QString &prefix)
void associate(const CASSEvent &evt)
associate the event with this analyzer
SignalProducer::signals_t & operator()(SignalProducer::signals_t &sig)
extract signals form the CASSEvent