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