I discovered a nasty bug in CORRFW/AliCFGridSparse.cxx:
[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>
02544cea 31#include <cstdlib>
8c50acf2 32#ifdef ALI_DATE
df0f3179 33#include <TROOT.h>
34#include <TSystem.h>
35#include <TDatime.h>
36#include "AliRawReaderDate.h"
37#include "event.h"
38#include "monitor.h"
39#endif
40
df0f3179 41//_____________________________________________________________________________
42class AliGDCInterruptHandler : public TSignalHandler {
43public:
44 AliGDCInterruptHandler();
45 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
46 Bool_t Stop() const {return fStop;};
47private:
48 Bool_t fStop; // CTRL-C pressed
49};
50
51//_____________________________________________________________________________
52AliGDCInterruptHandler::AliGDCInterruptHandler() :
e41f1e44 53 TSignalHandler(kSigInterrupt, kFALSE),
54 fStop(kFALSE)
df0f3179 55{
e41f1e44 56
cae21299 57}
df0f3179 58
59
60//_____________________________________________________________________________
8c50acf2 61#ifdef ALI_DATE
df0f3179 62int main(int argc, char** argv)
63{
64 // set ROOT in batch mode
65 gROOT->SetBatch();
66
67 // get data from a file or online from this node
68 Int_t status = 0;
69 if (argc > 1) {
70 status = monitorSetDataSource(argv[1]);
71 } else {
72 status = monitorSetDataSource(":");
73 }
74 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
75
76 // monitor only a sample of physics events
77 char* table[] = {"Physics event", "yes", NULL};
78 status = monitorDeclareTable(table);
79 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
80
81 // declare this monitoring program to DATE
82 status = monitorDeclareMp("data consistency check");
83 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
84
85 // create the signal handler
86 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
87 gSystem->AddSignalHandler(handler);
88
89 // endless loop
90 void* ptr = NULL;
91 while (!handler->Stop()) {
92 // get the next event
93 status = monitorGetEventDynamic(&ptr);
94 if (status == (Int_t)MON_ERR_EOF) break;
95 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
96
97 // if no new event
98 if (!ptr) {
99 gSystem->Sleep(1000); // sleep for 1 second
100 continue;
101 }
102
103 // check the data
104 AliRawReaderDate rawReader(ptr);
105 Int_t errorCode = rawReader.CheckData();
106 if ((errorCode != 0) && (errorCode != AliRawReader::kErrSize)) {
107 TDatime time;
108 printf("\n%s\n", time.AsString());
109 const char* errMsg[6] = {"no error", "wrong magic word in sub event",
110 "no mini header",
111 "wrong magic word in mini header",
112 "inconsistent size in sub event and mini header",
113 "access to data out of bounds"};
114 printf("Error: %s\n", errMsg[errorCode]);
115 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
116 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
117 printf("trigger: %08x %08x detector: %08x\n",
118 rawReader.GetTriggerPattern()[0],
119 rawReader.GetTriggerPattern()[1],
120 rawReader.GetDetectorPattern()[0]);
121 printf("attributes: %08x %08x %08x\n", rawReader.GetAttributes()[0],
122 rawReader.GetAttributes()[1], rawReader.GetAttributes()[2]);
123 }
124
125 free(ptr);
126 gSystem->ProcessEvents();
127 }
128
129 gSystem->RemoveSignalHandler(handler);
130
131 return 0;
132}
133
134#else
135int main(int /*argc*/, char** /*argv*/)
136{
137 ::Fatal("main", "this program was compiled without DATE");
138
139 return 1;
140}
141#endif