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