From Stefano:
[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"
3d94b490 15
16#include "TH2F.h"
17#include "TMath.h"
18#include "TGLViewer.h"
19#include "TEveWindow.h"
20#include "TEveManager.h"
21#include "TEveBrowser.h"
22#include "TEveViewer.h"
23#include "TEveScene.h"
24#include "TEveCaloLegoOverlay.h"
25#include "TEveCalo.h"
26#include "TEveCaloData.h"
27#include "TEveLegoEventHandler.h"
28#include "TEveTrans.h"
29#include "TEveProjectionManager.h"
30#include "TEveProjectionAxes.h"
31#include "TGLWidget.h"
a096a7bf 32#include "TStopwatch.h"
3d94b490 33
34//______________________________________________________________________________
35// Allow histograms visualization in 2D and 3D.
36//
37
38ClassImp(AliEveLego)
4171aa4e 39Double_t kPi = TMath::Pi();
3d94b490 40
41//______________________________________________________________________________
42AliEveLego::AliEveLego(const char* name) :
43 TEveElementList(name),
6e994a7b 44 fIsMC(kFALSE),
45 fCollisionCandidatesOnly(kFALSE),
46 fParticleTypeId(0),
47 fParticleTypeIdAE(0),
3d94b490 48 fTracksId(1),
3d94b490 49 fMaxPt(10000),
3d94b490 50 fTracksIdAE(0),
a096a7bf 51 fMaxPtAE(10000),
3d94b490 52 fEsd(0),
53 fPhysicsSelection(0),
54 fHistopos(0),
4171aa4e 55 fHistoposAllEvents(0),
3d94b490 56 fHistoneg(0),
4171aa4e 57 fHistonegAllEvents(0),
6e994a7b 58 fHistoElectrons(0),
59 fHistoElectronsAllEvents(0),
60 fHistoMuons(0),
61 fHistoMuonsAllEvents(0),
62 fHistoPions(0),
63 fHistoPionsAllEvents(0),
64 fHistoKaons(0),
65 fHistoKaonsAllEvents(0),
66 fHistoProtons(0),
67 fHistoProtonsAllEvents(0),
3d94b490 68 fData(0),
4171aa4e 69 fDataAllEvents(0),
3d94b490 70 fLego(0),
4171aa4e 71 fLegoAllEvents(0),
3d94b490 72 fCalo3d(0),
4171aa4e 73 fCalo3dAllEvents(0),
3d94b490 74 fGlv(0),
4171aa4e 75 fHisto2dv(0),
76 fHisto2ds(0),
77 fHisto2ds2(0),
78 fHisto2dAllEventsv0(0),
79 fHisto2dAllEventsv1(0),
80 fHisto2dAllEventsv2(0),
81 fHisto2dAllEventsv3(0),
82 fHisto2dAllEventss0(0),
83 fHisto2dAllEventss1(0),
84 fHisto2dAllEventss2(0),
85 fHisto2dAllEventss3(0),
3d94b490 86 fAl(0),
4171aa4e 87 fHisto2dLegoOverlay(0),
88 fHisto2dAllEventsLegoOverlay(0),
6e994a7b 89 fHisto2dAllEventsSlot(0)
3d94b490 90{
91 // Constructor.
92 gEve->AddToListTree(this,0);
93
94 // Get Current ESD event
95 fEsd = AliEveEventManager::AssertESD();
96
6e994a7b 97 // Particles types per default
98 fParticleTypeId = new Bool_t[7];
99 fParticleTypeIdAE = new Bool_t[7];
100
101 for (Int_t s = 0; s < 7; s++)
102 {
103 if (s > 1){
104 fParticleTypeId[s] = kFALSE;
105 fParticleTypeIdAE[s] = kFALSE;
106 } else {
107 fParticleTypeId[s] = kTRUE;
108 fParticleTypeIdAE[s] = kTRUE;
109 }
110 }
111
3d94b490 112 fPhysicsSelection = new AliPhysicsSelection();
113 fPhysicsSelection->Initialize(fEsd->GetRunNumber());
114
6e994a7b 115 fHistopos = new TH2F("histopos","Histo 2d positive", 100, -1.5, 1.5, 80, -kPi, kPi);
116 fHistoneg = new TH2F("histoneg","Histo 2d negative", 100, -1.5, 1.5, 80, -kPi, kPi);
117 fHistoElectrons = new TH2F("histoele","Histo 2d electron", 100, -1.5, 1.5, 80, -kPi, kPi);
118 fHistoMuons = new TH2F("histomuo","Histo 2d muons ", 100, -1.5, 1.5, 80, -kPi, kPi);
119 fHistoPions = new TH2F("histopio","Histo 2d pions ", 100, -1.5, 1.5, 80, -kPi, kPi);
120 fHistoKaons = new TH2F("histokao","Histo 2d kaons ", 100, -1.5, 1.5, 80, -kPi, kPi);
121 fHistoProtons = new TH2F("histopro","Histo 2d protons ", 100, -1.5, 1.5, 80, -kPi, kPi);
a096a7bf 122
123 fHistopos->SetDirectory(0);
124 fHistoneg->SetDirectory(0);
6e994a7b 125 fHistoElectrons->SetDirectory(0);
126 fHistoMuons->SetDirectory(0);
127 fHistoPions->SetDirectory(0);
128 fHistoKaons->SetDirectory(0);
129 fHistoProtons->SetDirectory(0);
130
131 // colors from get_pdg_color() in /alice-macros/kine_tracks.C
132 static Color_t fElectro = 5;
133 static Color_t fMuon = 30;
134 static Color_t fPion = 3;
135 static Color_t fKaon = 38;
136 static Color_t fProton = 10;
3d94b490 137
138 fData = new TEveCaloDataHist();
6e994a7b 139
3d94b490 140 fData->AddHistogram(fHistoneg);
141 fData->RefSliceInfo(0).Setup("NegCg:", 0, kBlue);
142 fData->AddHistogram(fHistopos);
143 fData->RefSliceInfo(1).Setup("PosCg:", 0, kRed);
6e994a7b 144 fData->AddHistogram(fHistoElectrons);
145 fData->RefSliceInfo(2).Setup("Electrons:", 0, fElectro);
146 fData->AddHistogram(fHistoMuons);
147 fData->RefSliceInfo(3).Setup("Muons:", 0, fMuon);
148 fData->AddHistogram(fHistoPions);
149 fData->RefSliceInfo(4).Setup("Pions:", 0, fPion);
150 fData->AddHistogram(fHistoKaons);
151 fData->RefSliceInfo(5).Setup("Kaons:", 0, fKaon);
152 fData->AddHistogram(fHistoProtons);
153 fData->RefSliceInfo(6).Setup("Protons:", 0, fProton);
154
3d94b490 155 fData->GetEtaBins()->SetTitleFont(120);
156 fData->GetEtaBins()->SetTitle("h");
157 fData->GetPhiBins()->SetTitleFont(120);
158 fData->GetPhiBins()->SetTitle("f");
159 fData->IncDenyDestroy();
160
161 fCalo3d = new TEveCalo3D(fData);
162 fCalo3d->SetBarrelRadius(550);
163 fCalo3d->SetEndCapPos(550);
164
165 // plotting histo
166 fLego = new TEveCaloLego(fData);
167
168 // projections
169 fAl = AliEveMultiView::Instance();
170 fAl->ImportEventRPhi(fCalo3d);
171 fAl->ImportEventRhoZ(fCalo3d);
172
3d94b490 173 // Update
174 Update();
175}
176
177//______________________________________________________________________________
178AliEveLego::~AliEveLego()
179{
4171aa4e 180 // deleting variables
3d94b490 181 delete fEsd;
182 delete fPhysicsSelection;
183 delete fHistopos;
4171aa4e 184 delete fHistoposAllEvents;
3d94b490 185 delete fHistoneg;
4171aa4e 186 delete fHistonegAllEvents;
6e994a7b 187 delete fHistoElectrons;
188 delete fHistoElectronsAllEvents;
189 delete fHistoMuons;
190 delete fHistoMuonsAllEvents;
191 delete fHistoPions;
192 delete fHistoPionsAllEvents;
193 delete fHistoKaons;
194 delete fHistoKaonsAllEvents;
195 delete fHistoProtons;
196 delete fHistoProtonsAllEvents;
197
198 delete[] fParticleTypeId;
199 delete[] fParticleTypeIdAE;
3d94b490 200
201 delete fData;
4171aa4e 202 delete fDataAllEvents;
3d94b490 203 delete fLego;
4171aa4e 204 delete fLegoAllEvents;
3d94b490 205 delete fCalo3d;
4171aa4e 206 delete fCalo3dAllEvents;
3d94b490 207 delete fGlv;
208
4171aa4e 209 delete fHisto2dv;
210 delete fHisto2ds;
211 delete fHisto2ds2;
212 delete fHisto2dAllEventsv0;
213 delete fHisto2dAllEventsv1;
214 delete fHisto2dAllEventsv2;
215 delete fHisto2dAllEventsv3;
216 delete fHisto2dAllEventss0;
217 delete fHisto2dAllEventss1;
218 delete fHisto2dAllEventss2;
219 delete fHisto2dAllEventss3;
3d94b490 220
221 delete fAl;
4171aa4e 222 delete fHisto2dLegoOverlay;
223 delete fHisto2dAllEventsLegoOverlay;
224 delete fHisto2dAllEventsSlot;
3d94b490 225
3d94b490 226}
227
4171aa4e 228namespace
3d94b490 229{
4171aa4e 230 //____________________________________________________________________________
231 Double_t getphi(Double_t phi)
232 {
233 // phi correction for alice
234
235 if (phi > TMath::Pi()) {
236 phi -= TMath::TwoPi();
237 }
238 return phi;
239 }
3d94b490 240}
241
242//______________________________________________________________________________
243TEveCaloDataHist* AliEveLego::LoadData()
244{
4171aa4e 245 // Load data from ESD tree
3d94b490 246 fHistopos->Reset();
247 fHistoneg->Reset();
6e994a7b 248 fHistoElectrons->Reset();
249 fHistoMuons->Reset();
250 fHistoPions->Reset();
251 fHistoKaons->Reset();
252 fHistoProtons->Reset();
3d94b490 253
254 // Getting current tracks, filling histograms
255 for (int n = 0; n < fEsd->GetNumberOfTracks(); ++n) {
256
6e994a7b 257 AliESDtrack *track = fEsd->GetTrack(n);
258 const Double_t sign = fEsd->GetTrack(n)->GetSign();
259 const Int_t prob = GetParticleType(track);
3d94b490 260
6e994a7b 261 if (sign > 0)
262 fHistopos->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
263
264 if (sign < 0)
265 fHistoneg->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
266
267 if (prob == 0)
268 fHistoElectrons->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
269
270 if (prob == 1)
271 fHistoMuons->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
272
273 if (prob == 2)
274 fHistoPions->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
275
276 if (prob == 3)
277 fHistoKaons->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
278
279 if (prob == 4)
280 fHistoProtons->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
3d94b490 281 }
282
3d94b490 283 fData->DataChanged();
284
285 FilterData();
286
287 return fData;
288}
289
290//______________________________________________________________________________
291TEveCaloDataHist* AliEveLego::LoadAllData()
292{
4171aa4e 293 // load data from all events ESD
294 fHistoposAllEvents->Reset();
295 fHistonegAllEvents->Reset();
6e994a7b 296 fHistoElectronsAllEvents->Reset();
297 fHistoMuonsAllEvents->Reset();
298 fHistoPionsAllEvents->Reset();
299 fHistoKaonsAllEvents->Reset();
300 fHistoProtonsAllEvents->Reset();
3d94b490 301
302 TTree* t = AliEveEventManager::GetMaster()->GetESDTree();
303
304 // Getting current tracks for each event, filling histograms
6e994a7b 305 Int_t fAcceptedEvents = 0;
3d94b490 306 for (int event = 0; event < t->GetEntries(); event++) {
307 t->GetEntry(event);
6e994a7b 308
309 if (fCollisionCandidatesOnly == kTRUE)
310 if (fPhysicsSelection->IsCollisionCandidate(fEsd) == kFALSE) continue;
311
312 fAcceptedEvents++;
313
314 for (int n = 0; n < fEsd->GetNumberOfTracks(); ++n) {
315
316 AliESDtrack *track = fEsd->GetTrack(n);
317 const Double_t sign = track->GetSign();
318 const Int_t prob = GetParticleType(track);
319
320 if (sign > 0)
321 fHistoposAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
322
323 if (sign < 0)
324 fHistonegAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
325
326 if (prob == 0)
327 fHistoElectronsAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
328
329 if (prob == 1)
330 fHistoMuonsAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
331
332 if (prob == 2)
333 fHistoPionsAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
334
335 if (prob == 3)
336 fHistoKaonsAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
337
338 if (prob == 4)
339 fHistoProtonsAllEvents->Fill(track->Eta(), getphi(track->Phi()), fabs(track->Pt()));
3d94b490 340 }
341 }
6e994a7b 342 t->GetEntry(0);
343 printf("Number of events loaded: %i, with AliPhysicsSelection: %i\n",fAcceptedEvents,fCollisionCandidatesOnly);
3d94b490 344
4171aa4e 345 fDataAllEvents->DataChanged();
3d94b490 346
4171aa4e 347 return fDataAllEvents;
3d94b490 348}
349
350//______________________________________________________________________________
351TEveCaloDataHist* AliEveLego::FilterData()
352{
353 // Tracks selection
354 if ( fTracksId == 2 )
355 {
356 fHistopos->Reset();
357 fHistoneg->Reset();
6e994a7b 358 fHistoElectrons->Reset();
359 fHistoMuons->Reset();
360 fHistoPions->Reset();
361 fHistoKaons->Reset();
362 fHistoProtons->Reset();
3d94b490 363
364 const AliESDVertex *pv = fEsd->GetPrimaryVertex();
365
366 for (Int_t n = 0; n < pv->GetNIndices(); n++ )
367 {
368 AliESDtrack *at = fEsd->GetTrack(pv->GetIndices()[n]);
6e994a7b 369 const Double_t sign = at->GetSign();
370 const Int_t prob = GetParticleType(at);
371
372 if (sign > 0)
373 fHistopos->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
374
375 if (sign < 0)
376 fHistoneg->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
377
378 if (prob == 0)
379 fHistoElectrons->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
380
381 if (prob == 1)
382 fHistoMuons->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
383
384 if (prob == 2)
385 fHistoPions->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
386
387 if (prob == 3)
388 fHistoKaons->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
389
390 if (prob == 4)
391 fHistoProtons->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
3d94b490 392 }
393 }
394
395 fData->DataChanged();
396
397 // Max Pt threshold
398 if (GetPtMax() >= fMaxPt){
399 for (Int_t binx = 1; binx <= 100; binx++) {
400 for (Int_t biny = 1; biny <= 80; biny++) {
6e994a7b 401
402 if (fHistopos->GetBinContent(binx, biny) >= fMaxPt)
403 fHistopos->SetBinContent(binx, biny, fMaxPt);
404
405 if (fHistoneg->GetBinContent(binx, biny) >= fMaxPt)
406 fHistoneg->SetBinContent(binx, biny, fMaxPt);
407
408 if (fHistoElectrons->GetBinContent(binx, biny) >= fMaxPt)
409 fHistoElectrons->SetBinContent(binx, biny, fMaxPt);
410
411 if (fHistoMuons->GetBinContent(binx, biny) >= fMaxPt)
412 fHistoMuons->SetBinContent(binx, biny, fMaxPt);
413
414 if (fHistoPions->GetBinContent(binx, biny) >= fMaxPt)
415 fHistoPions->SetBinContent(binx, biny, fMaxPt);
416
417 if (fHistoKaons->GetBinContent(binx, biny) >= fMaxPt)
418 fHistoKaons->SetBinContent(binx, biny, fMaxPt);
419
420 if (fHistoProtons->GetBinContent(binx, biny) >= fMaxPt)
421 fHistoProtons->SetBinContent(binx, biny, fMaxPt);
3d94b490 422 }
423 }
424 }
425
6e994a7b 426 // Particle type filter
427 if ( fParticleTypeId[0] == kFALSE) fHistopos->Reset();
428 if ( fParticleTypeId[1] == kFALSE) fHistoneg->Reset();
429 if ( fParticleTypeId[2] == kFALSE) fHistoElectrons->Reset();
430 if ( fParticleTypeId[3] == kFALSE) fHistoMuons->Reset();
431 if ( fParticleTypeId[4] == kFALSE) fHistoPions->Reset();
432 if ( fParticleTypeId[5] == kFALSE) fHistoKaons->Reset();
433 if ( fParticleTypeId[6] == kFALSE) fHistoProtons->Reset();
3d94b490 434
435 fData->DataChanged();
436
437 return fData;
438}
439
3d94b490 440//______________________________________________________________________________
441TEveCaloDataHist* AliEveLego::FilterAllData()
442{
443 // Tracks selection
444 if ( fTracksIdAE == 2 )
445 {
4171aa4e 446 fHistoposAllEvents->Reset();
447 fHistonegAllEvents->Reset();
6e994a7b 448 fHistoElectronsAllEvents->Reset();
449 fHistoMuonsAllEvents->Reset();
450 fHistoPionsAllEvents->Reset();
451 fHistoKaonsAllEvents->Reset();
452 fHistoProtonsAllEvents->Reset();
3d94b490 453
454 TTree* t = AliEveEventManager::GetMaster()->GetESDTree();
455
456 // Getting current tracks for each event, filling histograms
6e994a7b 457 Int_t fAcceptedEvents = 0;
3d94b490 458 for (int event = 0; event < t->GetEntries(); event++) {
a096a7bf 459
6e994a7b 460 t->GetEntry(event);
461 const AliESDVertex *pv = fEsd->GetPrimaryVertex();
3d94b490 462
6e994a7b 463 if (fCollisionCandidatesOnly == kTRUE)
464 if (fPhysicsSelection->IsCollisionCandidate(fEsd) == kFALSE) continue;
3d94b490 465
6e994a7b 466 fAcceptedEvents++;
a096a7bf 467
6e994a7b 468 for (Int_t n = 0; n < pv->GetNIndices(); n++ )
469 {
470 AliESDtrack *at = fEsd->GetTrack(pv->GetIndices()[n]);
471 const Double_t sign = at->GetSign();
472 const Int_t prob = GetParticleType(at);
473
474 if (sign > 0)
4171aa4e 475 fHistoposAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
6e994a7b 476
477 if (sign < 0)
4171aa4e 478 fHistonegAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
6e994a7b 479
480 if (prob == 0)
481 fHistoElectronsAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
482
483 if (prob == 1)
484 fHistoMuonsAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
485
486 if (prob == 2)
487 fHistoPionsAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
488
489 if (prob == 3)
490 fHistoKaonsAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
491
492 if (prob == 4)
493 fHistoProtonsAllEvents->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
494 }
a096a7bf 495 }
6e994a7b 496 t->GetEntry(0);
497 printf("Number of events loaded: %i, with AliPhysicsSelection: %i\n",fAcceptedEvents,fCollisionCandidatesOnly);
498
3d94b490 499 } else {
6e994a7b 500
3d94b490 501 LoadAllData();
6e994a7b 502
503 }
3d94b490 504
4171aa4e 505 fDataAllEvents->DataChanged();
a096a7bf 506
3d94b490 507 // Max Pt threshold
508 if (GetPtMaxAE() >= fMaxPtAE){
509 for (Int_t binx = 1; binx <= 100; binx++) {
510 for (Int_t biny = 1; biny <= 80; biny++) {
6e994a7b 511
512 if (fHistoposAllEvents->GetBinContent(binx, biny) >= fMaxPtAE)
513 fHistoposAllEvents->SetBinContent(binx, biny, fMaxPtAE);
514
515 if (fHistonegAllEvents->GetBinContent(binx, biny) >= fMaxPtAE)
516 fHistonegAllEvents->SetBinContent(binx, biny, fMaxPtAE);
517
518 if (fHistoElectronsAllEvents->GetBinContent(binx, biny) >= fMaxPt)
519 fHistoElectronsAllEvents->SetBinContent(binx, biny, fMaxPt);
520
521 if (fHistoMuonsAllEvents->GetBinContent(binx, biny) >= fMaxPt)
522 fHistoMuonsAllEvents->SetBinContent(binx, biny, fMaxPt);
523
524 if (fHistoPionsAllEvents->GetBinContent(binx, biny) >= fMaxPt)
525 fHistoPionsAllEvents->SetBinContent(binx, biny, fMaxPt);
526
527 if (fHistoKaonsAllEvents->GetBinContent(binx, biny) >= fMaxPt)
528 fHistoKaonsAllEvents->SetBinContent(binx, biny, fMaxPt);
529
530 if (fHistoProtonsAllEvents->GetBinContent(binx, biny) >= fMaxPt)
531 fHistoProtonsAllEvents->SetBinContent(binx, biny, fMaxPt);
3d94b490 532 }
533 }
534 }
535
536 // Positive only
6e994a7b 537 if ( fParticleTypeIdAE[0] == kFALSE ) fHistoposAllEvents->Reset();
538 if ( fParticleTypeIdAE[1] == kFALSE ) fHistonegAllEvents->Reset();
539 if ( fParticleTypeIdAE[2] == kFALSE ) fHistoElectronsAllEvents->Reset();
540 if ( fParticleTypeIdAE[3] == kFALSE ) fHistoMuonsAllEvents->Reset();
541 if ( fParticleTypeIdAE[4] == kFALSE ) fHistoPionsAllEvents->Reset();
542 if ( fParticleTypeIdAE[5] == kFALSE ) fHistoKaonsAllEvents->Reset();
543 if ( fParticleTypeIdAE[6] == kFALSE ) fHistoProtonsAllEvents->Reset();
3d94b490 544
4171aa4e 545 fDataAllEvents->DataChanged();
3d94b490 546
547 gEve->Redraw3D(kTRUE);
548
4171aa4e 549 return fDataAllEvents;
3d94b490 550}
551
552//______________________________________________________________________________
553void AliEveLego::Update()
554{
555 // Load/Reload data
556 LoadData();
557
558 // Create new histo2d
559 CreateHistoLego();
560
561 // Create 3d view
562 Create3DView();
563
3d94b490 564 // Update the viewers
565 gEve->Redraw3D(kTRUE);
566}
567
568//______________________________________________________________________________
569TEveCaloLego* AliEveLego::CreateHistoLego()
570{
571 // Viewer initialization, tab creation
4171aa4e 572 if (fHisto2dv == 0) {
3d94b490 573 TEveWindowSlot *fslot = 0;
574 TEveBrowser *fbrowser = gEve->GetBrowser();
575
576 fslot = TEveWindow::CreateWindowInTab(fbrowser->GetTabRight());
577 fslot->MakeCurrent();
4171aa4e 578 fHisto2dv = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram");
579 fHisto2ds = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram");
580 fHisto2dv->AddScene(fHisto2ds);
581 fHisto2dv->SetElementName("2D Lego Viewer");
582 fHisto2ds->SetElementName("2D Lego Scene");
583
584 fGlv = fHisto2dv->GetGLViewer();
585 fHisto2dLegoOverlay = new TEveCaloLegoOverlay();
586 fGlv->AddOverlayElement(fHisto2dLegoOverlay);
3d94b490 587 fGlv->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
588
4171aa4e 589 fHisto2ds->AddElement(fLego);
3d94b490 590
591 // move to real world coordinates
592 fLego->InitMainTrans();
593 Float_t sc = TMath::Min(fLego->GetEtaRng(), fLego->GetPhiRng());
594 fLego->RefMainTrans().SetScale(sc, sc, sc);
595
596 // set event handler to move from perspective to orthographic view.
597 fGlv->SetEventHandler(new TEveLegoEventHandler(fGlv->GetGLWidget(), fGlv, fLego));
598
4171aa4e 599 fHisto2dLegoOverlay->SetCaloLego(fLego);
3d94b490 600 }
601
602 return fLego;
603}
604
605//______________________________________________________________________________
606TEveCaloLego* AliEveLego::CreateHistoLego(TEveWindowSlot *slot)
607{
608 // Viewer initialization, tab creation
4171aa4e 609 if (fHisto2dAllEventsv0 == 0) {
3d94b490 610
611 slot->MakeCurrent();
4171aa4e 612 fHisto2dAllEventsv0 = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram");
613 fHisto2dAllEventss0 = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram");
614 fHisto2dAllEventsv0->AddScene(fHisto2dAllEventss0);
615 fHisto2dAllEventsv0->SetElementName("2D Lego Viewer");
616 fHisto2dAllEventss0->SetElementName("2D Lego Scene");
617
618 TGLViewer* glv = fHisto2dAllEventsv0->GetGLViewer();
619 fHisto2dAllEventsLegoOverlay = new TEveCaloLegoOverlay();
620 glv->AddOverlayElement(fHisto2dAllEventsLegoOverlay);
3d94b490 621 glv->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
622
623 // Plotting histogram lego
4171aa4e 624 fLegoAllEvents = new TEveCaloLego(fDataAllEvents);
625 fHisto2dAllEventss0->AddElement(fLegoAllEvents);
3d94b490 626
627 // Move to real world coordinates
4171aa4e 628 fLegoAllEvents->InitMainTrans();
629 Float_t sc = TMath::Min(fLegoAllEvents->GetEtaRng(), fLegoAllEvents->GetPhiRng());
630 fLegoAllEvents->RefMainTrans().SetScale(sc, sc, sc);
3d94b490 631
632 // Set event handler to move from perspective to orthographic view.
4171aa4e 633 glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, fLegoAllEvents));
3d94b490 634
4171aa4e 635 fHisto2dAllEventsLegoOverlay->SetCaloLego(fLegoAllEvents);
3d94b490 636 }
637
4171aa4e 638 return fLegoAllEvents;
3d94b490 639}
640
641//______________________________________________________________________________
642TEveCalo3D* AliEveLego::Create3DView()
643{
644 //initialization
4171aa4e 645 if (fHisto2ds2 == 0) {
646 fHisto2ds2 = gEve->SpawnNewScene("3D Histogram", "3D Histogram");
647 gEve->GetDefaultViewer()->AddScene(fHisto2ds2);
648 fHisto2ds2->SetElementName("3D Histogram Scene");
649 fHisto2ds2->AddElement(fCalo3d);
3d94b490 650 }
651
652 return fCalo3d;
653}
654
655//______________________________________________________________________________
656TEveCalo3D* AliEveLego::Create3DView(TEveWindowSlot *slot)
657{
4171aa4e 658 // creates a 3d view for the 3d histogram
659 if ( fHisto2dAllEventsv1 == 0 ) {
3d94b490 660
661 slot->MakeCurrent();
4171aa4e 662 fHisto2dAllEventsv1 = gEve->SpawnNewViewer("3D Histogram", "3D Histogram");
663 fHisto2dAllEventss1 = gEve->SpawnNewScene("3D Histogram", "3D Histogram");
664 fHisto2dAllEventsv1->AddScene(fHisto2dAllEventss1);
665 fHisto2dAllEventsv1->SetElementName("3D Histogram Viewer");
666 fHisto2dAllEventss1->SetElementName("3D Histogram Scene");
3d94b490 667
4171aa4e 668 fCalo3dAllEvents = new TEveCalo3D(fDataAllEvents);
3d94b490 669
4171aa4e 670 fCalo3dAllEvents->SetBarrelRadius(550);
671 fCalo3dAllEvents->SetEndCapPos(550);
672 fHisto2dAllEventss1->AddElement(fCalo3dAllEvents);
3d94b490 673 }
674
4171aa4e 675 return fCalo3dAllEvents;
3d94b490 676}
677
678//______________________________________________________________________________
4171aa4e 679void AliEveLego::CreateProjections(TEveWindowSlot* slot1, TEveWindowSlot* slot2)
680{
681 // create projections
682 if (fHisto2dAllEventsv2 == 0) {
3d94b490 683
684 slot1->MakeCurrent();
4171aa4e 685 fHisto2dAllEventsv2 = gEve->SpawnNewViewer("RPhi projection", "RPhi projection");
686 fHisto2dAllEventss2 = gEve->SpawnNewScene("RPhi projection", "RPhi projection");
687 fHisto2dAllEventsv2->AddScene(fHisto2dAllEventss2);
688 fHisto2dAllEventsv2->SetElementName("RPhi Projection Viewer");
689 fHisto2dAllEventss2->SetElementName("RPhi Projection Scene");
3d94b490 690
691 TEveProjectionManager* mng1 = new TEveProjectionManager();
692 mng1->SetProjection(TEveProjection::kPT_RPhi);
693
4171aa4e 694 TEveProjectionAxes* axeghisto2dAllEventss1 = new TEveProjectionAxes(mng1);
695 fHisto2dAllEventss2->AddElement(axeghisto2dAllEventss1);
696 TEveCalo2D* fcalo2d1 = (TEveCalo2D*) mng1->ImportElements(fCalo3dAllEvents);
697 fHisto2dAllEventss2->AddElement(fcalo2d1);
3d94b490 698
4171aa4e 699 fHisto2dAllEventsv2->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
3d94b490 700 }
701
4171aa4e 702 if (fHisto2dAllEventsv3 == 0) {
3d94b490 703
704 slot2->MakeCurrent();
4171aa4e 705 fHisto2dAllEventsv3 = gEve->SpawnNewViewer("RhoZ projection", "RhoZ projection");
706 fHisto2dAllEventss3 = gEve->SpawnNewScene("RhoZ projection", "RhoZ projection");
707 fHisto2dAllEventsv3->AddScene(fHisto2dAllEventss3);
708 fHisto2dAllEventsv3->SetElementName("RhoZ Projection Viewer");
709 fHisto2dAllEventss3->SetElementName("RhoZ Projection Viewer");
3d94b490 710
711 TEveProjectionManager* mng2 = new TEveProjectionManager();
712 mng2->SetProjection(TEveProjection::kPT_RhoZ);
713
4171aa4e 714 TEveProjectionAxes* axeghisto2dAllEventss2 = new TEveProjectionAxes(mng2);
715 fHisto2dAllEventss3->AddElement(axeghisto2dAllEventss2);
716 TEveCalo2D* fcalo2d2 = (TEveCalo2D*) mng2->ImportElements(fCalo3dAllEvents);
717 fHisto2dAllEventss3->AddElement(fcalo2d2);
3d94b490 718
4171aa4e 719 fHisto2dAllEventsv3->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
3d94b490 720 }
721
722 return;
723}
724
725//______________________________________________________________________________
726TEveCaloDataHist* AliEveLego::LoadAllEvents()
727{
4171aa4e 728 // load all events data from ESD
729 if ( fHisto2dAllEventsSlot == 0 ) {
3d94b490 730
731 printf("Filling histogram...\n");
a096a7bf 732 TStopwatch timer;
733 timer.Start();
3d94b490 734
735 // Creating 2D histograms
4171aa4e 736 fHistoposAllEvents = new TH2F("fHistoposAllEvents","Histo 2d positive",
737 100,-1.5,1.5,80,-kPi,kPi);
738 fHistonegAllEvents = new TH2F("fHistonegAllEvents","Histo 2d negative",
739 100,-1.5,1.5,80,-kPi,kPi);
6e994a7b 740 fHistoElectronsAllEvents = new TH2F("fHistoElectronsAllEvents","Histo 2d electrons",
741 100,-1.5,1.5,80,-kPi,kPi);
742 fHistoMuonsAllEvents = new TH2F("fHistoMuonsAllEvents","Histo 2d muons",
743 100,-1.5,1.5,80,-kPi,kPi);
744 fHistoPionsAllEvents = new TH2F("fHistoPionsAllEvents","Histo 2d pions",
745 100,-1.5,1.5,80,-kPi,kPi);
746 fHistoKaonsAllEvents = new TH2F("fHistoKaonsAllEvents","Histo 2d kaons",
747 100,-1.5,1.5,80,-kPi,kPi);
748 fHistoProtonsAllEvents = new TH2F("fHistoProtonsAllEvents","Histo 2d protons",
749 100,-1.5,1.5,80,-kPi,kPi);
4171aa4e 750
751 fHistoposAllEvents->SetDirectory(0);
752 fHistonegAllEvents->SetDirectory(0);
6e994a7b 753 fHistoElectronsAllEvents->SetDirectory(0);
754 fHistoMuonsAllEvents->SetDirectory(0);
755 fHistoPionsAllEvents->SetDirectory(0);
756 fHistoKaonsAllEvents->SetDirectory(0);
757 fHistoProtonsAllEvents->SetDirectory(0);
758
759 // colors from get_pdg_color() in /alice-macros/kine_tracks.C
760 static Color_t fElectro = 5;
761 static Color_t fMuon = 30;
762 static Color_t fPion = 3;
763 static Color_t fKaon = 38;
764 static Color_t fProton = 10;
4171aa4e 765
766 fDataAllEvents = new TEveCaloDataHist();
767 fDataAllEvents->AddHistogram(fHistonegAllEvents);
768 fDataAllEvents->RefSliceInfo(0).Setup("NegCg:", 0, kBlue);
769 fDataAllEvents->AddHistogram(fHistoposAllEvents);
770 fDataAllEvents->RefSliceInfo(1).Setup("PosCg:", 0, kRed);
6e994a7b 771 fDataAllEvents->AddHistogram(fHistoElectronsAllEvents);
772 fDataAllEvents->RefSliceInfo(2).Setup("Electrons:", 0, fElectro);
773 fDataAllEvents->AddHistogram(fHistoMuonsAllEvents);
774 fDataAllEvents->RefSliceInfo(3).Setup("Muons:", 0, fMuon);
775 fDataAllEvents->AddHistogram(fHistoPionsAllEvents);
776 fDataAllEvents->RefSliceInfo(4).Setup("Pions:", 0, fPion);
777 fDataAllEvents->AddHistogram(fHistoKaonsAllEvents);
778 fDataAllEvents->RefSliceInfo(5).Setup("Kaons:", 0, fKaon);
779 fDataAllEvents->AddHistogram(fHistoProtonsAllEvents);
780 fDataAllEvents->RefSliceInfo(6).Setup("Protons:", 0, fProton);
781
4171aa4e 782 fDataAllEvents->GetEtaBins()->SetTitleFont(120);
783 fDataAllEvents->GetEtaBins()->SetTitle("h");
784 fDataAllEvents->GetPhiBins()->SetTitleFont(120);
785 fDataAllEvents->GetPhiBins()->SetTitle("f");
786 fDataAllEvents->IncDenyDestroy();
3d94b490 787
788 // Creating frames
4171aa4e 789 fHisto2dAllEventsSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
790 TEveWindowPack* packH = fHisto2dAllEventsSlot->MakePack();
3d94b490 791 packH->SetElementName("Projections");
792 packH->SetHorizontal();
793 packH->SetShowTitleBar(kFALSE);
794
4171aa4e 795 fHisto2dAllEventsSlot = packH->NewSlot();
796 TEveWindowPack* pack0 = fHisto2dAllEventsSlot->MakePack();
3d94b490 797 pack0->SetShowTitleBar(kFALSE);
798 TEveWindowSlot* slotLeftTop = pack0->NewSlot();
799 TEveWindowSlot* slotLeftBottom = pack0->NewSlot();
800
4171aa4e 801 fHisto2dAllEventsSlot = packH->NewSlot();
802 TEveWindowPack* pack1 = fHisto2dAllEventsSlot->MakePack();
3d94b490 803 pack1->SetShowTitleBar(kFALSE);
804 TEveWindowSlot* slotRightTop = pack1->NewSlot();
805 TEveWindowSlot* slotRightBottom = pack1->NewSlot();
806
807 // Creating viewers and scenes
808 Create3DView(slotLeftTop);
809 CreateHistoLego(slotLeftBottom);
810 CreateProjections(slotRightTop, slotRightBottom);
811
6e994a7b 812 FilterAllData();
3d94b490 813
814 gEve->Redraw3D(kTRUE);
815
816 printf("Filling histogram... Finished\n");
a096a7bf 817 timer.Stop();
818 timer.Print();
819
3d94b490 820 }
821
4171aa4e 822 return fDataAllEvents;
3d94b490 823}
824
6e994a7b 825//______________________________________________________________________________
826void AliEveLego::ApplyParticleTypeSelectionAE()
827{
828 // reload all events applying particle type selection
829 FilterAllData();
830}
831
3d94b490 832//______________________________________________________________________________
833Float_t AliEveLego::GetPtMax()
834{
6e994a7b 835 // return pT maximum
3d94b490 836 return fData->GetMaxVal(fLego->GetPlotEt());
837}
838
839//______________________________________________________________________________
840Float_t AliEveLego::GetPtMaxAE()
841{
6e994a7b 842 // return pT max from all events
4171aa4e 843 return fDataAllEvents->GetMaxVal(fLegoAllEvents->GetPlotEt());
3d94b490 844}
845
6e994a7b 846//______________________________________________________________________________
847Int_t AliEveLego::GetParticleType(AliESDtrack *track)
848{
849 // determine the particle type
850 Double_t *prob = new Double_t[5];
851 track->GetESDpid(prob);
852
853 Double_t max = prob[0];
854 Int_t index = 0;
855
856 for (Int_t i = 1 ; i < 5; i++)
857 {
858 if (prob[i] > max){
859 max = prob[i];
860 index = i;
861 }
862 }
863 return index;
864}
865
866//______________________________________________________________________________
867void AliEveLego::SetParticleType(Int_t id)
868{
869 // activate/deactivate particles types
870 if (fParticleTypeId[id] == 0)
871 {
872 fParticleTypeId[id] = 1;
873 } else {
874 fParticleTypeId[id] = 0;
875 }
876
877 Update();
878}
879
880//______________________________________________________________________________
881void AliEveLego::SetParticleTypeAE(Int_t id)
882{
883 // activate/deactivate particles types
884 if (fParticleTypeIdAE[id] == 0)
885 {
886 fParticleTypeIdAE[id] = 1;
887 } else {
888 fParticleTypeIdAE[id] = 0;
889 }
890}
891
3d94b490 892//______________________________________________________________________________
893void AliEveLego::SetMaxPt(Double_t val)
894{
895 // Add new maximum
896 fMaxPt = val;
897 Update();
898}
899
900//______________________________________________________________________________
901void AliEveLego::SetMaxPtAE(Double_t val)
902{
903 // Add new maximum
904 fMaxPtAE = val;
905 FilterAllData();
906}
907
908//______________________________________________________________________________
909void AliEveLego::SetThreshold(Double_t val)
910{
911 // Setting up the new threshold for all histograms
912 fData->SetSliceThreshold(0,val);
913 fData->SetSliceThreshold(1,val);
6e994a7b 914 fData->SetSliceThreshold(2,val);
915 fData->SetSliceThreshold(3,val);
916 fData->SetSliceThreshold(4,val);
917 fData->SetSliceThreshold(5,val);
918 fData->SetSliceThreshold(6,val);
3d94b490 919 fData->DataChanged();
920
921 gEve->Redraw3D(kTRUE);
922}
923
924//______________________________________________________________________________
925void AliEveLego::SetThresholdAE(Double_t val)
926{
927 // Setting up the new threshold for all histograms
4171aa4e 928 fDataAllEvents->SetSliceThreshold(0,val);
929 fDataAllEvents->SetSliceThreshold(1,val);
6e994a7b 930 fDataAllEvents->SetSliceThreshold(2,val);
931 fDataAllEvents->SetSliceThreshold(3,val);
932 fDataAllEvents->SetSliceThreshold(4,val);
933 fDataAllEvents->SetSliceThreshold(5,val);
934 fDataAllEvents->SetSliceThreshold(6,val);
4171aa4e 935 fDataAllEvents->DataChanged();
3d94b490 936
937 gEve->Redraw3D(kTRUE);
938}
939
940//______________________________________________________________________________
6e994a7b 941void AliEveLego::SwitchDataType()
3d94b490 942{
6e994a7b 943 // activate/deactivate MC / real data type
944 if (fIsMC == 0)
945 {
946 fIsMC = 1;
947 } else {
948 fIsMC = 0;
949 }
950 //Removing defaul physics selection
3d94b490 951
6e994a7b 952 delete fPhysicsSelection;
953 fPhysicsSelection = NULL;
3d94b490 954
6e994a7b 955 fPhysicsSelection = new AliPhysicsSelection();
956 fPhysicsSelection->SetAnalyzeMC(fIsMC);
957 fPhysicsSelection->Initialize(fEsd->GetRunNumber());
958 FilterAllData();
3d94b490 959}
960
961//______________________________________________________________________________
6e994a7b 962void AliEveLego::SetCollisionCandidatesOnly()
3d94b490 963{
6e994a7b 964 // activate/deactivate MC / real data type
965 if (fCollisionCandidatesOnly == 0)
966 {
967 fCollisionCandidatesOnly = 1;
968 } else {
969 fCollisionCandidatesOnly = 0;
970 }
971 FilterAllData();
3d94b490 972}
973
3d94b490 974/******************************************************************************/
975
976