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 Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
140 // Run the Hough Transformer
141 fBenchmark->Start("Init");
142 AliL3Hough *hough1 = new AliL3Hough();
144 hough1->SetThreshold(4);
145 hough1->CalcTransformerParams(ptmin);
146 hough1->SetPeakThreshold(70,-1);
147 // printf("Pointer is %x\n",ptr);
148 hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,0.0);
149 hough1->SetAddHistograms();
150 fBenchmark->Stop("Init");
152 fBenchmark->Start("Init");
153 AliL3Hough *hough2 = new AliL3Hough();
155 hough2->SetThreshold(4);
156 hough2->CalcTransformerParams(ptmin);
157 hough2->SetPeakThreshold(70,-1);
158 // printf("Pointer is %x\n",ptr);
159 hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,0.0);
160 hough2->SetAddHistograms();
161 fBenchmark->Stop("Init");
163 Int_t n_global_tracks = 0;
164 hough1->StartProcessInThread(0,17);
165 hough2->StartProcessInThread(18,35);
167 // gSystem->Sleep(20000);
168 if(hough1->WaitForThreadFinish())
169 ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
170 if(hough2->WaitForThreadFinish())
171 ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
173 gSystem->MakeDirectory("hough1");
174 hough1->WriteTracks("./hough1");
175 gSystem->MakeDirectory("hough2");
176 hough2->WriteTracks("./hough2");
179 for(int slice=0; slice<=35; slice++)
181 // cout<<"Processing slice "<<slice<<endl;
182 fBenchmark->Start("ReadData");
183 hough->ReadData(slice,0);
184 fBenchmark->Stop("ReadData");
185 fBenchmark->Start("Transform");
187 fBenchmark->Stop("Transform");
188 hough->AddAllHistogramsRows();
189 hough->FindTrackCandidatesRow();
190 fBenchmark->Start("AddTracks");
192 fBenchmark->Stop("AddTracks");
194 AliL3TrackArray* tracks = (AliL3TrackArray*)hough->GetTracks(0);
195 n_global_tracks += tracks->GetNTracks();
198 fBenchmark->Stop("Overall timing");
200 if (file) fprintf(file, "%s\n", time.AsString());
201 if (file) fprintf(file, "run: %d event: %d %d\n",
202 rawReader.GetRunNumber(),
203 rawReader.GetEventId()[0],
204 rawReader.GetEventId()[1]);
205 if (errorCode) fprintf(file, "ERROR: %d\n", errorCode);
207 if (file) fprintf(file, "Hough Transformer found %d tracks\n",n_global_tracks);
209 hough1->DoBench("hough1");
210 hough2->DoBench("hough2");
211 fBenchmark->Analyze("overall");
213 FILE* bench = fopen("hough1.dat", "r");
214 while (bench && !feof(bench)) {
216 if (!fgets(buffer, 256, bench)) break;
217 fprintf(file, "%s", buffer);
222 FILE* bench = fopen("hough2.dat", "r");
223 while (bench && !feof(bench)) {
225 if (!fgets(buffer, 256, bench)) break;
226 fprintf(file, "%s", buffer);
231 FILE* bench = fopen("overall.dat", "r");
232 while (bench && !feof(bench)) {
234 if (!fgets(buffer, 256, bench)) break;
235 fprintf(file, "%s", buffer);
238 fprintf(file, "\n\n");
247 // read run, event, detector, DDL numbers and data size
248 AliRawReaderDate rawReader(ptr);
250 printf("\n%s\n", time.AsString());
251 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
252 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
253 while (rawReader.ReadMiniHeader()) {
254 printf(" detector: %d DDL: %d size: %d\n",
255 rawReader.GetDetectorID(), rawReader.GetDDLID(),
256 rawReader.GetDataSize());
261 gSystem->Sleep(100); // sleep for 0.1 second
264 gSystem->ProcessEvents();
265 if (file) fflush(file);
269 gSystem->RemoveSignalHandler(handler);
270 if (file) fclose(file);
276 int main(int /*argc*/, char** /*argv*/)
278 ::Fatal("main", "this program was compiled without DATE");