add a better alpha cut to default cut
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveLego.cxx
CommitLineData
3d94b490 1// $Id$
2// Author: Stefano Carrazza 2010
3
4/**************************************************************************
5 * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliESDEvent.h"
11#include "AliEveLego.h"
12#include "AliEveEventManager.h"
13#include "AliEveMultiView.h"
14#include "AliPhysicsSelection.h"
15#include "AliEveEventSelector.h"
16
17#include "TH2F.h"
18#include "TMath.h"
19#include "TGLViewer.h"
20#include "TEveWindow.h"
21#include "TEveManager.h"
22#include "TEveBrowser.h"
23#include "TEveViewer.h"
24#include "TEveScene.h"
25#include "TEveCaloLegoOverlay.h"
26#include "TEveCalo.h"
27#include "TEveCaloData.h"
28#include "TEveLegoEventHandler.h"
29#include "TEveTrans.h"
30#include "TEveProjectionManager.h"
31#include "TEveProjectionAxes.h"
32#include "TGLWidget.h"
33#include "TGLOverlayButton.h"
a096a7bf 34#include "TStopwatch.h"
3d94b490 35
36//______________________________________________________________________________
37// Allow histograms visualization in 2D and 3D.
38//
39
40ClassImp(AliEveLego)
4171aa4e 41Double_t kPi = TMath::Pi();
3d94b490 42
43//______________________________________________________________________________
44AliEveLego::AliEveLego(const char* name) :
45 TEveElementList(name),
46 fChargeId(1),
47 fTracksId(1),
48 fEventsId(1),
49 fMaxPt(10000),
50 fChargeIdAE(0),
51 fTracksIdAE(0),
a096a7bf 52 fMaxPtAE(10000),
3d94b490 53 fEsd(0),
54 fPhysicsSelection(0),
55 fHistopos(0),
4171aa4e 56 fHistoposAllEvents(0),
3d94b490 57 fHistoneg(0),
4171aa4e 58 fHistonegAllEvents(0),
3d94b490 59 fData(0),
4171aa4e 60 fDataAllEvents(0),
3d94b490 61 fLego(0),
4171aa4e 62 fLegoAllEvents(0),
3d94b490 63 fCalo3d(0),
4171aa4e 64 fCalo3dAllEvents(0),
3d94b490 65 fGlv(0),
4171aa4e 66 fHisto2dv(0),
67 fHisto2ds(0),
68 fHisto2ds2(0),
69 fHisto2dAllEventsv0(0),
70 fHisto2dAllEventsv1(0),
71 fHisto2dAllEventsv2(0),
72 fHisto2dAllEventsv3(0),
73 fHisto2dAllEventss0(0),
74 fHisto2dAllEventss1(0),
75 fHisto2dAllEventss2(0),
76 fHisto2dAllEventss3(0),
3d94b490 77 fAl(0),
4171aa4e 78 fHisto2dLegoOverlay(0),
79 fHisto2dAllEventsLegoOverlay(0),
80 fHisto2dAllEventsSlot(0),
3d94b490 81 fEventSelector(0),
82 fShowEventsInfo(0),
83 fGButton(0),
84 fB1(0),
85 fB2(0)
86{
87 // Constructor.
88 gEve->AddToListTree(this,0);
89
90 // Get Current ESD event
91 fEsd = AliEveEventManager::AssertESD();
92
93 fPhysicsSelection = new AliPhysicsSelection();
94 fPhysicsSelection->Initialize(fEsd->GetRunNumber());
95
96 fEventSelector = AliEveEventManager::GetMaster()->GetEventSelector();
97
4171aa4e 98 fHistopos = new TH2F("histopos","Histo 2d positive", 100, -1.5, 1.5, 80, -kPi, kPi);
99 fHistoneg = new TH2F("histoneg","Histo 2d negative", 100, -1.5, 1.5, 80, -kPi, kPi);
a096a7bf 100
101 fHistopos->SetDirectory(0);
102 fHistoneg->SetDirectory(0);
3d94b490 103
104 fData = new TEveCaloDataHist();
105 fData->AddHistogram(fHistoneg);
106 fData->RefSliceInfo(0).Setup("NegCg:", 0, kBlue);
107 fData->AddHistogram(fHistopos);
108 fData->RefSliceInfo(1).Setup("PosCg:", 0, kRed);
109 fData->GetEtaBins()->SetTitleFont(120);
110 fData->GetEtaBins()->SetTitle("h");
111 fData->GetPhiBins()->SetTitleFont(120);
112 fData->GetPhiBins()->SetTitle("f");
113 fData->IncDenyDestroy();
114
115 fCalo3d = new TEveCalo3D(fData);
116 fCalo3d->SetBarrelRadius(550);
117 fCalo3d->SetEndCapPos(550);
118
119 // plotting histo
120 fLego = new TEveCaloLego(fData);
121
122 // projections
123 fAl = AliEveMultiView::Instance();
124 fAl->ImportEventRPhi(fCalo3d);
125 fAl->ImportEventRhoZ(fCalo3d);
126
127 // glbutton
128 fGButton = new TGLOverlayButton(0, "", 10.0, -10.0, 190.0, 20.0);
129 fGButton->SetAlphaValues(1.5,1.5);
130 fB1 = new TGLOverlayButton(0, "", 10.0, -30.0, 190.0, 20.0);
131 fB1->SetAlphaValues(1.5,1.5);
132 fB2 = new TGLOverlayButton(0, "", 10.0, -50.0, 190.0, 20.0);
133 fB2->SetAlphaValues(1.5,1.5);
134
135 // Update
136 Update();
137}
138
139//______________________________________________________________________________
140AliEveLego::~AliEveLego()
141{
4171aa4e 142 // deleting variables
3d94b490 143 delete fEsd;
144 delete fPhysicsSelection;
145 delete fHistopos;
4171aa4e 146 delete fHistoposAllEvents;
3d94b490 147 delete fHistoneg;
4171aa4e 148 delete fHistonegAllEvents;
3d94b490 149
150 delete fData;
4171aa4e 151 delete fDataAllEvents;
3d94b490 152 delete fLego;
4171aa4e 153 delete fLegoAllEvents;
3d94b490 154 delete fCalo3d;
4171aa4e 155 delete fCalo3dAllEvents;
3d94b490 156 delete fGlv;
157
4171aa4e 158 delete fHisto2dv;
159 delete fHisto2ds;
160 delete fHisto2ds2;
161 delete fHisto2dAllEventsv0;
162 delete fHisto2dAllEventsv1;
163 delete fHisto2dAllEventsv2;
164 delete fHisto2dAllEventsv3;
165 delete fHisto2dAllEventss0;
166 delete fHisto2dAllEventss1;
167 delete fHisto2dAllEventss2;
168 delete fHisto2dAllEventss3;
3d94b490 169
170 delete fAl;
4171aa4e 171 delete fHisto2dLegoOverlay;
172 delete fHisto2dAllEventsLegoOverlay;
173 delete fHisto2dAllEventsSlot;
3d94b490 174
175 delete fEventSelector;
176 delete fGButton;
177 delete fB1;
178 delete fB2;
179}
180
4171aa4e 181namespace
3d94b490 182{
4171aa4e 183 //____________________________________________________________________________
184 Double_t getphi(Double_t phi)
185 {
186 // phi correction for alice
187
188 if (phi > TMath::Pi()) {
189 phi -= TMath::TwoPi();
190 }
191 return phi;
192 }
3d94b490 193}
194
195//______________________________________________________________________________
196TEveCaloDataHist* AliEveLego::LoadData()
197{
4171aa4e 198 // Load data from ESD tree
3d94b490 199 fHistopos->Reset();
200 fHistoneg->Reset();
201
202 // Getting current tracks, filling histograms
203 for (int n = 0; n < fEsd->GetNumberOfTracks(); ++n) {
204
205 if (fEsd->GetTrack(n)->GetSign() > 0) {
206 fHistopos->Fill(fEsd->GetTrack(n)->Eta(),
207 getphi(fEsd->GetTrack(n)->Phi()),
208 fabs(fEsd->GetTrack(n)->Pt()));
209 }
210
211 if (fEsd->GetTrack(n)->GetSign() < 0) {
212 fHistoneg->Fill(fEsd->GetTrack(n)->Eta(),
213 getphi(fEsd->GetTrack(n)->Phi()),
214 fabs(fEsd->GetTrack(n)->Pt()));
215 }
216 }
217
3d94b490 218 fData->DataChanged();
219
220 FilterData();
221
222 return fData;
223}
224
225//______________________________________________________________________________
226TEveCaloDataHist* AliEveLego::LoadAllData()
227{
4171aa4e 228 // load data from all events ESD
229 fHistoposAllEvents->Reset();
230 fHistonegAllEvents->Reset();
3d94b490 231
232 TTree* t = AliEveEventManager::GetMaster()->GetESDTree();
233
234 // Getting current tracks for each event, filling histograms
235 for (int event = 0; event < t->GetEntries(); event++) {
236 t->GetEntry(event);
237 for (int n = 0; n < fEsd->GetNumberOfTracks(); ++n) {
238
239 if (fEsd->GetTrack(n)->GetSign() > 0) {
4171aa4e 240 fHistoposAllEvents->Fill(fEsd->GetTrack(n)->Eta(),
3d94b490 241 getphi(fEsd->GetTrack(n)->Phi()),
242 fabs(fEsd->GetTrack(n)->Pt()));
243 } else {
4171aa4e 244 fHistonegAllEvents->Fill(fEsd->GetTrack(n)->Eta(),
3d94b490 245 getphi(fEsd->GetTrack(n)->Phi()),
246 fabs(fEsd->GetTrack(n)->Pt()));
247 }
248 }
249 }
250
4171aa4e 251 fDataAllEvents->DataChanged();
3d94b490 252
4171aa4e 253 return fDataAllEvents;
3d94b490 254}
255
256//______________________________________________________________________________
257TEveCaloDataHist* AliEveLego::FilterData()
258{
259 // Tracks selection
260 if ( fTracksId == 2 )
261 {
262 fHistopos->Reset();
263 fHistoneg->Reset();
264
265 const AliESDVertex *pv = fEsd->GetPrimaryVertex();
266
267 for (Int_t n = 0; n < pv->GetNIndices(); n++ )
268 {
269 AliESDtrack *at = fEsd->GetTrack(pv->GetIndices()[n]);
270 if (at->GetSign() > 0) {
271 fHistopos->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
272 }
273 if (at->GetSign() < 0) {
274 fHistoneg->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
275 }
276 }
277 }
278
279 fData->DataChanged();
280
281 // Max Pt threshold
282 if (GetPtMax() >= fMaxPt){
283 for (Int_t binx = 1; binx <= 100; binx++) {
284 for (Int_t biny = 1; biny <= 80; biny++) {
285 if (fHistopos->GetBinContent(binx, biny) >= fMaxPt)
286 {
287 fHistopos->SetBinContent(binx, biny, fMaxPt);
288 }
289 if (fHistoneg->GetBinContent(binx, biny) >= fMaxPt)
290 {
291 fHistoneg->SetBinContent(binx, biny, fMaxPt);
292 }
293 }
294 }
295 }
296
297 // Positive only
298 if ( fChargeId == 2 ) fHistoneg->Reset();
299
300 // Negative only
301 if ( fChargeId == 3 ) fHistopos->Reset();
302
303 fData->DataChanged();
304
305 return fData;
306}
307
308
309//______________________________________________________________________________
310TEveCaloDataHist* AliEveLego::FilterAllData()
311{
312 // Tracks selection
313 if ( fTracksIdAE == 2 )
314 {
4171aa4e 315 fHistoposAllEvents->Reset();
316 fHistonegAllEvents->Reset();
3d94b490 317
318 TTree* t = AliEveEventManager::GetMaster()->GetESDTree();
319
320 // Getting current tracks for each event, filling histograms
321 for (int event = 0; event < t->GetEntries(); event++) {
a096a7bf 322
3d94b490 323 t->GetEntry(event);
324
325 const AliESDVertex *pv = fEsd->GetPrimaryVertex();
326
327 for (Int_t n = 0; n < pv->GetNIndices(); n++ )
328 {
329 AliESDtrack *at = fEsd->GetTrack(pv->GetIndices()[n]);
a096a7bf 330
3d94b490 331 if (at->GetSign() > 0) {
4171aa4e 332 fHistoposAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
3d94b490 333 }
334 if (at->GetSign() < 0) {
4171aa4e 335 fHistonegAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
3d94b490 336 }
337 }
a096a7bf 338 }
3d94b490 339 } else {
340 LoadAllData();
341 }
342
4171aa4e 343 fDataAllEvents->DataChanged();
a096a7bf 344
3d94b490 345 // Max Pt threshold
346 if (GetPtMaxAE() >= fMaxPtAE){
347 for (Int_t binx = 1; binx <= 100; binx++) {
348 for (Int_t biny = 1; biny <= 80; biny++) {
4171aa4e 349 if (fHistoposAllEvents->GetBinContent(binx, biny) >= fMaxPtAE)
3d94b490 350 {
4171aa4e 351 fHistoposAllEvents->SetBinContent(binx, biny, fMaxPtAE);
3d94b490 352 }
4171aa4e 353 if (fHistonegAllEvents->GetBinContent(binx, biny) >= fMaxPtAE)
3d94b490 354 {
4171aa4e 355 fHistonegAllEvents->SetBinContent(binx, biny, fMaxPtAE);
3d94b490 356 }
357 }
358 }
359 }
360
361 // Positive only
4171aa4e 362 if ( fChargeIdAE == 2 ) fHistonegAllEvents->Reset();
3d94b490 363
364 // Negative only
4171aa4e 365 if ( fChargeIdAE == 3 ) fHistoposAllEvents->Reset();
3d94b490 366
4171aa4e 367 fDataAllEvents->DataChanged();
3d94b490 368
369 gEve->Redraw3D(kTRUE);
370
4171aa4e 371 return fDataAllEvents;
3d94b490 372}
373
374//______________________________________________________________________________
375void AliEveLego::Update()
376{
377 // Load/Reload data
378 LoadData();
379
380 // Create new histo2d
381 CreateHistoLego();
382
383 // Create 3d view
384 Create3DView();
385
386 // Show information about event;
387 ShowEventSeletion(fShowEventsInfo, kTRUE);
388
389 // Update the viewers
390 gEve->Redraw3D(kTRUE);
391}
392
393//______________________________________________________________________________
394TEveCaloLego* AliEveLego::CreateHistoLego()
395{
396 // Viewer initialization, tab creation
4171aa4e 397 if (fHisto2dv == 0) {
3d94b490 398 TEveWindowSlot *fslot = 0;
399 TEveBrowser *fbrowser = gEve->GetBrowser();
400
401 fslot = TEveWindow::CreateWindowInTab(fbrowser->GetTabRight());
402 fslot->MakeCurrent();
4171aa4e 403 fHisto2dv = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram");
404 fHisto2ds = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram");
405 fHisto2dv->AddScene(fHisto2ds);
406 fHisto2dv->SetElementName("2D Lego Viewer");
407 fHisto2ds->SetElementName("2D Lego Scene");
408
409 fGlv = fHisto2dv->GetGLViewer();
410 fHisto2dLegoOverlay = new TEveCaloLegoOverlay();
411 fGlv->AddOverlayElement(fHisto2dLegoOverlay);
3d94b490 412 fGlv->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
413
4171aa4e 414 fHisto2ds->AddElement(fLego);
3d94b490 415
416 // move to real world coordinates
417 fLego->InitMainTrans();
418 Float_t sc = TMath::Min(fLego->GetEtaRng(), fLego->GetPhiRng());
419 fLego->RefMainTrans().SetScale(sc, sc, sc);
420
421 // set event handler to move from perspective to orthographic view.
422 fGlv->SetEventHandler(new TEveLegoEventHandler(fGlv->GetGLWidget(), fGlv, fLego));
423
4171aa4e 424 fHisto2dLegoOverlay->SetCaloLego(fLego);
3d94b490 425 }
426
427 return fLego;
428}
429
430//______________________________________________________________________________
431TEveCaloLego* AliEveLego::CreateHistoLego(TEveWindowSlot *slot)
432{
433 // Viewer initialization, tab creation
4171aa4e 434 if (fHisto2dAllEventsv0 == 0) {
3d94b490 435
436 slot->MakeCurrent();
4171aa4e 437 fHisto2dAllEventsv0 = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram");
438 fHisto2dAllEventss0 = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram");
439 fHisto2dAllEventsv0->AddScene(fHisto2dAllEventss0);
440 fHisto2dAllEventsv0->SetElementName("2D Lego Viewer");
441 fHisto2dAllEventss0->SetElementName("2D Lego Scene");
442
443 TGLViewer* glv = fHisto2dAllEventsv0->GetGLViewer();
444 fHisto2dAllEventsLegoOverlay = new TEveCaloLegoOverlay();
445 glv->AddOverlayElement(fHisto2dAllEventsLegoOverlay);
3d94b490 446 glv->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
447
448 // Plotting histogram lego
4171aa4e 449 fLegoAllEvents = new TEveCaloLego(fDataAllEvents);
450 fHisto2dAllEventss0->AddElement(fLegoAllEvents);
3d94b490 451
452 // Move to real world coordinates
4171aa4e 453 fLegoAllEvents->InitMainTrans();
454 Float_t sc = TMath::Min(fLegoAllEvents->GetEtaRng(), fLegoAllEvents->GetPhiRng());
455 fLegoAllEvents->RefMainTrans().SetScale(sc, sc, sc);
3d94b490 456
457 // Set event handler to move from perspective to orthographic view.
4171aa4e 458 glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, fLegoAllEvents));
3d94b490 459
4171aa4e 460 fHisto2dAllEventsLegoOverlay->SetCaloLego(fLegoAllEvents);
3d94b490 461 }
462
4171aa4e 463 return fLegoAllEvents;
3d94b490 464}
465
466//______________________________________________________________________________
467TEveCalo3D* AliEveLego::Create3DView()
468{
469 //initialization
4171aa4e 470 if (fHisto2ds2 == 0) {
471 fHisto2ds2 = gEve->SpawnNewScene("3D Histogram", "3D Histogram");
472 gEve->GetDefaultViewer()->AddScene(fHisto2ds2);
473 fHisto2ds2->SetElementName("3D Histogram Scene");
474 fHisto2ds2->AddElement(fCalo3d);
3d94b490 475 }
476
477 return fCalo3d;
478}
479
480//______________________________________________________________________________
481TEveCalo3D* AliEveLego::Create3DView(TEveWindowSlot *slot)
482{
4171aa4e 483 // creates a 3d view for the 3d histogram
484 if ( fHisto2dAllEventsv1 == 0 ) {
3d94b490 485
486 slot->MakeCurrent();
4171aa4e 487 fHisto2dAllEventsv1 = gEve->SpawnNewViewer("3D Histogram", "3D Histogram");
488 fHisto2dAllEventss1 = gEve->SpawnNewScene("3D Histogram", "3D Histogram");
489 fHisto2dAllEventsv1->AddScene(fHisto2dAllEventss1);
490 fHisto2dAllEventsv1->SetElementName("3D Histogram Viewer");
491 fHisto2dAllEventss1->SetElementName("3D Histogram Scene");
3d94b490 492
4171aa4e 493 fCalo3dAllEvents = new TEveCalo3D(fDataAllEvents);
3d94b490 494
4171aa4e 495 fCalo3dAllEvents->SetBarrelRadius(550);
496 fCalo3dAllEvents->SetEndCapPos(550);
497 fHisto2dAllEventss1->AddElement(fCalo3dAllEvents);
3d94b490 498 }
499
4171aa4e 500 return fCalo3dAllEvents;
3d94b490 501}
502
503//______________________________________________________________________________
4171aa4e 504void AliEveLego::CreateProjections(TEveWindowSlot* slot1, TEveWindowSlot* slot2)
505{
506 // create projections
507 if (fHisto2dAllEventsv2 == 0) {
3d94b490 508
509 slot1->MakeCurrent();
4171aa4e 510 fHisto2dAllEventsv2 = gEve->SpawnNewViewer("RPhi projection", "RPhi projection");
511 fHisto2dAllEventss2 = gEve->SpawnNewScene("RPhi projection", "RPhi projection");
512 fHisto2dAllEventsv2->AddScene(fHisto2dAllEventss2);
513 fHisto2dAllEventsv2->SetElementName("RPhi Projection Viewer");
514 fHisto2dAllEventss2->SetElementName("RPhi Projection Scene");
3d94b490 515
516 TEveProjectionManager* mng1 = new TEveProjectionManager();
517 mng1->SetProjection(TEveProjection::kPT_RPhi);
518
4171aa4e 519 TEveProjectionAxes* axeghisto2dAllEventss1 = new TEveProjectionAxes(mng1);
520 fHisto2dAllEventss2->AddElement(axeghisto2dAllEventss1);
521 TEveCalo2D* fcalo2d1 = (TEveCalo2D*) mng1->ImportElements(fCalo3dAllEvents);
522 fHisto2dAllEventss2->AddElement(fcalo2d1);
3d94b490 523
4171aa4e 524 fHisto2dAllEventsv2->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
3d94b490 525 }
526
4171aa4e 527 if (fHisto2dAllEventsv3 == 0) {
3d94b490 528
529 slot2->MakeCurrent();
4171aa4e 530 fHisto2dAllEventsv3 = gEve->SpawnNewViewer("RhoZ projection", "RhoZ projection");
531 fHisto2dAllEventss3 = gEve->SpawnNewScene("RhoZ projection", "RhoZ projection");
532 fHisto2dAllEventsv3->AddScene(fHisto2dAllEventss3);
533 fHisto2dAllEventsv3->SetElementName("RhoZ Projection Viewer");
534 fHisto2dAllEventss3->SetElementName("RhoZ Projection Viewer");
3d94b490 535
536 TEveProjectionManager* mng2 = new TEveProjectionManager();
537 mng2->SetProjection(TEveProjection::kPT_RhoZ);
538
4171aa4e 539 TEveProjectionAxes* axeghisto2dAllEventss2 = new TEveProjectionAxes(mng2);
540 fHisto2dAllEventss3->AddElement(axeghisto2dAllEventss2);
541 TEveCalo2D* fcalo2d2 = (TEveCalo2D*) mng2->ImportElements(fCalo3dAllEvents);
542 fHisto2dAllEventss3->AddElement(fcalo2d2);
3d94b490 543
4171aa4e 544 fHisto2dAllEventsv3->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
3d94b490 545 }
546
547 return;
548}
549
550//______________________________________________________________________________
551TEveCaloDataHist* AliEveLego::LoadAllEvents()
552{
4171aa4e 553 // load all events data from ESD
554 if ( fHisto2dAllEventsSlot == 0 ) {
3d94b490 555
556 printf("Filling histogram...\n");
a096a7bf 557 TStopwatch timer;
558 timer.Start();
3d94b490 559
560 // Creating 2D histograms
4171aa4e 561 fHistoposAllEvents = new TH2F("fHistoposAllEvents","Histo 2d positive",
562 100,-1.5,1.5,80,-kPi,kPi);
563 fHistonegAllEvents = new TH2F("fHistonegAllEvents","Histo 2d negative",
564 100,-1.5,1.5,80,-kPi,kPi);
565
566 fHistoposAllEvents->SetDirectory(0);
567 fHistonegAllEvents->SetDirectory(0);
568
569 fDataAllEvents = new TEveCaloDataHist();
570 fDataAllEvents->AddHistogram(fHistonegAllEvents);
571 fDataAllEvents->RefSliceInfo(0).Setup("NegCg:", 0, kBlue);
572 fDataAllEvents->AddHistogram(fHistoposAllEvents);
573 fDataAllEvents->RefSliceInfo(1).Setup("PosCg:", 0, kRed);
574 fDataAllEvents->GetEtaBins()->SetTitleFont(120);
575 fDataAllEvents->GetEtaBins()->SetTitle("h");
576 fDataAllEvents->GetPhiBins()->SetTitleFont(120);
577 fDataAllEvents->GetPhiBins()->SetTitle("f");
578 fDataAllEvents->IncDenyDestroy();
3d94b490 579
580 // Creating frames
4171aa4e 581 fHisto2dAllEventsSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
582 TEveWindowPack* packH = fHisto2dAllEventsSlot->MakePack();
3d94b490 583 packH->SetElementName("Projections");
584 packH->SetHorizontal();
585 packH->SetShowTitleBar(kFALSE);
586
4171aa4e 587 fHisto2dAllEventsSlot = packH->NewSlot();
588 TEveWindowPack* pack0 = fHisto2dAllEventsSlot->MakePack();
3d94b490 589 pack0->SetShowTitleBar(kFALSE);
590 TEveWindowSlot* slotLeftTop = pack0->NewSlot();
591 TEveWindowSlot* slotLeftBottom = pack0->NewSlot();
592
4171aa4e 593 fHisto2dAllEventsSlot = packH->NewSlot();
594 TEveWindowPack* pack1 = fHisto2dAllEventsSlot->MakePack();
3d94b490 595 pack1->SetShowTitleBar(kFALSE);
596 TEveWindowSlot* slotRightTop = pack1->NewSlot();
597 TEveWindowSlot* slotRightBottom = pack1->NewSlot();
598
599 // Creating viewers and scenes
600 Create3DView(slotLeftTop);
601 CreateHistoLego(slotLeftBottom);
602 CreateProjections(slotRightTop, slotRightBottom);
603
604 LoadAllData();
605
606 gEve->Redraw3D(kTRUE);
607
608 printf("Filling histogram... Finished\n");
a096a7bf 609 timer.Stop();
610 timer.Print();
611
3d94b490 612 }
613
4171aa4e 614 return fDataAllEvents;
3d94b490 615}
616
617//______________________________________________________________________________
618Float_t AliEveLego::GetPtMax()
619{
620 return fData->GetMaxVal(fLego->GetPlotEt());
621}
622
623//______________________________________________________________________________
624Float_t AliEveLego::GetPtMaxAE()
625{
4171aa4e 626 return fDataAllEvents->GetMaxVal(fLegoAllEvents->GetPlotEt());
3d94b490 627}
628
629//______________________________________________________________________________
630void AliEveLego::SetMaxPt(Double_t val)
631{
632 // Add new maximum
633 fMaxPt = val;
634 Update();
635}
636
637//______________________________________________________________________________
638void AliEveLego::SetMaxPtAE(Double_t val)
639{
640 // Add new maximum
641 fMaxPtAE = val;
642 FilterAllData();
643}
644
645//______________________________________________________________________________
646void AliEveLego::SetThreshold(Double_t val)
647{
648 // Setting up the new threshold for all histograms
649 fData->SetSliceThreshold(0,val);
650 fData->SetSliceThreshold(1,val);
651 fData->DataChanged();
652
653 gEve->Redraw3D(kTRUE);
654}
655
656//______________________________________________________________________________
657void AliEveLego::SetThresholdAE(Double_t val)
658{
659 // Setting up the new threshold for all histograms
4171aa4e 660 fDataAllEvents->SetSliceThreshold(0,val);
661 fDataAllEvents->SetSliceThreshold(1,val);
662 fDataAllEvents->DataChanged();
3d94b490 663
664 gEve->Redraw3D(kTRUE);
665}
666
667//______________________________________________________________________________
668void AliEveLego::SetEventSelection()
669{
4171aa4e 670 // activate/deactivate info box
3d94b490 671 if (fShowEventsInfo == 0)
672 {
673 fShowEventsInfo = 1;
674 } else {
675 fShowEventsInfo = 0;
676 }
677
678 ShowEventSeletion(fShowEventsInfo);
679}
680
681//______________________________________________________________________________
682void AliEveLego::ShowEventSeletion(Bool_t show, Bool_t updateonly)
683{
4171aa4e 684 // activate/deactivate info box
3d94b490 685 if (show == 0)
686 {
687 gEve->GetDefaultGLViewer()->RemoveOverlayElement(fGButton);
688 fAl->Get3DView()->GetGLViewer()->RemoveOverlayElement(fGButton);
4171aa4e 689 fHisto2dv->GetGLViewer()->RemoveOverlayElement(fGButton);
3d94b490 690
691 gEve->GetDefaultGLViewer()->RemoveOverlayElement(fB1);
692 fAl->Get3DView()->GetGLViewer()->RemoveOverlayElement(fB1);
4171aa4e 693 fHisto2dv->GetGLViewer()->RemoveOverlayElement(fB1);
3d94b490 694
695 gEve->GetDefaultGLViewer()->RemoveOverlayElement(fB2);
696 fAl->Get3DView()->GetGLViewer()->RemoveOverlayElement(fB2);
4171aa4e 697 fHisto2dv->GetGLViewer()->RemoveOverlayElement(fB2);
3d94b490 698
699 } else {
700
701 //Collision candidate
702 if (updateonly == kFALSE) {
703 gEve->GetDefaultGLViewer()->AddOverlayElement(fGButton);
704 fAl->Get3DView()->GetGLViewer()->AddOverlayElement(fGButton);
4171aa4e 705 fHisto2dv->GetGLViewer()->AddOverlayElement(fGButton);
3d94b490 706 }
707
708 Bool_t ev = fPhysicsSelection->IsCollisionCandidate(fEsd);
709
710 if (ev == 1)
711 {
712 fGButton->SetText("Collision candidate: YES");
713 } else {
714 fGButton->SetText("Collision candidate: NO ");
715 }
716
717 // Beam 1 & 2 setup: method 1
718 if (updateonly == kFALSE) {
719 gEve->GetDefaultGLViewer()->AddOverlayElement(fB1);
720 fAl->Get3DView()->GetGLViewer()->AddOverlayElement(fB1);
4171aa4e 721 fHisto2dv->GetGLViewer()->AddOverlayElement(fB1);
3d94b490 722
723 gEve->GetDefaultGLViewer()->AddOverlayElement(fB2);
724 fAl->Get3DView()->GetGLViewer()->AddOverlayElement(fB2);
4171aa4e 725 fHisto2dv->GetGLViewer()->AddOverlayElement(fB2);
3d94b490 726 }
727
728 Bool_t b1 = fEsd->IsTriggerClassFired("CINT1A-ABCE-NOPF-ALL");
729 Bool_t b2 = fEsd->IsTriggerClassFired("CINT1C-ABCE-NOPF-ALL");
730 Bool_t b12 = fEsd->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL");
731
732 if (b1 == 1 || b12 == 1)
733 {
734 fB1->SetText("Beam 1: YES");
735 fB1->SetBackColor(0x00ff00);
736 } else {
737 fB1->SetText("Beam 1: NO");
738 fB1->SetBackColor(0xff0000);
739 }
740
741 if (b2 == 1 || b12 == 1)
742 {
743 fB2->SetText("Beam 2: YES");
744 fB2->SetBackColor(0x00ff00);
745 } else {
746 fB2->SetText("Beam 2: NO");
747 fB2->SetBackColor(0xff0000);
748 }
749 }
750
751 gEve->Redraw3D(kTRUE);
752
753}
754
755//______________________________________________________________________________
756void AliEveLego::SelectEventSelection(Int_t id)
757{
4171aa4e 758 // show trigger information
3d94b490 759 if (id == 0)
760 {
761 fEventSelector->SetSelectOnTriggerType(kFALSE);
762 } else {
763 if (id == 1) fEventSelector->SetTriggerType("CINT1A-ABCE-NOPF-ALL");
764 if (id == 2) fEventSelector->SetTriggerType("CINT1C-ABCE-NOPF-ALL");
765 if (id == 3) fEventSelector->SetTriggerType("CINT1B-ABCE-NOPF-ALL");
766 fEventSelector->SetSelectOnTriggerType(kTRUE);
767 }
768}
769
770//______________________________________________________________________________
771void AliEveLego::ShowPrevEvent()
772{
773 AliEveEventManager::GetMaster()->PrevEvent();
774}
775
776//______________________________________________________________________________
777void AliEveLego::ShowNextEvent()
778{
779 AliEveEventManager::GetMaster()->NextEvent();
780}
781/******************************************************************************/
782
783