17 using namespace Diana;
21 fAvgNoiseInput = GetString(
"AvgNoiseInput",
"");
22 fAvgPulseInput= GetString(
"AvgPulseInput",
"");
23 fAvgPulseOwner = GetString(
"AvgPulseOwner",
"AveragePulses",
false);
24 fAvgNoiseOwner = GetString(
"AvgNoiseOwner",
"NoiseAvgPowerSpectrum",
false);
26 std::string searchMode = GetString(
"AmplitudeMode",
"AbsoluteMaximum");
31 else Panic(
"AmplitudeMode %s not available",searchMode.c_str());
33 fInterpolationOn = GetBool(
"InterpolationOn",
true,
true);
35 double defaultChi2Threshold1 = 0.1;
36 fChi2Threshold1 = GetDouble(
"Chi2Threshold1",defaultChi2Threshold1,
false);
37 if(fChi2Threshold1 < 0 || fChi2Threshold1 > 1) {
38 Error(
"Chi2Threshold1 value %f must be between 0 and 1, resetting to default %f",fChi2Threshold1, defaultChi2Threshold1);
39 fChi2Threshold1 = defaultChi2Threshold1;
43 fMaxJitter = GetInt(
"MaxJitter",-1,
false);
44 fParametersOutput = GetString(
"ParametersOutput",
"",
false);
45 fDifferentiationOn = GetBool(
"DifferentiationOn",
true);
46 fTomV = GetBool(
"ConvertTomV",
true,
false);
56 fSaveSamples = GetBool(
"SaveSamples",
false,
false);
57 fShiftFilteredSamples = GetBool(
"ShiftFilteredSamples",
true,
false);
59 ev.
Add<QVector>(
"FilteredSamples").SetWrite(fSaveSamples);
60 fPulseLabel = GetString(
"PulseLabel",
"DAQ@Pulse",
false);
75 GlobalData().Get(
"",&
rHandle,
"");
81 if(fTomV) ADC2mV = channelRunData.
fADC2mV;
83 if(fMap.find(chan) == fMap.end()) {
85 GlobalHandle<QInt> dHandle(
"Dataset");
86 GlobalData().Get(
"",&dHandle,
"");
88 fMap[chan].BlackSheep =
false;
91 AVG_Noise_Handle.SetDataset(dHandle.Get());
92 GlobalData().Get(fAvgNoiseOwner,&AVG_Noise_Handle,fAvgNoiseInput);
94 if(!AVG_Noise_Handle.IsValid()) {
95 AVG_Noise_Handle.SetRun(header.GetRun());
97 GlobalData().Get(fAvgNoiseOwner,&AVG_Noise_Handle,fAvgNoiseInput);
99 if(!AVG_Noise_Handle.IsValid()) {
100 Warn(
"%s. Channel %d will not be processed",AVG_Noise_Handle.GetError().GetDescription().c_str(),chan);
101 fMap[chan].BlackSheep =
true;
104 AVG_Pulse_Handle.SetDataset(dHandle.Get());
105 GlobalData().Get(fAvgPulseOwner,&AVG_Pulse_Handle,fAvgPulseInput);
107 if(!AVG_Pulse_Handle.IsValid()) {
108 AVG_Pulse_Handle.SetRun(header.GetRun());
110 GlobalData().Get(fAvgPulseOwner,&AVG_Pulse_Handle,fAvgPulseInput);
113 if(!fMap[chan].BlackSheep && !AVG_Pulse_Handle.IsValid()) {
114 Warn(
"%s. Channel %d will not be processed",AVG_Pulse_Handle.GetError().GetDescription().c_str(),chan);
115 fMap[chan].BlackSheep =
true;
117 if(!fMap[chan].BlackSheep) {
119 fMap[chan].ADC2Time = 1000./samplingFreq;
121 const QVector& avg_noise = AVG_Noise_Handle.Get();
122 const QVector& avg_pulse = AVG_Pulse_Handle.Get();
124 fMap[chan].of =
new QOptimumFilter(avg_pulse, avg_noise,fMaxJitter , fDifferentiationOn,
false );
125 Info(
"Channel %d: Maximum Jitter = +/- %d [samples], Cutoff = %.0f [Hz]",chan, fMap[chan].
of->
GetMaxJitter(), fMap[chan].of->GetCutOffFrequency()*samplingFreq);
128 cofData.
fResolutionmV = fMap[chan].of->GetFilteredNoiseRMS()*ADC2mV;
131 cofhandle.SetChannel(chan);
132 cofhandle.SetDataset(dHandle.Get());
133 cofhandle.Set(cofData);
136 if (!fParametersOutput.empty()) {
137 cofhandle.
SetAPLabel(AVG_Pulse_Handle.GetLabel());
145 cofhandle.
SetNPSLabel(AVG_Noise_Handle.GetLabel());
154 GlobalData().Set(&cofhandle,fParametersOutput);
163 const QVector& Samples = rawPulse.
GetSamples();
166 Debug(
"Event number %d %s",header.GetEventNumber(),
err.GetDescription().c_str());
179 Debug(
"Event number %d %s",header.GetEventNumber(),
err.GetDescription().c_str());
182 if(fShiftFilteredSamples)
187 double a1, chi2, integral, jitter,chileft,chiright;
188 if(!fInterpolationOn || pulseInfo.
GetIsNoise()) {
189 err = chanInfo.
of->
Get(jitter,chi2, a1, integral,chileft,chiright);
194 Debug(
"Event number %d %s",header.GetEventNumber(),
err.GetDescription().c_str());
200 ev.
Get<
QDouble>(
"Integral") = integral*ADC2mV/samplingFreq;
203 ev.
Get<
QDouble>(
"Jitter") = jitter*fMap[chan].ADC2Time;
212 Debug(
"Event number %d %s",header.GetEventNumber(),
err.GetDescription().c_str());
215 ev.
Get<
QDouble>(
"HighSNRChiSquare") = highSNRChi21;
QOptimumFilter of(ap, an,-1, false)
QRunDataHandle rHandle(753)
#define REGISTER_MODULE(clazz)
void Init(Diana::QEvent &ev)
Init method.
void Do(Diana::QEvent &ev)
Do method. Declare and implement only one of the two versions.
global handle for average noise power spectra
global handle for average pulse
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
general quantities about COF
void SetAPLabel(const std::string &apl)
void SetAPVersion(const std::string &apv)
void SetNPSLabel(const std::string &npsl)
void SetAPValidityKind(const std::string &apvk)
void SetNPSVersion(const std::string &npsv)
void SetNPSValidityKind(const std::string &npsvk)
basic channel and run based info. Used in the QRunData object.
double fSamplingFrequency
sampling frequency in Hz
double fADC2mV
conversion: mV = ADC * fADC2mV
error class with error type and description
const Q & GetByLabel(const QEventLabel &label) const
Get a QObject in read mode by label.
void RequireByLabel(const QEventLabel &label) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
Optimum filter implemented with windowing and zeros.
QError GetInterpolated(double &jitter, double &chi2, double &litude, double &integral, double &left, double &right) const
get values at interpolated chi^2 minimum. Three points around the minimum are used for a parabolic in...
QError GetHighSNRChi2(const double &threshold, double &chi2) const
get chi^2 (mean 0, variance 1) restricting the DoF to frequencies with SNR > threshold
Diana::QVector GetFilteredShifted() const
get filtered and shifted samples by fMaxPos
QError SetJitter(JitterMode mode, int start=0)
QError Get(double &jitter, double &chi2, double &litude, double &integral, double &left, double &right) const
const Diana::QVector & GetFiltered() const
get filtered samples
QError Filter(const Diana::QVector &p)
filter. In case of failure an error is returned.
Raw event: bolometer channel, trigger positions and types.
const QSampleInfo & GetMasterSample() const
Get MasterSample.
bool GetIsNoise() const
Get IsNoise.
const int & GetChannelId() const
Get ChannelId.
Raw event: sampled waveform.
const Diana::QVector & GetSamples() const
Get Samples casted to double (QVector instead of QVectorI). Use this method in place of GetSamplesADC...
global handle for QRunData
const QChannelRunData & GetChannelRunData(const int channel) const
get channel based run data quantities
Int_t GetSampleIndex() const
Get SampleIndex from the beginning of the waveform.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...