]>
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 | |
a30a000f | 57 | #include "AliSegmentation.h" |
a9e2aefa | 58 | #include "AliMUONResponse.h" |
59 | #include "AliMUONChamber.h" | |
f665c1ea | 60 | #include "AliMUONConstants.h" |
5d12ce38 | 61 | #include "AliMC.h" |
8c343c7c | 62 | #include "AliLog.h" |
a9e2aefa | 63 | // to manage the same zoom on both cathodes |
64 | ||
65 | ||
66 | ||
67 | ClassImp(AliMUONDisplay) | |
68 | ||
69 | ||
70 | //_____________________________________________________________________________ | |
71 | AliMUONDisplay::AliMUONDisplay() | |
30178c30 | 72 | : AliDisplay() |
a9e2aefa | 73 | { |
74 | // Constructor | |
d226f81b | 75 | fPoints = 0; |
76 | fPhits = 0; | |
77 | fRpoints = 0; | |
78 | fCanvas = 0; | |
a9e2aefa | 79 | fNextCathode = kFALSE; |
d226f81b | 80 | fColPad = 0; |
a9e2aefa | 81 | } |
82 | ||
83 | //_____________________________________________________________________________ | |
307d9d04 | 84 | AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader) |
30178c30 | 85 | : AliDisplay() |
a9e2aefa | 86 | { |
87 | // Create an event display object. | |
88 | // A canvas named "edisplay" is created with a vertical size in pixels | |
89 | // | |
90 | // A QUICK Overview of the Event Display functions | |
91 | // =============================================== | |
92 | // | |
93 | // The event display can ve invoked by executing the macro "display.C" | |
94 | // A canvas like in the picture below will appear. | |
95 | // | |
96 | // On the left side of the canvas, the following buttons appear: | |
97 | // *Next* to move to the next event | |
98 | // *Previous* to move to the previous event | |
99 | ||
100 | // *Pick* Select this option to be able to point on a track with the | |
101 | // mouse. Once on the track, use the right button to select | |
102 | // an action. For example, select SetMarkerAttributes to | |
103 | // change the marker type/color/size for the track. | |
104 | // *Zoom* Select this option (default) if you want to zoom. | |
105 | // To zoom, simply select the selected area with the left button. | |
106 | // *UnZoom* To revert to the previous picture size. | |
107 | // | |
108 | // slider R On the left side, the vertical slider can be used to | |
109 | // set the default picture size. | |
110 | // | |
111 | // When you are in Zoom mode, you can click on the black part of the canvas | |
112 | // to select special options with the right mouse button. | |
113 | ||
114 | // | |
115 | // When you are in pick mode, you can "Inspect" the object pointed by the mouse. | |
116 | // When you are on a track, select the menu item "InspectParticle" | |
117 | // to display the current particle attributes. | |
118 | // | |
119 | // You can activate the Root browser by selecting the Inspect menu | |
120 | // in the canvas tool bar menu. Then select "Start Browser" | |
121 | // This will open a new canvas with the browser. At this point, you may want | |
122 | // to display some histograms (from the Trees). Go to the "File" menu | |
123 | // of the browser and click on "New canvas". | |
124 | // In the browser, click on item "ROOT files" in the left pane. | |
125 | // Click on galice.root. | |
126 | // Click on TH | |
127 | // Click on TPC for example | |
128 | // Click on any variable (eg TPC.fX) to histogram the variable. | |
129 | // | |
130 | // If you are lost, you can click on HELP in any Root canvas or browser. | |
131 | //Begin_Html | |
132 | /* | |
133 | <img src="gif/AliMUONDisplay.gif"> | |
134 | */ | |
135 | //End_Html | |
136 | ||
137 | ||
138 | fPad = 0; | |
139 | ||
140 | gAlice->SetDisplay(this); | |
141 | ||
142 | // Initialize display default parameters | |
143 | SetRange(200,2000); | |
144 | // Set front view by default | |
145 | fTheta = 0; | |
146 | fPhi = -90; | |
147 | fPsi = 0; | |
148 | fChamber = 1; | |
149 | fCathode = 1; | |
150 | // fRzone = 1.e10; | |
151 | fDrawClusters = kTRUE; | |
152 | fDrawCoG = kTRUE; | |
572d5bb2 | 153 | fDrawTracks = kFALSE; |
a9e2aefa | 154 | fZoomMode = 1; |
155 | fZooms = 0; | |
156 | fClustersCuts = 0; | |
d226f81b | 157 | fPoints = 0; |
158 | fPhits = 0; | |
159 | fRpoints = 0; | |
a9e2aefa | 160 | // Create colors |
161 | CreateColors(); | |
162 | // Create display canvas | |
163 | Int_t ysize = size; | |
164 | if (ysize < 100) ysize = 750; | |
165 | Int_t xsize = Int_t(size*830./ysize); | |
572d5bb2 | 166 | fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize); |
a9e2aefa | 167 | fCanvas->ToggleEventStatus(); |
168 | ||
169 | // Create main display pad | |
170 | fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1); | |
171 | fPad->Draw(); | |
172 | fPad->Modified(); | |
173 | fPad->SetFillColor(30); | |
174 | fPad->SetBorderSize(2); | |
175 | ||
176 | fCanvas->cd(); | |
177 | ||
178 | // Create colors pad | |
179 | fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1); | |
180 | fColPad->Draw(); | |
181 | fColPad->SetFillColor(17); | |
182 | fColPad->SetBorderSize(2); | |
183 | fColPad->cd(); | |
184 | DisplayColorScale(); | |
185 | ||
186 | fCanvas->cd(); | |
187 | // Create user interface control pad | |
188 | DisplayButtons(); | |
189 | fCanvas->cd(); | |
190 | ||
191 | // Create Range and mode pad | |
192 | Float_t dxtr = 0.15; | |
193 | Float_t dytr = 0.45; | |
194 | fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr); | |
a9e2aefa | 195 | fTrigPad->Draw(); |
196 | fTrigPad->cd(); | |
197 | fTrigPad->SetFillColor(22); | |
198 | fTrigPad->SetBorderSize(2); | |
199 | fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98); | |
200 | fRangeSlider->SetObject(this); | |
201 | char pickmode[] = "gAlice->Display()->SetPickMode()"; | |
202 | Float_t db = 0.09; | |
203 | fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db); | |
204 | fPickButton->SetFillColor(38); | |
205 | fPickButton->Draw(); | |
206 | char zoommode[] = "gAlice->Display()->SetZoomMode()"; | |
207 | fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db); | |
208 | fZoomButton->SetFillColor(38); | |
209 | fZoomButton->Draw(); | |
210 | fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db); | |
211 | fArcButton->SetFillColor(kGreen); | |
212 | fArcButton->Draw(); | |
213 | char butUnzoom[] = "gAlice->Display()->UnZoom()"; | |
214 | TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15); | |
215 | button->SetFillColor(38); | |
216 | button->Draw(); | |
217 | AppendPad(); // append display object as last object to force selection | |
218 | ||
219 | fCanvas->cd(); | |
1c4b7942 | 220 | fTrigPad->SetEditable(kFALSE); |
221 | fButtons->SetEditable(kFALSE); | |
a9e2aefa | 222 | fCanvas->Update(); |
223 | fNextCathode = kFALSE; | |
307d9d04 | 224 | fLoader = loader; |
d226f81b | 225 | // initialize container |
226 | if(fLoader) | |
227 | fMUONData = new AliMUONData(fLoader,"MUON","MUON"); | |
228 | else | |
229 | fMUONData =0x0; | |
a9e2aefa | 230 | } |
231 | ||
30178c30 | 232 | AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display) |
233 | : AliDisplay(display) | |
a9e2aefa | 234 | { |
30178c30 | 235 | // Protected copy constructor |
236 | ||
8c343c7c | 237 | AliFatal("Not implemented."); |
a9e2aefa | 238 | } |
239 | ||
240 | ||
241 | ||
242 | //_____________________________________________________________________________ | |
243 | AliMUONDisplay::~AliMUONDisplay() | |
244 | { | |
245 | // Delete space point structure | |
246 | if (fPoints) fPoints->Delete(); | |
247 | delete fPoints; | |
248 | fPoints = 0; | |
249 | // | |
250 | if (fPhits) fPhits->Delete(); | |
251 | delete fPhits; | |
252 | fPhits = 0; | |
253 | // | |
d226f81b | 254 | if (fRpoints) fRpoints->Delete(); |
a9e2aefa | 255 | delete fRpoints; |
d226f81b | 256 | fRpoints = 0; |
a9e2aefa | 257 | } |
258 | ||
259 | //_____________________________________________________________________________ | |
260 | void AliMUONDisplay::Clear(Option_t *) | |
261 | { | |
262 | // Delete graphics temporary objects | |
263 | } | |
264 | ||
265 | //_____________________________________________________________________________ | |
266 | void AliMUONDisplay::DisplayButtons() | |
267 | { | |
268 | // Create the user interface buttons | |
269 | ||
270 | ||
271 | fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1); | |
a9e2aefa | 272 | fButtons->Draw(); |
273 | fButtons->SetFillColor(38); | |
274 | fButtons->SetBorderSize(2); | |
275 | fButtons->cd(); | |
276 | ||
277 | // Int_t butcolor = 33; | |
278 | Float_t dbutton = 0.08; | |
279 | Float_t y = 0.96; | |
280 | Float_t dy = 0.014; | |
281 | Float_t x0 = 0.05; | |
282 | Float_t x1 = 0.95; | |
283 | ||
284 | TButton *button; | |
285 | char but1[] = "gAlice->Display()->ShowNextEvent(1)"; | |
286 | button = new TButton("Event +", but1, x0, y - dbutton, x1, y); | |
287 | button->SetFillColor(38); | |
288 | button->Draw(); | |
289 | ||
290 | y -= dbutton + dy; | |
291 | char but2[] = "gAlice->Display()->ShowNextEvent(-1)"; | |
292 | button = new TButton("Event -", but2, x0, y - dbutton, x1, y); | |
293 | button->SetFillColor(38); | |
294 | button->Draw(); | |
295 | ||
296 | y -= dbutton + dy; | |
297 | char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)"; | |
298 | button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y); | |
299 | button->SetFillColor(38); | |
300 | button->Draw(); | |
301 | ||
302 | y -= dbutton + dy; | |
303 | char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)"; | |
304 | button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y); | |
305 | button->SetFillColor(38); | |
306 | button->Draw(); | |
307 | ||
308 | y -= dbutton + dy; | |
309 | char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)"; | |
310 | button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y); | |
311 | button->SetFillColor(38); | |
312 | button->Draw(); | |
313 | ||
314 | y -= dbutton + dy; | |
315 | char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()"; | |
316 | button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y); | |
317 | button->SetFillColor(38); | |
318 | button->Draw(); | |
319 | ||
320 | y -= dbutton + dy; | |
321 | char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()"; | |
322 | button = new TButton("Trigger", but7, x0, y - dbutton, x1, y); | |
323 | button->SetFillColor(38); | |
324 | button->Draw(); | |
325 | ||
572d5bb2 | 326 | y -= dbutton + dy; |
327 | char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()"; | |
328 | button = new TButton("Tracking", but8, x0, y - dbutton, x1, y); | |
329 | button->SetFillColor(38); | |
330 | button->Draw(); | |
331 | ||
a9e2aefa | 332 | // display logo |
333 | TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22); | |
334 | diamond->SetFillColor(50); | |
335 | diamond->SetTextAlign(22); | |
336 | diamond->SetTextColor(5); | |
337 | diamond->SetTextSize(0.11); | |
338 | diamond->Draw(); | |
339 | diamond->AddText(".. "); | |
340 | diamond->AddText("ROOT"); | |
341 | diamond->AddText("MUON"); | |
342 | diamond->AddText("... "); | |
343 | diamond->AddText(" "); | |
344 | } | |
345 | ||
346 | //_____________________________________________________________________________ | |
30178c30 | 347 | void AliMUONDisplay::CreateColors() const |
a9e2aefa | 348 | { |
349 | // Create the colors palette used to display clusters | |
350 | ||
351 | Int_t k,i; | |
352 | Int_t color; | |
353 | Float_t r,g,b; | |
354 | ||
355 | for (k=1;k<=5;k++) { | |
356 | switch(k) { | |
357 | case 1: | |
358 | for (i=1;i<=5;i++) { | |
359 | r=1.; | |
360 | g=i*0.2; | |
361 | b=0.; | |
362 | color=i; | |
363 | color=260+23-color; | |
364 | new TColor(color,r,g,b); | |
365 | } | |
366 | break; | |
367 | case 2: | |
368 | for (i=1;i<=4;i++) { | |
369 | r=1.1-i*0.2; | |
370 | g=1.; | |
371 | b=0.; | |
372 | color=i+5; | |
373 | color=260+23-color; | |
374 | new TColor(color,r,g,b); | |
375 | } | |
376 | break; | |
377 | case 3: | |
378 | for (i=1;i<=4;i++) { | |
379 | r=0.; | |
380 | g=1.; | |
381 | b=i*0.2+0.2; | |
382 | color=i+9; | |
383 | color=260+23-color; | |
384 | new TColor(color,r,g,b); | |
385 | } | |
386 | break; | |
387 | case 4: | |
388 | for (i=1;i<=4;i++) { | |
389 | r=0.; | |
390 | g=1.1-i*0.2; | |
391 | b=1.; | |
392 | color=i+13; | |
393 | color=260+23-color; | |
394 | new TColor(color,r,g,b); | |
395 | } | |
396 | break; | |
397 | case 5: | |
398 | for (i=1;i<=5;i++) { | |
399 | r=i*0.2; | |
400 | g=0.; | |
401 | b=1.; | |
402 | color=i+17; | |
403 | color=260+23-color; | |
404 | new TColor(color,r,g,b); | |
405 | } | |
406 | break; | |
407 | } | |
408 | } | |
409 | } | |
410 | ||
411 | //_____________________________________________________________________________ | |
412 | void AliMUONDisplay::DisplayColorScale() | |
413 | { | |
414 | // Display pulse height color scale | |
415 | Int_t i; | |
416 | Int_t color; | |
417 | Float_t xlow, ylow, xup, yup, hs; | |
418 | Float_t x1, y1, x2, y2; | |
419 | x1 = y1 = 0; | |
420 | x2 = y2 = 1.0; | |
421 | ||
422 | TText *text = new TText(0,0,""); | |
423 | text->SetTextFont(61); | |
424 | text->SetTextSize(0.2); | |
425 | text->SetTextAlign(22); | |
426 | ||
427 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
428 | AliMUONChamber *iChamber = &(pMUON->Chamber(fChamber-1)); | |
429 | AliMUONResponse * response=iChamber->ResponseModel(); | |
430 | Int_t adcmax=1024; | |
08a636a8 | 431 | if (response) adcmax = (Int_t) response->MaxAdc(); |
a9e2aefa | 432 | |
433 | ||
434 | TBox *box; | |
435 | char label[8]; | |
436 | //*-* draw colortable boxes | |
437 | hs = (y2-y1)/Float_t(22); | |
438 | xlow=x1+.05; | |
439 | xup=x2-0.5; | |
440 | for (i=0;i<22;i++) { | |
441 | ylow = y1 + hs*(Float_t(i)); | |
442 | yup = y1 + hs*(Float_t(i+1)); | |
443 | color = 261+i; | |
444 | Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22); | |
445 | Int_t scale=(Int_t)TMath::Exp(logscale); | |
446 | sprintf(label,"%d",scale); | |
447 | box = new TBox(xlow, ylow, xup, yup); | |
448 | box->Draw(); | |
449 | box->SetFillColor(color); | |
450 | text->DrawText(xlow+0.7, 0.5*(ylow+yup),label); | |
451 | } | |
452 | } | |
453 | ||
454 | //______________________________________________________________________________ | |
455 | Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t) | |
456 | { | |
457 | // Compute distance from point px,py to objects in event | |
458 | ||
459 | gPad->SetCursor(kCross); | |
460 | ||
461 | if (gPad == fTrigPad) return 9999; | |
462 | ||
463 | const Int_t kBig = 9999; | |
464 | Int_t dist = kBig; | |
465 | Float_t xmin = gPad->GetX1(); | |
466 | Float_t xmax = gPad->GetX2(); | |
467 | Float_t dx = 0.02*(xmax - xmin); | |
468 | Float_t x = gPad->AbsPixeltoX(px); | |
469 | if (x < xmin+dx || x > xmax-dx) return dist; | |
470 | ||
471 | if (fZoomMode) return 0; | |
472 | else return 7; | |
473 | } | |
474 | ||
475 | //_____________________________________________________________________________ | |
476 | void AliMUONDisplay::Draw(Option_t *) | |
477 | { | |
478 | // Display current event | |
479 | ||
572d5bb2 | 480 | if (!fDrawTracks) |
481 | DrawChamber(); | |
482 | else | |
483 | DrawReco(); | |
484 | ||
485 | } | |
486 | //_____________________________________________________________________________ | |
487 | void AliMUONDisplay::DrawChamber() | |
488 | { | |
a9e2aefa | 489 | |
572d5bb2 | 490 | fDrawTracks = kFALSE; |
491 | fPad->cd(); | |
492 | DrawView(fTheta, fPhi, fPsi); | |
493 | // Display the event number and title | |
494 | fPad->cd(); | |
495 | DrawTitle(); | |
496 | ||
497 | } | |
498 | //_____________________________________________________________________________ | |
499 | void AliMUONDisplay::DrawReco(Option_t *) | |
500 | { | |
501 | // Display current event | |
502 | ||
503 | fDrawTracks = kTRUE; | |
504 | // print kinematics of generated particles | |
505 | PrintKinematics(); | |
506 | // Draw global view of muon system | |
507 | fPad->cd(); | |
508 | DrawGlobalView(135, -50, -140); | |
509 | ||
a9e2aefa | 510 | // Display the event number and title |
511 | fPad->cd(); | |
512 | DrawTitle(); | |
513 | } | |
514 | ||
572d5bb2 | 515 | //_____________________________________________________________________________ |
516 | void AliMUONDisplay::PrintKinematics() | |
517 | { | |
518 | AliRunLoader * runLoader; | |
519 | TParticle *particle = new TParticle(); | |
520 | Int_t nPart; | |
521 | Float_t vertex[3], momentum[3]; | |
522 | ||
523 | if (fLoader) | |
524 | runLoader = fLoader->GetRunLoader(); | |
525 | else | |
526 | runLoader = 0x0; | |
527 | ||
528 | printf("****** Event # %d ******\n",runLoader->GetEventNumber()); | |
529 | runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle); | |
530 | nPart = (Int_t)runLoader->TreeK()->GetEntries(); | |
531 | for(Int_t iPart = 0; iPart < nPart; iPart++) { | |
532 | runLoader->TreeK()->GetEvent(iPart); | |
533 | vertex[0] = particle->Vx(); | |
534 | vertex[1] = particle->Vy(); | |
535 | vertex[2] = particle->Vz(); | |
536 | momentum[0] = particle->Px(); | |
537 | momentum[1] = particle->Py(); | |
538 | momentum[2] = particle->Pz(); | |
539 | ||
540 | printf("===================================================\n"); | |
541 | printf(" Generated particle # %d \n",iPart); | |
542 | printf(" name: %s \n",particle->GetName()); | |
543 | printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]); | |
544 | printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]); | |
545 | } | |
546 | delete particle; | |
547 | } | |
548 | ||
a9e2aefa | 549 | void AliMUONDisplay::DrawSegmentation() |
550 | { | |
551 | // Draw graphical representation of segmenatation | |
552 | // Attention: still experimental code | |
553 | Int_t icat=1; | |
554 | ||
555 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
a30a000f | 556 | AliMUONChamber* iChamber; |
557 | AliSegmentation* seg; | |
a9e2aefa | 558 | iChamber = &(pMUON->Chamber(fChamber)); |
559 | seg=iChamber->SegmentationModel(icat); | |
560 | Float_t zpos=iChamber->Z(); | |
561 | Float_t r=iChamber->ROuter(); | |
562 | ||
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.; | |
802a864d | 568 | for (seg->FirstPad(0.,y0,0,300,0.); |
a9e2aefa | 569 | seg->MorePads(); |
570 | seg->NextPad()) | |
571 | { | |
572 | if (seg->ISector()==0) continue; | |
802a864d | 573 | Float_t x,y,z; |
a30a000f | 574 | seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z); |
a9e2aefa | 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); | |
588 | ||
802a864d | 589 | for (seg->FirstPad(x0,0,0,0,y0); |
a9e2aefa | 590 | seg->MorePads(); |
591 | seg->NextPad()) | |
592 | { | |
593 | if (seg->ISector()==0) continue; | |
594 | ||
802a864d | 595 | Float_t x,y,z; |
a30a000f | 596 | seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z); |
a9e2aefa | 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 | } | |
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 | |
d226f81b | 753 | printf("\n Draw View\n"); |
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; |
a30a000f | 925 | AliSegmentation* segmentation; |
a9e2aefa | 926 | AliMUONResponse* response; |
307d9d04 | 927 | |
d226f81b | 928 | GetMUONData()->SetTreeAddress("D"); |
a9e2aefa | 929 | |
d226f81b | 930 | TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1); |
a9e2aefa | 931 | if (muonDigits == 0) return; |
932 | ||
d226f81b | 933 | gAlice->ResetDigits(); |
00f56532 | 934 | Int_t nent = 0; |
935 | ||
307d9d04 | 936 | if (GetLoader()->TreeD()) { |
937 | nent = (Int_t) GetLoader()->TreeD()->GetEntries(); | |
49b640e7 | 938 | // gAlice->TreeD()->GetEvent(nent-2+cathode-1); |
d226f81b | 939 | GetMUONData()->GetCathode(cathode-1); |
00f56532 | 940 | } |
941 | ||
a9e2aefa | 942 | Int_t ndigits = muonDigits->GetEntriesFast(); |
943 | if (ndigits == 0) return; | |
944 | if (fPoints == 0) fPoints = new TObjArray(ndigits); | |
945 | ||
946 | iChamber = &(pMUON->Chamber(chamber-1)); | |
947 | ||
948 | segmentation = iChamber->SegmentationModel(cathode); | |
949 | response = iChamber->ResponseModel(); | |
08a636a8 | 950 | Float_t zpos = iChamber->Z(); |
951 | ||
a9e2aefa | 952 | AliMUONDigit *mdig; |
08a636a8 | 953 | AliMUONPoints *points = 0; |
954 | TMarker3DBox *marker = 0; | |
a9e2aefa | 955 | // |
956 | //loop over all digits and store their position | |
957 | ||
08a636a8 | 958 | Int_t npoints = 1; |
959 | Float_t adcmax = 1024; | |
4554f81d | 960 | if (response&&chamber<11) adcmax = response->MaxAdc(); |
a9e2aefa | 961 | |
08a636a8 | 962 | for (Int_t digit = 0; digit < ndigits; digit++) { |
a9e2aefa | 963 | mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit); |
08a636a8 | 964 | if (mdig->Cathode() != cathode-1) continue; |
4554f81d | 965 | |
a9e2aefa | 966 | // |
967 | // First get all needed parameters | |
968 | // | |
08a636a8 | 969 | Int_t charge = mdig->Signal(); |
970 | Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22)); | |
971 | Int_t color = 261+index; | |
972 | Int_t colorTrigger = 2; | |
973 | if (color > 282) color = 282; | |
a9e2aefa | 974 | |
975 | if (chamber > 10) { // trigger chamber | |
4554f81d | 976 | |
08a636a8 | 977 | Int_t sumCharge = 0; |
978 | for (Int_t icharge = 0; icharge < 10; icharge++) { | |
979 | sumCharge = sumCharge+mdig->TrackCharge(icharge); | |
a9e2aefa | 980 | } |
08a636a8 | 981 | Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10; |
982 | if(sumCharge <= 10 || testCharge > 0) { | |
983 | colorTrigger = color; | |
a9e2aefa | 984 | } else { |
08a636a8 | 985 | colorTrigger = 5; |
a9e2aefa | 986 | } |
987 | } | |
988 | ||
989 | // get the center of the pad - add on x and y half of pad size | |
802a864d | 990 | Float_t xpad, ypad, zpad; |
08a636a8 | 991 | segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad); |
992 | ||
993 | Int_t isec = segmentation->Sector(mdig->PadX(), mdig->PadY()); | |
994 | Float_t dpx = segmentation->Dpx(isec)/2; | |
995 | Float_t dpy = segmentation->Dpy(isec)/2; | |
996 | // | |
997 | // segmentation->Dump(); | |
a9e2aefa | 998 | |
a9e2aefa | 999 | // |
1000 | // Then set the objects | |
1001 | // | |
1002 | points = new AliMUONPoints(npoints); | |
1003 | fPoints->AddAt(points,digit); | |
1004 | if (chamber > 10) { | |
1005 | points->SetMarkerColor(colorTrigger); | |
1006 | } else { | |
1007 | points->SetMarkerColor(color); | |
1008 | } | |
1009 | points->SetMarkerStyle(21); | |
1010 | points->SetMarkerSize(0.5); | |
1011 | points->SetParticle(-1); | |
1012 | points->SetHitIndex(-1); | |
1013 | points->SetTrackIndex(-1); | |
1014 | points->SetDigitIndex(digit); | |
4554f81d | 1015 | points->SetPoint(0,xpad,ypad,zpos); |
1016 | ||
08a636a8 | 1017 | Int_t lineColor = (zpad-zpos > 0) ? 2:3; |
1018 | marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0); | |
1019 | ||
1020 | ||
1021 | marker->SetLineColor(lineColor); | |
1022 | marker->SetFillStyle(1001); | |
1023 | marker->SetFillColor(color); | |
1024 | marker->SetRefObject((TObject*)points); | |
1025 | points->Set3DMarker(0, marker); | |
a9e2aefa | 1026 | } |
1027 | } | |
1028 | //___________________________________________ | |
e0875ac1 | 1029 | void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/) |
a9e2aefa | 1030 | { |
d226f81b | 1031 | // Read raw clusters info and store x,y,z info in arrays fRpoints |
1032 | // Loop on all detectors | |
a9e2aefa | 1033 | |
1034 | if (chamber > 10) return; | |
1035 | ||
1036 | ResetRpoints(); | |
1037 | ||
1038 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
1039 | AliMUONChamber* iChamber; | |
1040 | ||
d226f81b | 1041 | GetMUONData()->SetTreeAddress("RC"); |
1042 | TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1); | |
a9e2aefa | 1043 | |
7985603c | 1044 | if (muonRawClusters == 0) return; |
a9e2aefa | 1045 | |
00f56532 | 1046 | Int_t nent = 0; |
d226f81b | 1047 | if (GetMUONData()->TreeR()) { |
1048 | nent=(Int_t) GetMUONData()->TreeR()->GetEntries(); | |
1049 | GetMUONData()->TreeR()->GetEvent(0); | |
00f56532 | 1050 | } |
1051 | ||
a9e2aefa | 1052 | Int_t nrawcl = muonRawClusters->GetEntriesFast(); |
1053 | if (nrawcl == 0) return; | |
d226f81b | 1054 | if (fRpoints == 0) fRpoints = new TObjArray(nrawcl); |
a9e2aefa | 1055 | |
1056 | iChamber = &(pMUON->Chamber(chamber-1)); | |
1057 | Float_t zpos=iChamber->Z(); | |
1058 | AliMUONRawCluster *mRaw; | |
1059 | AliMUONPoints *points = 0; | |
1060 | // | |
1061 | //loop over all raw clusters and store their position | |
1062 | points = new AliMUONPoints(nrawcl); | |
1063 | for (Int_t iraw=0;iraw<nrawcl;iraw++) { | |
1064 | mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw); | |
a9e2aefa | 1065 | points->SetMarkerColor(51); |
1066 | points->SetMarkerStyle(2); | |
1067 | points->SetMarkerSize(1.); | |
1068 | points->SetParticle(-1); | |
1069 | points->SetHitIndex(-1); | |
1070 | points->SetTrackIndex(-1); | |
1071 | points->SetDigitIndex(-1); | |
ba12c242 | 1072 | points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos); |
d226f81b | 1073 | fRpoints->AddAt(points,iraw); |
ba12c242 | 1074 | // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0)); |
a9e2aefa | 1075 | } |
1076 | } | |
572d5bb2 | 1077 | |
1078 | //___________________________________________ | |
1079 | void AliMUONDisplay::LoadTracks() | |
1080 | { | |
1081 | // Load tracks | |
1082 | AliMUONTrack* recTrack = 0; | |
1083 | AliMUONTrackParam* trackParam = 0; | |
1084 | TClonesArray * trackParamAtHit = 0; | |
1085 | ||
1086 | ResetRpoints(); | |
1087 | ||
1088 | GetMUONData()->SetTreeAddress("RT"); | |
1089 | TClonesArray* recTracksArray = GetMUONData()->RecTracks(); | |
1090 | if (recTracksArray == NULL) return; | |
1091 | GetMUONData()->GetRecTracks(); | |
1092 | ||
1093 | Int_t nRecTracks = 0; | |
1094 | if (recTracksArray) | |
1095 | nRecTracks = (Int_t) recTracksArray->GetEntriesFast(); | |
1096 | ||
1097 | ||
1098 | if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks); | |
1099 | ||
1100 | for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) { | |
1101 | // reading info from tracks | |
1102 | recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks); | |
1103 | ||
1104 | Int_t nTrackHits = recTrack->GetNTrackHits(); | |
1105 | ||
1106 | if (nTrackHits == 0) continue; | |
1107 | ||
1108 | Int_t iPoint = 0; | |
1109 | TPolyLine3D *points = new TPolyLine3D(nTrackHits+1); | |
1110 | points->SetLineColor(6); | |
1111 | points->SetLineWidth(1); | |
1112 | fRpoints->AddAt(points,iRecTracks); | |
1113 | ||
1114 | Float_t xRec=0; | |
1115 | Float_t yRec=0; | |
1116 | Float_t zRec=0; | |
1117 | ||
1118 | trackParam = recTrack->GetTrackParamAtVertex(); | |
1119 | xRec = trackParam->GetNonBendingCoor(); | |
1120 | yRec = trackParam->GetBendingCoor(); | |
1121 | zRec = trackParam->GetZ(); | |
1122 | points->SetPoint(iPoint,xRec,yRec,zRec); | |
1123 | iPoint++; | |
1124 | ||
1125 | for (Int_t iHit = 0; iHit < nTrackHits; iHit++){ | |
1126 | trackParamAtHit = recTrack->GetTrackParamAtHit(); | |
1127 | trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit); | |
1128 | xRec = trackParam->GetNonBendingCoor(); | |
1129 | yRec = trackParam->GetBendingCoor(); | |
1130 | zRec = trackParam->GetZ(); | |
1131 | points->SetPoint(iPoint,xRec,yRec,zRec); | |
1132 | iPoint++; | |
1133 | } // end loop rec. hits | |
1134 | PrintTrack(iRecTracks,recTrack); | |
1135 | } // end loop tracks | |
1136 | ||
1137 | ||
1138 | } | |
1139 | ||
1140 | void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack) | |
1141 | { | |
1142 | AliMUONTrackParam *trackParam; | |
1143 | Float_t vertex[3], momentum[3]; | |
1144 | Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof; | |
1145 | Int_t charge; | |
1146 | ||
1147 | trackParam = recTrack->GetTrackParamAtVertex(); | |
1148 | vertex[0] = trackParam->GetNonBendingCoor(); | |
1149 | vertex[1] = trackParam->GetBendingCoor(); | |
1150 | vertex[2] = trackParam->GetZ(); | |
1151 | pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum()); | |
1152 | bendingSlope = trackParam->GetBendingSlope(); | |
1153 | nonBendingSlope = trackParam->GetNonBendingSlope(); | |
1154 | momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope); | |
1155 | momentum[0] = momentum[2] * nonBendingSlope; | |
1156 | momentum[1] = momentum[2] * bendingSlope; | |
1157 | charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum())); | |
1158 | chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.); | |
1159 | ||
1160 | printf("===================================================\n"); | |
1161 | printf(" Reconstructed track # %d \n",iRecTracks); | |
1162 | printf(" charge: %d \n",charge); | |
1163 | printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]); | |
1164 | printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]); | |
1165 | printf(" track chi2/dof: %f \n",chi2dof); | |
1166 | ||
1167 | } | |
1168 | ||
a9e2aefa | 1169 | //___________________________________________ |
a9e2aefa | 1170 | void AliMUONDisplay::LoadHits(Int_t chamber) |
1171 | { | |
307d9d04 | 1172 | // Read hits info and store x,y,z info in arrays fPhits |
1173 | // Loop on all detectors | |
a9e2aefa | 1174 | |
1175 | if (chamber > 14) return; | |
1176 | Int_t track; | |
1177 | ||
1178 | fChamber=chamber; | |
1179 | ||
1180 | ResetPhits(); | |
1181 | ||
1182 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
1183 | AliMUONChamber* iChamber; | |
1184 | ||
1185 | iChamber = &(pMUON->Chamber(chamber-1)); | |
1186 | Float_t zpos=iChamber->Z(); | |
1187 | ||
c856e086 | 1188 | |
1189 | if (GetMUONData()->TreeH()) { | |
1190 | GetMUONData()->SetTreeAddress("H"); | |
1191 | Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron | |
1192 | Int_t nthits = 0; | |
1193 | for (track = 0; track < ntracks; track++) { | |
d226f81b | 1194 | GetMUONData()->ResetHits(); |
1195 | GetMUONData()->GetTrack(track);//skowron | |
1196 | TClonesArray *muonHits = GetMUONData()->Hits(); | |
a9e2aefa | 1197 | if (muonHits == 0) return; |
1198 | nthits += muonHits->GetEntriesFast(); | |
c856e086 | 1199 | } |
1200 | if (fPhits == 0) fPhits = new TObjArray(nthits); | |
1201 | Int_t nhold=0; | |
1202 | for (track=0; track<ntracks;track++) { | |
d226f81b | 1203 | GetMUONData()->ResetHits(); |
1204 | GetMUONData()->GetTrack(track);//skowron | |
1205 | TClonesArray *muonHits = GetMUONData()->Hits(); | |
a9e2aefa | 1206 | if (muonHits == 0) return; |
1207 | Int_t nhits = muonHits->GetEntriesFast(); | |
1208 | if (nhits == 0) continue; | |
1209 | AliMUONHit *mHit; | |
1210 | AliMUONPoints *points = 0; | |
1211 | Int_t npoints=1; | |
1212 | for (Int_t hit=0;hit<nhits;hit++) { | |
c856e086 | 1213 | mHit = (AliMUONHit*)muonHits->UncheckedAt(hit); |
1214 | Int_t nch = mHit->Chamber(); // chamber number | |
1215 | if (nch != chamber) continue; | |
1216 | // | |
1217 | // Retrieve info and set the objects | |
1218 | // | |
1219 | points = new AliMUONPoints(npoints); | |
1220 | fPhits->AddAt(points,nhold+hit); | |
1221 | points->SetMarkerColor(kRed); | |
1222 | points->SetMarkerStyle(5); | |
1223 | points->SetMarkerSize(1.); | |
1224 | points->SetParticle(mHit->Track()); | |
1225 | points->SetHitIndex(hit); | |
1226 | points->SetTrackIndex(track); | |
1227 | points->SetDigitIndex(-1); | |
1228 | points->SetPoint(0,mHit->X(),mHit->Y(),zpos); | |
1229 | // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z()); | |
a9e2aefa | 1230 | } |
1231 | nhold+=nhits; | |
c856e086 | 1232 | } |
a9e2aefa | 1233 | } |
1234 | } | |
1235 | ||
1236 | //_____________________________________________________________________________ | |
1237 | void AliMUONDisplay::Paint(Option_t *) | |
1238 | { | |
1239 | // Paint miscellaneous items | |
1240 | } | |
1241 | ||
1242 | //_____________________________________________________________________________ | |
1243 | void AliMUONDisplay::SetPickMode() | |
1244 | { | |
1245 | // Set parameters for pick mode. | |
1246 | // | |
1247 | fZoomMode = 0; | |
1248 | ||
1249 | fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC()); | |
1250 | fTrigPad->Modified(); | |
1251 | } | |
1252 | ||
1253 | //_____________________________________________________________________________ | |
1254 | void AliMUONDisplay::SetZoomMode() | |
1255 | { | |
1256 | // Set parameters for zoom mode | |
1257 | fZoomMode = 1; | |
1258 | ||
1259 | fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC()); | |
1260 | fTrigPad->Modified(); | |
1261 | } | |
1262 | ||
1263 | //_____________________________________________________________________________ | |
1264 | void AliMUONDisplay::NextChamber(Int_t delta) | |
1265 | { | |
1266 | // to go from chamber to next chamber if delta = 1 | |
1267 | // or previous chamber otherwise | |
1268 | if (delta == 1) { | |
f665c1ea | 1269 | if (fChamber < AliMUONConstants::NCh()) fChamber++; |
a9e2aefa | 1270 | } else { |
1271 | if (fChamber > 1) fChamber--; | |
1272 | } | |
1273 | if (!fPad) return; | |
1274 | fPad->Clear(); | |
1275 | LoadDigits(fChamber, fCathode); | |
572d5bb2 | 1276 | DrawChamber(); |
a9e2aefa | 1277 | } |
1278 | ||
1279 | //_____________________________________________________________________________ | |
1280 | void AliMUONDisplay::NextCathode() | |
1281 | { | |
1282 | // to switch to other cathode plane | |
1283 | if (!fPad) return; | |
1284 | fPad->Clear(); | |
1285 | if (fCathode == 1) { | |
1286 | LoadDigits(fChamber, 2); | |
1287 | } else { | |
1288 | LoadDigits(fChamber, 1); | |
1289 | } | |
1290 | fNextCathode = kTRUE; // to keep the same zoom | |
572d5bb2 | 1291 | DrawChamber(); |
a9e2aefa | 1292 | fNextCathode = kFALSE; |
1293 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
1294 | pad->Range(fZoomX0[fZooms], fZoomY0[fZooms], | |
1295 | fZoomX1[fZooms], fZoomY1[fZooms]); | |
1296 | pad->Modified(); | |
1297 | fPad->cd(); | |
1298 | DrawTitle(); | |
1299 | } | |
1300 | ||
1301 | //_____________________________________________________________________________ | |
1302 | void AliMUONDisplay::Trigger() | |
1303 | { | |
52c9bc11 | 1304 | |
d226f81b | 1305 | AliMUONGlobalTrigger* globalTrig; |
1306 | ||
1307 | GetMUONData()->SetTreeAddress("GLT"); | |
95e68a13 | 1308 | GetMUONData()->GetTriggerD(); |
d226f81b | 1309 | |
1310 | globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0); | |
1311 | if (globalTrig == 0) return; | |
1312 | ||
1313 | printf("===================================================\n"); | |
1314 | printf(" Global Trigger output Low pt High pt All\n"); | |
1315 | ||
1316 | printf(" number of Single Plus :\t"); | |
1317 | printf("%i\t",globalTrig->SinglePlusLpt()); | |
1318 | printf("%i\t",globalTrig->SinglePlusHpt()); | |
1319 | printf("%i\t",globalTrig->SinglePlusApt()); | |
1320 | printf("\n"); | |
1321 | ||
1322 | printf(" number of Single Minus :\t"); | |
1323 | printf("%i\t",globalTrig->SingleMinusLpt()); | |
1324 | printf("%i\t",globalTrig->SingleMinusHpt()); | |
1325 | printf("%i\t",globalTrig->SingleMinusApt()); | |
1326 | printf("\n"); | |
1327 | ||
1328 | printf(" number of Single Undefined :\t"); | |
1329 | printf("%i\t",globalTrig->SingleUndefLpt()); | |
1330 | printf("%i\t",globalTrig->SingleUndefHpt()); | |
1331 | printf("%i\t",globalTrig->SingleUndefApt()); | |
1332 | printf("\n"); | |
1333 | ||
1334 | printf(" number of UnlikeSign pair :\t"); | |
1335 | printf("%i\t",globalTrig->PairUnlikeLpt()); | |
1336 | printf("%i\t",globalTrig->PairUnlikeHpt()); | |
1337 | printf("%i\t",globalTrig->PairUnlikeApt()); | |
1338 | printf("\n"); | |
1339 | ||
1340 | printf(" number of LikeSign pair :\t"); | |
1341 | printf("%i\t",globalTrig->PairLikeLpt()); | |
1342 | printf("%i\t",globalTrig->PairLikeHpt()); | |
1343 | printf("%i\t",globalTrig->PairLikeApt()); | |
1344 | printf("\n"); | |
1345 | printf("===================================================\n"); | |
1346 | printf("\n"); | |
1347 | ||
1348 | ||
1349 | // // returns Trigger Decision for current event | |
1350 | // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1); | |
1351 | ||
1352 | // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1); | |
1353 | // AliMUONData* muonData = decision->GetMUONData(); | |
1354 | // muonData->SetTreeAddress("D"); | |
1355 | // decision->Trigger(); | |
a9e2aefa | 1356 | } |
a9e2aefa | 1357 | //_____________________________________________________________________________ |
1358 | void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode) | |
1359 | { | |
1360 | // Set chamber and cathode number | |
1361 | fChamber = chamber; | |
1362 | fCathode = cathode; | |
1363 | ||
1364 | if (!fPad) return; | |
1365 | fPad->Clear(); | |
1366 | LoadDigits(chamber,cathode); | |
572d5bb2 | 1367 | DrawChamber(); |
a9e2aefa | 1368 | } |
1369 | ||
1370 | void AliMUONDisplay::SetEvent(Int_t newevent) | |
1371 | { | |
1372 | // Chose event | |
1373 | gAlice->GetEvent(newevent); | |
1374 | fEvent=newevent; | |
1375 | if (!gAlice->TreeD()) return; | |
1376 | if (!fPad) return; | |
1377 | fPad->Clear(); | |
1378 | LoadDigits(fChamber,fCathode); | |
1379 | Draw(); | |
1380 | } | |
1381 | ||
1382 | //_____________________________________________________________________________ | |
1383 | void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange) | |
1384 | { | |
1385 | // Set view range along R and Z | |
1386 | fRrange = rrange; | |
1387 | fZrange = zrange; | |
1388 | ||
1389 | if (!fPad) return; | |
1390 | fPad->Clear(); | |
1391 | Draw(); | |
1392 | } | |
1393 | ||
1394 | //_____________________________________________________________________________ | |
1395 | void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi) | |
1396 | { | |
1397 | // change viewing angles for current event | |
1398 | ||
1399 | fPad->cd(); | |
1400 | fPhi = phi; | |
1401 | fTheta = theta; | |
1402 | fPsi = psi; | |
1403 | Int_t iret = 0; | |
1404 | ||
1405 | TView *view = gPad->GetView(); | |
1406 | if (view) view->SetView(fPhi, fTheta, fPsi, iret); | |
1407 | else Draw(); | |
1408 | gPad->Modified(); | |
1409 | } | |
1410 | ||
1411 | //_____________________________________________________________________________ | |
1412 | void AliMUONDisplay::ShowNextEvent(Int_t delta) | |
1413 | { | |
30178c30 | 1414 | AliRunLoader * runLoader; |
307d9d04 | 1415 | if (fLoader) |
30178c30 | 1416 | runLoader = fLoader->GetRunLoader(); |
307d9d04 | 1417 | else |
30178c30 | 1418 | runLoader = 0x0; |
1391e633 | 1419 | |
a9e2aefa | 1420 | // Display (current event_number + delta) |
1421 | // delta = 1 shown next event | |
1422 | // delta = -1 show previous event | |
1423 | if (delta) { | |
30178c30 | 1424 | //runLoader->CleanDetectors(); |
1425 | //runLoader->CleanKinematics(); | |
1426 | Int_t currentEvent = runLoader->GetEventNumber(); | |
1391e633 | 1427 | Int_t newEvent = currentEvent + delta; |
30178c30 | 1428 | runLoader->GetEvent(newEvent); |
1391e633 | 1429 | fEvent=newEvent; |
a9e2aefa | 1430 | } |
a9e2aefa | 1431 | LoadDigits(fChamber, fCathode); |
1432 | fPad->cd(); | |
1433 | Draw(); | |
1434 | } | |
1435 | ||
1436 | //______________________________________________________________________________ | |
1437 | void AliMUONDisplay::UnZoom() | |
1438 | { | |
1439 | // Unzoom | |
1440 | if (fZooms <= 0) return; | |
1441 | fZooms--; | |
1442 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
1443 | pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]); | |
1444 | pad->Modified(); | |
1445 | } | |
1446 | ||
1447 | //_____________________________________________________________________________ | |
1448 | void AliMUONDisplay::ResetPoints() | |
1449 | { | |
1450 | // | |
1451 | // Reset array of points | |
1452 | // | |
1453 | if (fPoints) { | |
1454 | fPoints->Delete(); | |
1455 | delete fPoints; | |
1456 | fPoints = 0; | |
1457 | } | |
1458 | } | |
1459 | //_____________________________________________________________________________ | |
1460 | void AliMUONDisplay::ResetPhits() | |
1461 | { | |
1462 | // | |
1463 | // Reset array of points | |
1464 | // | |
1465 | if (fPhits) { | |
1466 | fPhits->Delete(); | |
1467 | delete fPhits; | |
1468 | fPhits = 0; | |
1469 | } | |
1470 | } | |
1471 | //_____________________________________________________________________________ | |
1472 | void AliMUONDisplay::ResetRpoints() | |
1473 | { | |
1474 | // | |
1475 | // Reset array of points | |
1476 | // | |
d226f81b | 1477 | if (fRpoints) { |
1478 | fRpoints->Clear(); | |
1479 | // delete fRpoints; | |
1480 | fRpoints = 0; | |
a9e2aefa | 1481 | } |
1482 | } | |
a9e2aefa | 1483 | |
30178c30 | 1484 | AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs) |
a9e2aefa | 1485 | { |
30178c30 | 1486 | // Protected assignement operator |
1487 | ||
1488 | if (this == &rhs) return *this; | |
1489 | ||
8c343c7c | 1490 | AliFatal("Not implemented."); |
30178c30 | 1491 | |
1492 | return *this; | |
a9e2aefa | 1493 | } |
1494 | ||
1495 | ||
1496 | ||
1497 | ||
1498 | ||
1499 | ||
1500 | ||
1501 | ||
1502 |