1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // this program performs local monitoring on a GDC by running the HLT code //
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. //
26 ///////////////////////////////////////////////////////////////////////////////
29 #include <TSysEvtHandler.h>
34 #include "AliRawReaderDate.h"
37 #include <AliL3StandardIncludes.h>
38 #include <AliL3Transform.h>
39 #include <AliL3MemHandler.h>
40 #include <AliL3TrackArray.h>
41 #include <AliL3HoughMaxFinder.h>
42 #include <AliL3HoughBaseTransformer.h>
43 #include <AliL3Hough.h>
44 #include <AliL3Benchmark.h>
48 //_____________________________________________________________________________
49 class AliGDCInterruptHandler : public TSignalHandler {
51 AliGDCInterruptHandler();
52 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
53 Bool_t Stop() const {return fStop;};
55 Bool_t fStop; // CTRL-C pressed
58 //_____________________________________________________________________________
59 AliGDCInterruptHandler::AliGDCInterruptHandler() :
60 TSignalHandler(kSigInterrupt, kFALSE)
66 //_____________________________________________________________________________
68 int main(int argc, char** argv)
70 // set ROOT in batch mode
74 FILE* file = fopen("monitorGDC.log", "w");
78 // get data from a file or online from this node
81 status = monitorSetDataSource(argv[1]);
83 status = monitorSetDataSource(":");
85 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
87 // monitor only a sample of physics events
88 char* table[] = {"Physics event", "yes", NULL};
89 status = monitorDeclareTable(table);
90 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
92 // declare this monitoring program to DATE
93 status = monitorDeclareMp("GDC physics monitoring");
94 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
96 // initialize HLT transformations
97 if (!AliL3Transform::Init("./", kFALSE)) {
98 ::Fatal("AliL3Transform::Init", "HLT initialization failed");
101 // create the signal handler
102 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
103 gSystem->AddSignalHandler(handler);
107 while (!handler->Stop()) {
108 // get the next event
109 status = monitorGetEventDynamic(&ptr);
110 if (status == (Int_t)MON_ERR_EOF) break;
111 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
115 gSystem->Sleep(1000); // sleep for 1 second
119 AliRawReaderDate rawReader(ptr);
120 // if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
122 // Int_t errorCode = rawReader.CheckData();
124 if (errorCode && (errorCode != AliRawReader::kErrSize)) {
126 if (file) fprintf(file, "%s\n", time.AsString());
127 if (file) fprintf(file, "run: %d event: %d %d\n",
128 rawReader.GetRunNumber(),
129 rawReader.GetEventId()[0],
130 rawReader.GetEventId()[1]);
131 fprintf(file, "ERROR: %d\n\n", errorCode);
135 AliL3Benchmark *fBenchmark = new AliL3Benchmark();
136 fBenchmark->Start("Overall timing");
138 // Run the Hough Transformer
139 fBenchmark->Start("Init");
140 AliL3Hough *hough1 = new AliL3Hough();
142 hough1->SetThreshold(4);
143 hough1->SetTransformerParams(76,140,0.4,-1);
144 hough1->SetPeakThreshold(70,-1);
145 // printf("Pointer is %x\n",ptr);
146 hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,3.82147);
147 hough1->SetAddHistograms();
148 fBenchmark->Stop("Init");
150 fBenchmark->Start("Init");
151 AliL3Hough *hough2 = new AliL3Hough();
153 hough2->SetThreshold(4);
154 hough2->SetTransformerParams(76,140,0.4,-1);
155 hough2->SetPeakThreshold(70,-1);
156 // printf("Pointer is %x\n",ptr);
157 hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,3.82147);
158 hough2->SetAddHistograms();
159 fBenchmark->Stop("Init");
161 Int_t n_global_tracks = 0;
162 hough1->StartProcessInThread(0,17);
163 hough2->StartProcessInThread(18,35);
165 // gSystem->Sleep(20000);
166 if(hough1->WaitForThreadFinish())
167 ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
168 if(hough2->WaitForThreadFinish())
169 ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
171 gSystem->MakeDirectory("hough1");
172 hough1->WriteTracks("./hough1");
173 gSystem->MakeDirectory("hough2");
174 hough2->WriteTracks("./hough2");
177 for(int slice=0; slice<=35; slice++)
179 // cout<<"Processing slice "<<slice<<endl;
180 fBenchmark->Start("ReadData");
181 hough->ReadData(slice,0);
182 fBenchmark->Stop("ReadData");
183 fBenchmark->Start("Transform");
185 fBenchmark->Stop("Transform");
186 hough->AddAllHistogramsRows();
187 hough->FindTrackCandidatesRow();
188 fBenchmark->Start("AddTracks");
190 fBenchmark->Stop("AddTracks");
192 AliL3TrackArray* tracks = (AliL3TrackArray*)hough->GetTracks(0);
193 n_global_tracks += tracks->GetNTracks();
196 fBenchmark->Stop("Overall timing");
198 if (file) fprintf(file, "%s\n", time.AsString());
199 if (file) fprintf(file, "run: %d event: %d %d\n",
200 rawReader.GetRunNumber(),
201 rawReader.GetEventId()[0],
202 rawReader.GetEventId()[1]);
203 if (errorCode) fprintf(file, "ERROR: %d\n", errorCode);
205 if (file) fprintf(file, "Hough Transformer found %d tracks\n",n_global_tracks);
207 hough1->DoBench("hough1");
208 hough2->DoBench("hough2");
209 fBenchmark->Analyze("overall");
211 FILE* bench = fopen("hough1.dat", "r");
212 while (bench && !feof(bench)) {
214 if (!fgets(buffer, 256, bench)) break;
215 fprintf(file, "%s", buffer);
220 FILE* bench = fopen("hough2.dat", "r");
221 while (bench && !feof(bench)) {
223 if (!fgets(buffer, 256, bench)) break;
224 fprintf(file, "%s", buffer);
229 FILE* bench = fopen("overall.dat", "r");
230 while (bench && !feof(bench)) {
232 if (!fgets(buffer, 256, bench)) break;
233 fprintf(file, "%s", buffer);
236 fprintf(file, "\n\n");
245 // read run, event, detector, DDL numbers and data size
246 AliRawReaderDate rawReader(ptr);
248 printf("\n%s\n", time.AsString());
249 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
250 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
251 while (rawReader.ReadMiniHeader()) {
252 printf(" detector: %d DDL: %d size: %d\n",
253 rawReader.GetDetectorID(), rawReader.GetDDLID(),
254 rawReader.GetDataSize());
259 gSystem->Sleep(100); // sleep for 0.1 second
262 gSystem->ProcessEvents();
263 if (file) fflush(file);
267 gSystem->RemoveSignalHandler(handler);
268 if (file) fclose(file);
274 int main(int /*argc*/, char** /*argv*/)
276 ::Fatal("main", "this program was compiled without DATE");