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),
79 //_____________________________________________________________________________
81 int main(int argc, char** argv)
83 // set ROOT in batch mode
87 FILE* file = fopen("monitorGDC.log", "w");
91 // get data from a file or online from this node
94 status = monitorSetDataSource(argv[1]);
96 status = monitorSetDataSource(":");
98 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
100 // monitor only a sample of physics events
101 char* table[] = {"Physics event", "yes", NULL};
102 status = monitorDeclareTable(table);
103 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
105 // declare this monitoring program to DATE
106 status = monitorDeclareMp("GDC physics monitoring");
107 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
109 // initialize HLT transformations
110 // if (!AliHLTTransform::Init("./", kFALSE)) {
111 // ::Fatal("AliHLTTransform::Init", "HLT initialization failed");
114 AliESDEvent *esd = new AliESDEvent;
115 esd->CreateStdContent();
117 // AliITSgeom *geom = new AliITSgeom();
118 // geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det");
119 // if (!geom) return 1;
121 // switch ((Int_t)(AliHLTTransform::GetSolenoidField()+0.5)) {
123 // sfield = AliMagFMaps::k2kG;
126 // sfield = AliMagFMaps::k4kG;
129 // sfield = AliMagFMaps::k5kG;
132 // ::Fatal("AliHLTTransform::GetSolenoidField", "Incorrect magnetic field");
134 AliMagF* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., AliMagFMaps::k5kG);
135 AliTracker::SetFieldMap(field,kTRUE);
140 // create the signal handler
141 AliGDCInterruptHandler* handler = new AliGDCInterruptHandler;
142 gSystem->AddSignalHandler(handler);
146 while (!handler->Stop()) {
147 // get the next event
148 status = monitorGetEventDynamic(&ptr);
149 if (status == (Int_t)MON_ERR_EOF) break;
150 if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status));
154 gSystem->Sleep(1000); // sleep for 1 second
158 AliRawReaderDate rawReader(ptr);
159 // if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
161 // Int_t errorCode = rawReader.CheckData();
163 if (errorCode && (errorCode != AliRawReader::kErrSize)) {
165 if (file) fprintf(file, "%s\n", time.AsString());
166 if (file) fprintf(file, "run: %d event: %d %d\n",
167 rawReader.GetRunNumber(),
168 rawReader.GetEventId()[0],
169 rawReader.GetEventId()[1]);
170 fprintf(file, "ERROR: %d\n\n", errorCode);
174 // AliHLTBenchmark *fBenchmark = new AliHLTBenchmark();
175 // fBenchmark->Start("Overall timing");
177 // // ITS clusterer and vertexer
178 // fBenchmark->Start("ITS Clusterer");
179 // AliHLTITSclusterer clusterer(0);
180 // AliRawReader *itsrawreader=new AliRawReaderDate(ptr);
181 // TTree* treeClusters = new TTree("TreeL3ITSclusters"," "); //make a tree
182 // clusterer.Digits2Clusters(itsrawreader,treeClusters);
183 // fBenchmark->Stop("ITS Clusterer");
185 // AliHLTITSVertexerZ vertexer;
186 // AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters);
187 // Double_t vtxPos[3];
188 // Double_t vtxErr[3]={0.005,0.005,0.010};
189 // vertex->GetXYZ(vtxPos);
190 // // vertex->GetSigmaXYZ(vtxErr);
191 // esd->SetVertex(vertex);
193 // // TPC Hough reconstruction
194 // Float_t ptmin = 0.1*AliHLTTransform::GetSolenoidField();
195 // Float_t zvertex = vtxPos[2];
197 // // Run the Hough Transformer
198 // fBenchmark->Start("Init");
199 // AliHLTHough *hough1 = new AliHLTHough();
201 // hough1->SetThreshold(4);
202 // hough1->CalcTransformerParams(ptmin);
203 // hough1->SetPeakThreshold(70,-1);
204 // // printf("Pointer is %x\n",ptr);
205 // hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex);
206 // hough1->SetAddHistograms();
207 // fBenchmark->Stop("Init");
209 // fBenchmark->Start("Init");
210 // AliHLTHough *hough2 = new AliHLTHough();
212 // hough2->SetThreshold(4);
213 // hough2->CalcTransformerParams(ptmin);
214 // hough2->SetPeakThreshold(70,-1);
215 // // printf("Pointer is %x\n",ptr);
216 // hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex);
217 // hough2->SetAddHistograms();
218 // fBenchmark->Stop("Init");
220 // Int_t nglobaltracks = 0;
222 // hough1->StartProcessInThread(0,17);
223 // hough2->StartProcessInThread(18,35);
225 // // gSystem->Sleep(20000);
226 // if(hough1->WaitForThreadFinish())
227 // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! ");
228 // if(hough2->WaitForThreadFinish())
229 // ::Fatal("AliHLTHough::WaitForThreadFinish"," Can not join the required thread! ");
231 // gSystem->MakeDirectory("hough1");
232 // hough1->WriteTracks("./hough1");
233 // gSystem->MakeDirectory("hough2");
234 // hough2->WriteTracks("./hough2");
237 // for(int slice=0; slice<=17; slice++)
239 // // cout<<"Processing slice "<<slice<<endl;
240 // fBenchmark->Start("ReadData");
241 // hough1->ReadData(slice,0);
242 // fBenchmark->Stop("ReadData");
243 // fBenchmark->Start("Transform");
244 // hough1->Transform();
245 // fBenchmark->Stop("Transform");
246 // hough1->AddAllHistogramsRows();
247 // hough1->FindTrackCandidatesRow();
248 // fBenchmark->Start("AddTracks");
249 // hough1->AddTracks();
250 // fBenchmark->Stop("AddTracks");
252 // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough1->GetTracks(0);
253 // // nglobaltracks += tracks->GetNTracks();
255 // for(int slice=18; slice<=35; slice++)
257 // // cout<<"Processing slice "<<slice<<endl;
258 // fBenchmark->Start("ReadData");
259 // hough2->ReadData(slice,0);
260 // fBenchmark->Stop("ReadData");
261 // fBenchmark->Start("Transform");
262 // hough2->Transform();
263 // fBenchmark->Stop("Transform");
264 // hough2->AddAllHistogramsRows();
265 // hough2->FindTrackCandidatesRow();
266 // fBenchmark->Start("AddTracks");
267 // hough2->AddTracks();
268 // fBenchmark->Stop("AddTracks");
270 // // AliHLTTrackArray* tracks = (AliHLTTrackArray*)hough2->GetTracks(0);
271 // // nglobaltracks += tracks->GetNTracks();
274 // nglobaltracks += hough1->FillESD(esd);
275 // nglobaltracks += hough2->FillESD(esd);
278 // AliHLTITStracker itsTracker(0);
279 // itsTracker.SetVertex(vtxPos,vtxErr);
281 // itsTracker.LoadClusters(treeClusters);
282 // itsTracker.Clusters2Tracks(esd);
283 // itsTracker.UnloadClusters();
285 // fBenchmark->Stop("Overall timing");
287 // if (file) fprintf(file, "%s\n", time.AsString());
288 // if (file) fprintf(file, "run: %d event: %d %d\n",
289 // rawReader.GetRunNumber(),
290 // rawReader.GetEventId()[0],
291 // rawReader.GetEventId()[1]);
292 // if (errorCode) fprintf(file, "ERROR: %d\n", errorCode);
294 // if (file) fprintf(file, "Hough Transformer found %d tracks\n",nglobaltracks);
296 // hough1->DoBench("hough1");
297 // hough2->DoBench("hough2");
298 // fBenchmark->Analyze("overall");
300 // FILE* bench = fopen("hough1.dat", "r");
301 // while (bench && !feof(bench)) {
303 // if (!fgets(buffer, 256, bench)) break;
304 // fprintf(file, "%s", buffer);
309 // FILE* bench = fopen("hough2.dat", "r");
310 // while (bench && !feof(bench)) {
312 // if (!fgets(buffer, 256, bench)) break;
313 // fprintf(file, "%s", buffer);
318 // FILE* bench = fopen("overall.dat", "r");
319 // while (bench && !feof(bench)) {
321 // if (!fgets(buffer, 256, bench)) break;
322 // fprintf(file, "%s", buffer);
325 // fprintf(file, "\n\n");
336 // read run, event, detector, DDL numbers and data size
337 AliRawReaderDate rawReader(ptr);
339 printf("\n%s\n", time.AsString());
340 printf("run: %d event: %d %d\n", rawReader.GetRunNumber(),
341 rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
342 while (rawReader.ReadMiniHeader()) {
343 printf(" detector: %d DDL: %d size: %d\n",
344 rawReader.GetDetectorID(), rawReader.GetDDLID(),
345 rawReader.GetDataSize());
350 gSystem->Sleep(100); // sleep for 0.1 second
353 gSystem->ProcessEvents();
354 if (file) fflush(file);
358 gSystem->RemoveSignalHandler(handler);
359 if (file) fclose(file);
365 int main(int /*argc*/, char** /*argv*/)
367 ::Fatal("main", "this program was compiled without DATE");