14 using namespace Diana;
20 fRiseVars.clear(); fDecayVars.clear();
22 int nrise = GetInt(
"NumberOfRiseTimes", 1);
23 if(nrise < 0) Panic(
"NumberOfRiseTimes must be >= 0");
24 vector<QInterval> rises;
25 for(
int i = 1; i < nrise+1; i++) {
28 snprintf(buf,256,
"RiseTime%d_Interval",i);
29 vector<int> in; in.push_back(10); in.push_back(90);
30 in = GetVectorInt(buf,in);
31 if(in.size() != 2) Panic(
"%s needs 2 parameters instead of %d",buf,in.size());
32 else if(in[0] > in[1]) Panic(
"%s: first element (%d) must be smaller than second element (%d)",buf,in[0],in[1]);
33 else if(in[1] > 100) Panic(
"%s: elements cannot be greater than 100",buf);
34 else if(in[0] < 0 ) Panic(
"%s: elements cannot be negative",buf);
37 rise.
SetMin(
double(in[0])/100); rise.
SetMax(
double(in[1])/100);
38 rises.push_back(rise);
40 snprintf(buf,256,
"RiseTime%02d%02d",in[0],in[1]);
41 snprintf(buf2,256,
"RiseTime%02d%02dWindow",in[0],in[1]);
44 fRiseVars.push_back(buf);
47 int ndecay = GetInt(
"NumberOfDecayTimes", 1);
48 if(ndecay < 0) Panic(
"NumberOfDecayTimes must be >= 0");
49 vector<QInterval> decays;
50 for(
int i = 1; i < ndecay+1; i++) {
53 snprintf(buf,256,
"DecayTime%d_Interval",i);
54 vector<int> in; in.push_back(90); in.push_back(30);
55 in = GetVectorInt(buf,in);
56 if(in.size() != 2) Panic(
"%s needs 2 parameters instead of %d",buf,in.size());
57 else if(in[1] > in[0]) Panic(
"%s: first element (%d) must be greater than second element (%d)",buf,in[0],in[1]);
58 else if(in[0] > 100) Panic(
"%s: elements cannot be greater than 100",buf);
59 else if(in[1] < 0 ) Panic(
"%s: elements cannot be negative",buf);
62 decay.
SetMin(
double(in[1])/100); decay.
SetMax(
double(in[0])/100);
63 decays.push_back(decay);
65 snprintf(buf,256,
"DecayTime%02d%02d",in[0],in[1]);
66 snprintf(buf2,256,
"DecayTime%02d%02dWindow",in[0],in[1]);
69 fDecayVars.push_back(buf);
74 fPulseLabel = GetString(
"PulseLabel",
"DAQ@Pulse",
false);
75 fInputExtraLabel = GetString(
"InputExtraLabel",
"",
false);
76 fBaselineOwner = GetString(
"BaselineOwner",
"BaselineModule",
false);
77 fPulseBasicParamsOwner = GetString(
"PulseBasicParametersOwner",
"PulseBasicParameters",
false);
78 if(!fInputExtraLabel.empty()) {
79 fInputExtraLabel.insert(0,
"_");
80 fBaselineOwner += fInputExtraLabel;
81 fPulseBasicParamsOwner += fInputExtraLabel;
83 fTomV = GetBool(
"ConvertTomV",
true,
false);
97 const int run = header.
GetRun();
99 GlobalData().Get(
"",&
rHandle,
"");
108 const double baseline = ev.
Get<
QBaselineData>(fBaselineOwner.c_str(),
"BaselineData").GetBaseline()/ADC2mV;
109 int maxPos = ev.
Get<
QPulseParameters>(fPulseBasicParamsOwner.c_str(),
"Parameters").fMaxPosition;
112 vector<double> outputRise,outputDecay;
113 QError err = fTimeConstants->Compute(samples,maxPos,baseline,outputRise,outputDecay);
116 if(outputRise.size() != fRiseVars.size()) Panic(
"Output rise time variables differ in number from expected");
117 for(
size_t i = 0; i < outputRise.size(); i++) {
118 ev.
Get<
QDouble>(fRiseVars[i].c_str()) = outputRise[i]/samplingFreq;
119 ev.
Get<
QDouble>((fRiseVars[i]+
"Window").c_str()) = outputRise[i]/(
double)samples.Size();
122 if(outputDecay.size() != fDecayVars.size()) Panic(
"Output decay time variables differ in number from expected");
123 for(
size_t i = 0; i < outputDecay.size(); i++) {
124 ev.
Get<
QDouble>(fDecayVars[i].c_str()) = outputDecay[i]/samplingFreq;
125 ev.
Get<
QDouble>((fDecayVars[i]+
"Window").c_str()) = outputDecay[i]/(
double)samples.Size();
131 if(fTimeConstants)
delete fTimeConstants;
QRunDataHandle rHandle(753)
QChannelRunData chanRunData
#define REGISTER_MODULE(clazz)
Computes rise and decay times of a pulse.
void Do(Diana::QEvent &ev)
Do method. Declare and implement only one of the two versions.
void Init(Diana::QEvent &ev)
Init method.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
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.
Interval of real numbers.
void SetMin(const double min)
Set minimum of the interval.
void SetMax(const double max)
Set maximum of the interval.
Raw event: bolometer channel, trigger positions and types.
Raw event: sampled waveform.
global handle for QRunData
const QChannelRunData & GetChannelRunData(const int channel) const
get channel based run data quantities
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...