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"
57 #include "AliMagFMaps.h"
60 //_____________________________________________________________________________
61 class AliGDCInterruptHandler : public TSignalHandler {
63 AliGDCInterruptHandler();
64 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
65 Bool_t Stop() const {return fStop;};
67 Bool_t fStop; // CTRL-C pressed
70 //_____________________________________________________________________________
71 AliGDCInterruptHandler::AliGDCInterruptHandler() :
72 TSignalHandler(kSigInterrupt, kFALSE)
78 //_____________________________________________________________________________
80 int main(int argc, char** argv)
82 // set ROOT in batch mode
86 FILE* file = fopen("monitorGDC.log", "w");
90 // get data from a file or online from this node
93 status = monitorSetDataSource(argv[1]);
95 status = monitorSetDataSource(":");
97 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
99 // monitor only a sample of physics events
100 char* table[] = {"Physics event", "yes", NULL};
101 status = monitorDeclareTable(table);
102 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
104 // declare this monitoring program to DATE
105 status = monitorDeclareMp("GDC physics monitoring");
106 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
108 // initialize HLT transformations
109 // if (!AliHLTTransform::Init("./", kFALSE)) {
110 // ::Fatal("AliHLTTransform::Init", "HLT initialization failed");
113 AliESDEvent *esd = new AliESDEvent;
114 esd->CreateStdContent();
116 // AliITSgeom *geom = new AliITSgeom();
117 // geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det");
118 // if (!geom) return 1;
120 // switch ((Int_t)(AliHLTTransform::GetSolenoidField()+0.5)) {
122 // sfield = AliMagFMaps::k2kG;
125 // sfield = AliMagFMaps::k4kG;
128 // sfield = AliMagFMaps::k5kG;
131 // ::Fatal("AliHLTTransform::GetSolenoidField", "Incorrect magnetic field");
133 AliMagF* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., AliMagFMaps::k5kG);
134 AliTracker::SetFieldMap(field,kTRUE);
139 // create the signal handler
140 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
141 gSystem->AddSignalHandler(handler);
145 while (!handler->Stop()) {
146 // get the next event
147 status = monitorGetEventDynamic(&ptr);
148 if (status == (Int_t)MON_ERR_EOF) break;
149 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
153 gSystem->Sleep(1000); // sleep for 1 second
157 AliRawReaderDate rawReader(ptr);
158 // if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
160 // Int_t errorCode = rawReader.CheckData();
162 if (errorCode && (errorCode != AliRawReader::kErrSize)) {
164 if (file) fprintf(file, "%s\n", time.AsString());
165 if (file) fprintf(file, "run: %d event: %d %d\n",
166 rawReader.GetRunNumber(),
167 rawReader.GetEventId()[0],
168 rawReader.GetEventId()[1]);
169 fprintf(file, "ERROR: %d\n\n", errorCode);
173 // AliHLTBenchmark *fBenchmark = new AliHLTBenchmark();
174 // fBenchmark->Start("Overall timing");
176 // // ITS clusterer and vertexer
177 // fBenchmark->Start("ITS Clusterer");
178 // AliHLTITSclusterer clusterer(0);
179 // AliRawReader *itsrawreader=new AliRawReaderDate(ptr);
180 // TTree* treeClusters = new TTree("TreeL3ITSclusters"," "); //make a tree
181 // clusterer.Digits2Clusters(itsrawreader,treeClusters);
182 // fBenchmark->Stop("ITS Clusterer");
184 // AliHLTITSVertexerZ vertexer;
185 // AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters);
186 // Double_t vtxPos[3];
187 // Double_t vtxErr[3]={0.005,0.005,0.010};
188 // vertex->GetXYZ(vtxPos);
189 // // vertex->GetSigmaXYZ(vtxErr);
190 // esd->SetVertex(vertex);
192 // // TPC Hough reconstruction
193 // Float_t ptmin = 0.1*AliHLTTransform::GetSolenoidField();
194 // Float_t zvertex = vtxPos[2];
196 // // Run the Hough Transformer
197 // fBenchmark->Start("Init");
198 // AliHLTHough *hough1 = new AliHLTHough();
200 // hough1->SetThreshold(4);
201 // hough1->CalcTransformerParams(ptmin);
202 // hough1->SetPeakThreshold(70,-1);
203 // // printf("Pointer is %x\n",ptr);
204 // hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex);
205 // hough1->SetAddHistograms();
206 // fBenchmark->Stop("Init");
208 // fBenchmark->Start("Init");
209 // AliHLTHough *hough2 = new AliHLTHough();
211 // hough2->SetThreshold(4);
212 // hough2->CalcTransformerParams(ptmin);
213 // hough2->SetPeakThreshold(70,-1);
214 // // printf("Pointer is %x\n",ptr);
215 // hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex);
216 // hough2->SetAddHistograms();
217 // fBenchmark->Stop("Init");
219 // Int_t nglobaltracks = 0;
221 // hough1->StartProcessInThread(0,17);
222 // hough2->StartProcessInThread(18,35);
224 // // gSystem->Sleep(20000);
225 // if(hough1->WaitForThreadFinish())
226 // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! ");
227 // if(hough2->WaitForThreadFinish())
228 // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! ");
230 // gSystem->MakeDirectory("hough1");
231 // hough1->WriteTracks("./hough1");
232 // gSystem->MakeDirectory("hough2");
233 // hough2->WriteTracks("./hough2");
236 // for(int slice=0; slice<=17; slice++)
238 // // cout<<"Processing slice "<<slice<<endl;
239 // fBenchmark->Start("ReadData");
240 // hough1->ReadData(slice,0);
241 // fBenchmark->Stop("ReadData");
242 // fBenchmark->Start("Transform");
243 // hough1->Transform();
244 // fBenchmark->Stop("Transform");
245 // hough1->AddAllHistogramsRows();
246 // hough1->FindTrackCandidatesRow();
247 // fBenchmark->Start("AddTracks");
248 // hough1->AddTracks();
249 // fBenchmark->Stop("AddTracks");
251 // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough1->GetTracks(0);
252 // // nglobaltracks += tracks->GetNTracks();
254 // for(int slice=18; slice<=35; slice++)
256 // // cout<<"Processing slice "<<slice<<endl;
257 // fBenchmark->Start("ReadData");
258 // hough2->ReadData(slice,0);
259 // fBenchmark->Stop("ReadData");
260 // fBenchmark->Start("Transform");
261 // hough2->Transform();
262 // fBenchmark->Stop("Transform");
263 // hough2->AddAllHistogramsRows();
264 // hough2->FindTrackCandidatesRow();
265 // fBenchmark->Start("AddTracks");
266 // hough2->AddTracks();
267 // fBenchmark->Stop("AddTracks");
269 // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough2->GetTracks(0);
270 // // nglobaltracks += tracks->GetNTracks();
273 // nglobaltracks += hough1->FillESD(esd);
274 // nglobaltracks += hough2->FillESD(esd);
277 // AliHLTITStracker itsTracker(0);
278 // itsTracker.SetVertex(vtxPos,vtxErr);
280 // itsTracker.LoadClusters(treeClusters);
281 // itsTracker.Clusters2Tracks(esd);
282 // itsTracker.UnloadClusters();
284 // fBenchmark->Stop("Overall timing");
286 // if (file) fprintf(file, "%s\n", time.AsString());
287 // if (file) fprintf(file, "run: %d event: %d %d\n",
288 // rawReader.GetRunNumber(),
289 // rawReader.GetEventId()[0],
290 // rawReader.GetEventId()[1]);
291 // if (errorCode) fprintf(file, "ERROR: %d\n", errorCode);
293 // if (file) fprintf(file, "Hough Transformer found %d tracks\n",nglobaltracks);
295 // hough1->DoBench("hough1");
296 // hough2->DoBench("hough2");
297 // fBenchmark->Analyze("overall");
299 // FILE* bench = fopen("hough1.dat", "r");
300 // while (bench && !feof(bench)) {
302 // if (!fgets(buffer, 256, bench)) break;
303 // fprintf(file, "%s", buffer);
308 // FILE* bench = fopen("hough2.dat", "r");
309 // while (bench && !feof(bench)) {
311 // if (!fgets(buffer, 256, bench)) break;
312 // fprintf(file, "%s", buffer);
317 // FILE* bench = fopen("overall.dat", "r");
318 // while (bench && !feof(bench)) {
320 // if (!fgets(buffer, 256, bench)) break;
321 // fprintf(file, "%s", buffer);
324 // fprintf(file, "\n\n");
335 // read run, event, detector, DDL numbers and data size
336 AliRawReaderDate rawReader(ptr);
338 printf("\n%s\n", time.AsString());
339 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
340 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
341 while (rawReader.ReadMiniHeader()) {
342 printf(" detector: %d DDL: %d size: %d\n",
343 rawReader.GetDetectorID(), rawReader.GetDDLID(),
344 rawReader.GetDataSize());
349 gSystem->Sleep(100); // sleep for 0.1 second
352 gSystem->ProcessEvents();
353 if (file) fflush(file);
357 gSystem->RemoveSignalHandler(handler);
358 if (file) fclose(file);
364 int main(int /*argc*/, char** /*argv*/)
366 ::Fatal("main", "this program was compiled without DATE");