]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/monitorGDC.cxx
Transient pointer to AliRunDigitizer
[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 #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 //_____________________________________________________________________________
65 #ifdef DATE_SYS
66 int main(int argc, char** argv)
67 {
68   // set ROOT in batch mode
69   gROOT->SetBatch();   
70
71   // open a log file
72   FILE* file = fopen("monitorGDC.log", "w");
73   TDatime time;
74
75   // get data from a file or online from this node
76   Int_t status = 0;
77   if (argc > 1) {
78     status = monitorSetDataSource(argv[1]);
79   } else {
80     status = monitorSetDataSource(":");
81   }
82   if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
83
84   // monitor only a sample of physics events
85   char* table[] = {"Physics event", "yes", NULL};
86   status = monitorDeclareTable(table);
87   if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
88
89   // declare this monitoring program to DATE
90   status = monitorDeclareMp("GDC physics monitoring");
91   if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
92
93 #ifdef ALI_HLT
94   // initialize HLT transformations
95   if (!AliL3Transform::Init("./", kFALSE)) {
96     ::Fatal("AliL3Transform::Init", "HLT initialization failed");
97   }
98 #endif
99
100   // create the signal handler
101   AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
102   gSystem->AddSignalHandler(handler);
103
104   // endless loop
105   void* ptr = NULL;
106   while (!handler->Stop()) {
107     // get the next event
108     status = monitorGetEventDynamic(&ptr);
109     if (status == (Int_t)MON_ERR_EOF) break;
110     if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
111
112     // if no new event
113     if (!ptr) {
114       gSystem->Sleep(1000);   // sleep for 1 second
115       continue;
116     }
117
118 #ifdef ALI_HLT
119     AliRawReaderDate rawReader(ptr);
120     if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
121
122       // run the HLT tracker
123       AliLevel3* hlt = new AliLevel3((Char_t*)ptr);
124       hlt->Init("./", AliLevel3::kDate, 1);
125
126       hlt->SetClusterFinderParam(-1, -1, kTRUE);
127   
128       Int_t phiSegments = 50;
129       Int_t etaSegments = 100;
130       Int_t trackletlength = 3;
131       Int_t tracklength = 20;//40 or 5
132       Int_t rowscopetracklet = 2;
133       Int_t rowscopetrack = 10;
134       Double_t minPtFit = 0;
135       Double_t maxangle = 0.1745;
136       Double_t goodDist = 5;
137       Double_t maxphi = 0.1;
138       Double_t maxeta = 0.1;
139       Double_t hitChi2Cut = 15;//100 or 15
140       Double_t goodHitChi2 = 5;//20 or 5
141       Double_t trackChi2Cut = 10;//50 or 10
142       hlt->SetTrackerParam(phiSegments, etaSegments, 
143                            trackletlength, tracklength,
144                            rowscopetracklet, rowscopetrack,
145                            minPtFit, maxangle, goodDist, hitChi2Cut,
146                            goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, 
147                            kTRUE);
148   
149       gSystem->Exec("rm -rf hlt");
150       gSystem->MakeDirectory("hlt");
151       hlt->WriteFiles("./hlt/");
152       hlt->ProcessEvent(0, 35, 0);
153
154       time.Set();
155       if (file) fprintf(file, "%s\n", time.AsString());
156       if (file) fprintf(file, "run: %d  event: %d %d\n", 
157                         rawReader.GetRunNumber(), 
158                         rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
159
160       AliL3MemHandler memHandler;
161       if (!memHandler.SetBinaryInput("hlt/tracks_0.raw")) {
162         if (file) fprintf(file, "no HLT tracks\n");
163         continue;
164       }
165       AliL3TrackArray* tracks = new AliL3TrackArray;
166       memHandler.Binary2TrackArray(tracks);
167       if (file) fprintf(file, "HLT found %d tracks\n", tracks->GetNTracks());
168       delete tracks;
169       memHandler.CloseBinaryInput();
170
171       hlt->DoBench("hlt");
172       if (file) {
173         FILE* bench = fopen("hlt.dat", "r");
174         while (bench && !feof(bench)) {
175           char buffer[256];
176           if (!fgets(buffer, 256, bench)) break;
177           fprintf(file, "%s", buffer);
178         }
179         fclose(bench);
180         fprintf(file, "\n");
181       }
182
183       gSystem->Exec("rm -rf hlt");
184       delete hlt;
185     }
186
187 #else
188     // read run, event, detector, DDL numbers and data size
189     AliRawReaderDate rawReader(ptr);
190     printf("run: %d  event: %d %d\n", rawReader.GetRunNumber(), 
191            rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
192     while (rawReader.ReadMiniHeader()) {
193       printf(" detector: %d   DDL: %d  size: %d\n", 
194              rawReader.GetDetectorID(), rawReader.GetDDLID(), 
195              rawReader.GetDataSize());
196     }
197
198     time.Set();
199     if (file) fprintf(file, "%s\n", time.AsString());
200
201 #endif
202
203     free(ptr);
204
205     gSystem->ProcessEvents();
206     if (file) fflush(file);
207   }
208
209   gSystem->RemoveSignalHandler(handler);
210   if (file) fclose(file);
211
212   return 0;
213 }
214
215 #else
216 int main(int /*argc*/, char** /*argv*/)
217 {
218   ::Fatal("main", "this program was compiled without DATE");
219
220   return 1;
221 }
222 #endif