Make sure that 3D view rotates around origin.
[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;
e9b9f7d2 11class TEveProjectionManager;
12class TEveGeoShape;
13class TEveUtil;
4f222c66 14class TSystem;
15class TInterpreter;
e9b9f7d2 16
20dae051 17
3545fba9 18Bool_t gShowMuonRPhi = kFALSE;
19Bool_t gShowMuonRhoZ = kTRUE;
20dae051 20
21Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
e9b9f7d2 22
c63f2997 23
24void visscan_init(const TString& cdburi = "",
4f222c66 25 const TString& path = ".",
26 Bool_t showMuon = kTRUE,
27 Bool_t showTrd = kFALSE)
e9b9f7d2 28{
4f222c66 29
30 if (showMuon)
31 {
32 if (gSystem->Getenv("ALICE_ROOT") != 0)
33 {
34 gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
35 gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
36 }
37 }
38 else
39 {
40 gShowMuonRPhi = gShowMuonRhoZ = kFALSE;
41 }
42
c63f2997 43 if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
44 {
45 gEnv->SetValue("Root.Stacktrace", "no");
46 Fatal("visscan_init.C", "OCDB path MUST be specified as the first argument.");
47 }
48
f8d5a389 49 AliEveEventManager::AddAODfriend("AliAOD.VertexingHF.root");
50
e9b9f7d2 51 TEveUtil::LoadMacro("alieve_init.C");
c63f2997 52 alieve_init(cdburi, path, -1);
e9b9f7d2 53
20dae051 54 // TEveLine::SetDefaultSmooth(1);
e9b9f7d2 55
20dae051 56 TEveUtil::AssertMacro("VizDB_scan.C");
57
58 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
59 TEveBrowser *browser = gEve->GetBrowser();
3545fba9 60 browser->ShowCloseTab(kFALSE);
61
20dae051 62
63 //==============================================================================
64 // Geometry, scenes, projections and viewers
65 //==============================================================================
66
1e9caa37 67 AliEveMultiView *mv = new AliEveMultiView;
20dae051 68
1e9caa37 69 mv->SetDepth(-10);
4267948f 70
f6afd0e1 71 TEveUtil::LoadMacro("geom_gentle.C");
1e9caa37 72 mv->InitGeomGentle(geom_gentle(), geom_gentle_rphi(), geom_gentle_rhoz());
3545fba9 73
4f222c66 74 if (showTrd) {
f6afd0e1 75 TEveUtil::LoadMacro("geom_gentle_trd.C");
1e9caa37 76 mv->InitGeomGentleTrd(geom_gentle_trd());
f6afd0e1 77 }
f6afd0e1 78
3545fba9 79 if (gShowMuonRPhi || gShowMuonRhoZ) {
80 TEveUtil::LoadMacro("geom_gentle_muon.C");
1e9caa37 81 mv->InitGeomGentleMuon(geom_gentle_muon(kFALSE), gShowMuonRPhi, gShowMuonRhoZ);
68ca2fe7 82 }
20dae051 83
1e9caa37 84 mv->SetDepth(0);
20dae051 85
86 //==============================================================================
87 // Registration of per-event macros
88 //==============================================================================
89
15c12442 90 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track", "kine_tracks.C+", "kine_tracks", "", kFALSE));
20dae051 91
9dcd42ea 92 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits ITS", "its_hits.C", "its_hits", "", kFALSE));
93 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TPC", "tpc_hits.C", "tpc_hits", "", kFALSE));
94 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits T0", "t0_hits.C", "t0_hits", "", kFALSE));
95 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits FMD", "fmd_hits.C", "fmd_hits", "", kFALSE));
199f125c 96 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits ACORDE", "acorde_hits.C", "acorde_hits", "", kFALSE));
97 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits EMCAL", "emcal_hits.C", "emcal_hits", "", kFALSE));
98 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TOF", "tof_hits.C", "tof_hits", "", kFALSE));
99 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TRD", "trd_hits.C", "trd_hits", "", kFALSE));
100 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits VZERO", "vzero_hits.C", "vzero_hits", "", kFALSE));
20dae051 101
1eda7a67 102 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG ITS", "its_digits.C", "its_digits", "", kFALSE));
391fa967 103 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG TPC", "tpc_digits.C", "tpc_digits", "", kFALSE));
104 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG TOF", "tof_digits.C", "tof_digits", "", kFALSE));
105 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG HMPID", "hmpid_digits.C","hmpid_digits","", kFALSE));
20dae051 106 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD", "fmd_digits.C", "fmd_digits", "", kFALSE));
107
1eda7a67 108 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS", "its_raw.C", "its_raw", "", kFALSE));
20dae051 109 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC", "tpc_raw.C", "tpc_raw", "", kFALSE));
391fa967 110 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF", "tof_raw.C", "tof_raw", "", kFALSE));
111 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW HMPID", "hmpid_raw.C", "hmpid_raw", "", kFALSE));
20dae051 112 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW T0", "t0_raw.C", "t0_raw", "", kFALSE));
113 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD", "fmd_raw.C", "fmd_raw", "", kFALSE));
114 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO", "vzero_raw.C", "vzero_raw", "", kFALSE));
115 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE", "acorde_raw.C", "acorde_raw", "", kFALSE));
116
3aff0c2e 117 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C+", "primary_vertex", "", kTRUE));
118 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C+", "primary_vertex_ellipse", "", kTRUE));
119 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C+", "primary_vertex_box", "kFALSE, 3, 3, 3", kFALSE));
30650838 120 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX SPD", "primary_vertex.C+", "primary_vertex_spd", "", kTRUE));
121 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse SPD", "primary_vertex.C+", "primary_vertex_ellipse_spd", "", kTRUE));
122 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box SPD", "primary_vertex.C+", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
123 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX TPC", "primary_vertex.C+", "primary_vertex_tpc", "", kFALSE));
124 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse TPC", "primary_vertex.C+", "primary_vertex_ellipse_tpc", "", kFALSE));
125 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box TPC", "primary_vertex.C+", "primary_vertex_box_tpc", "kFALSE, 3, 3, 3", kFALSE));
20dae051 126
127 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0_points.C", "esd_V0_points_onfly"));
128 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0_points.C", "esd_V0_points_offline"));
129 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0.C", "esd_V0"));
130 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade_points.C", "esd_cascade_points"));
131 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade.C", "esd_cascade"));
4711ad43 132 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink_points.C", "esd_kink_points"));
133 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink.C", "esd_kink"));
20dae051 134
3aff0c2e 135 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks", "esd_tracks.C+", "esd_tracks", "", kFALSE));
7b4a06f8 136 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks ITS standalone", "esd_tracks.C+", "esd_tracks_ITS_standalone", "", kFALSE));
8e37954c 137 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks ITS", "esd_tracks.C+", "esd_tracks_ITS", "", kFALSE));
138 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks TPC", "esd_tracks.C+", "esd_tracks_TPC", "", kFALSE));
3aff0c2e 139 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MI", "esd_tracks.C+", "esd_tracks_MI", "", kFALSE));
140 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by category", "esd_tracks.C+", "esd_tracks_by_category", "", kTRUE));
141 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by anal cuts", "esd_tracks.C+", "esd_tracks_by_anal_cuts", "", kFALSE));
20dae051 142
3aff0c2e 143 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklets SPD", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kTRUE));
20dae051 144
145 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC", "esd_zdc.C", "esd_zdc", "", kFALSE));
146
9dcd42ea 147 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters", "clusters.C+", "clusters", "", kFALSE));
148 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters ITS", "its_clusters.C+", "its_clusters"));
149 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TPC", "tpc_clusters.C+", "tpc_clusters"));
150 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TRD", "trd_clusters.C+", "trd_clusters"));
151 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TOF", "tof_clusters.C+", "tof_clusters"));
199f125c 152 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters HMPID", "hmpid_clusters.C+", "hmpid_clusters"));
153 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters PHOS", "phos_clusters.C+", "phos_clusters"));
20dae051 154
9dcd42ea 155 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TPC", "vplot_tpc.C+", "vplot_tpc", "", kFALSE));
08b0f222 156
f8d5a389 157 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA HF", "aod_HF.C", "aod_HF", "", kFALSE));
08b0f222 158 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
20dae051 159
9b5db6d1 160 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "DUMP VZERO", "vzero_dump.C", "vzero_dump", "", kFALSE));
4f222c66 161
162 if (showMuon)
163 {
164 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM TrackRef MUON", "muon_trackRefs.C+", "muon_trackRefs", "kTRUE", kFALSE));
165 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON", "muon_raw.C+", "muon_raw", "", kFALSE));
166 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG MUON", "muon_digits.C+", "muon_digits", "", kFALSE));
167 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters MUON", "muon_clusters.C+", "muon_clusters", "", kTRUE));
168 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MUON", "esd_muon_tracks.C+", "esd_muon_tracks", "kTRUE,kFALSE", kTRUE));
169 }
3545fba9 170
20dae051 171 //==============================================================================
172 // Additional GUI components
173 //==============================================================================
174
51158ea3 175 // Macro / data selection
20dae051 176 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
177 slot->StartEmbedding();
178 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
179 slot->StopEmbedding("DataSelection");
180 exewin->PopulateMacros();
181
51158ea3 182 // Event selection tab
20dae051 183 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
184 slot->StartEmbedding();
51158ea3 185 new AliEveEventSelectorWindow(gClient->GetRoot(), 600, 400, AliEveEventManager::GetMaster()->GetEventSelector());
186 slot->StopEmbedding("Selections");
20dae051 187
51158ea3 188 // QA viewer
008ac94c 189 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
190 slot->StartEmbedding();
51158ea3 191 new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
192 slot->StopEmbedding("QA histograms");
008ac94c 193
20dae051 194 browser->GetTabRight()->SetTab(1);
195
196 browser->StartEmbedding(TRootBrowser::kBottom);
197 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
198 browser->StopEmbedding("EventCtrl");
199
200 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
201 TEveWindowTab *store_tab = slot->MakeTab();
202 store_tab->SetElementNameTitle("WindowStore",
203 "Undocked windows whose previous container is not known\n"
204 "are placed here when the main-frame is closed.");
205 gEve->GetWindowManager()->SetDefaultContainer(store_tab);
68ca2fe7 206
3545fba9 207
20dae051 208 //==============================================================================
209 // AliEve objects - global tools
210 //==============================================================================
211
212 AliEveTrackFitter* fitter = new AliEveTrackFitter();
213 gEve->AddToListTree(fitter, 1);
214 gEve->AddElement(fitter, gEve->GetEventScene());
215
216 AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
217 gEve->AddToListTree(g_trkcnt, kFALSE);
218
219
220 //==============================================================================
221 // Final stuff
222 //==============================================================================
223
224 // A refresh to show proper window.
3cb3592a 225 gEve->GetViewers()->SwitchColorSet();
20dae051 226 gEve->Redraw3D(kTRUE);
227 gSystem->ProcessEvents();
228
229 // Register command to call on each event.
4d62585e 230 AliEveEventManager::GetMaster()->AddNewEventCommand("on_new_event();");
231 AliEveEventManager::GetMaster()->GotoEvent(0);
e9b9f7d2 232
ca49b003 233 gEve->EditElement(g_trkcnt);
234
e9b9f7d2 235 gEve->Redraw3D(kTRUE);
b070c6d9 236
237 // Assure 3D view rotates around the origin.
238 gSystem->ProcessEvents();
239 AliEveMultiView::Instance()->Get3DView()->GetGLViewer()->CurrentCamera().SetCenterVec(0,0,0);
240 AliEveMultiView::Instance()->Get3DView()->GetGLViewer()->RequestDraw();
e9b9f7d2 241}
242
243/******************************************************************************/
244
245void on_new_event()
246{
20dae051 247 Double_t x[3] = { 0, 0, 0 };
248
249 if (AliEveEventManager::HasESD())
a27140cb 250 {
20dae051 251 AliESDEvent* esd = AliEveEventManager::AssertESD();
252 esd->GetPrimaryVertex()->GetXYZ(x);
253
a27140cb 254 TTimeStamp ts(esd->GetTimeStamp());
255 TString win_title("Eve Main Window -- Timestamp: ");
256 win_title += ts.AsString("s");
5858bcbe 257 win_title += "; Event # in ESD file: ";
a27140cb 258 win_title += esd->GetEventNumberInFile();
259 gEve->GetBrowser()->SetWindowName(win_title);
260 }
e9b9f7d2 261
262 TEveElement* top = gEve->GetCurrentEvent();
263
1e9caa37 264 AliEveMultiView *mv = AliEveMultiView::Instance();
265
266 mv->DestroyEventRPhi();
3545fba9 267 if (gCenterProjectionsAtPrimaryVertex)
1e9caa37 268 mv->SetCenterRPhi(x[0], x[1], x[2]);
269 mv->ImportEventRPhi(top);
3545fba9 270
1e9caa37 271 mv->DestroyEventRhoZ();
3545fba9 272 if (gCenterProjectionsAtPrimaryVertex)
1e9caa37 273 mv->SetCenterRhoZ(x[0], x[1], x[2]);
274 mv->ImportEventRhoZ(top);
e9b9f7d2 275}