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"
37 #include <AliL3StandardIncludes.h>
38 #include <AliL3Transform.h>
39 #include <AliL3MemHandler.h>
40 #include <AliL3TrackArray.h>
41 #include <AliL3HoughMaxFinder.h>
42 #include <AliL3HoughBaseTransformer.h>
43 #include <AliL3Hough.h>
44 #include <AliL3Benchmark.h>
45 #include <AliKalmanTrack.h>
46 #include "AliITSgeom.h"
48 #include "AliMagFMaps.h"
49 #include <AliL3ITSclusterer.h>
50 #include <AliL3ITSVertexerZ.h>
51 #include <AliL3ITStracker.h>
54 //_____________________________________________________________________________
55 class AliGDCInterruptHandler : public TSignalHandler {
57 AliGDCInterruptHandler();
58 Bool_t Notify() {fStop = kTRUE; return kTRUE;};
59 Bool_t Stop() const {return fStop;};
61 Bool_t fStop; // CTRL-C pressed
64 //_____________________________________________________________________________
65 AliGDCInterruptHandler::AliGDCInterruptHandler() :
66 TSignalHandler(kSigInterrupt, kFALSE)
72 //_____________________________________________________________________________
74 int main(int argc, char** argv)
76 // set ROOT in batch mode
80 FILE* file = fopen("monitorGDC.log", "w");
84 // get data from a file or online from this node
87 status = monitorSetDataSource(argv[1]);
89 status = monitorSetDataSource(":");
91 if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status));
93 // monitor only a sample of physics events
94 char* table[] = {"Physics event", "yes", NULL};
95 status = monitorDeclareTable(table);
96 if (status) ::Fatal("monitorDeclareTable", monitorDecodeError(status));
98 // declare this monitoring program to DATE
99 status = monitorDeclareMp("GDC physics monitoring");
100 if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status));
102 // initialize HLT transformations
103 if (!AliL3Transform::Init("./", kFALSE)) {
104 ::Fatal("AliL3Transform::Init", "HLT initialization failed");
106 AliESD *esd = new AliESD;
107 // AliKalmanTrack::SetConvConst(
108 // 1000/0.299792458/AliL3Transform::GetSolenoidField()
110 AliITSgeom *geom = new AliITSgeom();
111 geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det");
114 switch ((Int_t)(AliL3Transform::GetSolenoidField()+0.5)) {
116 sfield = AliMagFMaps::k2kG;
119 sfield = AliMagFMaps::k4kG;
122 sfield = AliMagFMaps::k5kG;
125 ::Fatal("AliL3Transform::GetSolenoidField", "Incorrect magnetic field");
127 AliMagF* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., sfield);
128 AliTracker::SetFieldMap(field,kTRUE);
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 AliL3Benchmark *fBenchmark = new AliL3Benchmark();
168 fBenchmark->Start("Overall timing");
170 // ITS clusterer and vertexer
171 fBenchmark->Start("ITS Clusterer");
172 AliL3ITSclusterer clusterer(geom);
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 AliL3ITSVertexerZ vertexer;
179 AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters);
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*AliL3Transform::GetSolenoidField();
188 Float_t zvertex = vtxPos[2];
190 // Run the Hough Transformer
191 fBenchmark->Start("Init");
192 AliL3Hough *hough1 = new AliL3Hough();
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 AliL3Hough *hough2 = new AliL3Hough();
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("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
221 if(hough2->WaitForThreadFinish())
222 ::Fatal("AliL3Hough::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");
238 fBenchmark->Stop("Transform");
239 hough1->AddAllHistogramsRows();
240 hough1->FindTrackCandidatesRow();
241 fBenchmark->Start("AddTracks");
243 fBenchmark->Stop("AddTracks");
245 // AliL3TrackArray* tracks = (AliL3TrackArray*)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");
256 fBenchmark->Stop("Transform");
257 hough2->AddAllHistogramsRows();
258 hough2->FindTrackCandidatesRow();
259 fBenchmark->Start("AddTracks");
261 fBenchmark->Stop("AddTracks");
263 // AliL3TrackArray* tracks = (AliL3TrackArray*)hough2->GetTracks(0);
264 // nglobaltracks += tracks->GetNTracks();
267 nglobaltracks += hough1->FillESD(esd);
268 nglobaltracks += hough2->FillESD(esd);
271 AliL3ITStracker itsTracker(geom);
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");