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