]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/monitorGDC.cxx
Removing warnings. From now on they are considered as errors
[u/mrichter/AliRoot.git] / MONITOR / monitorGDC.cxx
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 DATE_SYS
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 #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>
45 #endif
46
47
48 //_____________________________________________________________________________
49 class AliGDCInterruptHandler : public TSignalHandler {
50 public:
51   AliGDCInterruptHandler();
52   Bool_t Notify() {fStop = kTRUE; return kTRUE;};
53   Bool_t Stop() const {return fStop;};
54 private:
55   Bool_t fStop;  // CTRL-C pressed
56 };
57
58 //_____________________________________________________________________________
59 AliGDCInterruptHandler::AliGDCInterruptHandler() : 
60   TSignalHandler(kSigInterrupt, kFALSE) 
61 {
62   fStop = kFALSE;
63 };
64
65
66 //_____________________________________________________________________________
67 #ifdef DATE_SYS
68 int main(int argc, char** argv)
69 {
70   // set ROOT in batch mode
71   gROOT->SetBatch();   
72
73   // open a log file
74   FILE* file = fopen("monitorGDC.log", "w");
75
76   TDatime time;
77
78   // get data from a file or online from this node
79   Int_t status = 0;
80   if (argc > 1) {
81     status = monitorSetDataSource(argv[1]);
82   } else {
83     status = monitorSetDataSource(":");
84   }
85   if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
86
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));
91
92   // declare this monitoring program to DATE
93   status = monitorDeclareMp("GDC physics monitoring");
94   if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
95
96   // initialize HLT transformations
97   if (!AliL3Transform::Init("./", kFALSE)) {
98     ::Fatal("AliL3Transform::Init", "HLT initialization failed");
99   }
100
101   // create the signal handler
102   AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
103   gSystem->AddSignalHandler(handler);
104
105   // endless loop
106   void* ptr = NULL;
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));
112
113     // if no new event
114     if (!ptr) {
115       gSystem->Sleep(1000);   // sleep for 1 second
116       continue;
117     }
118
119     AliRawReaderDate rawReader(ptr);
120     //    if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
121
122     //      Int_t errorCode = rawReader.CheckData();
123     Int_t errorCode = 0;
124       if (errorCode && (errorCode != AliRawReader::kErrSize)) {
125         time.Set();
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);
132
133       } else {
134
135         AliL3Benchmark *fBenchmark = new AliL3Benchmark();
136         fBenchmark->Start("Overall timing");
137
138         Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
139
140         // Run the Hough Transformer
141         fBenchmark->Start("Init");
142         AliL3Hough *hough1 = new AliL3Hough();
143
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");
151
152         fBenchmark->Start("Init");
153         AliL3Hough *hough2 = new AliL3Hough();
154
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");
162
163         Int_t n_global_tracks = 0;
164         hough1->StartProcessInThread(0,17);
165         hough2->StartProcessInThread(18,35);
166
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! ");
172
173         gSystem->MakeDirectory("hough1");
174         hough1->WriteTracks("./hough1");
175         gSystem->MakeDirectory("hough2");
176         hough2->WriteTracks("./hough2");
177
178         /*
179         for(int slice=0; slice<=35; slice++)
180         {
181           //      cout<<"Processing slice "<<slice<<endl;
182           fBenchmark->Start("ReadData");
183           hough->ReadData(slice,0);
184           fBenchmark->Stop("ReadData");
185           fBenchmark->Start("Transform");
186           hough->Transform();
187           fBenchmark->Stop("Transform");
188           hough->AddAllHistogramsRows();
189           hough->FindTrackCandidatesRow();
190           fBenchmark->Start("AddTracks");
191           hough->AddTracks();
192           fBenchmark->Stop("AddTracks");
193
194           AliL3TrackArray* tracks = (AliL3TrackArray*)hough->GetTracks(0);
195           n_global_tracks += tracks->GetNTracks();
196         }
197         */
198         fBenchmark->Stop("Overall timing");
199         time.Set();
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);
206
207         if (file) fprintf(file, "Hough Transformer found %d tracks\n",n_global_tracks);
208
209         hough1->DoBench("hough1");
210         hough2->DoBench("hough2");
211         fBenchmark->Analyze("overall");
212         if (file) {
213           FILE* bench = fopen("hough1.dat", "r");
214           while (bench && !feof(bench)) {
215             char buffer[256];
216             if (!fgets(buffer, 256, bench)) break;
217             fprintf(file, "%s", buffer);
218           }
219           fclose(bench);
220         }
221         if (file) {
222           FILE* bench = fopen("hough2.dat", "r");
223           while (bench && !feof(bench)) {
224             char buffer[256];
225             if (!fgets(buffer, 256, bench)) break;
226             fprintf(file, "%s", buffer);
227           }
228           fclose(bench);
229         }
230         if (file) {
231           FILE* bench = fopen("overall.dat", "r");
232           while (bench && !feof(bench)) {
233             char buffer[256];
234             if (!fgets(buffer, 256, bench)) break;
235             fprintf(file, "%s", buffer);
236           }
237           fclose(bench);
238           fprintf(file, "\n\n");
239         }
240
241         delete hough1;
242         delete hough2;
243       }
244     //    }
245
246     /*
247     // read run, event, detector, DDL numbers and data size
248     AliRawReaderDate rawReader(ptr);
249     time.Set();
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());
257     }
258
259     */
260
261     gSystem->Sleep(100);   // sleep for 0.1 second
262     free(ptr);
263
264     gSystem->ProcessEvents();
265     if (file) fflush(file);
266
267   }
268
269   gSystem->RemoveSignalHandler(handler);
270   if (file) fclose(file);
271
272   return 0;
273 }
274
275 #else
276 int main(int /*argc*/, char** /*argv*/)
277 {
278   ::Fatal("main", "this program was compiled without DATE");
279
280   return 1;
281 }
282 #endif