Diana Software
MPulseIntegral.cc
Go to the documentation of this file.
1 #include "MPulseIntegral.hh"
2 #include "QEvent.hh"
3 #include "QEventList.hh"
4 #include "QBaselineData.hh"
5 #include "QPulse.hh"
6 #include "QBaseType.hh"
7 #include "QHeader.hh"
8 #include "QPulseInfo.hh"
9 #include "QRunDataHandle.hh"
10 
11 
13 
14 using namespace Diana;
15 
17 {
18  fPulseLabel = GetString("PulseLabel","DAQ@Pulse",false);
19  fBaselineOwner = GetString("BaselineOwner","BaselineModule",false);
20  ev.RequireByLabel<QPulse>(fPulseLabel);
21  ev.Require<QBaselineData>(fBaselineOwner,"BaselineData");
22  ev.Require<QHeader>("DAQ","Header");
23  ev.Require<QPulseInfo>("DAQ","PulseInfo");
24 
25  ev.Add<QDouble>("Integral");
26 
27  fNormalizeAmplitude = GetBool("NormalizeAmplitude",false,false);
28  if(fNormalizeAmplitude) {
29  fAmplitudeLabel = GetString("AmplitudeLabel",Q_STRING_DEFAULT);
30  ev.RequireByLabel<QDouble>(fAmplitudeLabel);
31  ev.Add<QDouble>("NormalizedAmplitude");
32  }
33 
34  fTomV = GetBool("ConvertTomV",true,false);
35 }
36 
38 {
39  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
40  const int channel = ev.Get<QPulseInfo>("DAQ","PulseInfo").GetChannelId();
41  int run = header.GetRun();
43  GlobalData().Get("",&rHandle,"");
44  const QRunData& runData = rHandle.Get();
46 
47  double ADC2mV = 1;
48  if(fTomV) ADC2mV = chanRunData.fADC2mV;
49  const double samplingFreq = chanRunData.fSamplingFrequency;
50 
51  const QVector& samples = ev.GetByLabel<QPulse>(fPulseLabel).GetSamples()*ADC2mV;
52  const double baseline = ev.Get<QBaselineData>(fBaselineOwner.c_str(),"BaselineData").GetBaseline();
53  const size_t N = samples.Size();
54  double integral = samples.Sum(N,0)-baseline*N;
55  integral /= samplingFreq;
56  ev.Get<QDouble>("Integral") = integral;
57 
58  if(fNormalizeAmplitude) {
59  ev.Get<QDouble>("NormalizedAmplitude") = ev.GetByLabel<QDouble>(fAmplitudeLabel)/integral;
60  }
61 
62 
63 }
64 
66 {
67 }
68 
int N
Definition: CheckOF.C:24
QRunDataHandle rHandle(753)
const int channel
QChannelRunData chanRunData
#define Q_STRING_DEFAULT
Definition: QDiana.hh:38
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Compute the pulse integral.
void Init(Diana::QEvent &ev)
Init method.
void Do(Diana::QEvent &ev)
Do method. Declare and implement only one of the two versions.
void Done()
Done method.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
Definition: QBaseType.hh:17
baseline data
basic channel and run based info. Used in the QRunData object.
double fSamplingFrequency
sampling frequency in Hz
double fADC2mV
conversion: mV = ADC * fADC2mV
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
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
Definition: QEvent.hh:232
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
Definition: QEvent.hh:193
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
int GetRun() const
destructor
Definition: QHeader.hh:22
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
Raw event: sampled waveform.
Definition: QPulse.hh:22
global handle for QRunData
Basic run based info.
Definition: QRunData.hh:20
const QChannelRunData & GetChannelRunData(const int channel) const
get channel based run data quantities
Definition: QRunData.cc:339
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...