]>
Commit | Line | Data |
---|---|---|
e516f157 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
3 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
4 | * full copyright notice. * | |
5 | **************************************************************************/ | |
6 | ||
7 | double pi = TMath::Pi(); | |
8 | TEveViewer *v_0 = 0; | |
9 | TEveViewer *v_1 = 0; | |
10 | TEveViewer *v_2 = 0; | |
11 | TEveViewer *v_3 = 0; | |
12 | TEveScene *s_0 = 0; | |
13 | TEveScene *s_1 = 0; | |
14 | TEveScene *s_2 = 0; | |
15 | TEveScene *s_3 = 0; | |
16 | TEveCaloLegoOverlay* lego_overlay_t = 0; | |
17 | TEveWindowSlot* slot_t = 0; | |
18 | ||
19 | ||
20 | TEveCaloDataHist* histo2d_all_events() | |
21 | { | |
22 | ||
23 | TEveCaloDataHist* data_t; | |
24 | ||
25 | if(slot_t == 0){ | |
26 | cout<<"Filling histogram..."<<endl; | |
27 | ||
28 | // Access to esdTree | |
29 | AliESDEvent* esd = AliEveEventManager::AssertESD(); | |
30 | TTree* t = AliEveEventManager::GetMaster()->GetESDTree(); | |
31 | ||
32 | // Creating 2D histograms | |
33 | TH2F *histopos_t = new TH2F("histopos_t","Histo 2d positive", | |
34 | 100,-1.5,1.5,80,-pi,pi); | |
35 | TH2F *histoneg_t = new TH2F("histoneg_t","Histo 2d negative", | |
36 | 100,-1.5,1.5,80,-pi,pi); | |
37 | ||
38 | // Getting current tracks for each event, filling histograms | |
39 | for (int event = 0; event < t->GetEntries(); event++) { | |
40 | t->GetEntry(event); | |
41 | for (int n = 0; n < esd->GetNumberOfTracks(); ++n) { | |
42 | ||
43 | if (esd->GetTrack(n)->GetSign() > 0) { | |
44 | histopos_t->Fill(esd->GetTrack(n)->Eta(), | |
45 | getphi(esd->GetTrack(n)->Phi()), | |
46 | fabs(esd->GetTrack(n)->Pt())); | |
47 | } else { | |
48 | histoneg_t->Fill(esd->GetTrack(n)->Eta(), | |
49 | getphi(esd->GetTrack(n)->Phi()), | |
50 | fabs(esd->GetTrack(n)->Pt())); | |
51 | } | |
52 | } | |
53 | } | |
54 | ||
55 | data_t = new TEveCaloDataHist(); | |
56 | data_t->AddHistogram(histoneg_t); | |
57 | data_t->RefSliceInfo(0).Setup("NegCg:", 0, kBlue); | |
58 | data_t->AddHistogram(histopos_t); | |
59 | data_t->RefSliceInfo(1).Setup("PosCg:", 0, kRed); | |
60 | data_t->GetEtaBins()->SetTitleFont(120); | |
61 | data_t->GetEtaBins()->SetTitle("h"); | |
62 | data_t->GetPhiBins()->SetTitleFont(120); | |
63 | data_t->GetPhiBins()->SetTitle("f"); | |
64 | data_t->IncDenyDestroy(); | |
65 | ||
66 | // Creating frames | |
67 | slot_t = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); | |
68 | TEveWindowPack* packH = slot_t->MakePack(); | |
69 | packH->SetElementName("Projections"); | |
70 | packH->SetHorizontal(); | |
71 | packH->SetShowTitleBar(kFALSE); | |
72 | ||
73 | slot_t = packH->NewSlot(); | |
74 | TEveWindowPack* pack0 = slot_t->MakePack(); | |
75 | pack0->SetShowTitleBar(kFALSE); | |
76 | TEveWindowSlot* slotLeftTop = pack0->NewSlot(); | |
77 | TEveWindowSlot* slotLeftBottom = pack0->NewSlot(); | |
78 | ||
79 | slot_t = packH->NewSlot(); | |
80 | TEveWindowPack* pack1 = slot_t->MakePack(); | |
81 | pack1->SetShowTitleBar(kFALSE); | |
82 | TEveWindowSlot* slotRightTop = pack1->NewSlot(); | |
83 | TEveWindowSlot* slotRightBottom = pack1->NewSlot(); | |
84 | ||
85 | // Creating viewers and scenes | |
86 | TEveCalo3D* calo3d = Create_3D_view(data_t, slotLeftTop); | |
87 | Create_histo_lego(data_t, slotLeftBottom); | |
88 | Create_projections(data_t, calo3d, slotRightTop, slotRightBottom); | |
89 | ||
90 | gEve->Redraw3D(kTRUE); | |
91 | ||
92 | cout<<"Filling histogram... Finished"<<endl; | |
93 | } | |
94 | ||
95 | return data_t; | |
96 | } | |
97 | ||
98 | //______________________________________________________________________________ | |
99 | Double_t getphi(Double_t phi) | |
100 | { | |
101 | if (phi > pi) { | |
102 | phi -= 2*pi; | |
103 | } | |
104 | return phi; | |
105 | } | |
106 | ||
107 | //______________________________________________________________________________ | |
108 | TEveCaloLego* Create_histo_lego(TEveCaloData* data, TEveWindowSlot* slot){ | |
109 | ||
110 | TEveCaloLego* lego; | |
111 | ||
112 | // Viewer initialization, tab creation | |
113 | if (v_0 == 0) { | |
114 | ||
115 | TEveBrowser *browser = gEve->GetBrowser(); | |
116 | slot->MakeCurrent(); | |
117 | v_0 = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram"); | |
118 | s_0 = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram"); | |
119 | v_0->AddScene(s_0); | |
120 | v_0->SetElementName("2D Lego Viewer"); | |
121 | s_0->SetElementName("2D Lego Scene"); | |
122 | ||
123 | TGLViewer* glv = v_0->GetGLViewer(); | |
124 | lego_overlay_t = new TEveCaloLegoOverlay(); | |
125 | glv->AddOverlayElement(lego_overlay_t); | |
126 | glv->SetCurrentCamera(TGLViewer::kCameraPerspXOY); | |
127 | ||
128 | // Plotting histogram lego | |
129 | lego = new TEveCaloLego(data); | |
130 | s_0->AddElement(lego); | |
131 | ||
132 | // Move to real world coordinates | |
133 | lego->InitMainTrans(); | |
134 | Float_t sc = TMath::Min(lego->GetEtaRng(), lego->GetPhiRng()); | |
135 | lego->RefMainTrans().SetScale(sc, sc, sc); | |
136 | ||
137 | // Set event handler to move from perspective to orthographic view. | |
138 | glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego)); | |
139 | ||
140 | lego_overlay_t->SetCaloLego(lego); | |
141 | } | |
142 | ||
143 | return lego; | |
144 | } | |
145 | ||
146 | //______________________________________________________________________________ | |
147 | TEveCalo3D* Create_3D_view(TEveCaloData* data, TEveWindowSlot* slot){ | |
148 | ||
149 | TEveCalo3D* calo3d; | |
150 | ||
151 | if (v_1 == 0) { | |
152 | ||
153 | TEveBrowser *browser = gEve->GetBrowser(); | |
154 | slot->MakeCurrent(); | |
155 | v_1 = gEve->SpawnNewViewer("3D Histogram", "3D Histogram"); | |
156 | s_1 = gEve->SpawnNewScene("3D Histogram", "3D Histogram"); | |
157 | v_1->AddScene(s_1); | |
158 | v_1->SetElementName("3D Histogram Viewer"); | |
159 | s_1->SetElementName("3D Histogram Scene"); | |
160 | ||
161 | calo3d = new TEveCalo3D(data); | |
162 | ||
163 | calo3d->SetBarrelRadius(550); | |
164 | calo3d->SetEndCapPos(550); | |
165 | s_1->AddElement(calo3d); | |
166 | } | |
167 | ||
168 | return calo3d; | |
169 | } | |
170 | ||
171 | //______________________________________________________________________________ | |
172 | void Create_projections(TEveCaloData* data, TEveCalo3D *calo3d, TEveWindowSlot* slot1, TEveWindowSlot* slot2){ | |
173 | ||
174 | if (v_2 == 0) { | |
175 | ||
176 | TEveBrowser *browser = gEve->GetBrowser(); | |
177 | slot1->MakeCurrent(); | |
178 | v_2 = gEve->SpawnNewViewer("RPhi projection", "RPhi projection"); | |
179 | s_2 = gEve->SpawnNewScene("RPhi projection", "RPhi projection"); | |
180 | v_2->AddScene(s_2); | |
181 | v_2->SetElementName("RPhi Projection Viewer"); | |
182 | s_2->SetElementName("RPhi Projection Scene"); | |
183 | ||
184 | TEveProjectionManager* mng1 = new TEveProjectionManager(); | |
185 | mng1->SetProjection(TEveProjection::kPT_RPhi); | |
186 | ||
187 | TEveProjectionAxes* axes_1 = new TEveProjectionAxes(mng1); | |
188 | s_2->AddElement(axes_1); | |
189 | TEveCalo2D* calo2d1 = (TEveCalo2D*) mng1->ImportElements(calo3d); | |
190 | s_2->AddElement(calo2d1); | |
191 | ||
192 | v_2->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); | |
193 | } | |
194 | ||
195 | if (v_3 == 0) { | |
196 | ||
197 | TEveBrowser *browser = gEve->GetBrowser(); | |
198 | slot2->MakeCurrent(); | |
199 | v_3 = gEve->SpawnNewViewer("RhoZ projection", "RhoZ projection"); | |
200 | s_3 = gEve->SpawnNewScene("RhoZ projection", "RhoZ projection"); | |
201 | v_3->AddScene(s_3); | |
202 | v_3->SetElementName("RhoZ Projection Viewer"); | |
203 | s_3->SetElementName("RhoZ Projection Viewer"); | |
204 | ||
205 | TEveProjectionManager* mng2 = new TEveProjectionManager(); | |
206 | mng2->SetProjection(TEveProjection::kPT_RhoZ); | |
207 | ||
208 | TEveProjectionAxes* axes_2 = new TEveProjectionAxes(mng2); | |
209 | s_3->AddElement(axes_2); | |
210 | TEveCalo2D* calo2d2 = (TEveCalo2D*) mng2->ImportElements(calo3d); | |
211 | s_3->AddElement(calo2d2); | |
212 | ||
213 | v_3->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); | |
214 | } | |
215 | ||
216 | return; | |
217 | } |