]>
Commit | Line | Data |
---|---|---|
b5279783 | 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 by running the HLT code // | |
21 | // // | |
22 | // If an argument is given, this is taken as the name of a date file which // | |
23 | // is used instead of the local node. // | |
24 | // The program can be stopped by pressing CTRL-C. // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include <TError.h> | |
8ecba4b2 | 29 | #include <TSysEvtHandler.h> |
b5279783 | 30 | #ifdef DATE_SYS |
31 | #include <TROOT.h> | |
32 | #include <TSystem.h> | |
b5279783 | 33 | #include <TDatime.h> |
34 | #include "AliRawReaderDate.h" | |
35 | #include "event.h" | |
36 | #include "monitor.h" | |
37 | #ifdef ALI_HLT | |
38 | #include <AliLevel3.h> | |
39 | #include <AliL3Transform.h> | |
40 | #include <AliL3MemHandler.h> | |
41 | #include <AliL3TrackArray.h> | |
42 | #endif | |
43 | #endif | |
44 | ||
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 | //_____________________________________________________________________________ | |
b5279783 | 65 | #ifdef DATE_SYS |
120b3c73 | 66 | int main(int argc, char** argv) |
67 | { | |
b5279783 | 68 | // set ROOT in batch mode |
69 | gROOT->SetBatch(); | |
70 | ||
71 | // open a log file | |
df0f3179 | 72 | #ifdef ALI_HLT |
b5279783 | 73 | FILE* file = fopen("monitorGDC.log", "w"); |
df0f3179 | 74 | #else |
75 | FILE* file = NULL; | |
76 | #endif | |
b5279783 | 77 | TDatime time; |
78 | ||
79 | // get data from a file or online from this node | |
80 | Int_t status = 0; | |
81 | if (argc > 1) { | |
82 | status = monitorSetDataSource(argv[1]); | |
83 | } else { | |
84 | status = monitorSetDataSource(":"); | |
85 | } | |
86 | if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status)); | |
87 | ||
88 | // monitor only a sample of physics events | |
89 | char* table[] = {"Physics event", "yes", NULL}; | |
90 | status = monitorDeclareTable(table); | |
91 | if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status)); | |
92 | ||
93 | // declare this monitoring program to DATE | |
04b48a95 | 94 | status = monitorDeclareMp("GDC physics monitoring"); |
b5279783 | 95 | if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status)); |
96 | ||
97 | #ifdef ALI_HLT | |
98 | // initialize HLT transformations | |
99 | if (!AliL3Transform::Init("./", kFALSE)) { | |
100 | ::Fatal("AliL3Transform::Init", "HLT initialization failed"); | |
101 | } | |
102 | #endif | |
103 | ||
104 | // create the signal handler | |
105 | AliGDCInterruptHandler* handler = new AliGDCInterruptHandler; | |
106 | gSystem->AddSignalHandler(handler); | |
107 | ||
108 | // endless loop | |
109 | void* ptr = NULL; | |
110 | while (!handler->Stop()) { | |
111 | // get the next event | |
112 | status = monitorGetEventDynamic(&ptr); | |
113 | if (status == (Int_t)MON_ERR_EOF) break; | |
114 | if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status)); | |
115 | ||
116 | // if no new event | |
117 | if (!ptr) { | |
118 | gSystem->Sleep(1000); // sleep for 1 second | |
119 | continue; | |
120 | } | |
121 | ||
122 | #ifdef ALI_HLT | |
04b48a95 | 123 | AliRawReaderDate rawReader(ptr); |
124 | if ((rawReader.GetAttributes()[0] & 0x02) != 0) { | |
125 | ||
3256212a | 126 | Int_t errorCode = rawReader.CheckData(); |
127 | if (errorCode && (errorCode != AliRawReader::kErrSize)) { | |
128 | time.Set(); | |
129 | if (file) fprintf(file, "%s\n", time.AsString()); | |
130 | if (file) fprintf(file, "run: %d event: %d %d\n", | |
131 | rawReader.GetRunNumber(), | |
132 | rawReader.GetEventId()[0], | |
133 | rawReader.GetEventId()[1]); | |
134 | fprintf(file, "ERROR: %d\n\n", errorCode); | |
135 | ||
136 | } else { | |
137 | ||
138 | // run the HLT tracker | |
139 | AliLevel3* hlt = new AliLevel3((Char_t*)ptr); | |
140 | hlt->Init("./", AliLevel3::kDate, 1); | |
141 | ||
142 | hlt->SetClusterFinderParam(-1, -1, kTRUE); | |
b5279783 | 143 | |
3256212a | 144 | Int_t phiSegments = 50; |
145 | Int_t etaSegments = 100; | |
146 | Int_t trackletlength = 3; | |
147 | Int_t tracklength = 20;//40 or 5 | |
148 | Int_t rowscopetracklet = 2; | |
149 | Int_t rowscopetrack = 10; | |
150 | Double_t minPtFit = 0; | |
151 | Double_t maxangle = 0.1745; | |
152 | Double_t goodDist = 5; | |
153 | Double_t maxphi = 0.1; | |
154 | Double_t maxeta = 0.1; | |
155 | Double_t hitChi2Cut = 15;//100 or 15 | |
156 | Double_t goodHitChi2 = 5;//20 or 5 | |
157 | Double_t trackChi2Cut = 10;//50 or 10 | |
158 | hlt->SetTrackerParam(phiSegments, etaSegments, | |
159 | trackletlength, tracklength, | |
160 | rowscopetracklet, rowscopetrack, | |
161 | minPtFit, maxangle, goodDist, hitChi2Cut, | |
162 | goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, | |
163 | kTRUE); | |
b5279783 | 164 | |
3256212a | 165 | gSystem->Exec("rm -rf hlt"); |
166 | gSystem->MakeDirectory("hlt"); | |
167 | hlt->WriteFiles("./hlt/"); | |
168 | hlt->ProcessEvent(0, 35, 0); | |
169 | ||
170 | time.Set(); | |
171 | if (file) fprintf(file, "%s\n", time.AsString()); | |
172 | if (file) fprintf(file, "run: %d event: %d %d\n", | |
173 | rawReader.GetRunNumber(), | |
174 | rawReader.GetEventId()[0], | |
175 | rawReader.GetEventId()[1]); | |
176 | if (errorCode) fprintf(file, "ERROR: %d\n", errorCode); | |
177 | ||
178 | AliL3MemHandler memHandler; | |
179 | if (!memHandler.SetBinaryInput("hlt/tracks_0.raw")) { | |
180 | if (file) fprintf(file, "no HLT tracks\n"); | |
181 | continue; | |
182 | } | |
183 | AliL3TrackArray* tracks = new AliL3TrackArray; | |
184 | memHandler.Binary2TrackArray(tracks); | |
185 | if (file) fprintf(file, "HLT found %d tracks\n", tracks->GetNTracks()); | |
186 | delete tracks; | |
187 | memHandler.CloseBinaryInput(); | |
188 | ||
189 | hlt->DoBench("hlt"); | |
190 | if (file) { | |
191 | FILE* bench = fopen("hlt.dat", "r"); | |
192 | while (bench && !feof(bench)) { | |
193 | char buffer[256]; | |
194 | if (!fgets(buffer, 256, bench)) break; | |
195 | fprintf(file, "%s", buffer); | |
196 | } | |
197 | fclose(bench); | |
198 | fprintf(file, "\n"); | |
04b48a95 | 199 | } |
b5279783 | 200 | |
3256212a | 201 | gSystem->Exec("rm -rf hlt"); |
202 | delete hlt; | |
203 | } | |
04b48a95 | 204 | } |
b5279783 | 205 | |
206 | #else | |
207 | // read run, event, detector, DDL numbers and data size | |
208 | AliRawReaderDate rawReader(ptr); | |
df0f3179 | 209 | time.Set(); |
210 | printf("\n%s\n", time.AsString()); | |
b5279783 | 211 | printf("run: %d event: %d %d\n", rawReader.GetRunNumber(), |
212 | rawReader.GetEventId()[0], rawReader.GetEventId()[1]); | |
213 | while (rawReader.ReadMiniHeader()) { | |
214 | printf(" detector: %d DDL: %d size: %d\n", | |
215 | rawReader.GetDetectorID(), rawReader.GetDDLID(), | |
216 | rawReader.GetDataSize()); | |
217 | } | |
218 | ||
b5279783 | 219 | #endif |
220 | ||
df0f3179 | 221 | gSystem->Sleep(100); // sleep for 0.1 second |
b5279783 | 222 | free(ptr); |
223 | ||
224 | gSystem->ProcessEvents(); | |
225 | if (file) fflush(file); | |
226 | } | |
227 | ||
228 | gSystem->RemoveSignalHandler(handler); | |
229 | if (file) fclose(file); | |
230 | ||
120b3c73 | 231 | return 0; |
232 | } | |
233 | ||
b5279783 | 234 | #else |
120b3c73 | 235 | int main(int /*argc*/, char** /*argv*/) |
236 | { | |
b5279783 | 237 | ::Fatal("main", "this program was compiled without DATE"); |
b5279783 | 238 | |
120b3c73 | 239 | return 1; |
b5279783 | 240 | } |
120b3c73 | 241 | #endif |