Diana Software
MTutorialAmplitudeFilter.cc

Example filter which selects events with amplitude in given range, implementation file.

Author
Marco Vignati

See header in MTutorialAmplitudeFilter.hh.

#include "QEvent.hh"
#include "QBaseType.hh"
using namespace Diana;
// GetCuts method is called before the event loop (like QModule::Init())
{
// Get cuts from config file
fAmplitudeMinimum = GetDouble("AmplitudeMinimum",0);
fAmplitudeMaximum = GetDouble("AmplitudeMaximum",10000);
// Get from config file the label of the amplitude variable to be used
fAmplitudeLabel = GetString("AmplitudeLabel","PulseBasicParameters@MaxBaseline");
ev.RequireByLabel<QDouble>(fAmplitudeLabel);
}
// Filter method is called on each event (like QModule::Do())
{
// get amplitude from the event
const QDouble& amp = ev.GetByLabel<QDouble>(fAmplitudeLabel);
// true if amplitude is in the range, false otherwise
if(amp > fAmplitudeMinimum && amp < fAmplitudeMaximum) {
return true;
}
return false;
}
// There is no method called at the end of the event loop, like QModule::Done()
double amp
Definition: CheckOF.C:32
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
bool Filter(const Diana::QEvent &ev)
return true if ev passes the cuts
void GetCuts(const Diana::QEvent &ev)
Get cuts from config file.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
Definition: QBaseType.hh:17
diana event
Definition: QEvent.hh:46
const Q & GetByLabel(const QEventLabel &label) const
Get a QObject in read mode by label.
Definition: QEvent.hh:135
void RequireByLabel(const QEventLabel &label) const
notify the QEvent that we need a QObject, if not found an exception is thrown
Definition: QEvent.hh:242
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...