]>
Commit | Line | Data |
---|---|---|
e18ce6a3 | 1 | // Author: Stefano Carrazza 2010 |
2 | ||
e516f157 | 3 | /************************************************************************** |
4 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
5 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
6 | * full copyright notice. * | |
7 | **************************************************************************/ | |
8 | ||
9 | double pi = TMath::Pi(); | |
bfd5d6c1 | 10 | TEveViewer *g_histo2d_v = 0; |
11 | TEveScene *g_histo2d_s = 0; | |
12 | TEveScene *g_histo2d_s2 = 0; | |
13 | TEveCaloLegoOverlay* g_histo2d_lego_overlay = 0; | |
e516f157 | 14 | |
15 | ||
16 | TEveCaloDataHist* histo2d() | |
bfd5d6c1 | 17 | { |
e516f157 | 18 | |
19 | // Access to esdTree | |
20 | AliESDEvent* esd = AliEveEventManager::AssertESD(); | |
21 | ||
22 | // Creating 2D histograms | |
23 | TH2F *histopos = new TH2F("histopos","Histo 2d positive",100,-1.5,1.5,80,-pi,pi); | |
24 | TH2F *histoneg = new TH2F("histoneg","Histo 2d negative",100,-1.5,1.5,80,-pi,pi); | |
25 | ||
26 | cout<<"Event: "<<AliEveEventManager::GetMaster()->GetEventId() | |
27 | <<", Number of tracks: "<<esd->GetNumberOfTracks()<<endl; | |
28 | ||
29 | // Getting current tracks, filling histograms | |
e18ce6a3 | 30 | for ( int n = 0; n < esd->GetNumberOfTracks(); ++n ) { |
e516f157 | 31 | |
32 | if (esd->GetTrack(n)->GetSign() > 0) { | |
33 | histopos->Fill(esd->GetTrack(n)->Eta(), | |
e18ce6a3 | 34 | GetPhi(esd->GetTrack(n)->Phi()), |
e516f157 | 35 | fabs(esd->GetTrack(n)->Pt())); |
36 | } else { | |
37 | histoneg->Fill(esd->GetTrack(n)->Eta(), | |
e18ce6a3 | 38 | GetPhi(esd->GetTrack(n)->Phi()), |
e516f157 | 39 | fabs(esd->GetTrack(n)->Pt())); |
40 | } | |
41 | } | |
42 | ||
43 | TEveCaloDataHist* data = new TEveCaloDataHist(); | |
44 | AliEveEventManager::RegisterTransient(data); | |
45 | ||
46 | data->AddHistogram(histoneg); | |
47 | data->RefSliceInfo(0).Setup("NegCg:", 0, kBlue); | |
48 | data->AddHistogram(histopos); | |
49 | data->RefSliceInfo(1).Setup("PosCg:", 0, kRed); | |
50 | data->GetEtaBins()->SetTitleFont(120); | |
51 | data->GetEtaBins()->SetTitle("h"); | |
52 | data->GetPhiBins()->SetTitleFont(120); | |
53 | data->GetPhiBins()->SetTitle("f"); | |
54 | data->IncDenyDestroy(); | |
55 | ||
56 | // Plotting the lego histogram in a new tab | |
e18ce6a3 | 57 | CreateHistoLego(data); |
e516f157 | 58 | |
59 | // Plotting the 3D histogram | |
e18ce6a3 | 60 | TEveCalo3D *calo3d = Create3DView(data); |
e516f157 | 61 | |
62 | // Plotting projections RPhi and RhoZ | |
e18ce6a3 | 63 | CreateProjections(data, calo3d); |
e516f157 | 64 | |
65 | gEve->Redraw3D(kTRUE); | |
66 | ||
67 | return data; | |
68 | } | |
69 | ||
70 | //______________________________________________________________________________ | |
e18ce6a3 | 71 | Double_t GetPhi(Double_t phi) |
e516f157 | 72 | { |
73 | if (phi > pi) { | |
74 | phi -= 2*pi; | |
75 | } | |
76 | return phi; | |
77 | } | |
78 | ||
79 | //______________________________________________________________________________ | |
e18ce6a3 | 80 | TEveCaloLego* CreateHistoLego(TEveCaloData* data){ |
e516f157 | 81 | |
82 | TGLViewer* glv; | |
83 | ||
84 | // Viewer initialization, tab creation | |
e18ce6a3 | 85 | if ( g_histo2d_v == 0 ) { |
e516f157 | 86 | TEveWindowSlot *slot = 0; |
87 | TEveBrowser *browser = gEve->GetBrowser(); | |
88 | ||
89 | slot = TEveWindow::CreateWindowInTab(browser->GetTabRight()); | |
90 | slot->MakeCurrent(); | |
bfd5d6c1 | 91 | g_histo2d_v = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram"); |
92 | g_histo2d_s = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram"); | |
93 | g_histo2d_v->AddScene(g_histo2d_s); | |
94 | g_histo2d_v->SetElementName("2D Lego Viewer"); | |
95 | g_histo2d_s->SetElementName("2D Lego Scene"); | |
96 | ||
97 | glv = g_histo2d_v->GetGLViewer(); | |
98 | g_histo2d_lego_overlay = new TEveCaloLegoOverlay(); | |
99 | glv->AddOverlayElement(g_histo2d_lego_overlay); | |
e516f157 | 100 | glv->SetCurrentCamera(TGLViewer::kCameraPerspXOY); |
101 | } else { | |
bfd5d6c1 | 102 | glv = g_histo2d_v->GetGLViewer(); |
e516f157 | 103 | } |
104 | ||
105 | //plotting histo | |
106 | TEveCaloLego* lego = new TEveCaloLego(data); | |
bfd5d6c1 | 107 | g_histo2d_s->AddElement(lego); |
e516f157 | 108 | AliEveEventManager::RegisterTransient(lego); |
109 | ||
110 | // move to real world coordinates | |
111 | lego->InitMainTrans(); | |
112 | Float_t sc = TMath::Min(lego->GetEtaRng(), lego->GetPhiRng()); | |
113 | lego->RefMainTrans().SetScale(sc, sc, sc); | |
114 | ||
115 | // set event handler to move from perspective to orthographic view. | |
116 | glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego)); | |
117 | ||
bfd5d6c1 | 118 | g_histo2d_lego_overlay->SetCaloLego(lego); |
e516f157 | 119 | |
120 | return lego; | |
121 | } | |
122 | ||
123 | //______________________________________________________________________________ | |
e18ce6a3 | 124 | TEveCalo3D* Create3DView(TEveCaloData* data){ |
e516f157 | 125 | |
126 | //initialization | |
e18ce6a3 | 127 | if ( g_histo2d_s2 == 0 ) { |
bfd5d6c1 | 128 | g_histo2d_s2 = gEve->SpawnNewScene("3D Histogram", "3D Histogram"); |
129 | gEve->GetDefaultViewer()->AddScene(g_histo2d_s2); | |
130 | g_histo2d_s2->SetElementName("3D Histogram Scene"); | |
e516f157 | 131 | } |
132 | ||
133 | TEveCalo3D* calo3d = new TEveCalo3D(data); | |
134 | AliEveEventManager::RegisterTransient(calo3d); | |
135 | ||
136 | calo3d->SetBarrelRadius(550); | |
137 | calo3d->SetEndCapPos(550); | |
bfd5d6c1 | 138 | g_histo2d_s2->AddElement(calo3d); |
e516f157 | 139 | |
140 | return calo3d; | |
141 | } | |
142 | ||
143 | //______________________________________________________________________________ | |
e18ce6a3 | 144 | AliEveMultiView* CreateProjections(TEveCaloData* data, TEveCalo3D *calo3d){ |
e516f157 | 145 | |
146 | AliEveMultiView *al = AliEveMultiView::Instance(); | |
147 | al->ImportEventRPhi(calo3d); | |
148 | al->ImportEventRhoZ(calo3d); | |
149 | ||
150 | return al; | |
151 | } |