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