]>
Commit | Line | Data |
---|---|---|
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> | |
29 | #include <TSysEvtHandler.h> | |
30 | #ifdef ALI_DATE | |
31 | #include <TROOT.h> | |
32 | #include <TSystem.h> | |
33 | #include <TDatime.h> | |
34 | #include "AliRawReaderDate.h" | |
35 | #include "event.h" | |
36 | #include "monitor.h" | |
37 | /* | |
38 | #include <AliHLTStandardIncludes.h> | |
39 | #include <AliHLTTransform.h> | |
40 | #include <AliHLTMemHandler.h> | |
41 | #include <AliHLTTrackArray.h> | |
42 | #include <AliHLTHoughMaxFinder.h> | |
43 | #include <AliHLTHoughBaseTransformer.h> | |
44 | #include <AliHLTHough.h> | |
45 | #include <AliHLTBenchmark.h> | |
46 | #include <AliHLTITSclusterer.h> | |
47 | #include <AliHLTITSVertexerZ.h> | |
48 | #include <AliHLTITStracker.h> | |
49 | */ | |
50 | #include "AliESDEvent.h" | |
51 | #include "AliESDVertex.h" | |
52 | #include "AliTracker.h" | |
53 | #include <AliKalmanTrack.h> | |
54 | #include "AliITSgeomTGeo.h" | |
55 | #include "AliITSgeom.h" | |
56 | #endif | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | class AliGDCInterruptHandler : public TSignalHandler { | |
60 | public: | |
61 | AliGDCInterruptHandler(); | |
62 | Bool_t Notify() {fStop = kTRUE; return kTRUE;}; | |
63 | Bool_t Stop() const {return fStop;}; | |
64 | private: | |
65 | Bool_t fStop; // CTRL-C pressed | |
66 | }; | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | AliGDCInterruptHandler::AliGDCInterruptHandler() : | |
70 | TSignalHandler(kSigInterrupt, kFALSE), | |
71 | fStop(kFALSE) | |
72 | { | |
73 | ||
74 | } | |
75 | ||
76 | ||
77 | //_____________________________________________________________________________ | |
78 | #ifdef ALI_DATE | |
79 | int main(int argc, char** argv) | |
80 | { | |
81 | // set ROOT in batch mode | |
82 | gROOT->SetBatch(); | |
83 | ||
84 | // open a log file | |
85 | FILE* file = fopen("monitorGDC.log", "w"); | |
86 | ||
87 | TDatime time; | |
88 | ||
89 | // get data from a file or online from this node | |
90 | Int_t status = 0; | |
91 | if (argc > 1) { | |
92 | status = monitorSetDataSource(argv[1]); | |
93 | } else { | |
94 | status = monitorSetDataSource(":"); | |
95 | } | |
96 | if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status)); | |
97 | ||
98 | // monitor only a sample of physics events | |
99 | char* table[] = {"Physics event", "yes", NULL}; | |
100 | status = monitorDeclareTable(table); | |
101 | if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status)); | |
102 | ||
103 | // declare this monitoring program to DATE | |
104 | status = monitorDeclareMp("GDC physics monitoring"); | |
105 | if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status)); | |
106 | ||
107 | // initialize HLT transformations | |
108 | // if (!AliHLTTransform::Init("./", kFALSE)) { | |
109 | // ::Fatal("AliHLTTransform::Init", "HLT initialization failed"); | |
110 | // } | |
111 | ||
112 | AliESDEvent *esd = new AliESDEvent; | |
113 | esd->CreateStdContent(); | |
114 | ||
115 | // AliITSgeom *geom = new AliITSgeom(); | |
116 | // geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det"); | |
117 | // if (!geom) return 1; | |
118 | // Int_t sfield = 0; | |
119 | // switch ((Int_t)(AliHLTTransform::GetSolenoidField()+0.5)) { | |
120 | // case 2: | |
121 | // sfield = AliMagF::k2kG; | |
122 | // break; | |
123 | // case 5: | |
124 | // sfield = AliMagF::k5kG; | |
125 | // break; | |
126 | // default: | |
127 | // ::Fatal("AliHLTTransform::GetSolenoidField", "Incorrect magnetic field"); | |
128 | // } | |
129 | ||
130 | // Init PID | |
131 | AliPID pid; | |
132 | ||
133 | // create the signal handler | |
134 | AliGDCInterruptHandler* handler = new AliGDCInterruptHandler; | |
135 | gSystem->AddSignalHandler(handler); | |
136 | ||
137 | // endless loop | |
138 | void* ptr = NULL; | |
139 | while (!handler->Stop()) { | |
140 | // get the next event | |
141 | status = monitorGetEventDynamic(&ptr); | |
142 | if (status == (Int_t)MON_ERR_EOF) break; | |
143 | if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status)); | |
144 | ||
145 | // if no new event | |
146 | if (!ptr) { | |
147 | gSystem->Sleep(1000); // sleep for 1 second | |
148 | continue; | |
149 | } | |
150 | ||
151 | AliRawReaderDate rawReader(ptr); | |
152 | // if ((rawReader.GetAttributes()[0] & 0x02) != 0) { | |
153 | ||
154 | // Int_t errorCode = rawReader.CheckData(); | |
155 | Int_t errorCode = 0; | |
156 | if (errorCode && (errorCode != AliRawReader::kErrSize)) { | |
157 | time.Set(); | |
158 | if (file) fprintf(file, "%s\n", time.AsString()); | |
159 | if (file) fprintf(file, "run: %d event: %d %d\n", | |
160 | rawReader.GetRunNumber(), | |
161 | rawReader.GetEventId()[0], | |
162 | rawReader.GetEventId()[1]); | |
163 | fprintf(file, "ERROR: %d\n\n", errorCode); | |
164 | ||
165 | } else { | |
166 | ||
167 | // AliHLTBenchmark *fBenchmark = new AliHLTBenchmark(); | |
168 | // fBenchmark->Start("Overall timing"); | |
169 | ||
170 | // // ITS clusterer and vertexer | |
171 | // fBenchmark->Start("ITS Clusterer"); | |
172 | // AliHLTITSclusterer clusterer(0); | |
173 | // AliRawReader *itsrawreader=new AliRawReaderDate(ptr); | |
174 | // TTree* treeClusters = new TTree("TreeL3ITSclusters"," "); //make a tree | |
175 | // clusterer.Digits2Clusters(itsrawreader,treeClusters); | |
176 | // fBenchmark->Stop("ITS Clusterer"); | |
177 | ||
178 | // AliHLTITSVertexerZ vertexer; | |
179 | // AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters); | |
180 | // Double_t vtxPos[3]; | |
181 | // Double_t vtxErr[3]={0.005,0.005,0.010}; | |
182 | // vertex->GetXYZ(vtxPos); | |
183 | // // vertex->GetSigmaXYZ(vtxErr); | |
184 | // esd->SetVertex(vertex); | |
185 | ||
186 | // // TPC Hough reconstruction | |
187 | // Float_t ptmin = 0.1*AliHLTTransform::GetSolenoidField(); | |
188 | // Float_t zvertex = vtxPos[2]; | |
189 | ||
190 | // // Run the Hough Transformer | |
191 | // fBenchmark->Start("Init"); | |
192 | // AliHLTHough *hough1 = new AliHLTHough(); | |
193 | ||
194 | // hough1->SetThreshold(4); | |
195 | // hough1->CalcTransformerParams(ptmin); | |
196 | // hough1->SetPeakThreshold(70,-1); | |
197 | // // printf("Pointer is %x\n",ptr); | |
198 | // hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex); | |
199 | // hough1->SetAddHistograms(); | |
200 | // fBenchmark->Stop("Init"); | |
201 | ||
202 | // fBenchmark->Start("Init"); | |
203 | // AliHLTHough *hough2 = new AliHLTHough(); | |
204 | ||
205 | // hough2->SetThreshold(4); | |
206 | // hough2->CalcTransformerParams(ptmin); | |
207 | // hough2->SetPeakThreshold(70,-1); | |
208 | // // printf("Pointer is %x\n",ptr); | |
209 | // hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex); | |
210 | // hough2->SetAddHistograms(); | |
211 | // fBenchmark->Stop("Init"); | |
212 | ||
213 | // Int_t nglobaltracks = 0; | |
214 | // /* | |
215 | // hough1->StartProcessInThread(0,17); | |
216 | // hough2->StartProcessInThread(18,35); | |
217 | ||
218 | // // gSystem->Sleep(20000); | |
219 | // if(hough1->WaitForThreadFinish()) | |
220 | // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! "); | |
221 | // if(hough2->WaitForThreadFinish()) | |
222 | // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! "); | |
223 | ||
224 | // gSystem->MakeDirectory("hough1"); | |
225 | // hough1->WriteTracks("./hough1"); | |
226 | // gSystem->MakeDirectory("hough2"); | |
227 | // hough2->WriteTracks("./hough2"); | |
228 | // */ | |
229 | ||
230 | // for(int slice=0; slice<=17; slice++) | |
231 | // { | |
232 | // // cout<<"Processing slice "<<slice<<endl; | |
233 | // fBenchmark->Start("ReadData"); | |
234 | // hough1->ReadData(slice,0); | |
235 | // fBenchmark->Stop("ReadData"); | |
236 | // fBenchmark->Start("Transform"); | |
237 | // hough1->Transform(); | |
238 | // fBenchmark->Stop("Transform"); | |
239 | // hough1->AddAllHistogramsRows(); | |
240 | // hough1->FindTrackCandidatesRow(); | |
241 | // fBenchmark->Start("AddTracks"); | |
242 | // hough1->AddTracks(); | |
243 | // fBenchmark->Stop("AddTracks"); | |
244 | ||
245 | // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough1->GetTracks(0); | |
246 | // // nglobaltracks += tracks->GetNTracks(); | |
247 | // } | |
248 | // for(int slice=18; slice<=35; slice++) | |
249 | // { | |
250 | // // cout<<"Processing slice "<<slice<<endl; | |
251 | // fBenchmark->Start("ReadData"); | |
252 | // hough2->ReadData(slice,0); | |
253 | // fBenchmark->Stop("ReadData"); | |
254 | // fBenchmark->Start("Transform"); | |
255 | // hough2->Transform(); | |
256 | // fBenchmark->Stop("Transform"); | |
257 | // hough2->AddAllHistogramsRows(); | |
258 | // hough2->FindTrackCandidatesRow(); | |
259 | // fBenchmark->Start("AddTracks"); | |
260 | // hough2->AddTracks(); | |
261 | // fBenchmark->Stop("AddTracks"); | |
262 | ||
263 | // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough2->GetTracks(0); | |
264 | // // nglobaltracks += tracks->GetNTracks(); | |
265 | // } | |
266 | ||
267 | // nglobaltracks += hough1->FillESD(esd); | |
268 | // nglobaltracks += hough2->FillESD(esd); | |
269 | ||
270 | // // ITS tracker | |
271 | // AliHLTITStracker itsTracker(0); | |
272 | // itsTracker.SetVertex(vtxPos,vtxErr); | |
273 | ||
274 | // itsTracker.LoadClusters(treeClusters); | |
275 | // itsTracker.Clusters2Tracks(esd); | |
276 | // itsTracker.UnloadClusters(); | |
277 | ||
278 | // fBenchmark->Stop("Overall timing"); | |
279 | // time.Set(); | |
280 | // if (file) fprintf(file, "%s\n", time.AsString()); | |
281 | // if (file) fprintf(file, "run: %d event: %d %d\n", | |
282 | // rawReader.GetRunNumber(), | |
283 | // rawReader.GetEventId()[0], | |
284 | // rawReader.GetEventId()[1]); | |
285 | // if (errorCode) fprintf(file, "ERROR: %d\n", errorCode); | |
286 | ||
287 | // if (file) fprintf(file, "Hough Transformer found %d tracks\n",nglobaltracks); | |
288 | ||
289 | // hough1->DoBench("hough1"); | |
290 | // hough2->DoBench("hough2"); | |
291 | // fBenchmark->Analyze("overall"); | |
292 | // if (file) { | |
293 | // FILE* bench = fopen("hough1.dat", "r"); | |
294 | // while (bench && !feof(bench)) { | |
295 | // char buffer[256]; | |
296 | // if (!fgets(buffer, 256, bench)) break; | |
297 | // fprintf(file, "%s", buffer); | |
298 | // } | |
299 | // fclose(bench); | |
300 | // } | |
301 | // if (file) { | |
302 | // FILE* bench = fopen("hough2.dat", "r"); | |
303 | // while (bench && !feof(bench)) { | |
304 | // char buffer[256]; | |
305 | // if (!fgets(buffer, 256, bench)) break; | |
306 | // fprintf(file, "%s", buffer); | |
307 | // } | |
308 | // fclose(bench); | |
309 | // } | |
310 | // if (file) { | |
311 | // FILE* bench = fopen("overall.dat", "r"); | |
312 | // while (bench && !feof(bench)) { | |
313 | // char buffer[256]; | |
314 | // if (!fgets(buffer, 256, bench)) break; | |
315 | // fprintf(file, "%s", buffer); | |
316 | // } | |
317 | // fclose(bench); | |
318 | // fprintf(file, "\n\n"); | |
319 | // } | |
320 | ||
321 | // delete hough1; | |
322 | // delete hough2; | |
323 | ||
324 | // esd->Reset(); | |
325 | } | |
326 | // } | |
327 | ||
328 | /* | |
329 | // read run, event, detector, DDL numbers and data size | |
330 | AliRawReaderDate rawReader(ptr); | |
331 | time.Set(); | |
332 | printf("\n%s\n", time.AsString()); | |
333 | printf("run: %d event: %d %d\n", rawReader.GetRunNumber(), | |
334 | rawReader.GetEventId()[0], rawReader.GetEventId()[1]); | |
335 | while (rawReader.ReadMiniHeader()) { | |
336 | printf(" detector: %d DDL: %d size: %d\n", | |
337 | rawReader.GetDetectorID(), rawReader.GetDDLID(), | |
338 | rawReader.GetDataSize()); | |
339 | } | |
340 | ||
341 | */ | |
342 | ||
343 | gSystem->Sleep(100); // sleep for 0.1 second | |
344 | free(ptr); | |
345 | ||
346 | gSystem->ProcessEvents(); | |
347 | if (file) fflush(file); | |
348 | ||
349 | } | |
350 | ||
351 | gSystem->RemoveSignalHandler(handler); | |
352 | if (file) fclose(file); | |
353 | ||
354 | return 0; | |
355 | } | |
356 | ||
357 | #else | |
358 | int main(int /*argc*/, char** /*argv*/) | |
359 | { | |
360 | ::Fatal("main", "this program was compiled without DATE"); | |
361 | ||
362 | return 1; | |
363 | } | |
364 | #endif |