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 <AliHLTStandardIncludes.h>
39 #include <AliHLTTransform.h>
40 #include <AliHLTMemHandler.h>
41 #include <AliHLTTrackArray.h>
42 #include <AliHLTHoughMaxFinder.h>
43 #include <AliHLTHoughBaseTransformer.h>
44 #include <AliHLTHough.h>
45 #include <AliHLTBenchmark.h>
46 #include <AliHLTITSclusterer.h>
47 #include <AliHLTITSVertexerZ.h>
48 #include <AliHLTITStracker.h>
50 #include "AliESDEvent.h"
51 #include "AliESDVertex.h"
52 #include "AliTracker.h"
53 #include <AliKalmanTrack.h>
54 #include "AliITSgeomTGeo.h"
55 #include "AliITSgeom.h"
58 //_____________________________________________________________________________
59 class AliGDCInterruptHandler : public TSignalHandler {
61 AliGDCInterruptHandler();
62 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
63 Bool_t Stop() const {return fStop;};
65 Bool_t fStop; // CTRL-C pressed
68 //_____________________________________________________________________________
69 AliGDCInterruptHandler::AliGDCInterruptHandler() :
70 TSignalHandler(kSigInterrupt, kFALSE),
77 //_____________________________________________________________________________
79 int main(int argc, char** argv)
81 // set ROOT in batch mode
85 FILE* file = fopen("monitorGDC.log", "w");
89 // get data from a file or online from this node
92 status = monitorSetDataSource(argv[1]);
94 status = monitorSetDataSource(":");
96 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
98 // monitor only a sample of physics events
99 char* table[] = {"Physics event", "yes", NULL};
100 status = monitorDeclareTable(table);
101 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
103 // declare this monitoring program to DATE
104 status = monitorDeclareMp("GDC physics monitoring");
105 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
107 // initialize HLT transformations
108 // if (!AliHLTTransform::Init("./", kFALSE)) {
109 // ::Fatal("AliHLTTransform::Init", "HLT initialization failed");
112 AliESDEvent *esd = new AliESDEvent;
113 esd->CreateStdContent();
115 // AliITSgeom *geom = new AliITSgeom();
116 // geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det");
117 // if (!geom) return 1;
119 // switch ((Int_t)(AliHLTTransform::GetSolenoidField()+0.5)) {
121 // sfield = AliMagF::k2kG;
124 // sfield = AliMagF::k5kG;
127 // ::Fatal("AliHLTTransform::GetSolenoidField", "Incorrect magnetic field");
133 // create the signal handler
134 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
135 gSystem->AddSignalHandler(handler);
139 while (!handler->Stop()) {
140 // get the next event
141 status = monitorGetEventDynamic(&ptr);
142 if (status == (Int_t)MON_ERR_EOF) break;
143 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
147 gSystem->Sleep(1000); // sleep for 1 second
151 AliRawReaderDate rawReader(ptr);
152 // if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
154 // Int_t errorCode = rawReader.CheckData();
156 if (errorCode && (errorCode != AliRawReader::kErrSize)) {
158 if (file) fprintf(file, "%s\n", time.AsString());
159 if (file) fprintf(file, "run: %d event: %d %d\n",
160 rawReader.GetRunNumber(),
161 rawReader.GetEventId()[0],
162 rawReader.GetEventId()[1]);
163 fprintf(file, "ERROR: %d\n\n", errorCode);
167 // AliHLTBenchmark *fBenchmark = new AliHLTBenchmark();
168 // fBenchmark->Start("Overall timing");
170 // // ITS clusterer and vertexer
171 // fBenchmark->Start("ITS Clusterer");
172 // AliHLTITSclusterer clusterer(0);
173 // AliRawReader *itsrawreader=new AliRawReaderDate(ptr);
174 // TTree* treeClusters = new TTree("TreeL3ITSclusters"," "); //make a tree
175 // clusterer.Digits2Clusters(itsrawreader,treeClusters);
176 // fBenchmark->Stop("ITS Clusterer");
178 // AliHLTITSVertexerZ vertexer;
179 // AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters);
180 // Double_t vtxPos[3];
181 // Double_t vtxErr[3]={0.005,0.005,0.010};
182 // vertex->GetXYZ(vtxPos);
183 // // vertex->GetSigmaXYZ(vtxErr);
184 // esd->SetVertex(vertex);
186 // // TPC Hough reconstruction
187 // Float_t ptmin = 0.1*AliHLTTransform::GetSolenoidField();
188 // Float_t zvertex = vtxPos[2];
190 // // Run the Hough Transformer
191 // fBenchmark->Start("Init");
192 // AliHLTHough *hough1 = new AliHLTHough();
194 // hough1->SetThreshold(4);
195 // hough1->CalcTransformerParams(ptmin);
196 // hough1->SetPeakThreshold(70,-1);
197 // // printf("Pointer is %x\n",ptr);
198 // hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex);
199 // hough1->SetAddHistograms();
200 // fBenchmark->Stop("Init");
202 // fBenchmark->Start("Init");
203 // AliHLTHough *hough2 = new AliHLTHough();
205 // hough2->SetThreshold(4);
206 // hough2->CalcTransformerParams(ptmin);
207 // hough2->SetPeakThreshold(70,-1);
208 // // printf("Pointer is %x\n",ptr);
209 // hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex);
210 // hough2->SetAddHistograms();
211 // fBenchmark->Stop("Init");
213 // Int_t nglobaltracks = 0;
215 // hough1->StartProcessInThread(0,17);
216 // hough2->StartProcessInThread(18,35);
218 // // gSystem->Sleep(20000);
219 // if(hough1->WaitForThreadFinish())
220 // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! ");
221 // if(hough2->WaitForThreadFinish())
222 // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! ");
224 // gSystem->MakeDirectory("hough1");
225 // hough1->WriteTracks("./hough1");
226 // gSystem->MakeDirectory("hough2");
227 // hough2->WriteTracks("./hough2");
230 // for(int slice=0; slice<=17; slice++)
232 // // cout<<"Processing slice "<<slice<<endl;
233 // fBenchmark->Start("ReadData");
234 // hough1->ReadData(slice,0);
235 // fBenchmark->Stop("ReadData");
236 // fBenchmark->Start("Transform");
237 // hough1->Transform();
238 // fBenchmark->Stop("Transform");
239 // hough1->AddAllHistogramsRows();
240 // hough1->FindTrackCandidatesRow();
241 // fBenchmark->Start("AddTracks");
242 // hough1->AddTracks();
243 // fBenchmark->Stop("AddTracks");
245 // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough1->GetTracks(0);
246 // // nglobaltracks += tracks->GetNTracks();
248 // for(int slice=18; slice<=35; slice++)
250 // // cout<<"Processing slice "<<slice<<endl;
251 // fBenchmark->Start("ReadData");
252 // hough2->ReadData(slice,0);
253 // fBenchmark->Stop("ReadData");
254 // fBenchmark->Start("Transform");
255 // hough2->Transform();
256 // fBenchmark->Stop("Transform");
257 // hough2->AddAllHistogramsRows();
258 // hough2->FindTrackCandidatesRow();
259 // fBenchmark->Start("AddTracks");
260 // hough2->AddTracks();
261 // fBenchmark->Stop("AddTracks");
263 // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough2->GetTracks(0);
264 // // nglobaltracks += tracks->GetNTracks();
267 // nglobaltracks += hough1->FillESD(esd);
268 // nglobaltracks += hough2->FillESD(esd);
271 // AliHLTITStracker itsTracker(0);
272 // itsTracker.SetVertex(vtxPos,vtxErr);
274 // itsTracker.LoadClusters(treeClusters);
275 // itsTracker.Clusters2Tracks(esd);
276 // itsTracker.UnloadClusters();
278 // fBenchmark->Stop("Overall timing");
280 // if (file) fprintf(file, "%s\n", time.AsString());
281 // if (file) fprintf(file, "run: %d event: %d %d\n",
282 // rawReader.GetRunNumber(),
283 // rawReader.GetEventId()[0],
284 // rawReader.GetEventId()[1]);
285 // if (errorCode) fprintf(file, "ERROR: %d\n", errorCode);
287 // if (file) fprintf(file, "Hough Transformer found %d tracks\n",nglobaltracks);
289 // hough1->DoBench("hough1");
290 // hough2->DoBench("hough2");
291 // fBenchmark->Analyze("overall");
293 // FILE* bench = fopen("hough1.dat", "r");
294 // while (bench && !feof(bench)) {
296 // if (!fgets(buffer, 256, bench)) break;
297 // fprintf(file, "%s", buffer);
302 // FILE* bench = fopen("hough2.dat", "r");
303 // while (bench && !feof(bench)) {
305 // if (!fgets(buffer, 256, bench)) break;
306 // fprintf(file, "%s", buffer);
311 // FILE* bench = fopen("overall.dat", "r");
312 // while (bench && !feof(bench)) {
314 // if (!fgets(buffer, 256, bench)) break;
315 // fprintf(file, "%s", buffer);
318 // fprintf(file, "\n\n");
329 // read run, event, detector, DDL numbers and data size
330 AliRawReaderDate rawReader(ptr);
332 printf("\n%s\n", time.AsString());
333 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
334 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
335 while (rawReader.ReadMiniHeader()) {
336 printf(" detector: %d DDL: %d size: %d\n",
337 rawReader.GetDetectorID(), rawReader.GetDDLID(),
338 rawReader.GetDataSize());
343 gSystem->Sleep(100); // sleep for 0.1 second
346 gSystem->ProcessEvents();
347 if (file) fflush(file);
351 gSystem->RemoveSignalHandler(handler);
352 if (file) fclose(file);
358 int main(int /*argc*/, char** /*argv*/)
360 ::Fatal("main", "this program was compiled without DATE");