* AliEveEventSelectorWindow
[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;
3545fba9 11class MultiView;
e9b9f7d2 12class TEveProjectionManager;
13class TEveGeoShape;
14class TEveUtil;
15
20dae051 16
3545fba9 17Bool_t gShowTrd = kTRUE;
18Bool_t gShowMuonRPhi = kFALSE;
19Bool_t gShowMuonRhoZ = kTRUE;
20dae051 20
21Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
e9b9f7d2 22
c63f2997 23
24void visscan_init(const TString& cdburi = "",
25 const TString& path = ".", Bool_t show_extra_geo = kFALSE)
e9b9f7d2 26{
c63f2997 27 if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
28 {
29 gEnv->SetValue("Root.Stacktrace", "no");
30 Fatal("visscan_init.C", "OCDB path MUST be specified as the first argument.");
31 }
32
3545fba9 33 if (gROOT->LoadMacro("MultiView.C+") != 0)
34 {
35 gEnv->SetValue("Root.Stacktrace", "no");
36 Fatal("visscan_init.C", "Failed loading MultiView.C in compiled mode.");
37 }
38
115b6655 39 if (!show_extra_geo)
40 {
3545fba9 41 gShowTrd = gShowMuonRPhi = gShowMuonRhoZ = kFALSE;
115b6655 42 }
43
f8d5a389 44 AliEveEventManager::AddAODfriend("AliAOD.VertexingHF.root");
45
e9b9f7d2 46 TEveUtil::LoadMacro("alieve_init.C");
c63f2997 47 alieve_init(cdburi, path, -1);
e9b9f7d2 48
20dae051 49 // TEveLine::SetDefaultSmooth(1);
e9b9f7d2 50
20dae051 51 TEveUtil::AssertMacro("VizDB_scan.C");
52
53 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
54 TEveBrowser *browser = gEve->GetBrowser();
3545fba9 55 browser->ShowCloseTab(kFALSE);
56
20dae051 57
58 //==============================================================================
59 // Geometry, scenes, projections and viewers
60 //==============================================================================
61
3545fba9 62 gMultiView = new MultiView;
20dae051 63
f6afd0e1 64 TEveUtil::LoadMacro("geom_gentle.C");
3545fba9 65 gMultiView->InitGeomGentle(geom_gentle(),
66 geom_gentle_rphi(),
67 geom_gentle_rhoz());
68
69 if (gShowTrd) {
f6afd0e1 70 TEveUtil::LoadMacro("geom_gentle_trd.C");
3545fba9 71 gMultiView->InitGeomGentleTrd(geom_gentle_trd());
f6afd0e1 72 }
f6afd0e1 73
3545fba9 74 if (gShowMuonRPhi || gShowMuonRhoZ) {
75 TEveUtil::LoadMacro("geom_gentle_muon.C");
76 gMultiView->InitGeomGentleMuon(geom_gentle_muon(kFALSE), gShowMuonRPhi, gShowMuonRhoZ);
68ca2fe7 77 }
20dae051 78
79
80 //==============================================================================
81 // Registration of per-event macros
82 //==============================================================================
83
84 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track", "kine_tracks.C", "kine_tracks", "", kFALSE));
85
86 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit ITS", "its_hits.C", "its_hits", "", kFALSE));
87 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit TPC", "tpc_hits.C", "tpc_hits", "", kFALSE));
88 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit T0", "t0_hits.C", "t0_hits", "", kFALSE));
89 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit FMD", "fmd_hits.C", "fmd_hits", "", kFALSE));
90
1eda7a67 91 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG ITS", "its_digits.C", "its_digits", "", kFALSE));
20dae051 92 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD", "fmd_digits.C", "fmd_digits", "", kFALSE));
93
1eda7a67 94 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS", "its_raw.C", "its_raw", "", kFALSE));
20dae051 95 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC", "tpc_raw.C", "tpc_raw", "", kFALSE));
96 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW T0", "t0_raw.C", "t0_raw", "", kFALSE));
97 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD", "fmd_raw.C", "fmd_raw", "", kFALSE));
98 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO", "vzero_raw.C", "vzero_raw", "", kFALSE));
99 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE", "acorde_raw.C", "acorde_raw", "", kFALSE));
100
101 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex", "", kTRUE));
102 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse", "", kTRUE));
103 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box", "kFALSE, 3, 3, 3", kFALSE));
104 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_spd", "", kTRUE));
105 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "", kTRUE));
106 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
107 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_tpc", "", kFALSE));
108 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "", kFALSE));
109 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_tpc", "kFALSE, 3, 3, 3", kFALSE));
110
111 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0_points.C", "esd_V0_points_onfly"));
112 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0_points.C", "esd_V0_points_offline"));
113 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0", "esd_V0.C", "esd_V0"));
114 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade_points.C", "esd_cascade_points"));
115 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade.C", "esd_cascade"));
4711ad43 116 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink_points.C", "esd_kink_points"));
117 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink.C", "esd_kink"));
20dae051 118
119 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks", "", kFALSE));
120 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI", "", kFALSE));
121 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
122
3a20f984 123 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklet", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kTRUE));
20dae051 124
125 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC", "esd_zdc.C", "esd_zdc", "", kFALSE));
126
127 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus", "clusters.C+", "clusters", "", kFALSE));
128 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS", "its_clusters.C+", "its_clusters"));
129 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "tpc_clusters.C+", "tpc_clusters"));
130 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TRD", "trd_clusters.C+", "trd_clusters"));
131 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF", "tof_clusters.C+", "tof_clusters"));
132
08b0f222 133 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "vplot_tpc.C+", "vplot_tpc", "", kFALSE));
134
f8d5a389 135 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA HF", "aod_HF.C", "aod_HF", "", kFALSE));
08b0f222 136 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
20dae051 137
3545fba9 138
20dae051 139 //==============================================================================
140 // Additional GUI components
141 //==============================================================================
142
51158ea3 143 // Macro / data selection
20dae051 144 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
145 slot->StartEmbedding();
146 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
147 slot->StopEmbedding("DataSelection");
148 exewin->PopulateMacros();
149
51158ea3 150 // Event selection tab
20dae051 151 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
152 slot->StartEmbedding();
51158ea3 153 new AliEveEventSelectorWindow(gClient->GetRoot(), 600, 400, AliEveEventManager::GetMaster()->GetEventSelector());
154 slot->StopEmbedding("Selections");
20dae051 155
51158ea3 156 // QA viewer
008ac94c 157 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
158 slot->StartEmbedding();
51158ea3 159 new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
160 slot->StopEmbedding("QA histograms");
008ac94c 161
20dae051 162 browser->GetTabRight()->SetTab(1);
163
164 browser->StartEmbedding(TRootBrowser::kBottom);
165 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
166 browser->StopEmbedding("EventCtrl");
167
168 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
169 TEveWindowTab *store_tab = slot->MakeTab();
170 store_tab->SetElementNameTitle("WindowStore",
171 "Undocked windows whose previous container is not known\n"
172 "are placed here when the main-frame is closed.");
173 gEve->GetWindowManager()->SetDefaultContainer(store_tab);
68ca2fe7 174
3545fba9 175
20dae051 176 //==============================================================================
177 // AliEve objects - global tools
178 //==============================================================================
179
180 AliEveTrackFitter* fitter = new AliEveTrackFitter();
181 gEve->AddToListTree(fitter, 1);
182 gEve->AddElement(fitter, gEve->GetEventScene());
183
184 AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
185 gEve->AddToListTree(g_trkcnt, kFALSE);
186
187
188 //==============================================================================
189 // Final stuff
190 //==============================================================================
191
192 // A refresh to show proper window.
193 gEve->Redraw3D(kTRUE);
194 gSystem->ProcessEvents();
195
196 // Register command to call on each event.
4d62585e 197 AliEveEventManager::GetMaster()->AddNewEventCommand("on_new_event();");
198 AliEveEventManager::GetMaster()->GotoEvent(0);
e9b9f7d2 199
ca49b003 200 gEve->EditElement(g_trkcnt);
201
e9b9f7d2 202 gEve->Redraw3D(kTRUE);
203}
204
205/******************************************************************************/
206
207void on_new_event()
208{
f76c9e9b 209 AliEveTrackCounter* g_trkcnt = AliEveTrackCounter::fgInstance;
e9b9f7d2 210 g_trkcnt->Reset();
4d62585e 211 g_trkcnt->SetEventId(AliEveEventManager::GetMaster()->GetEventId());
29207369 212
20dae051 213 if (g_esd_tracks_by_category_container != 0)
df56539f 214 {
20dae051 215 TEveElementList* cont = g_esd_tracks_by_category_container;
216
217 // Here we expect several TEveTrackList containers.
218 // First two have reasonable primaries (sigma-to-prim-vertex < 5).
219 // Others are almost certainly secondaries.
220 Int_t count = 1;
221 TEveElement::List_i i = cont->BeginChildren();
222 while (i != cont->EndChildren())
29207369 223 {
20dae051 224 TEveTrackList* l = dynamic_cast<TEveTrackList*>(*i);
225 if (l != 0)
226 {
227 g_trkcnt->RegisterTracks(l, (count <= 2));
228 ++count;
229 }
230 ++i;
e9b9f7d2 231 }
20dae051 232
233 // Set it to zero, so that we do not reuse an old one.
234 g_esd_tracks_by_category_container = 0;
235 }
236 else
237 {
238 Warning("on_new_event", "g_esd_tracks_by_category_container not initialized.");
e9b9f7d2 239 }
240
3a20f984 241 TEveTrackList *tracklets = dynamic_cast<TEveTrackList*>(gEve->GetCurrentEvent()->FindChild("SPD Tracklets"));
242 if (tracklets)
243 {
244 g_trkcnt->RegisterTracklets(tracklets, kTRUE);
245 }
246 else
247 {
248 Warning("on_new_event", "'SPD Tracklets' not found.");
249 }
250
20dae051 251 Double_t x[3] = { 0, 0, 0 };
252
253 if (AliEveEventManager::HasESD())
a27140cb 254 {
20dae051 255 AliESDEvent* esd = AliEveEventManager::AssertESD();
256 esd->GetPrimaryVertex()->GetXYZ(x);
257
a27140cb 258 TTimeStamp ts(esd->GetTimeStamp());
259 TString win_title("Eve Main Window -- Timestamp: ");
260 win_title += ts.AsString("s");
5858bcbe 261 win_title += "; Event # in ESD file: ";
a27140cb 262 win_title += esd->GetEventNumberInFile();
263 gEve->GetBrowser()->SetWindowName(win_title);
264 }
e9b9f7d2 265
266 TEveElement* top = gEve->GetCurrentEvent();
267
3545fba9 268 gMultiView->DestroyEventRPhi();
269 if (gCenterProjectionsAtPrimaryVertex)
270 gMultiView->SetCenterRPhi(x[0], x[1], x[2]);
271 gMultiView->ImportEventRPhi(top);
272
273 gMultiView->DestroyEventRhoZ();
274 if (gCenterProjectionsAtPrimaryVertex)
275 gMultiView->SetCenterRhoZ(x[0], x[1], x[2]);
276 gMultiView->ImportEventRhoZ(top);
e9b9f7d2 277}