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