Diana Software
MTestUnroll.cc
Go to the documentation of this file.
1 #include "MTestUnroll.hh"
2 #include "QEvent.hh"
3 #include "QEventList.hh"
4 #include "QRawEvent.hh"
5 
6 using namespace Diana;
7 
9 
10 using std::stringstream;
11 #define ASSERT_EQUAL(x,y)\
12 if(x==y) fTestOK++;\
13 else {\
14 fTestKO++;\
15 stringstream difference;\
16 difference<<x<<" vs "<<y;\
17 Error("Test failed: file %s; line %d: %s", __FILE__ , __LINE__,difference.str().c_str());\
18 }
19 
20 
22 {
23  // called before event loop
24  fTestOK = 0;
25  fTestKO = 0;
26  fCallNumber = 0ULL;
27 }
28 
29 void MTestUnroll::Do(QEvent& ev, const QEventList& neighbours)
30 {
31  // called event by event
32 
33  const int occ = GetOccurrence();
34  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
35  const QPulseInfo& PI = ev.Get<QPulseInfo>("DAQ","PulseInfo");
36  const int evnum = header.GetEventNumber();
37  const bool isSide = PI.GetIsSide();
38 
39  if(occ == 0) {
40  if(!isSide) {
41  ASSERT_EQUAL(neighbours.Size(),fCallNumber % 5 +1);
42  fCallNumber++;
43  } else {
44  ASSERT_EQUAL(neighbours.Size(),1);
45  }
46  }
47 
48  if(occ == 1) {
49  ASSERT_EQUAL(isSide,false);
50  }
51  for(size_t i = 0; i < neighbours.Size(); i++) {
52  const QEvent& other = neighbours[i];
53  const QHeader& o_header = other.Get<QHeader>("DAQ","Header");
54  const QPulseInfo& o_PI = other.Get<QPulseInfo>("DAQ","PulseInfo");
55  const int o_evnum = o_header.GetEventNumber();
56  const bool o_isSide = o_PI.GetIsSide();
57  if(occ == 0) {
58  ASSERT_EQUAL(evnum,o_evnum);
59  }
60  else if(occ == 1) {
61  ASSERT_EQUAL(o_isSide,true);
62  }
63  }
64 }
65 
67 {
68  Info("----TEST SUMMARY (Occurrence = %d)-----",GetOccurrence());
69  Info("OK: %d", fTestOK);
70  if(fTestKO >0) Panic("KO: %d", fTestKO);
71  if(GetOccurrence() == 0 && fTestOK != 20000) Panic("Expected test %d vs %d",20000,fTestOK);
72  if(GetOccurrence() == 1 && fTestOK != 8000) Panic("Expected test %d vs %d",8000,fTestOK);
73 }
74 
#define ASSERT_EQUAL(x, y)
Definition: MTestUnroll.cc:11
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
one-line description of your module
Definition: MTestUnroll.hh:41
void Init(Diana::QEvent &ev)
Init method.
Definition: MTestUnroll.cc:21
void Done()
Done method.
Definition: MTestUnroll.cc:66
void Do(Diana::QEvent &ev, const Diana::QEventList &neighbours)
Do method.
Definition: MTestUnroll.cc:29
list of references to const QEvent (s)
Definition: QEventList.hh:21
size_t Size() const
number of QEvent (s)
Definition: QEventList.hh:36
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
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
int GetEventNumber() const
get EventNumber
Definition: QHeader.hh:25
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...