]>
Commit | Line | Data |
---|---|---|
b5279783 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // this program performs local monitoring on a GDC by running the HLT code // | |
21 | // // | |
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. // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include <TError.h> | |
8ecba4b2 | 29 | #include <TSysEvtHandler.h> |
b5279783 | 30 | #ifdef DATE_SYS |
31 | #include <TROOT.h> | |
32 | #include <TSystem.h> | |
b5279783 | 33 | #include <TDatime.h> |
34 | #include "AliRawReaderDate.h" | |
35 | #include "event.h" | |
36 | #include "monitor.h" | |
a8ffd46b | 37 | #include <AliL3StandardIncludes.h> |
b5279783 | 38 | #include <AliL3Transform.h> |
39 | #include <AliL3MemHandler.h> | |
40 | #include <AliL3TrackArray.h> | |
a8ffd46b | 41 | #include <AliL3HoughMaxFinder.h> |
42 | #include <AliL3HoughBaseTransformer.h> | |
43 | #include <AliL3Hough.h> | |
44 | #include <AliL3Benchmark.h> | |
b77a0228 | 45 | #include <AliKalmanTrack.h> |
46 | #include "AliITSgeom.h" | |
47 | #include "AliMagF.h" | |
48 | #include "AliMagFMaps.h" | |
49 | #include <AliL3ITSclusterer.h> | |
50 | #include <AliL3ITSVertexerZ.h> | |
51 | #include <AliL3ITStracker.h> | |
b5279783 | 52 | #endif |
b5279783 | 53 | |
b5279783 | 54 | //_____________________________________________________________________________ |
55 | class AliGDCInterruptHandler : public TSignalHandler { | |
56 | public: | |
57 | AliGDCInterruptHandler(); | |
58 | Bool_t Notify() {fStop = kTRUE; return kTRUE;}; | |
59 | Bool_t Stop() const {return fStop;}; | |
60 | private: | |
61 | Bool_t fStop; // CTRL-C pressed | |
62 | }; | |
63 | ||
64 | //_____________________________________________________________________________ | |
65 | AliGDCInterruptHandler::AliGDCInterruptHandler() : | |
66 | TSignalHandler(kSigInterrupt, kFALSE) | |
67 | { | |
68 | fStop = kFALSE; | |
69 | }; | |
70 | ||
71 | ||
72 | //_____________________________________________________________________________ | |
b5279783 | 73 | #ifdef DATE_SYS |
120b3c73 | 74 | int main(int argc, char** argv) |
75 | { | |
b5279783 | 76 | // set ROOT in batch mode |
77 | gROOT->SetBatch(); | |
78 | ||
79 | // open a log file | |
80 | FILE* file = fopen("monitorGDC.log", "w"); | |
a8ffd46b | 81 | |
b5279783 | 82 | TDatime time; |
83 | ||
84 | // get data from a file or online from this node | |
85 | Int_t status = 0; | |
86 | if (argc > 1) { | |
87 | status = monitorSetDataSource(argv[1]); | |
88 | } else { | |
89 | status = monitorSetDataSource(":"); | |
90 | } | |
91 | if (status) ::Fatal("monitorSetDataSource", monitorDecodeError(status)); | |
92 | ||
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)); | |
97 | ||
98 | // declare this monitoring program to DATE | |
04b48a95 | 99 | status = monitorDeclareMp("GDC physics monitoring"); |
b5279783 | 100 | if (status) ::Fatal("monitorDeclareMp", monitorDecodeError(status)); |
101 | ||
b5279783 | 102 | // initialize HLT transformations |
103 | if (!AliL3Transform::Init("./", kFALSE)) { | |
104 | ::Fatal("AliL3Transform::Init", "HLT initialization failed"); | |
105 | } | |
b77a0228 | 106 | AliESD *esd = new AliESD; |
aa95f9f7 | 107 | // AliKalmanTrack::SetConvConst( |
108 | // 1000/0.299792458/AliL3Transform::GetSolenoidField() | |
109 | // ); | |
b77a0228 | 110 | AliITSgeom *geom = new AliITSgeom(); |
111 | geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det"); | |
112 | if (!geom) return 1; | |
aa95f9f7 | 113 | Int_t sfield = 0; |
114 | switch ((Int_t)(AliL3Transform::GetSolenoidField()+0.5)) { | |
115 | case 2: | |
116 | sfield = AliMagFMaps::k2kG; | |
117 | break; | |
118 | case 4: | |
119 | sfield = AliMagFMaps::k4kG; | |
120 | break; | |
121 | case 5: | |
122 | sfield = AliMagFMaps::k5kG; | |
123 | break; | |
124 | default: | |
125 | ::Fatal("AliL3Transform::GetSolenoidField", "Incorrect magnetic field"); | |
126 | } | |
127 | AliMagF* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., sfield); | |
128 | AliTracker::SetFieldMap(field,kTRUE); | |
129 | ||
130 | // Init PID | |
131 | AliPID pid; | |
b5279783 | 132 | |
133 | // create the signal handler | |
134 | AliGDCInterruptHandler* handler = new AliGDCInterruptHandler; | |
135 | gSystem->AddSignalHandler(handler); | |
136 | ||
137 | // endless loop | |
138 | void* ptr = NULL; | |
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)); | |
144 | ||
145 | // if no new event | |
146 | if (!ptr) { | |
147 | gSystem->Sleep(1000); // sleep for 1 second | |
148 | continue; | |
149 | } | |
150 | ||
04b48a95 | 151 | AliRawReaderDate rawReader(ptr); |
a8ffd46b | 152 | // if ((rawReader.GetAttributes()[0] & 0x02) != 0) { |
04b48a95 | 153 | |
a8ffd46b | 154 | // Int_t errorCode = rawReader.CheckData(); |
155 | Int_t errorCode = 0; | |
3256212a | 156 | if (errorCode && (errorCode != AliRawReader::kErrSize)) { |
157 | time.Set(); | |
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); | |
164 | ||
165 | } else { | |
166 | ||
a8ffd46b | 167 | AliL3Benchmark *fBenchmark = new AliL3Benchmark(); |
168 | fBenchmark->Start("Overall timing"); | |
169 | ||
b77a0228 | 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"); | |
177 | ||
178 | AliL3ITSVertexerZ 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); | |
185 | ||
186 | // TPC Hough reconstruction | |
add57a93 | 187 | Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField(); |
b77a0228 | 188 | Float_t zvertex = vtxPos[2]; |
add57a93 | 189 | |
a8ffd46b | 190 | // Run the Hough Transformer |
191 | fBenchmark->Start("Init"); | |
192 | AliL3Hough *hough1 = new AliL3Hough(); | |
193 | ||
194 | hough1->SetThreshold(4); | |
add57a93 | 195 | hough1->CalcTransformerParams(ptmin); |
a8ffd46b | 196 | hough1->SetPeakThreshold(70,-1); |
197 | // printf("Pointer is %x\n",ptr); | |
b77a0228 | 198 | hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex); |
a8ffd46b | 199 | hough1->SetAddHistograms(); |
200 | fBenchmark->Stop("Init"); | |
201 | ||
202 | fBenchmark->Start("Init"); | |
203 | AliL3Hough *hough2 = new AliL3Hough(); | |
204 | ||
205 | hough2->SetThreshold(4); | |
add57a93 | 206 | hough2->CalcTransformerParams(ptmin); |
a8ffd46b | 207 | hough2->SetPeakThreshold(70,-1); |
208 | // printf("Pointer is %x\n",ptr); | |
b77a0228 | 209 | hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex); |
a8ffd46b | 210 | hough2->SetAddHistograms(); |
211 | fBenchmark->Stop("Init"); | |
212 | ||
b77a0228 | 213 | Int_t nglobaltracks = 0; |
214 | /* | |
a8ffd46b | 215 | hough1->StartProcessInThread(0,17); |
216 | hough2->StartProcessInThread(18,35); | |
217 | ||
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! "); | |
223 | ||
224 | gSystem->MakeDirectory("hough1"); | |
225 | hough1->WriteTracks("./hough1"); | |
226 | gSystem->MakeDirectory("hough2"); | |
227 | hough2->WriteTracks("./hough2"); | |
b77a0228 | 228 | */ |
a8ffd46b | 229 | |
b77a0228 | 230 | for(int slice=0; slice<=17; slice++) |
a8ffd46b | 231 | { |
232 | // cout<<"Processing slice "<<slice<<endl; | |
233 | fBenchmark->Start("ReadData"); | |
b77a0228 | 234 | hough1->ReadData(slice,0); |
a8ffd46b | 235 | fBenchmark->Stop("ReadData"); |
236 | fBenchmark->Start("Transform"); | |
b77a0228 | 237 | hough1->Transform(); |
a8ffd46b | 238 | fBenchmark->Stop("Transform"); |
b77a0228 | 239 | hough1->AddAllHistogramsRows(); |
240 | hough1->FindTrackCandidatesRow(); | |
a8ffd46b | 241 | fBenchmark->Start("AddTracks"); |
b77a0228 | 242 | hough1->AddTracks(); |
a8ffd46b | 243 | fBenchmark->Stop("AddTracks"); |
244 | ||
b77a0228 | 245 | // AliL3TrackArray* tracks = (AliL3TrackArray*)hough1->GetTracks(0); |
246 | // nglobaltracks += tracks->GetNTracks(); | |
a8ffd46b | 247 | } |
b77a0228 | 248 | for(int slice=18; slice<=35; slice++) |
249 | { | |
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"); | |
262 | ||
263 | // AliL3TrackArray* tracks = (AliL3TrackArray*)hough2->GetTracks(0); | |
264 | // nglobaltracks += tracks->GetNTracks(); | |
265 | } | |
266 | ||
267 | nglobaltracks += hough1->FillESD(esd); | |
268 | nglobaltracks += hough2->FillESD(esd); | |
269 | ||
270 | // ITS tracker | |
271 | AliL3ITStracker itsTracker(geom); | |
272 | itsTracker.SetVertex(vtxPos,vtxErr); | |
273 | ||
274 | itsTracker.LoadClusters(treeClusters); | |
275 | itsTracker.Clusters2Tracks(esd); | |
276 | itsTracker.UnloadClusters(); | |
277 | ||
a8ffd46b | 278 | fBenchmark->Stop("Overall timing"); |
3256212a | 279 | time.Set(); |
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); | |
286 | ||
b77a0228 | 287 | if (file) fprintf(file, "Hough Transformer found %d tracks\n",nglobaltracks); |
3256212a | 288 | |
a8ffd46b | 289 | hough1->DoBench("hough1"); |
290 | hough2->DoBench("hough2"); | |
291 | fBenchmark->Analyze("overall"); | |
292 | if (file) { | |
293 | FILE* bench = fopen("hough1.dat", "r"); | |
294 | while (bench && !feof(bench)) { | |
295 | char buffer[256]; | |
296 | if (!fgets(buffer, 256, bench)) break; | |
297 | fprintf(file, "%s", buffer); | |
298 | } | |
299 | fclose(bench); | |
300 | } | |
3256212a | 301 | if (file) { |
a8ffd46b | 302 | FILE* bench = fopen("hough2.dat", "r"); |
3256212a | 303 | while (bench && !feof(bench)) { |
304 | char buffer[256]; | |
305 | if (!fgets(buffer, 256, bench)) break; | |
306 | fprintf(file, "%s", buffer); | |
307 | } | |
308 | fclose(bench); | |
a8ffd46b | 309 | } |
310 | if (file) { | |
311 | FILE* bench = fopen("overall.dat", "r"); | |
312 | while (bench && !feof(bench)) { | |
313 | char buffer[256]; | |
314 | if (!fgets(buffer, 256, bench)) break; | |
315 | fprintf(file, "%s", buffer); | |
316 | } | |
317 | fclose(bench); | |
318 | fprintf(file, "\n\n"); | |
04b48a95 | 319 | } |
b5279783 | 320 | |
a8ffd46b | 321 | delete hough1; |
322 | delete hough2; | |
b77a0228 | 323 | |
324 | esd->Reset(); | |
3256212a | 325 | } |
a8ffd46b | 326 | // } |
327 | ||
328 | /* | |
329 | // read run, event, detector, DDL numbers and data size | |
330 | AliRawReaderDate rawReader(ptr); | |
331 | time.Set(); | |
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()); | |
04b48a95 | 339 | } |
b5279783 | 340 | |
a8ffd46b | 341 | */ |
342 | ||
df0f3179 | 343 | gSystem->Sleep(100); // sleep for 0.1 second |
b5279783 | 344 | free(ptr); |
345 | ||
346 | gSystem->ProcessEvents(); | |
347 | if (file) fflush(file); | |
a8ffd46b | 348 | |
b5279783 | 349 | } |
350 | ||
351 | gSystem->RemoveSignalHandler(handler); | |
352 | if (file) fclose(file); | |
353 | ||
120b3c73 | 354 | return 0; |
355 | } | |
356 | ||
b5279783 | 357 | #else |
120b3c73 | 358 | int main(int /*argc*/, char** /*argv*/) |
359 | { | |
b5279783 | 360 | ::Fatal("main", "this program was compiled without DATE"); |
b5279783 | 361 | |
120b3c73 | 362 | return 1; |
b5279783 | 363 | } |
120b3c73 | 364 | #endif |