Removing a circular dependence.
[u/mrichter/AliRoot.git] / EVE / macros / visscan_init.C
CommitLineData
20dae051 1// $Id$
e9b9f7d2 2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
20dae051 10class AliEveMacroExecutor;
11
e9b9f7d2 12class TEveProjectionManager;
13class TEveGeoShape;
14class TEveUtil;
15
5e078eda 16TEveGeoShape *gGeomGentle = 0;
17TEveGeoShape *gGeomGentleRPhi = 0;
18TEveGeoShape *gGeomGentleRhoZ = 0;
19TEveGeoShape *gGeomGentleTRD = 0;
20dae051 20TEveGeoShape *gGeomGentleMUON = 0;
21
22TEveScene *gRPhiGeomScene = 0;
23TEveScene *gRhoZGeomScene = 0;
24TEveScene *gRPhiEventScene = 0;
25TEveScene *gRhoZEventScene = 0;
26
27TEveProjectionManager *gRPhiMgr = 0;
28TEveProjectionManager *gRhoZMgr = 0;
29
30TEveViewer *g3DView = 0;
31TEveViewer *gRPhiView = 0;
32TEveViewer *gRhoZView = 0;
503bfbc8 33
20dae051 34Bool_t gShowTRD = kFALSE;
35Bool_t gShowMUON = kTRUE;
36Bool_t gShowMUONRPhi = kFALSE;
115b6655 37Bool_t gShowMUONRhoZ = kTRUE;
20dae051 38
39Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
e9b9f7d2 40
115b6655 41void visscan_init(Bool_t show_extra_geo=kFALSE)
e9b9f7d2 42{
115b6655 43 if (!show_extra_geo)
44 {
45 gShowTRD = gShowMUON = gShowMUONRPhi = gShowMUONRhoZ = kFALSE;
46 }
47
f8d5a389 48 AliEveEventManager::AddAODfriend("AliAOD.VertexingHF.root");
49
e9b9f7d2 50 TEveUtil::LoadMacro("alieve_init.C");
20dae051 51 alieve_init(".", -1);
e9b9f7d2 52
20dae051 53 // TEveLine::SetDefaultSmooth(1);
e9b9f7d2 54
20dae051 55 TEveUtil::AssertMacro("VizDB_scan.C");
56
57 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
58 TEveBrowser *browser = gEve->GetBrowser();
59
60 //==============================================================================
61 // Geometry, scenes, projections and viewers
62 //==============================================================================
63
64 browser->ShowCloseTab(kFALSE);
e9b9f7d2 65
68ca2fe7 66 // Geometry
20dae051 67
f6afd0e1 68 TEveUtil::LoadMacro("geom_gentle.C");
20dae051 69 gGeomGentle = geom_gentle();
5e078eda 70 gGeomGentleRPhi = geom_gentle_rphi(); gGeomGentleRPhi->IncDenyDestroy();
71 gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();
f6afd0e1 72 if (gShowTRD) {
73 TEveUtil::LoadMacro("geom_gentle_trd.C");
74 gGeomGentleTRD = geom_gentle_trd();
75 }
20dae051 76 if (gShowMUON) {
77 TEveUtil::LoadMacro("geom_gentle_muon.C");
ae8fef5f 78 gGeomGentleMUON = geom_gentle_muon(kFALSE);
20dae051 79 }
f6afd0e1 80
20dae051 81 // Scenes
68ca2fe7 82
20dae051 83 gRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",
84 "Scene holding projected geometry for the RPhi view.");
85 gRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",
86 "Scene holding projected geometry for the RhoZ view.");
87 gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
88 "Scene holding projected geometry for the RPhi view.");
89 gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
90 "Scene holding projected geometry for the RhoZ view.");
f6afd0e1 91
20dae051 92 // Projection managers
f6afd0e1 93
20dae051 94 gRPhiMgr = new TEveProjectionManager();
95 gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);
96 gEve->AddToListTree(gRPhiMgr, kFALSE);
97 {
68ca2fe7 98 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);
99 a->SetMainColor(kWhite);
100 a->SetTitle("R-Phi");
101 a->SetTitleSize(0.05);
115b6655 102 a->SetTitleFont(102);
68ca2fe7 103 a->SetLabelSize(0.025);
115b6655 104 a->SetLabelFont(102);
20dae051 105 gRPhiGeomScene->AddElement(a);
68ca2fe7 106 }
9851a663 107 gRPhiMgr->SetCurrentDepth(-10);
20dae051 108 gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);
9851a663 109 gRPhiMgr->SetCurrentDepth(0);
20dae051 110 if (gShowTRD) gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);
111 if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);
112
113 gRhoZMgr = new TEveProjectionManager();
114 gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);
115 gEve->AddToListTree(gRhoZMgr, kFALSE);
116 {
68ca2fe7 117 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);
118 a->SetMainColor(kWhite);
119 a->SetTitle("Rho-Z");
120 a->SetTitleSize(0.05);
115b6655 121 a->SetTitleFont(102);
68ca2fe7 122 a->SetLabelSize(0.025);
115b6655 123 a->SetLabelFont(102);
20dae051 124 gRhoZGeomScene->AddElement(a);
68ca2fe7 125 }
9851a663 126 gRhoZMgr->SetCurrentDepth(-10);
20dae051 127 gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);
9851a663 128 gRhoZMgr->SetCurrentDepth(0);
20dae051 129 if (gShowTRD) gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);
130 if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);
131
132 // Viewers
133
134 TEveWindowSlot *slot = 0;
135 TEveWindowPack *pack = 0;
136
137 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
138 pack = slot->MakePack();
139 pack->SetElementName("Multi View");
140 pack->SetHorizontal();
141 pack->SetShowTitleBar(kFALSE);
142 pack->NewSlot()->MakeCurrent();
143 g3DView = gEve->SpawnNewViewer("3D View", "");
144 g3DView->AddScene(gEve->GetGlobalScene());
145 g3DView->AddScene(gEve->GetEventScene());
146
147 pack = pack->NewSlot()->MakePack();
148 pack->SetShowTitleBar(kFALSE);
149 pack->NewSlot()->MakeCurrent();
150 gRPhiView = gEve->SpawnNewViewer("RPhi View", "");
151 gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
152 gRPhiView->AddScene(gRPhiGeomScene);
153 gRPhiView->AddScene(gRPhiEventScene);
154
155 pack->NewSlot()->MakeCurrent();
156 gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
157 gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
158 gRhoZView->AddScene(gRhoZGeomScene);
159 gRhoZView->AddScene(gRhoZEventScene);
160
161
162 //==============================================================================
163 // Registration of per-event macros
164 //==============================================================================
165
166 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track", "kine_tracks.C", "kine_tracks", "", kFALSE));
167
168 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit ITS", "its_hits.C", "its_hits", "", kFALSE));
169 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit TPC", "tpc_hits.C", "tpc_hits", "", kFALSE));
170 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit T0", "t0_hits.C", "t0_hits", "", kFALSE));
171 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit FMD", "fmd_hits.C", "fmd_hits", "", kFALSE));
172
173 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD", "fmd_digits.C", "fmd_digits", "", kFALSE));
174
175 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC", "tpc_raw.C", "tpc_raw", "", kFALSE));
176 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW T0", "t0_raw.C", "t0_raw", "", kFALSE));
177 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD", "fmd_raw.C", "fmd_raw", "", kFALSE));
178 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO", "vzero_raw.C", "vzero_raw", "", kFALSE));
179 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE", "acorde_raw.C", "acorde_raw", "", kFALSE));
180
181 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex", "", kTRUE));
182 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse", "", kTRUE));
183 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box", "kFALSE, 3, 3, 3", kFALSE));
184 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_spd", "", kTRUE));
185 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "", kTRUE));
186 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
187 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_tpc", "", kFALSE));
188 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "", kFALSE));
189 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_tpc", "kFALSE, 3, 3, 3", kFALSE));
190
191 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0_points.C", "esd_V0_points_onfly"));
192 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0_points.C", "esd_V0_points_offline"));
193 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0.C", "esd_V0"));
194 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade_points.C", "esd_cascade_points"));
195 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade.C", "esd_cascade"));
4711ad43 196 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink_points.C", "esd_kink_points"));
197 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink.C", "esd_kink"));
20dae051 198
199 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks", "", kFALSE));
200 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI", "", kFALSE));
201 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
202
203 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklet", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kFALSE));
204
205 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC", "esd_zdc.C", "esd_zdc", "", kFALSE));
206
207 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus", "clusters.C+", "clusters", "", kFALSE));
208 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS", "its_clusters.C+", "its_clusters"));
209 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "tpc_clusters.C+", "tpc_clusters"));
210 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TRD", "trd_clusters.C+", "trd_clusters"));
211 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF", "tof_clusters.C+", "tof_clusters"));
212
08b0f222 213 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "vplot_tpc.C+", "vplot_tpc", "", kFALSE));
214
f8d5a389 215 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA HF", "aod_HF.C", "aod_HF", "", kFALSE));
08b0f222 216 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
20dae051 217
218 //==============================================================================
219 // Additional GUI components
220 //==============================================================================
221
222 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
223 slot->StartEmbedding();
224 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
225 slot->StopEmbedding("DataSelection");
226 exewin->PopulateMacros();
227
228 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
229 slot->StartEmbedding();
230 new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
231 slot->StopEmbedding("QA histograms");
232
233 browser->GetTabRight()->SetTab(1);
234
235 browser->StartEmbedding(TRootBrowser::kBottom);
236 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
237 browser->StopEmbedding("EventCtrl");
238
239 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
240 TEveWindowTab *store_tab = slot->MakeTab();
241 store_tab->SetElementNameTitle("WindowStore",
242 "Undocked windows whose previous container is not known\n"
243 "are placed here when the main-frame is closed.");
244 gEve->GetWindowManager()->SetDefaultContainer(store_tab);
68ca2fe7 245
20dae051 246 //==============================================================================
247 // AliEve objects - global tools
248 //==============================================================================
249
250 AliEveTrackFitter* fitter = new AliEveTrackFitter();
251 gEve->AddToListTree(fitter, 1);
252 gEve->AddElement(fitter, gEve->GetEventScene());
253
254 AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
255 gEve->AddToListTree(g_trkcnt, kFALSE);
256
257
258 //==============================================================================
259 // Final stuff
260 //==============================================================================
261
262 // A refresh to show proper window.
263 gEve->Redraw3D(kTRUE);
264 gSystem->ProcessEvents();
265
266 // Register command to call on each event.
4d62585e 267 AliEveEventManager::GetMaster()->AddNewEventCommand("on_new_event();");
268 AliEveEventManager::GetMaster()->GotoEvent(0);
e9b9f7d2 269
ca49b003 270 gEve->EditElement(g_trkcnt);
271
e9b9f7d2 272 gEve->Redraw3D(kTRUE);
273}
274
275/******************************************************************************/
276
277void on_new_event()
278{
f76c9e9b 279 AliEveTrackCounter* g_trkcnt = AliEveTrackCounter::fgInstance;
e9b9f7d2 280 g_trkcnt->Reset();
4d62585e 281 g_trkcnt->SetEventId(AliEveEventManager::GetMaster()->GetEventId());
29207369 282
20dae051 283 if (g_esd_tracks_by_category_container != 0)
df56539f 284 {
20dae051 285 TEveElementList* cont = g_esd_tracks_by_category_container;
286
287 // Here we expect several TEveTrackList containers.
288 // First two have reasonable primaries (sigma-to-prim-vertex < 5).
289 // Others are almost certainly secondaries.
290 Int_t count = 1;
291 TEveElement::List_i i = cont->BeginChildren();
292 while (i != cont->EndChildren())
29207369 293 {
20dae051 294 TEveTrackList* l = dynamic_cast<TEveTrackList*>(*i);
295 if (l != 0)
296 {
297 g_trkcnt->RegisterTracks(l, (count <= 2));
298 ++count;
299 }
300 ++i;
e9b9f7d2 301 }
20dae051 302
303 // Set it to zero, so that we do not reuse an old one.
304 g_esd_tracks_by_category_container = 0;
305 }
306 else
307 {
308 Warning("on_new_event", "g_esd_tracks_by_category_container not initialized.");
e9b9f7d2 309 }
310
20dae051 311 Double_t x[3] = { 0, 0, 0 };
312
313 if (AliEveEventManager::HasESD())
a27140cb 314 {
20dae051 315 AliESDEvent* esd = AliEveEventManager::AssertESD();
316 esd->GetPrimaryVertex()->GetXYZ(x);
317
a27140cb 318 TTimeStamp ts(esd->GetTimeStamp());
319 TString win_title("Eve Main Window -- Timestamp: ");
320 win_title += ts.AsString("s");
5858bcbe 321 win_title += "; Event # in ESD file: ";
a27140cb 322 win_title += esd->GetEventNumberInFile();
323 gEve->GetBrowser()->SetWindowName(win_title);
324 }
e9b9f7d2 325
326 TEveElement* top = gEve->GetCurrentEvent();
327
20dae051 328 if (gRPhiMgr && top)
329 {
330 gRPhiEventScene->DestroyElements();
331 if (gCenterProjectionsAtPrimaryVertex)
332 gRPhiMgr->SetCenter(x[0], x[1], x[2]);
333 gRPhiMgr->ImportElements(top, gRPhiEventScene);
e9b9f7d2 334 }
20dae051 335 if (gRhoZMgr && top)
336 {
337 gRhoZEventScene->DestroyElements();
338 if (gCenterProjectionsAtPrimaryVertex)
339 gRhoZMgr->SetCenter(x[0], x[1], x[2]);
340 gRhoZMgr->ImportElements(top, gRhoZEventScene);
e9b9f7d2 341 }
e9b9f7d2 342}