Protection against wrong trigger bc mask pattern
[u/mrichter/AliRoot.git] / MONITOR / monitorCheck.cxx
CommitLineData
df0f3179 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// this program performs local monitoring on a GDC and checks the //
21// consistency of the data //
22// //
23// If an argument is given, this is taken as the name of a date file which //
24// is used instead of the local node. //
25// The program can be stopped by pressing CTRL-C. //
26// //
27///////////////////////////////////////////////////////////////////////////////
28
29#include <TError.h>
30#include <TSysEvtHandler.h>
8c50acf2 31#ifdef ALI_DATE
df0f3179 32#include <TROOT.h>
33#include <TSystem.h>
34#include <TDatime.h>
35#include "AliRawReaderDate.h"
36#include "event.h"
37#include "monitor.h"
38#endif
39
df0f3179 40//_____________________________________________________________________________
41class AliGDCInterruptHandler : public TSignalHandler {
42public:
43 AliGDCInterruptHandler();
44 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
45 Bool_t Stop() const {return fStop;};
46private:
47 Bool_t fStop; // CTRL-C pressed
48};
49
50//_____________________________________________________________________________
51AliGDCInterruptHandler::AliGDCInterruptHandler() :
e41f1e44 52 TSignalHandler(kSigInterrupt, kFALSE),
53 fStop(kFALSE)
df0f3179 54{
e41f1e44 55
cae21299 56}
df0f3179 57
58
59//_____________________________________________________________________________
8c50acf2 60#ifdef ALI_DATE
df0f3179 61int main(int argc, char** argv)
62{
63 // set ROOT in batch mode
64 gROOT->SetBatch();
65
66 // get data from a file or online from this node
67 Int_t status = 0;
68 if (argc > 1) {
69 status = monitorSetDataSource(argv[1]);
70 } else {
71 status = monitorSetDataSource(":");
72 }
73 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
74
75 // monitor only a sample of physics events
76 char* table[] = {"Physics event", "yes", NULL};
77 status = monitorDeclareTable(table);
78 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
79
80 // declare this monitoring program to DATE
81 status = monitorDeclareMp("data consistency check");
82 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
83
84 // create the signal handler
85 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
86 gSystem->AddSignalHandler(handler);
87
88 // endless loop
89 void* ptr = NULL;
90 while (!handler->Stop()) {
91 // get the next event
92 status = monitorGetEventDynamic(&ptr);
93 if (status == (Int_t)MON_ERR_EOF) break;
94 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
95
96 // if no new event
97 if (!ptr) {
98 gSystem->Sleep(1000); // sleep for 1 second
99 continue;
100 }
101
102 // check the data
103 AliRawReaderDate rawReader(ptr);
104 Int_t errorCode = rawReader.CheckData();
105 if ((errorCode != 0) && (errorCode != AliRawReader::kErrSize)) {
106 TDatime time;
107 printf("\n%s\n", time.AsString());
108 const char* errMsg[6] = {"no error", "wrong magic word in sub event",
109 "no mini header",
110 "wrong magic word in mini header",
111 "inconsistent size in sub event and mini header",
112 "access to data out of bounds"};
113 printf("Error: %s\n", errMsg[errorCode]);
114 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
115 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
116 printf("trigger: %08x %08x detector: %08x\n",
117 rawReader.GetTriggerPattern()[0],
118 rawReader.GetTriggerPattern()[1],
119 rawReader.GetDetectorPattern()[0]);
120 printf("attributes: %08x %08x %08x\n", rawReader.GetAttributes()[0],
121 rawReader.GetAttributes()[1], rawReader.GetAttributes()[2]);
122 }
123
124 free(ptr);
125 gSystem->ProcessEvents();
126 }
127
128 gSystem->RemoveSignalHandler(handler);
129
130 return 0;
131}
132
133#else
134int main(int /*argc*/, char** /*argv*/)
135{
136 ::Fatal("main", "this program was compiled without DATE");
137
138 return 1;
139}
140#endif