Diana Software
MTestRawEvent.cc
Go to the documentation of this file.
1 #include "MTestRawEvent.hh"
2 #include "QEvent.hh"
3 #include "QRawEvent.hh"
4 #include "QPulse.hh"
5 #include "QInoDataReaderDebug.hh"
6 #include <sstream>
7 #include "QBaseType.hh"
8 #include "QBool.hh"
9 #include "QString.hh"
10 #include <cmath>
11 
12 
14 
15 #define ASSERT_EQUAL(x,y)\
16 if(x==y) fTestOK++;\
17 else {\
18 fTestKO++;\
19 stringstream difference;\
20 difference<<x<<" vs "<<y;\
21 Error("Test failed: file %s; line %d: %s", __FILE__ , __LINE__,difference.str().c_str());\
22 }
23 
24 using namespace std;
25 
27 {
28  // called once in a sequence
29  fTestOK = 0;
30  fTestKO = 0;
31 }
32 
34 {
35  if(!isEnabled()) return;
36  // called once in a sequence
37  Info("----TEST SUMMARY-----");
38  Info("OK: %d", fTestOK);
39  if(fTestKO >0 ) Error("KO: %d", fTestKO);
40  if(GetSequence().GetName() == "TestRaw" || GetSequence().GetName() == "Test")
41  if(fTestOK != 1050000) Panic("Expected test %d vs %d",1050000,fTestOK);
42  if(GetSequence().GetName() == "TestRawLight")
43  if(fTestOK != 52500000) Panic("Expected test %d vs %d",52500000,fTestOK);
44 }
45 
47 {
48  // called before event loop
49  fCheckInterval = GetInt("CheckInterval",50);
50  fReadNum = 0;
51  fTestOK = 0;
52  fTestKO = 0;
53  QString mystring;
54  mystring.Clear();
55  if(GetSequence().GetName() == "TestRaw")
56  ev.Add<QBool>("TestBoolAddition");
57  if(GetSequence().GetName() == "TestRawLight")
58  ev.Add<QBool>("TestBoolAddition");
59 }
60 
62 {
63  // called event by event
64  std::string seqName = GetSequence().GetName();
65  if(seqName == "TestRaw" || seqName == "TestRawLight") {
66  ev.Get<QBool>("TestBoolAddition") = true;
67  } else {
68  const QEvent& evc = ev;
69  evc.Get<QBool>("TestRawEvent","TestBoolAddition");
70  }
71  if(fReadNum % fCheckInterval == 0) {
72 
73  if(seqName == "TestRaw" || seqName == "TestRawLight") {
74  ev.Get<QBool>("TestBoolAddition") = false;
75  }
76  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
77  const QPulse& pulse = ev.Get<QPulse>("DAQ","Pulse");
78  const QPulseInfo& pulseInfo = ev.Get<QPulseInfo>("DAQ","PulseInfo");
79 
80  const QInoDataReaderDebug& debugData = ev.Get<QInoDataReaderDebug>("QinoDataReader","DebugData");
81 
82  // MV FIXME
83  //const QOFData& of = ev->GetOF();
84  const QSampleInfo& sampleInfo = pulseInfo.GetMasterSample();
85  //ASSERT_EQUAL(of.IsSet(),false);
86  ASSERT_EQUAL(header.GetRun(),
87  debugData.fRun);
88  ASSERT_EQUAL(header.GetEventNumber(),
89  debugData.fEventNumber);
90  ASSERT_EQUAL(pulseInfo.GetChannelId(),
91  debugData.fChannel);
92  ASSERT_EQUAL((int)sampleInfo.GetTriggerNumber(),
93  debugData.fTriggerType);
94  ASSERT_EQUAL(pulseInfo.GetIsPulser(),
95  debugData.fIsHeater);
96  ASSERT_EQUAL((pulseInfo.GetMasterSample().GetPulserDelay() == 1),
97  debugData.fIsStabHeater);
98  ASSERT_EQUAL((pulseInfo.GetMasterSample().GetPulserDelay() == 2),
99  debugData.fIsHighHeater);
100  ASSERT_EQUAL((pulseInfo.GetMasterSample().GetPulserDelay() == 3),
101  debugData.fIsLowHeater);
102  ASSERT_EQUAL(pulseInfo.GetIsSignal(),
103  debugData.fIsSignal);
104  ASSERT_EQUAL(pulseInfo.GetIsNoise(),
105  debugData.fIsNoise);
106  ASSERT_EQUAL(pulseInfo.GetIsVeto(),
107  debugData.fIsVeto);
108  ASSERT_EQUAL(header.GetTime(), debugData.fTime);
109  ASSERT_EQUAL(pulse.GetSamples().Size(),debugData.fSamples.Size());
110  for(size_t i = 0; i < debugData.fSamples.Size(); i++)
111  ASSERT_EQUAL(pulse.GetSamples()[i],debugData.fSamples[i]);
112  // MV FIXME
113  // ASSERT_EQUAL((int)pulse.GetTimedSample(), debugData.fTimedSample);
114 
115  }
116  fReadNum++;
117 }
118 
120 {
121  // called at the end of the event loop
122 }
123 
#define ASSERT_EQUAL(x, y)
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
one-line description of your module
void Init(QEvent &ev)
Init method.
void Done()
Done method.
~MTestRawEvent()
destructor
void Do(QEvent &ev)
Do method.
bool wrapped into a QObject
Definition: QBool.hh:17
diana event
Definition: QEvent.hh:46
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
const Diana::QTime & GetTime() const
get time
Definition: QHeader.hh:28
int GetRun() const
destructor
Definition: QHeader.hh:22
int GetEventNumber() const
get EventNumber
Definition: QHeader.hh:25
debug data for test sequences
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
Raw event: sampled waveform.
Definition: QPulse.hh:22
contains information on flagged samples
Definition: QSampleInfo.hh:24
string wrapped into a QObject
Definition: QString.hh:18
void Clear()
clear members
Definition: QString.hh:22