Diana Software
MOverlappedWindowFilter.cc
Go to the documentation of this file.
2 #include "QEvent.hh"
3 #include "QRawEvent.hh"
4 #include "QRunDataHandle.hh"
5 #include <cmath>
6 
7 using namespace Diana;
8 
10 /*
11 MOverlappedWindowFilter::MOverlappedWindowFilter(QSequence* s) : QFilter("OverlappedWindowFilter",s)
12 {
13  // called once in a sequence
14 }
15 
16 MOverlappedWindowFilter::~MOverlappedWindowFilter()
17 {
18  // called once in a sequence
19 }*/
20 
21 
22 void MOverlappedWindowFilter::GetCuts(const QEvent& ev)
23 {
24  // Get parameters from cfg
25  fPulseLabel = GetString("PulseLabel","DAQ@Pulse",false);
26 
27  fRun = -1;
28 }
29 
31 {
32 
33  const QHeader& hdr = ev.Get<QHeader>("DAQ","Header");
34 
36  GlobalData().Get("",&rHandle,"");
37  const QRunData& runData = rHandle.Get();
38 
39  int thisRun = runData.fNumber;
40  if(thisRun != fRun)
41  {
42  fChannels.clear();
43  fRun = thisRun;
44  }
45 
46  // check that this window is not overlapped with a previous one
47  // const QRawEvent& raw = ev.GetRawEvent();
48  // const int channel = raw.GetPulse().GetChannelId();
49  const QPulseInfo& pulseInfo = ev.Get<QPulseInfo>("DAQ","PulseInfo");
50  int channel = pulseInfo.GetChannelId();
51 
52  // const unsigned long long time = ev.GetTime().GetFromStartRunNs();
53  const unsigned long long time = hdr.GetTime().GetFromStartRunNs();
54  const double samplFreq = runData.GetChannelRunData(channel).fSamplingFrequency;
55  // const size_t N = raw.GetPulse().GetSamples().Size();
56  //const QPulse& pulse = ev.Get<QPulse>("DAQ","Pulse");
57  const QPulse &pulse = ev.GetByLabel<QPulse>(fPulseLabel);
58  const size_t N = pulse.GetSamples().Size();
59  // const int timedSample = pulse.GetTimedSample();
60  const int timedSample = pulseInfo.GetMasterSample().GetSampleIndex();
61  std::map<int, unsigned long long>::iterator chanIter = fChannels.find(channel);
62 
63  const unsigned long long firstTimeInWindow = time - (unsigned long long)(double(timedSample)*1.e09/samplFreq);
64  const unsigned long long lastTimeInWindow = firstTimeInWindow + (unsigned long long)(double(N)*1.e09/samplFreq);
65  if(chanIter != fChannels.end()) {
66  if(firstTimeInWindow <= chanIter->second) {
67  return false;
68  } else {
69  chanIter->second = lastTimeInWindow;
70  return true;
71  }
72 
73  } else {
74  fChannels[channel] = lastTimeInWindow;
75  return true;
76  }
77 
78 
79  return true;
80 }
int N
Definition: CheckOF.C:24
QRunDataHandle rHandle(753)
const int channel
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
filter non overlapped events
bool Filter(const Diana::QEvent &ev)
return true if ev passes the cuts
double fSamplingFrequency
sampling frequency in Hz
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 Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
const Diana::QTime & GetTime() const
get time
Definition: QHeader.hh:28
int GetRun() const
destructor
Definition: QHeader.hh:22
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
const QSampleInfo & GetMasterSample() const
Get MasterSample.
Definition: QPulseInfo.hh:26
const int & GetChannelId() const
Get ChannelId.
Definition: QPulseInfo.hh:22
Raw event: sampled waveform.
Definition: QPulse.hh:22
const Diana::QVector & GetSamples() const
Get Samples casted to double (QVector instead of QVectorI). Use this method in place of GetSamplesADC...
Definition: QPulse.cc:49
global handle for QRunData
Basic run based info.
Definition: QRunData.hh:20
int fNumber
Run Number.
Definition: QRunData.hh:41
const QChannelRunData & GetChannelRunData(const int channel) const
get channel based run data quantities
Definition: QRunData.cc:339
Int_t GetSampleIndex() const
Get SampleIndex from the beginning of the waveform.
Definition: QSampleInfo.hh:51
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...