]>
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; |
107 | AliKalmanTrack::SetConvConst( | |
108 | 1000/0.299792458/AliL3Transform::GetSolenoidField() | |
109 | ); | |
110 | AliITSgeom *geom = new AliITSgeom(); | |
111 | geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det"); | |
112 | if (!geom) return 1; | |
113 | AliMagF* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., AliMagFMaps::k5kG); | |
114 | AliTracker::SetFieldMap(field); | |
b5279783 | 115 | |
116 | // create the signal handler | |
117 | AliGDCInterruptHandler* handler = new AliGDCInterruptHandler; | |
118 | gSystem->AddSignalHandler(handler); | |
119 | ||
120 | // endless loop | |
121 | void* ptr = NULL; | |
122 | while (!handler->Stop()) { | |
123 | // get the next event | |
124 | status = monitorGetEventDynamic(&ptr); | |
125 | if (status == (Int_t)MON_ERR_EOF) break; | |
126 | if (status) ::Fatal("monitorGetEventDynamic", monitorDecodeError(status)); | |
127 | ||
128 | // if no new event | |
129 | if (!ptr) { | |
130 | gSystem->Sleep(1000); // sleep for 1 second | |
131 | continue; | |
132 | } | |
133 | ||
04b48a95 | 134 | AliRawReaderDate rawReader(ptr); |
a8ffd46b | 135 | // if ((rawReader.GetAttributes()[0] & 0x02) != 0) { |
04b48a95 | 136 | |
a8ffd46b | 137 | // Int_t errorCode = rawReader.CheckData(); |
138 | Int_t errorCode = 0; | |
3256212a | 139 | if (errorCode && (errorCode != AliRawReader::kErrSize)) { |
140 | time.Set(); | |
141 | if (file) fprintf(file, "%s\n", time.AsString()); | |
142 | if (file) fprintf(file, "run: %d event: %d %d\n", | |
143 | rawReader.GetRunNumber(), | |
144 | rawReader.GetEventId()[0], | |
145 | rawReader.GetEventId()[1]); | |
146 | fprintf(file, "ERROR: %d\n\n", errorCode); | |
147 | ||
148 | } else { | |
149 | ||
a8ffd46b | 150 | AliL3Benchmark *fBenchmark = new AliL3Benchmark(); |
151 | fBenchmark->Start("Overall timing"); | |
152 | ||
b77a0228 | 153 | // ITS clusterer and vertexer |
154 | fBenchmark->Start("ITS Clusterer"); | |
155 | AliL3ITSclusterer clusterer(geom); | |
156 | AliRawReader *itsrawreader=new AliRawReaderDate(ptr); | |
157 | TTree* treeClusters = new TTree("TreeL3ITSclusters"," "); //make a tree | |
158 | clusterer.Digits2Clusters(itsrawreader,treeClusters); | |
159 | fBenchmark->Stop("ITS Clusterer"); | |
160 | ||
161 | AliL3ITSVertexerZ vertexer; | |
162 | AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters); | |
163 | Double_t vtxPos[3]; | |
164 | Double_t vtxErr[3]={0.005,0.005,0.010}; | |
165 | vertex->GetXYZ(vtxPos); | |
166 | // vertex->GetSigmaXYZ(vtxErr); | |
167 | esd->SetVertex(vertex); | |
168 | ||
169 | // TPC Hough reconstruction | |
add57a93 | 170 | Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField(); |
b77a0228 | 171 | Float_t zvertex = vtxPos[2]; |
add57a93 | 172 | |
a8ffd46b | 173 | // Run the Hough Transformer |
174 | fBenchmark->Start("Init"); | |
175 | AliL3Hough *hough1 = new AliL3Hough(); | |
176 | ||
177 | hough1->SetThreshold(4); | |
add57a93 | 178 | hough1->CalcTransformerParams(ptmin); |
a8ffd46b | 179 | hough1->SetPeakThreshold(70,-1); |
180 | // printf("Pointer is %x\n",ptr); | |
b77a0228 | 181 | hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex); |
a8ffd46b | 182 | hough1->SetAddHistograms(); |
183 | fBenchmark->Stop("Init"); | |
184 | ||
185 | fBenchmark->Start("Init"); | |
186 | AliL3Hough *hough2 = new AliL3Hough(); | |
187 | ||
188 | hough2->SetThreshold(4); | |
add57a93 | 189 | hough2->CalcTransformerParams(ptmin); |
a8ffd46b | 190 | hough2->SetPeakThreshold(70,-1); |
191 | // printf("Pointer is %x\n",ptr); | |
b77a0228 | 192 | hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,zvertex); |
a8ffd46b | 193 | hough2->SetAddHistograms(); |
194 | fBenchmark->Stop("Init"); | |
195 | ||
b77a0228 | 196 | Int_t nglobaltracks = 0; |
197 | /* | |
a8ffd46b | 198 | hough1->StartProcessInThread(0,17); |
199 | hough2->StartProcessInThread(18,35); | |
200 | ||
201 | // gSystem->Sleep(20000); | |
202 | if(hough1->WaitForThreadFinish()) | |
203 | ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! "); | |
204 | if(hough2->WaitForThreadFinish()) | |
205 | ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! "); | |
206 | ||
207 | gSystem->MakeDirectory("hough1"); | |
208 | hough1->WriteTracks("./hough1"); | |
209 | gSystem->MakeDirectory("hough2"); | |
210 | hough2->WriteTracks("./hough2"); | |
b77a0228 | 211 | */ |
a8ffd46b | 212 | |
b77a0228 | 213 | for(int slice=0; slice<=17; slice++) |
a8ffd46b | 214 | { |
215 | // cout<<"Processing slice "<<slice<<endl; | |
216 | fBenchmark->Start("ReadData"); | |
b77a0228 | 217 | hough1->ReadData(slice,0); |
a8ffd46b | 218 | fBenchmark->Stop("ReadData"); |
219 | fBenchmark->Start("Transform"); | |
b77a0228 | 220 | hough1->Transform(); |
a8ffd46b | 221 | fBenchmark->Stop("Transform"); |
b77a0228 | 222 | hough1->AddAllHistogramsRows(); |
223 | hough1->FindTrackCandidatesRow(); | |
a8ffd46b | 224 | fBenchmark->Start("AddTracks"); |
b77a0228 | 225 | hough1->AddTracks(); |
a8ffd46b | 226 | fBenchmark->Stop("AddTracks"); |
227 | ||
b77a0228 | 228 | // AliL3TrackArray* tracks = (AliL3TrackArray*)hough1->GetTracks(0); |
229 | // nglobaltracks += tracks->GetNTracks(); | |
a8ffd46b | 230 | } |
b77a0228 | 231 | for(int slice=18; slice<=35; slice++) |
232 | { | |
233 | // cout<<"Processing slice "<<slice<<endl; | |
234 | fBenchmark->Start("ReadData"); | |
235 | hough2->ReadData(slice,0); | |
236 | fBenchmark->Stop("ReadData"); | |
237 | fBenchmark->Start("Transform"); | |
238 | hough2->Transform(); | |
239 | fBenchmark->Stop("Transform"); | |
240 | hough2->AddAllHistogramsRows(); | |
241 | hough2->FindTrackCandidatesRow(); | |
242 | fBenchmark->Start("AddTracks"); | |
243 | hough2->AddTracks(); | |
244 | fBenchmark->Stop("AddTracks"); | |
245 | ||
246 | // AliL3TrackArray* tracks = (AliL3TrackArray*)hough2->GetTracks(0); | |
247 | // nglobaltracks += tracks->GetNTracks(); | |
248 | } | |
249 | ||
250 | nglobaltracks += hough1->FillESD(esd); | |
251 | nglobaltracks += hough2->FillESD(esd); | |
252 | ||
253 | // ITS tracker | |
254 | AliL3ITStracker itsTracker(geom); | |
255 | itsTracker.SetVertex(vtxPos,vtxErr); | |
256 | ||
257 | itsTracker.LoadClusters(treeClusters); | |
258 | itsTracker.Clusters2Tracks(esd); | |
259 | itsTracker.UnloadClusters(); | |
260 | ||
a8ffd46b | 261 | fBenchmark->Stop("Overall timing"); |
3256212a | 262 | time.Set(); |
263 | if (file) fprintf(file, "%s\n", time.AsString()); | |
264 | if (file) fprintf(file, "run: %d event: %d %d\n", | |
265 | rawReader.GetRunNumber(), | |
266 | rawReader.GetEventId()[0], | |
267 | rawReader.GetEventId()[1]); | |
268 | if (errorCode) fprintf(file, "ERROR: %d\n", errorCode); | |
269 | ||
b77a0228 | 270 | if (file) fprintf(file, "Hough Transformer found %d tracks\n",nglobaltracks); |
3256212a | 271 | |
a8ffd46b | 272 | hough1->DoBench("hough1"); |
273 | hough2->DoBench("hough2"); | |
274 | fBenchmark->Analyze("overall"); | |
275 | if (file) { | |
276 | FILE* bench = fopen("hough1.dat", "r"); | |
277 | while (bench && !feof(bench)) { | |
278 | char buffer[256]; | |
279 | if (!fgets(buffer, 256, bench)) break; | |
280 | fprintf(file, "%s", buffer); | |
281 | } | |
282 | fclose(bench); | |
283 | } | |
3256212a | 284 | if (file) { |
a8ffd46b | 285 | FILE* bench = fopen("hough2.dat", "r"); |
3256212a | 286 | while (bench && !feof(bench)) { |
287 | char buffer[256]; | |
288 | if (!fgets(buffer, 256, bench)) break; | |
289 | fprintf(file, "%s", buffer); | |
290 | } | |
291 | fclose(bench); | |
a8ffd46b | 292 | } |
293 | if (file) { | |
294 | FILE* bench = fopen("overall.dat", "r"); | |
295 | while (bench && !feof(bench)) { | |
296 | char buffer[256]; | |
297 | if (!fgets(buffer, 256, bench)) break; | |
298 | fprintf(file, "%s", buffer); | |
299 | } | |
300 | fclose(bench); | |
301 | fprintf(file, "\n\n"); | |
04b48a95 | 302 | } |
b5279783 | 303 | |
a8ffd46b | 304 | delete hough1; |
305 | delete hough2; | |
b77a0228 | 306 | |
307 | esd->Reset(); | |
3256212a | 308 | } |
a8ffd46b | 309 | // } |
310 | ||
311 | /* | |
312 | // read run, event, detector, DDL numbers and data size | |
313 | AliRawReaderDate rawReader(ptr); | |
314 | time.Set(); | |
315 | printf("\n%s\n", time.AsString()); | |
316 | printf("run: %d event: %d %d\n", rawReader.GetRunNumber(), | |
317 | rawReader.GetEventId()[0], rawReader.GetEventId()[1]); | |
318 | while (rawReader.ReadMiniHeader()) { | |
319 | printf(" detector: %d DDL: %d size: %d\n", | |
320 | rawReader.GetDetectorID(), rawReader.GetDDLID(), | |
321 | rawReader.GetDataSize()); | |
04b48a95 | 322 | } |
b5279783 | 323 | |
a8ffd46b | 324 | */ |
325 | ||
df0f3179 | 326 | gSystem->Sleep(100); // sleep for 0.1 second |
b5279783 | 327 | free(ptr); |
328 | ||
329 | gSystem->ProcessEvents(); | |
330 | if (file) fflush(file); | |
a8ffd46b | 331 | |
b5279783 | 332 | } |
333 | ||
334 | gSystem->RemoveSignalHandler(handler); | |
335 | if (file) fclose(file); | |
336 | ||
120b3c73 | 337 | return 0; |
338 | } | |
339 | ||
b5279783 | 340 | #else |
120b3c73 | 341 | int main(int /*argc*/, char** /*argv*/) |
342 | { | |
b5279783 | 343 | ::Fatal("main", "this program was compiled without DATE"); |
b5279783 | 344 | |
120b3c73 | 345 | return 1; |
b5279783 | 346 | } |
120b3c73 | 347 | #endif |