]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
a9e2aefa | 17 | |
18 | ////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // AliDisplay // | |
21 | // // | |
22 | // Utility class to display ALICE outline, tracks, hits,.. // | |
23 | // // | |
24 | ////////////////////////////////////////////////////////////////////////// | |
25 | ||
a9e2aefa | 26 | #include <TButton.h> |
27 | #include <TColor.h> | |
28 | #include <TCanvas.h> | |
29 | #include <TView.h> | |
30 | #include <TText.h> | |
a9e2aefa | 31 | #include <TPaveLabel.h> |
32 | #include <TPaveText.h> | |
a9e2aefa | 33 | #include <TDiamond.h> |
34 | #include <TNode.h> | |
35 | #include <TArc.h> | |
a9e2aefa | 36 | #include <TSlider.h> |
a9e2aefa | 37 | #include <TVirtualX.h> |
38 | #include <TMath.h> | |
94de3818 | 39 | #include <TGeometry.h> |
a9e2aefa | 40 | #include <TMarker3DBox.h> |
572d5bb2 | 41 | #include <TParticle.h> |
e516b01d | 42 | #include <TPolyLine3D.h> |
a9e2aefa | 43 | |
30178c30 | 44 | #include "AliMUONDisplay.h" |
a9e2aefa | 45 | #include "AliRun.h" |
a9e2aefa | 46 | #include "AliMUON.h" |
a9e2aefa | 47 | #include "AliMUONPoints.h" |
d226f81b | 48 | #include "AliMUONGlobalTrigger.h" |
9e1a0ddb | 49 | #include "AliHeader.h" |
a9e2aefa | 50 | |
51 | #include "AliMUONHit.h" | |
a9e2aefa | 52 | #include "AliMUONDigit.h" |
53 | #include "AliMUONRawCluster.h" | |
572d5bb2 | 54 | #include "AliMUONTrack.h" |
55 | #include "AliMUONTrackParam.h" | |
a9e2aefa | 56 | |
76dadf7e | 57 | #include "AliMUONGeometrySegmentation.h" |
a9e2aefa | 58 | #include "AliMUONChamber.h" |
f665c1ea | 59 | #include "AliMUONConstants.h" |
5d12ce38 | 60 | #include "AliMC.h" |
8c343c7c | 61 | #include "AliLog.h" |
a9e2aefa | 62 | // to manage the same zoom on both cathodes |
63 | ||
64 | ||
65 | ||
66 | ClassImp(AliMUONDisplay) | |
67 | ||
68 | ||
69 | //_____________________________________________________________________________ | |
70 | AliMUONDisplay::AliMUONDisplay() | |
30178c30 | 71 | : AliDisplay() |
a9e2aefa | 72 | { |
73 | // Constructor | |
d226f81b | 74 | fPoints = 0; |
75 | fPhits = 0; | |
76 | fRpoints = 0; | |
77 | fCanvas = 0; | |
a9e2aefa | 78 | fNextCathode = kFALSE; |
d226f81b | 79 | fColPad = 0; |
a9e2aefa | 80 | } |
81 | ||
82 | //_____________________________________________________________________________ | |
307d9d04 | 83 | AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader) |
30178c30 | 84 | : AliDisplay() |
a9e2aefa | 85 | { |
86 | // Create an event display object. | |
87 | // A canvas named "edisplay" is created with a vertical size in pixels | |
88 | // | |
89 | // A QUICK Overview of the Event Display functions | |
90 | // =============================================== | |
91 | // | |
92 | // The event display can ve invoked by executing the macro "display.C" | |
93 | // A canvas like in the picture below will appear. | |
94 | // | |
95 | // On the left side of the canvas, the following buttons appear: | |
96 | // *Next* to move to the next event | |
97 | // *Previous* to move to the previous event | |
98 | ||
99 | // *Pick* Select this option to be able to point on a track with the | |
100 | // mouse. Once on the track, use the right button to select | |
101 | // an action. For example, select SetMarkerAttributes to | |
102 | // change the marker type/color/size for the track. | |
103 | // *Zoom* Select this option (default) if you want to zoom. | |
104 | // To zoom, simply select the selected area with the left button. | |
105 | // *UnZoom* To revert to the previous picture size. | |
106 | // | |
107 | // slider R On the left side, the vertical slider can be used to | |
108 | // set the default picture size. | |
109 | // | |
110 | // When you are in Zoom mode, you can click on the black part of the canvas | |
111 | // to select special options with the right mouse button. | |
112 | ||
113 | // | |
114 | // When you are in pick mode, you can "Inspect" the object pointed by the mouse. | |
115 | // When you are on a track, select the menu item "InspectParticle" | |
116 | // to display the current particle attributes. | |
117 | // | |
118 | // You can activate the Root browser by selecting the Inspect menu | |
119 | // in the canvas tool bar menu. Then select "Start Browser" | |
120 | // This will open a new canvas with the browser. At this point, you may want | |
121 | // to display some histograms (from the Trees). Go to the "File" menu | |
122 | // of the browser and click on "New canvas". | |
123 | // In the browser, click on item "ROOT files" in the left pane. | |
124 | // Click on galice.root. | |
125 | // Click on TH | |
126 | // Click on TPC for example | |
127 | // Click on any variable (eg TPC.fX) to histogram the variable. | |
128 | // | |
129 | // If you are lost, you can click on HELP in any Root canvas or browser. | |
130 | //Begin_Html | |
131 | /* | |
132 | <img src="gif/AliMUONDisplay.gif"> | |
133 | */ | |
134 | //End_Html | |
135 | ||
136 | ||
137 | fPad = 0; | |
138 | ||
139 | gAlice->SetDisplay(this); | |
140 | ||
141 | // Initialize display default parameters | |
142 | SetRange(200,2000); | |
143 | // Set front view by default | |
144 | fTheta = 0; | |
145 | fPhi = -90; | |
146 | fPsi = 0; | |
147 | fChamber = 1; | |
148 | fCathode = 1; | |
149 | // fRzone = 1.e10; | |
150 | fDrawClusters = kTRUE; | |
151 | fDrawCoG = kTRUE; | |
572d5bb2 | 152 | fDrawTracks = kFALSE; |
a9e2aefa | 153 | fZoomMode = 1; |
154 | fZooms = 0; | |
155 | fClustersCuts = 0; | |
d226f81b | 156 | fPoints = 0; |
157 | fPhits = 0; | |
158 | fRpoints = 0; | |
a9e2aefa | 159 | // Create colors |
160 | CreateColors(); | |
161 | // Create display canvas | |
162 | Int_t ysize = size; | |
163 | if (ysize < 100) ysize = 750; | |
164 | Int_t xsize = Int_t(size*830./ysize); | |
572d5bb2 | 165 | fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize); |
a9e2aefa | 166 | fCanvas->ToggleEventStatus(); |
167 | ||
168 | // Create main display pad | |
169 | fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1); | |
170 | fPad->Draw(); | |
171 | fPad->Modified(); | |
172 | fPad->SetFillColor(30); | |
173 | fPad->SetBorderSize(2); | |
174 | ||
175 | fCanvas->cd(); | |
176 | ||
177 | // Create colors pad | |
178 | fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1); | |
179 | fColPad->Draw(); | |
180 | fColPad->SetFillColor(17); | |
181 | fColPad->SetBorderSize(2); | |
182 | fColPad->cd(); | |
183 | DisplayColorScale(); | |
184 | ||
185 | fCanvas->cd(); | |
186 | // Create user interface control pad | |
187 | DisplayButtons(); | |
188 | fCanvas->cd(); | |
189 | ||
190 | // Create Range and mode pad | |
191 | Float_t dxtr = 0.15; | |
192 | Float_t dytr = 0.45; | |
193 | fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr); | |
a9e2aefa | 194 | fTrigPad->Draw(); |
195 | fTrigPad->cd(); | |
196 | fTrigPad->SetFillColor(22); | |
197 | fTrigPad->SetBorderSize(2); | |
198 | fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98); | |
199 | fRangeSlider->SetObject(this); | |
200 | char pickmode[] = "gAlice->Display()->SetPickMode()"; | |
201 | Float_t db = 0.09; | |
202 | fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db); | |
203 | fPickButton->SetFillColor(38); | |
204 | fPickButton->Draw(); | |
205 | char zoommode[] = "gAlice->Display()->SetZoomMode()"; | |
206 | fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db); | |
207 | fZoomButton->SetFillColor(38); | |
208 | fZoomButton->Draw(); | |
209 | fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db); | |
210 | fArcButton->SetFillColor(kGreen); | |
211 | fArcButton->Draw(); | |
212 | char butUnzoom[] = "gAlice->Display()->UnZoom()"; | |
213 | TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15); | |
214 | button->SetFillColor(38); | |
215 | button->Draw(); | |
216 | AppendPad(); // append display object as last object to force selection | |
217 | ||
218 | fCanvas->cd(); | |
1c4b7942 | 219 | fTrigPad->SetEditable(kFALSE); |
220 | fButtons->SetEditable(kFALSE); | |
a9e2aefa | 221 | fCanvas->Update(); |
222 | fNextCathode = kFALSE; | |
307d9d04 | 223 | fLoader = loader; |
d226f81b | 224 | // initialize container |
225 | if(fLoader) | |
226 | fMUONData = new AliMUONData(fLoader,"MUON","MUON"); | |
227 | else | |
228 | fMUONData =0x0; | |
a9e2aefa | 229 | } |
230 | ||
30178c30 | 231 | AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display) |
232 | : AliDisplay(display) | |
a9e2aefa | 233 | { |
30178c30 | 234 | // Protected copy constructor |
235 | ||
8c343c7c | 236 | AliFatal("Not implemented."); |
a9e2aefa | 237 | } |
238 | ||
239 | ||
240 | ||
241 | //_____________________________________________________________________________ | |
242 | AliMUONDisplay::~AliMUONDisplay() | |
243 | { | |
244 | // Delete space point structure | |
245 | if (fPoints) fPoints->Delete(); | |
246 | delete fPoints; | |
247 | fPoints = 0; | |
248 | // | |
249 | if (fPhits) fPhits->Delete(); | |
250 | delete fPhits; | |
251 | fPhits = 0; | |
252 | // | |
d226f81b | 253 | if (fRpoints) fRpoints->Delete(); |
a9e2aefa | 254 | delete fRpoints; |
d226f81b | 255 | fRpoints = 0; |
a9e2aefa | 256 | } |
257 | ||
258 | //_____________________________________________________________________________ | |
259 | void AliMUONDisplay::Clear(Option_t *) | |
260 | { | |
261 | // Delete graphics temporary objects | |
262 | } | |
263 | ||
264 | //_____________________________________________________________________________ | |
265 | void AliMUONDisplay::DisplayButtons() | |
266 | { | |
267 | // Create the user interface buttons | |
268 | ||
269 | ||
270 | fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1); | |
a9e2aefa | 271 | fButtons->Draw(); |
272 | fButtons->SetFillColor(38); | |
273 | fButtons->SetBorderSize(2); | |
274 | fButtons->cd(); | |
275 | ||
276 | // Int_t butcolor = 33; | |
277 | Float_t dbutton = 0.08; | |
278 | Float_t y = 0.96; | |
279 | Float_t dy = 0.014; | |
280 | Float_t x0 = 0.05; | |
281 | Float_t x1 = 0.95; | |
282 | ||
283 | TButton *button; | |
284 | char but1[] = "gAlice->Display()->ShowNextEvent(1)"; | |
285 | button = new TButton("Event +", but1, x0, y - dbutton, x1, y); | |
286 | button->SetFillColor(38); | |
287 | button->Draw(); | |
288 | ||
289 | y -= dbutton + dy; | |
290 | char but2[] = "gAlice->Display()->ShowNextEvent(-1)"; | |
291 | button = new TButton("Event -", but2, x0, y - dbutton, x1, y); | |
292 | button->SetFillColor(38); | |
293 | button->Draw(); | |
294 | ||
295 | y -= dbutton + dy; | |
296 | char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)"; | |
297 | button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y); | |
298 | button->SetFillColor(38); | |
299 | button->Draw(); | |
300 | ||
301 | y -= dbutton + dy; | |
302 | char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)"; | |
303 | button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y); | |
304 | button->SetFillColor(38); | |
305 | button->Draw(); | |
306 | ||
307 | y -= dbutton + dy; | |
308 | char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)"; | |
309 | button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y); | |
310 | button->SetFillColor(38); | |
311 | button->Draw(); | |
312 | ||
313 | y -= dbutton + dy; | |
314 | char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()"; | |
315 | button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y); | |
316 | button->SetFillColor(38); | |
317 | button->Draw(); | |
318 | ||
319 | y -= dbutton + dy; | |
320 | char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()"; | |
321 | button = new TButton("Trigger", but7, x0, y - dbutton, x1, y); | |
322 | button->SetFillColor(38); | |
323 | button->Draw(); | |
324 | ||
572d5bb2 | 325 | y -= dbutton + dy; |
326 | char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()"; | |
327 | button = new TButton("Tracking", but8, x0, y - dbutton, x1, y); | |
328 | button->SetFillColor(38); | |
329 | button->Draw(); | |
330 | ||
a9e2aefa | 331 | // display logo |
332 | TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22); | |
333 | diamond->SetFillColor(50); | |
334 | diamond->SetTextAlign(22); | |
335 | diamond->SetTextColor(5); | |
336 | diamond->SetTextSize(0.11); | |
337 | diamond->Draw(); | |
338 | diamond->AddText(".. "); | |
339 | diamond->AddText("ROOT"); | |
340 | diamond->AddText("MUON"); | |
341 | diamond->AddText("... "); | |
342 | diamond->AddText(" "); | |
343 | } | |
344 | ||
345 | //_____________________________________________________________________________ | |
30178c30 | 346 | void AliMUONDisplay::CreateColors() const |
a9e2aefa | 347 | { |
348 | // Create the colors palette used to display clusters | |
349 | ||
350 | Int_t k,i; | |
351 | Int_t color; | |
352 | Float_t r,g,b; | |
353 | ||
354 | for (k=1;k<=5;k++) { | |
355 | switch(k) { | |
356 | case 1: | |
357 | for (i=1;i<=5;i++) { | |
358 | r=1.; | |
359 | g=i*0.2; | |
360 | b=0.; | |
361 | color=i; | |
362 | color=260+23-color; | |
363 | new TColor(color,r,g,b); | |
364 | } | |
365 | break; | |
366 | case 2: | |
367 | for (i=1;i<=4;i++) { | |
368 | r=1.1-i*0.2; | |
369 | g=1.; | |
370 | b=0.; | |
371 | color=i+5; | |
372 | color=260+23-color; | |
373 | new TColor(color,r,g,b); | |
374 | } | |
375 | break; | |
376 | case 3: | |
377 | for (i=1;i<=4;i++) { | |
378 | r=0.; | |
379 | g=1.; | |
380 | b=i*0.2+0.2; | |
381 | color=i+9; | |
382 | color=260+23-color; | |
383 | new TColor(color,r,g,b); | |
384 | } | |
385 | break; | |
386 | case 4: | |
387 | for (i=1;i<=4;i++) { | |
388 | r=0.; | |
389 | g=1.1-i*0.2; | |
390 | b=1.; | |
391 | color=i+13; | |
392 | color=260+23-color; | |
393 | new TColor(color,r,g,b); | |
394 | } | |
395 | break; | |
396 | case 5: | |
397 | for (i=1;i<=5;i++) { | |
398 | r=i*0.2; | |
399 | g=0.; | |
400 | b=1.; | |
401 | color=i+17; | |
402 | color=260+23-color; | |
403 | new TColor(color,r,g,b); | |
404 | } | |
405 | break; | |
406 | } | |
407 | } | |
408 | } | |
409 | ||
410 | //_____________________________________________________________________________ | |
411 | void AliMUONDisplay::DisplayColorScale() | |
412 | { | |
413 | // Display pulse height color scale | |
414 | Int_t i; | |
415 | Int_t color; | |
416 | Float_t xlow, ylow, xup, yup, hs; | |
417 | Float_t x1, y1, x2, y2; | |
418 | x1 = y1 = 0; | |
419 | x2 = y2 = 1.0; | |
420 | ||
421 | TText *text = new TText(0,0,""); | |
422 | text->SetTextFont(61); | |
423 | text->SetTextSize(0.2); | |
424 | text->SetTextAlign(22); | |
425 | ||
7e4a628d | 426 | |
427 | Int_t adcmax=4096; // default 12 bits ADC | |
428 | ||
a9e2aefa | 429 | |
430 | ||
431 | TBox *box; | |
432 | char label[8]; | |
433 | //*-* draw colortable boxes | |
434 | hs = (y2-y1)/Float_t(22); | |
435 | xlow=x1+.05; | |
436 | xup=x2-0.5; | |
437 | for (i=0;i<22;i++) { | |
438 | ylow = y1 + hs*(Float_t(i)); | |
439 | yup = y1 + hs*(Float_t(i+1)); | |
440 | color = 261+i; | |
441 | Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22); | |
442 | Int_t scale=(Int_t)TMath::Exp(logscale); | |
443 | sprintf(label,"%d",scale); | |
444 | box = new TBox(xlow, ylow, xup, yup); | |
445 | box->Draw(); | |
446 | box->SetFillColor(color); | |
447 | text->DrawText(xlow+0.7, 0.5*(ylow+yup),label); | |
448 | } | |
449 | } | |
450 | ||
451 | //______________________________________________________________________________ | |
452 | Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t) | |
453 | { | |
454 | // Compute distance from point px,py to objects in event | |
455 | ||
456 | gPad->SetCursor(kCross); | |
457 | ||
458 | if (gPad == fTrigPad) return 9999; | |
459 | ||
460 | const Int_t kBig = 9999; | |
461 | Int_t dist = kBig; | |
462 | Float_t xmin = gPad->GetX1(); | |
463 | Float_t xmax = gPad->GetX2(); | |
464 | Float_t dx = 0.02*(xmax - xmin); | |
465 | Float_t x = gPad->AbsPixeltoX(px); | |
466 | if (x < xmin+dx || x > xmax-dx) return dist; | |
467 | ||
468 | if (fZoomMode) return 0; | |
469 | else return 7; | |
470 | } | |
471 | ||
472 | //_____________________________________________________________________________ | |
473 | void AliMUONDisplay::Draw(Option_t *) | |
474 | { | |
475 | // Display current event | |
476 | ||
572d5bb2 | 477 | if (!fDrawTracks) |
478 | DrawChamber(); | |
479 | else | |
480 | DrawReco(); | |
481 | ||
482 | } | |
483 | //_____________________________________________________________________________ | |
484 | void AliMUONDisplay::DrawChamber() | |
485 | { | |
a9e2aefa | 486 | |
572d5bb2 | 487 | fDrawTracks = kFALSE; |
488 | fPad->cd(); | |
489 | DrawView(fTheta, fPhi, fPsi); | |
490 | // Display the event number and title | |
491 | fPad->cd(); | |
492 | DrawTitle(); | |
493 | ||
494 | } | |
495 | //_____________________________________________________________________________ | |
496 | void AliMUONDisplay::DrawReco(Option_t *) | |
497 | { | |
498 | // Display current event | |
499 | ||
500 | fDrawTracks = kTRUE; | |
501 | // print kinematics of generated particles | |
502 | PrintKinematics(); | |
503 | // Draw global view of muon system | |
504 | fPad->cd(); | |
505 | DrawGlobalView(135, -50, -140); | |
506 | ||
a9e2aefa | 507 | // Display the event number and title |
508 | fPad->cd(); | |
509 | DrawTitle(); | |
510 | } | |
511 | ||
572d5bb2 | 512 | //_____________________________________________________________________________ |
513 | void AliMUONDisplay::PrintKinematics() | |
514 | { | |
515 | AliRunLoader * runLoader; | |
516 | TParticle *particle = new TParticle(); | |
517 | Int_t nPart; | |
518 | Float_t vertex[3], momentum[3]; | |
519 | ||
520 | if (fLoader) | |
521 | runLoader = fLoader->GetRunLoader(); | |
522 | else | |
523 | runLoader = 0x0; | |
524 | ||
525 | printf("****** Event # %d ******\n",runLoader->GetEventNumber()); | |
526 | runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle); | |
527 | nPart = (Int_t)runLoader->TreeK()->GetEntries(); | |
528 | for(Int_t iPart = 0; iPart < nPart; iPart++) { | |
529 | runLoader->TreeK()->GetEvent(iPart); | |
530 | vertex[0] = particle->Vx(); | |
531 | vertex[1] = particle->Vy(); | |
532 | vertex[2] = particle->Vz(); | |
533 | momentum[0] = particle->Px(); | |
534 | momentum[1] = particle->Py(); | |
535 | momentum[2] = particle->Pz(); | |
536 | ||
537 | printf("===================================================\n"); | |
538 | printf(" Generated particle # %d \n",iPart); | |
539 | printf(" name: %s \n",particle->GetName()); | |
540 | printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]); | |
541 | printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]); | |
542 | } | |
543 | delete particle; | |
544 | } | |
545 | ||
a9e2aefa | 546 | void AliMUONDisplay::DrawSegmentation() |
547 | { | |
002920d1 | 548 | // to be re-written for new seg |
a9e2aefa | 549 | // Draw graphical representation of segmenatation |
550 | // Attention: still experimental code | |
002920d1 | 551 | // Int_t icat=1; |
a9e2aefa | 552 | |
002920d1 | 553 | // AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); |
554 | // AliMUONChamber* iChamber; | |
76dadf7e | 555 | |
002920d1 | 556 | // AliSegmentation* seg; |
557 | // iChamber = &(pMUON->Chamber(fChamber)); | |
558 | // seg=iChamber->SegmentationModel(icat); | |
76dadf7e | 559 | |
002920d1 | 560 | // Float_t zpos=iChamber->Z(); |
561 | // Float_t r=iChamber->ROuter(); | |
a9e2aefa | 562 | |
002920d1 | 563 | // TMarker3DBox *marker; |
564 | // if (icat == 1) { | |
565 | // for (Int_t j=0; j<seg->Npy(); j++) { | |
566 | // Float_t y0; | |
567 | // y0=j*seg->Dpy()-seg->Dpy()/2.; | |
568 | // for (seg->FirstPad(0.,y0,0,300,0.); | |
569 | // seg->MorePads(); | |
570 | // seg->NextPad()) | |
571 | // { | |
572 | // if (seg->ISector()==0) continue; | |
573 | // Float_t x,y,z; | |
574 | // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z); | |
575 | // Float_t dpx=seg->Dpx(seg->ISector())/2; | |
576 | // Float_t dpy=seg->Dpy(seg->ISector())/2; | |
577 | // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0); | |
578 | // marker->SetLineColor(seg->ISector()+1); | |
579 | // marker->SetFillStyle(1001); | |
580 | // marker->SetFillColor(0); | |
581 | // marker->Draw(); | |
582 | // } | |
583 | // } | |
584 | // } else { | |
585 | // for (Int_t j=0; j<250; j++) { | |
586 | // Float_t x0=j*seg->Dpx(); | |
587 | // Float_t y0=TMath::Sqrt(r*r-x0*x0); | |
a9e2aefa | 588 | |
002920d1 | 589 | // for (seg->FirstPad(x0,0,0,0,y0); |
590 | // seg->MorePads(); | |
591 | // seg->NextPad()) | |
592 | // { | |
593 | // if (seg->ISector()==0) continue; | |
a9e2aefa | 594 | |
002920d1 | 595 | // Float_t x,y,z; |
596 | // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z); | |
597 | // Float_t dpx=seg->Dpx(seg->ISector())/2; | |
598 | // Float_t dpy=seg->Dpy(seg->ISector())/2; | |
599 | // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0); | |
600 | // marker->SetLineColor(seg->ISector()+1); | |
601 | // marker->SetFillStyle(1001); | |
602 | // marker->SetFillColor(0); | |
603 | // marker->Draw(); | |
604 | // } | |
605 | // } | |
606 | // } | |
607 | } | |
a9e2aefa | 608 | |
609 | //_____________________________________________________________________________ | |
610 | void AliMUONDisplay::DrawClusters() | |
611 | { | |
612 | // Draw clusters for MUON chambers | |
613 | ||
614 | Int_t ndigits, digit; | |
615 | TObjArray *points; | |
616 | AliMUONPoints *pm; | |
617 | ||
618 | ||
619 | fClustersCuts = 0; | |
620 | points = Points(); | |
621 | if (!points) return; | |
622 | ndigits = points->GetEntriesFast(); | |
623 | for (digit=0;digit<ndigits;digit++){ | |
624 | pm = (AliMUONPoints*)points->UncheckedAt(digit); | |
625 | if (!pm) continue; | |
626 | Float_t *pxyz; | |
627 | pxyz=pm->GetP(); | |
628 | for (Int_t im=0;im<3;im++) { | |
629 | TMarker3DBox *marker=pm->GetMarker(im); | |
630 | if (marker) | |
631 | marker->Draw(); | |
632 | } | |
633 | pm->Draw(); | |
634 | fClustersCuts +=pm->GetN(); | |
635 | } | |
636 | } | |
637 | ||
638 | //_____________________________________________________________________________ | |
639 | void AliMUONDisplay::DrawHits() | |
640 | { | |
641 | // Draw hits for MUON chambers | |
642 | ||
643 | LoadHits(fChamber); | |
644 | ||
645 | Int_t ntracks, track; | |
646 | TObjArray *points; | |
647 | AliMUONPoints *pm; | |
648 | ||
649 | fHitsCuts = 0; | |
650 | points = Phits(); | |
651 | if (!points) return; | |
652 | ntracks = points->GetEntriesFast(); | |
653 | for (track=0;track<ntracks;track++) { | |
654 | pm = (AliMUONPoints*)points->UncheckedAt(track); | |
655 | if (!pm) continue; | |
656 | pm->Draw(); | |
657 | fHitsCuts += pm->GetN(); | |
658 | } | |
659 | } | |
660 | ||
661 | ||
662 | //_____________________________________________________________________________ | |
663 | void AliMUONDisplay::DrawCoG() | |
664 | { | |
665 | // Draw hits for MUON chambers | |
666 | if (!fDrawCoG) return; | |
667 | if (fChamber > 10) return; | |
668 | LoadCoG(fChamber,fCathode); | |
669 | ||
670 | Int_t ncog, icog; | |
671 | TObjArray *points; | |
672 | AliMUONPoints *pm; | |
673 | ||
674 | points = Rpoints(); | |
675 | if (!points) return; | |
676 | ncog = points->GetEntriesFast(); | |
677 | for (icog=0;icog<ncog;icog++) { | |
678 | pm = (AliMUONPoints*)points->UncheckedAt(icog); | |
679 | if (!pm) continue; | |
680 | pm->Draw(); | |
681 | } | |
682 | } | |
a9e2aefa | 683 | //_____________________________________________________________________________ |
572d5bb2 | 684 | void AliMUONDisplay::DrawTracks() |
685 | { | |
686 | // Draw tracks | |
687 | if (!fDrawTracks) return; | |
688 | LoadTracks(); | |
689 | ||
690 | Int_t nTrack, iTrack; | |
691 | TObjArray *points; | |
692 | TPolyLine3D *pm; | |
693 | ||
694 | points = Rpoints(); | |
695 | if (!points) return; | |
696 | nTrack = points->GetEntriesFast(); | |
697 | for ( iTrack = 0; iTrack < nTrack; iTrack++) { | |
698 | pm = (TPolyLine3D*)points->UncheckedAt(iTrack); | |
699 | if (!pm) continue; | |
700 | pm->Draw(); | |
701 | } | |
702 | } | |
703 | //_____________________________________________________________________________ | |
a9e2aefa | 704 | |
705 | void AliMUONDisplay::DrawTitle(Option_t *option) | |
706 | { | |
707 | // Draw the event title | |
708 | ||
709 | Float_t xmin = gPad->GetX1(); | |
710 | Float_t xmax = gPad->GetX2(); | |
711 | Float_t ymin = gPad->GetY1(); | |
712 | Float_t ymax = gPad->GetY2(); | |
713 | Float_t dx = xmax-xmin; | |
714 | Float_t dy = ymax-ymin; | |
715 | ||
30178c30 | 716 | AliRunLoader * runLoader; |
307d9d04 | 717 | if (fLoader) |
30178c30 | 718 | runLoader = fLoader->GetRunLoader(); |
307d9d04 | 719 | else |
30178c30 | 720 | runLoader = 0x0; |
7985603c | 721 | |
722 | ||
a9e2aefa | 723 | if (strlen(option) == 0) { |
724 | TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy); | |
725 | // title->SetTextSize(0.023932); | |
726 | title->SetTextSize(0.02); | |
727 | title->SetBit(kCanDelete); | |
728 | title->SetFillColor(42); | |
729 | title->Draw(); | |
730 | char ptitle[100]; | |
731 | sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d", | |
30178c30 | 732 | runLoader->GetEventNumber(), |
a9e2aefa | 733 | gAlice->GetHeader()->GetRun(), |
734 | fChamber, | |
735 | fCathode); | |
736 | title->AddText(ptitle); | |
5d12ce38 | 737 | Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast(); |
a9e2aefa | 738 | sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d", |
739 | nparticles, fHitsCuts,fClustersCuts); | |
740 | title->AddText(ptitle); | |
741 | } else { | |
742 | TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option); | |
743 | label->SetBit(kCanDelete); | |
744 | label->SetFillColor(42); | |
745 | label->Draw(); | |
746 | } | |
747 | } | |
748 | ||
749 | //_____________________________________________________________________________ | |
750 | void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi) | |
751 | { | |
752 | // Draw a view of MUON clusters | |
c177f73d | 753 | AliInfo(" Draw View"); |
a9e2aefa | 754 | |
755 | gPad->SetCursor(kWatch); | |
756 | // gPad->SetFillColor(39); | |
757 | gPad->SetFillColor(1); | |
758 | gPad->Clear(); | |
759 | // gPad->SetFillColor(39); | |
760 | gPad->SetFillColor(1); | |
761 | ||
762 | ||
763 | Int_t iret=0; | |
764 | TView *view = new TView(1); | |
765 | ||
766 | Float_t range = fRrange*fRangeSlider->GetMaximum(); | |
767 | view->SetRange(-range,-range,-range,range, range, range); | |
768 | // zoom back to full scale only if DrawView not called from NextCathode | |
769 | if (!fNextCathode) { | |
770 | fZoomX0[0] = -1; | |
771 | fZoomY0[0] = -1; | |
772 | fZoomX1[0] = 1; | |
773 | fZoomY1[0] = 1; | |
774 | fZooms = 0; | |
775 | } | |
776 | ||
777 | // Display MUON Chamber Geometry | |
a9e2aefa | 778 | char nodeName[7]; |
779 | sprintf(nodeName,"MUON%d",100+fChamber); | |
a9e2aefa | 780 | |
781 | TNode *node1=gAlice->GetGeometry()->GetNode(nodeName); | |
782 | if (node1) node1->Draw("same"); | |
783 | //add clusters to the pad | |
784 | DrawClusters(); | |
a9e2aefa | 785 | DrawHits(); |
786 | DrawCoG(); | |
a9e2aefa | 787 | // DrawSegmentation(); |
788 | // add itself to the list (must be last) | |
789 | AppendPad(); | |
790 | view->SetView(phi, theta, psi, iret); | |
791 | } | |
792 | ||
572d5bb2 | 793 | //_____________________________________________________________________________ |
794 | void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi) | |
795 | { | |
796 | // Draw a view of muons chambers with tracks | |
797 | ||
798 | gPad->SetCursor(kWatch); | |
799 | // gPad->SetFillColor(39); | |
800 | gPad->SetFillColor(1); | |
801 | gPad->Clear(); | |
802 | // gPad->SetFillColor(39); | |
803 | gPad->SetFillColor(1); | |
804 | ||
805 | ||
806 | Int_t iret=0; | |
807 | TView *view = new TView(1); | |
808 | ||
809 | Float_t range = fRrange*fRangeSlider->GetMaximum()*3.; | |
810 | view->SetRange(-range,-range,-range,range,range,range); | |
811 | ||
812 | // Display all MUON Chambers segmentation | |
813 | char nodeName[7]; | |
814 | TNode *node1; | |
815 | sprintf(nodeName,"alice"); | |
816 | ||
817 | node1=gAlice->GetGeometry()->GetNode(nodeName); | |
818 | if (node1) node1->Draw("same"); | |
819 | ||
820 | ||
821 | // Draw clusters for all chambers | |
822 | Int_t chamberSave = fChamber; | |
823 | for (fChamber = 1; fChamber <= 10; fChamber++){ | |
824 | DrawCoG(); | |
825 | } | |
826 | fChamber = chamberSave; | |
827 | // Draw reconstructed tracks | |
828 | DrawTracks(); | |
829 | ||
830 | AppendPad(); | |
831 | ||
832 | Float_t zoom = 2.; | |
833 | Float_t shift = 0.9; | |
834 | Float_t x0 = (-1+shift)/zoom; | |
835 | Float_t y0 = (-1+shift)/zoom; | |
836 | Float_t x1 = (1+shift)/zoom; | |
837 | Float_t y1 = (1+shift)/zoom; | |
838 | gPad->Range(x0,y0,x1,y1); | |
839 | view->SetView(phi, theta, psi, iret); | |
840 | ||
841 | } | |
a9e2aefa | 842 | |
843 | //______________________________________________________________________________ | |
844 | void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) | |
845 | { | |
846 | // Execute action corresponding to the mouse event | |
847 | ||
848 | static Float_t x0, y0, x1, y1; | |
849 | ||
850 | static Int_t pxold, pyold; | |
851 | static Int_t px0, py0; | |
852 | static Int_t linedrawn; | |
853 | Float_t temp; | |
854 | ||
855 | if (px == 0 && py == 0) { //when called by sliders | |
856 | if (event == kButton1Up) { | |
857 | Draw(); | |
858 | } | |
859 | return; | |
860 | } | |
861 | if (!fZoomMode && gPad->GetView()) { | |
862 | gPad->GetView()->ExecuteRotateView(event, px, py); | |
863 | return; | |
864 | } | |
865 | ||
866 | // something to zoom ? | |
867 | gPad->SetCursor(kCross); | |
868 | ||
869 | switch (event) { | |
870 | ||
871 | case kButton1Down: | |
872 | gVirtualX->SetLineColor(-1); | |
873 | gPad->TAttLine::Modify(); //Change line attributes only if necessary | |
874 | x0 = gPad->AbsPixeltoX(px); | |
875 | y0 = gPad->AbsPixeltoY(py); | |
876 | px0 = px; py0 = py; | |
877 | pxold = px; pyold = py; | |
878 | linedrawn = 0; | |
879 | return; | |
880 | ||
881 | case kButton1Motion: | |
882 | if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); | |
883 | pxold = px; | |
884 | pyold = py; | |
885 | linedrawn = 1; | |
886 | gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); | |
887 | return; | |
888 | ||
889 | case kButton1Up: | |
890 | gPad->GetCanvas()->FeedbackMode(kFALSE); | |
891 | if (px == px0) return; | |
892 | if (py == py0) return; | |
893 | x1 = gPad->AbsPixeltoX(px); | |
894 | y1 = gPad->AbsPixeltoY(py); | |
895 | ||
896 | if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;} | |
897 | if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;} | |
898 | gPad->Range(x0,y0,x1,y1); | |
97ccf8cb | 899 | if (fZooms < AliMUONConstants::MaxZoom()-1) { |
a9e2aefa | 900 | fZooms++; |
901 | fZoomX0[fZooms] = x0; | |
902 | fZoomY0[fZooms] = y0; | |
903 | fZoomX1[fZooms] = x1; | |
904 | fZoomY1[fZooms] = y1; | |
905 | } | |
906 | gPad->Modified(kTRUE); | |
907 | return; | |
908 | } | |
909 | } | |
910 | ||
911 | //___________________________________________ | |
912 | void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode) | |
913 | { | |
914 | // Read digits info and store x,y,z info in arrays fPoints | |
915 | // Loop on all detectors | |
916 | ||
917 | if (chamber > 14) return; | |
08a636a8 | 918 | fChamber = chamber; |
919 | fCathode = cathode; | |
a9e2aefa | 920 | |
921 | ResetPoints(); | |
922 | ||
08a636a8 | 923 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); |
a9e2aefa | 924 | AliMUONChamber* iChamber; |
76dadf7e | 925 | AliMUONGeometrySegmentation* segmentation2 = 0x0; |
926 | ||
d226f81b | 927 | GetMUONData()->SetTreeAddress("D"); |
a9e2aefa | 928 | |
d226f81b | 929 | TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1); |
a9e2aefa | 930 | if (muonDigits == 0) return; |
931 | ||
d226f81b | 932 | gAlice->ResetDigits(); |
00f56532 | 933 | Int_t nent = 0; |
934 | ||
307d9d04 | 935 | if (GetLoader()->TreeD()) { |
936 | nent = (Int_t) GetLoader()->TreeD()->GetEntries(); | |
49b640e7 | 937 | // gAlice->TreeD()->GetEvent(nent-2+cathode-1); |
935b9895 | 938 | GetMUONData()->GetDigits(); |
00f56532 | 939 | } |
940 | ||
a9e2aefa | 941 | Int_t ndigits = muonDigits->GetEntriesFast(); |
942 | if (ndigits == 0) return; | |
943 | if (fPoints == 0) fPoints = new TObjArray(ndigits); | |
944 | ||
945 | iChamber = &(pMUON->Chamber(chamber-1)); | |
946 | ||
002920d1 | 947 | segmentation2 = iChamber->SegmentationModel2(cathode); |
76dadf7e | 948 | |
08a636a8 | 949 | Float_t zpos = iChamber->Z(); |
950 | ||
a9e2aefa | 951 | AliMUONDigit *mdig; |
08a636a8 | 952 | AliMUONPoints *points = 0; |
953 | TMarker3DBox *marker = 0; | |
a9e2aefa | 954 | // |
955 | //loop over all digits and store their position | |
956 | ||
08a636a8 | 957 | Int_t npoints = 1; |
7e4a628d | 958 | Float_t adcmax = 1024; // default |
959 | if (chamber<11) adcmax = 4096; | |
a9e2aefa | 960 | |
08a636a8 | 961 | for (Int_t digit = 0; digit < ndigits; digit++) { |
a9e2aefa | 962 | mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit); |
08a636a8 | 963 | if (mdig->Cathode() != cathode-1) continue; |
4554f81d | 964 | |
a9e2aefa | 965 | // |
966 | // First get all needed parameters | |
967 | // | |
08a636a8 | 968 | Int_t charge = mdig->Signal(); |
969 | Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22)); | |
970 | Int_t color = 261+index; | |
971 | Int_t colorTrigger = 2; | |
972 | if (color > 282) color = 282; | |
a9e2aefa | 973 | |
974 | if (chamber > 10) { // trigger chamber | |
4554f81d | 975 | |
08a636a8 | 976 | Int_t sumCharge = 0; |
977 | for (Int_t icharge = 0; icharge < 10; icharge++) { | |
978 | sumCharge = sumCharge+mdig->TrackCharge(icharge); | |
a9e2aefa | 979 | } |
08a636a8 | 980 | Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10; |
981 | if(sumCharge <= 10 || testCharge > 0) { | |
982 | colorTrigger = color; | |
a9e2aefa | 983 | } else { |
08a636a8 | 984 | colorTrigger = 5; |
a9e2aefa | 985 | } |
986 | } | |
987 | ||
988 | // get the center of the pad - add on x and y half of pad size | |
802a864d | 989 | Float_t xpad, ypad, zpad; |
76dadf7e | 990 | Int_t isec; |
991 | Float_t dpx, dpy; | |
992 | ||
002920d1 | 993 | Int_t detElemId = mdig->DetElemId(); |
994 | segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad); | |
995 | isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY()); | |
996 | dpx = segmentation2->Dpx(detElemId, isec)/2; | |
997 | dpy = segmentation2->Dpy(detElemId, isec)/2; | |
998 | ||
08a636a8 | 999 | // |
1000 | // segmentation->Dump(); | |
a9e2aefa | 1001 | |
a9e2aefa | 1002 | // |
1003 | // Then set the objects | |
1004 | // | |
1005 | points = new AliMUONPoints(npoints); | |
1006 | fPoints->AddAt(points,digit); | |
1007 | if (chamber > 10) { | |
1008 | points->SetMarkerColor(colorTrigger); | |
1009 | } else { | |
1010 | points->SetMarkerColor(color); | |
1011 | } | |
1012 | points->SetMarkerStyle(21); | |
1013 | points->SetMarkerSize(0.5); | |
1014 | points->SetParticle(-1); | |
1015 | points->SetHitIndex(-1); | |
1016 | points->SetTrackIndex(-1); | |
1017 | points->SetDigitIndex(digit); | |
4554f81d | 1018 | points->SetPoint(0,xpad,ypad,zpos); |
1019 | ||
08a636a8 | 1020 | Int_t lineColor = (zpad-zpos > 0) ? 2:3; |
1021 | marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0); | |
1022 | ||
1023 | ||
1024 | marker->SetLineColor(lineColor); | |
1025 | marker->SetFillStyle(1001); | |
1026 | marker->SetFillColor(color); | |
1027 | marker->SetRefObject((TObject*)points); | |
1028 | points->Set3DMarker(0, marker); | |
a9e2aefa | 1029 | } |
1030 | } | |
1031 | //___________________________________________ | |
e0875ac1 | 1032 | void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/) |
a9e2aefa | 1033 | { |
d226f81b | 1034 | // Read raw clusters info and store x,y,z info in arrays fRpoints |
1035 | // Loop on all detectors | |
a9e2aefa | 1036 | |
1037 | if (chamber > 10) return; | |
1038 | ||
1039 | ResetRpoints(); | |
1040 | ||
1041 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
1042 | AliMUONChamber* iChamber; | |
1043 | ||
d226f81b | 1044 | GetMUONData()->SetTreeAddress("RC"); |
1045 | TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1); | |
a9e2aefa | 1046 | |
7985603c | 1047 | if (muonRawClusters == 0) return; |
a9e2aefa | 1048 | |
00f56532 | 1049 | Int_t nent = 0; |
d226f81b | 1050 | if (GetMUONData()->TreeR()) { |
1051 | nent=(Int_t) GetMUONData()->TreeR()->GetEntries(); | |
1052 | GetMUONData()->TreeR()->GetEvent(0); | |
00f56532 | 1053 | } |
1054 | ||
a9e2aefa | 1055 | Int_t nrawcl = muonRawClusters->GetEntriesFast(); |
1056 | if (nrawcl == 0) return; | |
d226f81b | 1057 | if (fRpoints == 0) fRpoints = new TObjArray(nrawcl); |
a9e2aefa | 1058 | |
1059 | iChamber = &(pMUON->Chamber(chamber-1)); | |
1060 | Float_t zpos=iChamber->Z(); | |
1061 | AliMUONRawCluster *mRaw; | |
1062 | AliMUONPoints *points = 0; | |
1063 | // | |
1064 | //loop over all raw clusters and store their position | |
1065 | points = new AliMUONPoints(nrawcl); | |
1066 | for (Int_t iraw=0;iraw<nrawcl;iraw++) { | |
1067 | mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw); | |
a9e2aefa | 1068 | points->SetMarkerColor(51); |
1069 | points->SetMarkerStyle(2); | |
1070 | points->SetMarkerSize(1.); | |
1071 | points->SetParticle(-1); | |
1072 | points->SetHitIndex(-1); | |
1073 | points->SetTrackIndex(-1); | |
1074 | points->SetDigitIndex(-1); | |
ba12c242 | 1075 | points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos); |
d226f81b | 1076 | fRpoints->AddAt(points,iraw); |
ba12c242 | 1077 | // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0)); |
a9e2aefa | 1078 | } |
1079 | } | |
572d5bb2 | 1080 | |
1081 | //___________________________________________ | |
1082 | void AliMUONDisplay::LoadTracks() | |
1083 | { | |
1084 | // Load tracks | |
1085 | AliMUONTrack* recTrack = 0; | |
1086 | AliMUONTrackParam* trackParam = 0; | |
1087 | TClonesArray * trackParamAtHit = 0; | |
1088 | ||
1089 | ResetRpoints(); | |
1090 | ||
1091 | GetMUONData()->SetTreeAddress("RT"); | |
1092 | TClonesArray* recTracksArray = GetMUONData()->RecTracks(); | |
1093 | if (recTracksArray == NULL) return; | |
1094 | GetMUONData()->GetRecTracks(); | |
1095 | ||
1096 | Int_t nRecTracks = 0; | |
1097 | if (recTracksArray) | |
1098 | nRecTracks = (Int_t) recTracksArray->GetEntriesFast(); | |
1099 | ||
1100 | ||
1101 | if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks); | |
1102 | ||
1103 | for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) { | |
1104 | // reading info from tracks | |
1105 | recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks); | |
1106 | ||
1107 | Int_t nTrackHits = recTrack->GetNTrackHits(); | |
1108 | ||
1109 | if (nTrackHits == 0) continue; | |
1110 | ||
1111 | Int_t iPoint = 0; | |
1112 | TPolyLine3D *points = new TPolyLine3D(nTrackHits+1); | |
1113 | points->SetLineColor(6); | |
1114 | points->SetLineWidth(1); | |
1115 | fRpoints->AddAt(points,iRecTracks); | |
1116 | ||
1117 | Float_t xRec=0; | |
1118 | Float_t yRec=0; | |
1119 | Float_t zRec=0; | |
1120 | ||
1121 | trackParam = recTrack->GetTrackParamAtVertex(); | |
1122 | xRec = trackParam->GetNonBendingCoor(); | |
1123 | yRec = trackParam->GetBendingCoor(); | |
1124 | zRec = trackParam->GetZ(); | |
1125 | points->SetPoint(iPoint,xRec,yRec,zRec); | |
1126 | iPoint++; | |
1127 | ||
1128 | for (Int_t iHit = 0; iHit < nTrackHits; iHit++){ | |
1129 | trackParamAtHit = recTrack->GetTrackParamAtHit(); | |
1130 | trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit); | |
1131 | xRec = trackParam->GetNonBendingCoor(); | |
1132 | yRec = trackParam->GetBendingCoor(); | |
1133 | zRec = trackParam->GetZ(); | |
1134 | points->SetPoint(iPoint,xRec,yRec,zRec); | |
1135 | iPoint++; | |
1136 | } // end loop rec. hits | |
1137 | PrintTrack(iRecTracks,recTrack); | |
1138 | } // end loop tracks | |
1139 | ||
1140 | ||
1141 | } | |
1142 | ||
1143 | void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack) | |
1144 | { | |
1145 | AliMUONTrackParam *trackParam; | |
1146 | Float_t vertex[3], momentum[3]; | |
1147 | Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof; | |
1148 | Int_t charge; | |
1149 | ||
1150 | trackParam = recTrack->GetTrackParamAtVertex(); | |
1151 | vertex[0] = trackParam->GetNonBendingCoor(); | |
1152 | vertex[1] = trackParam->GetBendingCoor(); | |
1153 | vertex[2] = trackParam->GetZ(); | |
1154 | pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum()); | |
1155 | bendingSlope = trackParam->GetBendingSlope(); | |
1156 | nonBendingSlope = trackParam->GetNonBendingSlope(); | |
1157 | momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope); | |
1158 | momentum[0] = momentum[2] * nonBendingSlope; | |
1159 | momentum[1] = momentum[2] * bendingSlope; | |
1160 | charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum())); | |
1161 | chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.); | |
1162 | ||
1163 | printf("===================================================\n"); | |
1164 | printf(" Reconstructed track # %d \n",iRecTracks); | |
1165 | printf(" charge: %d \n",charge); | |
1166 | printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]); | |
1167 | printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]); | |
1168 | printf(" track chi2/dof: %f \n",chi2dof); | |
1169 | ||
1170 | } | |
1171 | ||
a9e2aefa | 1172 | //___________________________________________ |
a9e2aefa | 1173 | void AliMUONDisplay::LoadHits(Int_t chamber) |
1174 | { | |
307d9d04 | 1175 | // Read hits info and store x,y,z info in arrays fPhits |
1176 | // Loop on all detectors | |
a9e2aefa | 1177 | |
1178 | if (chamber > 14) return; | |
1179 | Int_t track; | |
1180 | ||
1181 | fChamber=chamber; | |
1182 | ||
1183 | ResetPhits(); | |
1184 | ||
1185 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
1186 | AliMUONChamber* iChamber; | |
1187 | ||
1188 | iChamber = &(pMUON->Chamber(chamber-1)); | |
1189 | Float_t zpos=iChamber->Z(); | |
1190 | ||
c856e086 | 1191 | |
1192 | if (GetMUONData()->TreeH()) { | |
1193 | GetMUONData()->SetTreeAddress("H"); | |
1194 | Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron | |
1195 | Int_t nthits = 0; | |
1196 | for (track = 0; track < ntracks; track++) { | |
d226f81b | 1197 | GetMUONData()->ResetHits(); |
1198 | GetMUONData()->GetTrack(track);//skowron | |
1199 | TClonesArray *muonHits = GetMUONData()->Hits(); | |
a9e2aefa | 1200 | if (muonHits == 0) return; |
1201 | nthits += muonHits->GetEntriesFast(); | |
c856e086 | 1202 | } |
1203 | if (fPhits == 0) fPhits = new TObjArray(nthits); | |
1204 | Int_t nhold=0; | |
1205 | for (track=0; track<ntracks;track++) { | |
d226f81b | 1206 | GetMUONData()->ResetHits(); |
1207 | GetMUONData()->GetTrack(track);//skowron | |
1208 | TClonesArray *muonHits = GetMUONData()->Hits(); | |
a9e2aefa | 1209 | if (muonHits == 0) return; |
1210 | Int_t nhits = muonHits->GetEntriesFast(); | |
1211 | if (nhits == 0) continue; | |
1212 | AliMUONHit *mHit; | |
1213 | AliMUONPoints *points = 0; | |
1214 | Int_t npoints=1; | |
1215 | for (Int_t hit=0;hit<nhits;hit++) { | |
c856e086 | 1216 | mHit = (AliMUONHit*)muonHits->UncheckedAt(hit); |
1217 | Int_t nch = mHit->Chamber(); // chamber number | |
1218 | if (nch != chamber) continue; | |
1219 | // | |
1220 | // Retrieve info and set the objects | |
1221 | // | |
1222 | points = new AliMUONPoints(npoints); | |
1223 | fPhits->AddAt(points,nhold+hit); | |
1224 | points->SetMarkerColor(kRed); | |
1225 | points->SetMarkerStyle(5); | |
1226 | points->SetMarkerSize(1.); | |
1227 | points->SetParticle(mHit->Track()); | |
1228 | points->SetHitIndex(hit); | |
1229 | points->SetTrackIndex(track); | |
1230 | points->SetDigitIndex(-1); | |
1231 | points->SetPoint(0,mHit->X(),mHit->Y(),zpos); | |
1232 | // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z()); | |
a9e2aefa | 1233 | } |
1234 | nhold+=nhits; | |
c856e086 | 1235 | } |
a9e2aefa | 1236 | } |
1237 | } | |
1238 | ||
1239 | //_____________________________________________________________________________ | |
1240 | void AliMUONDisplay::Paint(Option_t *) | |
1241 | { | |
1242 | // Paint miscellaneous items | |
1243 | } | |
1244 | ||
1245 | //_____________________________________________________________________________ | |
1246 | void AliMUONDisplay::SetPickMode() | |
1247 | { | |
1248 | // Set parameters for pick mode. | |
1249 | // | |
1250 | fZoomMode = 0; | |
1251 | ||
1252 | fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC()); | |
1253 | fTrigPad->Modified(); | |
1254 | } | |
1255 | ||
1256 | //_____________________________________________________________________________ | |
1257 | void AliMUONDisplay::SetZoomMode() | |
1258 | { | |
1259 | // Set parameters for zoom mode | |
1260 | fZoomMode = 1; | |
1261 | ||
1262 | fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC()); | |
1263 | fTrigPad->Modified(); | |
1264 | } | |
1265 | ||
1266 | //_____________________________________________________________________________ | |
1267 | void AliMUONDisplay::NextChamber(Int_t delta) | |
1268 | { | |
1269 | // to go from chamber to next chamber if delta = 1 | |
1270 | // or previous chamber otherwise | |
1271 | if (delta == 1) { | |
f665c1ea | 1272 | if (fChamber < AliMUONConstants::NCh()) fChamber++; |
a9e2aefa | 1273 | } else { |
1274 | if (fChamber > 1) fChamber--; | |
1275 | } | |
1276 | if (!fPad) return; | |
1277 | fPad->Clear(); | |
1278 | LoadDigits(fChamber, fCathode); | |
572d5bb2 | 1279 | DrawChamber(); |
a9e2aefa | 1280 | } |
1281 | ||
1282 | //_____________________________________________________________________________ | |
1283 | void AliMUONDisplay::NextCathode() | |
1284 | { | |
1285 | // to switch to other cathode plane | |
1286 | if (!fPad) return; | |
1287 | fPad->Clear(); | |
1288 | if (fCathode == 1) { | |
1289 | LoadDigits(fChamber, 2); | |
1290 | } else { | |
1291 | LoadDigits(fChamber, 1); | |
1292 | } | |
1293 | fNextCathode = kTRUE; // to keep the same zoom | |
572d5bb2 | 1294 | DrawChamber(); |
a9e2aefa | 1295 | fNextCathode = kFALSE; |
1296 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
1297 | pad->Range(fZoomX0[fZooms], fZoomY0[fZooms], | |
1298 | fZoomX1[fZooms], fZoomY1[fZooms]); | |
1299 | pad->Modified(); | |
1300 | fPad->cd(); | |
1301 | DrawTitle(); | |
1302 | } | |
1303 | ||
1304 | //_____________________________________________________________________________ | |
1305 | void AliMUONDisplay::Trigger() | |
1306 | { | |
52c9bc11 | 1307 | |
d226f81b | 1308 | AliMUONGlobalTrigger* globalTrig; |
1309 | ||
1310 | GetMUONData()->SetTreeAddress("GLT"); | |
95e68a13 | 1311 | GetMUONData()->GetTriggerD(); |
d226f81b | 1312 | |
1313 | globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0); | |
1314 | if (globalTrig == 0) return; | |
1315 | ||
1316 | printf("===================================================\n"); | |
1317 | printf(" Global Trigger output Low pt High pt All\n"); | |
1318 | ||
1319 | printf(" number of Single Plus :\t"); | |
1320 | printf("%i\t",globalTrig->SinglePlusLpt()); | |
1321 | printf("%i\t",globalTrig->SinglePlusHpt()); | |
1322 | printf("%i\t",globalTrig->SinglePlusApt()); | |
1323 | printf("\n"); | |
1324 | ||
1325 | printf(" number of Single Minus :\t"); | |
1326 | printf("%i\t",globalTrig->SingleMinusLpt()); | |
1327 | printf("%i\t",globalTrig->SingleMinusHpt()); | |
1328 | printf("%i\t",globalTrig->SingleMinusApt()); | |
1329 | printf("\n"); | |
1330 | ||
1331 | printf(" number of Single Undefined :\t"); | |
1332 | printf("%i\t",globalTrig->SingleUndefLpt()); | |
1333 | printf("%i\t",globalTrig->SingleUndefHpt()); | |
1334 | printf("%i\t",globalTrig->SingleUndefApt()); | |
1335 | printf("\n"); | |
1336 | ||
1337 | printf(" number of UnlikeSign pair :\t"); | |
1338 | printf("%i\t",globalTrig->PairUnlikeLpt()); | |
1339 | printf("%i\t",globalTrig->PairUnlikeHpt()); | |
1340 | printf("%i\t",globalTrig->PairUnlikeApt()); | |
1341 | printf("\n"); | |
1342 | ||
1343 | printf(" number of LikeSign pair :\t"); | |
1344 | printf("%i\t",globalTrig->PairLikeLpt()); | |
1345 | printf("%i\t",globalTrig->PairLikeHpt()); | |
1346 | printf("%i\t",globalTrig->PairLikeApt()); | |
1347 | printf("\n"); | |
1348 | printf("===================================================\n"); | |
1349 | printf("\n"); | |
1350 | ||
1351 | ||
1352 | // // returns Trigger Decision for current event | |
1353 | // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1); | |
1354 | ||
1355 | // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1); | |
1356 | // AliMUONData* muonData = decision->GetMUONData(); | |
1357 | // muonData->SetTreeAddress("D"); | |
1358 | // decision->Trigger(); | |
a9e2aefa | 1359 | } |
a9e2aefa | 1360 | //_____________________________________________________________________________ |
1361 | void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode) | |
1362 | { | |
1363 | // Set chamber and cathode number | |
1364 | fChamber = chamber; | |
1365 | fCathode = cathode; | |
1366 | ||
1367 | if (!fPad) return; | |
1368 | fPad->Clear(); | |
1369 | LoadDigits(chamber,cathode); | |
572d5bb2 | 1370 | DrawChamber(); |
a9e2aefa | 1371 | } |
1372 | ||
1373 | void AliMUONDisplay::SetEvent(Int_t newevent) | |
1374 | { | |
1375 | // Chose event | |
1376 | gAlice->GetEvent(newevent); | |
1377 | fEvent=newevent; | |
1378 | if (!gAlice->TreeD()) return; | |
1379 | if (!fPad) return; | |
1380 | fPad->Clear(); | |
1381 | LoadDigits(fChamber,fCathode); | |
1382 | Draw(); | |
1383 | } | |
1384 | ||
1385 | //_____________________________________________________________________________ | |
1386 | void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange) | |
1387 | { | |
1388 | // Set view range along R and Z | |
1389 | fRrange = rrange; | |
1390 | fZrange = zrange; | |
1391 | ||
1392 | if (!fPad) return; | |
1393 | fPad->Clear(); | |
1394 | Draw(); | |
1395 | } | |
1396 | ||
1397 | //_____________________________________________________________________________ | |
1398 | void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi) | |
1399 | { | |
1400 | // change viewing angles for current event | |
1401 | ||
1402 | fPad->cd(); | |
1403 | fPhi = phi; | |
1404 | fTheta = theta; | |
1405 | fPsi = psi; | |
1406 | Int_t iret = 0; | |
1407 | ||
1408 | TView *view = gPad->GetView(); | |
1409 | if (view) view->SetView(fPhi, fTheta, fPsi, iret); | |
1410 | else Draw(); | |
1411 | gPad->Modified(); | |
1412 | } | |
1413 | ||
1414 | //_____________________________________________________________________________ | |
1415 | void AliMUONDisplay::ShowNextEvent(Int_t delta) | |
1416 | { | |
30178c30 | 1417 | AliRunLoader * runLoader; |
307d9d04 | 1418 | if (fLoader) |
30178c30 | 1419 | runLoader = fLoader->GetRunLoader(); |
307d9d04 | 1420 | else |
30178c30 | 1421 | runLoader = 0x0; |
1391e633 | 1422 | |
a9e2aefa | 1423 | // Display (current event_number + delta) |
1424 | // delta = 1 shown next event | |
1425 | // delta = -1 show previous event | |
1426 | if (delta) { | |
30178c30 | 1427 | //runLoader->CleanDetectors(); |
1428 | //runLoader->CleanKinematics(); | |
1429 | Int_t currentEvent = runLoader->GetEventNumber(); | |
1391e633 | 1430 | Int_t newEvent = currentEvent + delta; |
30178c30 | 1431 | runLoader->GetEvent(newEvent); |
1391e633 | 1432 | fEvent=newEvent; |
a9e2aefa | 1433 | } |
a9e2aefa | 1434 | LoadDigits(fChamber, fCathode); |
1435 | fPad->cd(); | |
1436 | Draw(); | |
1437 | } | |
1438 | ||
1439 | //______________________________________________________________________________ | |
1440 | void AliMUONDisplay::UnZoom() | |
1441 | { | |
1442 | // Unzoom | |
1443 | if (fZooms <= 0) return; | |
1444 | fZooms--; | |
1445 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
1446 | pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]); | |
1447 | pad->Modified(); | |
1448 | } | |
1449 | ||
1450 | //_____________________________________________________________________________ | |
1451 | void AliMUONDisplay::ResetPoints() | |
1452 | { | |
1453 | // | |
1454 | // Reset array of points | |
1455 | // | |
1456 | if (fPoints) { | |
1457 | fPoints->Delete(); | |
1458 | delete fPoints; | |
1459 | fPoints = 0; | |
1460 | } | |
1461 | } | |
1462 | //_____________________________________________________________________________ | |
1463 | void AliMUONDisplay::ResetPhits() | |
1464 | { | |
1465 | // | |
1466 | // Reset array of points | |
1467 | // | |
1468 | if (fPhits) { | |
1469 | fPhits->Delete(); | |
1470 | delete fPhits; | |
1471 | fPhits = 0; | |
1472 | } | |
1473 | } | |
1474 | //_____________________________________________________________________________ | |
1475 | void AliMUONDisplay::ResetRpoints() | |
1476 | { | |
1477 | // | |
1478 | // Reset array of points | |
1479 | // | |
d226f81b | 1480 | if (fRpoints) { |
1481 | fRpoints->Clear(); | |
1482 | // delete fRpoints; | |
1483 | fRpoints = 0; | |
a9e2aefa | 1484 | } |
1485 | } | |
a9e2aefa | 1486 | |
30178c30 | 1487 | AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs) |
a9e2aefa | 1488 | { |
30178c30 | 1489 | // Protected assignement operator |
1490 | ||
1491 | if (this == &rhs) return *this; | |
1492 | ||
8c343c7c | 1493 | AliFatal("Not implemented."); |
30178c30 | 1494 | |
1495 | return *this; | |
a9e2aefa | 1496 | } |
1497 | ||
1498 | ||
1499 | ||
1500 | ||
1501 | ||
1502 | ||
1503 | ||
1504 | ||
1505 |