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"
38 #include <AliLevel3.h>
39 #include <AliL3Transform.h>
40 #include <AliL3MemHandler.h>
41 #include <AliL3TrackArray.h>
46 //_____________________________________________________________________________
47 class AliGDCInterruptHandler : public TSignalHandler {
49 AliGDCInterruptHandler();
50 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
51 Bool_t Stop() const {return fStop;};
53 Bool_t fStop; // CTRL-C pressed
56 //_____________________________________________________________________________
57 AliGDCInterruptHandler::AliGDCInterruptHandler() :
58 TSignalHandler(kSigInterrupt, kFALSE)
64 //_____________________________________________________________________________
66 int main(int argc, char** argv)
68 // set ROOT in batch mode
73 FILE* file = fopen("monitorGDC.log", "w");
79 // get data from a file or online from this node
82 status = monitorSetDataSource(argv[1]);
84 status = monitorSetDataSource(":");
86 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
88 // monitor only a sample of physics events
89 char* table[] = {"Physics event", "yes", NULL};
90 status = monitorDeclareTable(table);
91 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
93 // declare this monitoring program to DATE
94 status = monitorDeclareMp("GDC physics monitoring");
95 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
98 // initialize HLT transformations
99 if (!AliL3Transform::Init("./", kFALSE)) {
100 ::Fatal("AliL3Transform::Init", "HLT initialization failed");
104 // create the signal handler
105 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
106 gSystem->AddSignalHandler(handler);
110 while (!handler->Stop()) {
111 // get the next event
112 status = monitorGetEventDynamic(&ptr);
113 if (status == (Int_t)MON_ERR_EOF) break;
114 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
118 gSystem->Sleep(1000); // sleep for 1 second
123 AliRawReaderDate rawReader(ptr);
124 if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
126 // run the HLT tracker
127 AliLevel3* hlt = new AliLevel3((Char_t*)ptr);
128 hlt->Init("./", AliLevel3::kDate, 1);
130 hlt->SetClusterFinderParam(-1, -1, kTRUE);
132 Int_t phiSegments = 50;
133 Int_t etaSegments = 100;
134 Int_t trackletlength = 3;
135 Int_t tracklength = 20;//40 or 5
136 Int_t rowscopetracklet = 2;
137 Int_t rowscopetrack = 10;
138 Double_t minPtFit = 0;
139 Double_t maxangle = 0.1745;
140 Double_t goodDist = 5;
141 Double_t maxphi = 0.1;
142 Double_t maxeta = 0.1;
143 Double_t hitChi2Cut = 15;//100 or 15
144 Double_t goodHitChi2 = 5;//20 or 5
145 Double_t trackChi2Cut = 10;//50 or 10
146 hlt->SetTrackerParam(phiSegments, etaSegments,
147 trackletlength, tracklength,
148 rowscopetracklet, rowscopetrack,
149 minPtFit, maxangle, goodDist, hitChi2Cut,
150 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta,
153 gSystem->Exec("rm -rf hlt");
154 gSystem->MakeDirectory("hlt");
155 hlt->WriteFiles("./hlt/");
156 hlt->ProcessEvent(0, 35, 0);
159 if (file) fprintf(file, "%s\n", time.AsString());
160 if (file) fprintf(file, "run: %d event: %d %d\n",
161 rawReader.GetRunNumber(),
162 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
164 AliL3MemHandler memHandler;
165 if (!memHandler.SetBinaryInput("hlt/tracks_0.raw")) {
166 if (file) fprintf(file, "no HLT tracks\n");
169 AliL3TrackArray* tracks = new AliL3TrackArray;
170 memHandler.Binary2TrackArray(tracks);
171 if (file) fprintf(file, "HLT found %d tracks\n", tracks->GetNTracks());
173 memHandler.CloseBinaryInput();
177 FILE* bench = fopen("hlt.dat", "r");
178 while (bench && !feof(bench)) {
180 if (!fgets(buffer, 256, bench)) break;
181 fprintf(file, "%s", buffer);
187 gSystem->Exec("rm -rf hlt");
192 // read run, event, detector, DDL numbers and data size
193 AliRawReaderDate rawReader(ptr);
195 printf("\n%s\n", time.AsString());
196 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
197 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
198 while (rawReader.ReadMiniHeader()) {
199 printf(" detector: %d DDL: %d size: %d\n",
200 rawReader.GetDetectorID(), rawReader.GetDDLID(),
201 rawReader.GetDataSize());
206 gSystem->Sleep(100); // sleep for 0.1 second
209 gSystem->ProcessEvents();
210 if (file) fflush(file);
213 gSystem->RemoveSignalHandler(handler);
214 if (file) fclose(file);
220 int main(int /*argc*/, char** /*argv*/)
222 ::Fatal("main", "this program was compiled without DATE");