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