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