Example module which computes a simple pulse shape parameter, implementation file.
{
fAveragePulseInput = GetString("AveragePulseInput","NODEFAULT");
}
{
apHandle.SetChannel(chan);
GlobalData().Get("TutorialAveragePulse",&apHandle,fAveragePulseInput);
if(!apHandle.IsValid()) {
if(fChannelsWithoutAP.count(chan) == 0) {
fChannelsWithoutAP.insert(chan);
Warn("Average pulse not found for channel %04d",chan);
}
return;
}
const QVector& averagePulse = apHandle.Get();
double apBaseline = averagePulse[0];
double apAmplitude = averagePulse.
GetMax()-apBaseline;
double chisq = 0.;
for(size_t i =0; i < samples.Size(); i++) {
double res = (samples[i]-baseline) - (averagePulse[i]-apBaseline)*amplitude/apAmplitude;
chisq += res*res;
}
chisq /= (samples.Size() - 1)*baselineRMS*baselineRMS;
}
{
}
#define REGISTER_MODULE(clazz)
template class to handle diana global QObject with QGlobalDataManager
void Init(Diana::QEvent &ev)
Init method.
void Do(Diana::QEvent &ev)
Do method. Declare and implement only one of the two versions.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
double GetBaseline() const
double GetBaselineRMS() const
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.
Raw event: bolometer channel, trigger positions and types.
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...
Interface for vectors in Diana analysis.
double GetMax() const
get maximum element
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...