saveViews macro fixed. Some macros are now being compiled before using to fix issues...
[u/mrichter/AliRoot.git] / EVE / macros / online.C
CommitLineData
164d3d29 1/**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
3 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
4 * full copyright notice. *
5 **************************************************************************/
6
7#include <zmq.hpp>
8
9class TEveProjectionManager;
10class TEveGeoShape;
11class TEveUtil;
12class AliTriggerAnalysis;
13class AliSysInfo;
14
15TH2D* V0StateHistogram;
16
17Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
18//Container for gGeoManager till it is broken
19TGeoManager *fGeoManager = 0;
20
21void online()
22{
23 printf("online() ...\n");
24
25 if (gSystem->Getenv("ALICE_ROOT") != 0)
26 {
27 gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
28 gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
29 }
30
31 Info("alieve_init", "Adding standard macros.");
32 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
33 alieve_init_import_macros();
34 gSystem->cd(hack);
35
36 TEveUtil::LoadMacro("alieve_init.C");
37 alieve_init("local:///opt/OCDB/2013", ".", -1);
38
39
40 TEveUtil::AssertMacro("VizDB_scan.C");
41
42 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
43 TEveBrowser *browser = gEve->GetBrowser();
44 browser->ShowCloseTab(kFALSE);
45
46
47 //==============================================================================
48 // Geometry, scenes, projections and viewers
49 //==============================================================================
50
51 AliEveMultiView *mv = new AliEveMultiView;
52
53 mv->SetDepth(-10);
54
55 TEveUtil::LoadMacro("geom_gentle.C");
56 mv->InitGeomGentle(geom_gentle(), geom_gentle_rphi(), geom_gentle_rhoz(), 0);
57
58
59 TEveUtil::LoadMacro("geom_gentle_trd.C");
60 mv->InitGeomGentleTrd(geom_gentle_trd());
61
62
63
64 TEveUtil::LoadMacro("geom_gentle_muon.C");
65 mv->InitGeomGentleMuon(geom_gentle_muon(kFALSE), kFALSE, kFALSE, kFALSE);
66
67
68 mv->SetDepth(0);
69
70 //==============================================================================
71 // Registration of per-event macros
72 //==============================================================================
73
74 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track", "kine_tracks.C", "kine_tracks", "", kFALSE));
75
76 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits ITS", "its_hits.C", "its_hits", "", kFALSE));
77 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TPC", "tpc_hits.C", "tpc_hits", "", kFALSE));
78 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits T0", "t0_hits.C", "t0_hits", "", kFALSE));
79 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits FMD", "fmd_hits.C", "fmd_hits", "", kFALSE));
80 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits ACORDE", "acorde_hits.C", "acorde_hits", "", kFALSE));
81 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits EMCAL", "emcal_hits.C", "emcal_hits", "", kFALSE));
82 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TOF", "tof_hits.C", "tof_hits", "", kFALSE));
83 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TRD", "trd_hits.C", "trd_hits", "", kFALSE));
84 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits VZERO", "vzero_hits.C", "vzero_hits", "", kFALSE));
85
86 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG ITS", "its_digits.C", "its_digits", "", kFALSE));
87 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG TPC", "tpc_digits.C", "tpc_digits", "", kFALSE));
88 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG TOF", "tof_digits.C", "tof_digits", "", kFALSE));
89 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG HMPID", "hmpid_digits.C","hmpid_digits","", kFALSE));
90 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD", "fmd_digits.C", "fmd_digits", "", kFALSE));
91
92 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS", "its_raw.C", "its_raw", "", kFALSE));
93 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC", "tpc_raw.C", "tpc_raw", "", kFALSE));
94 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF", "tof_raw.C", "tof_raw", "", kFALSE));
95 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW HMPID", "hmpid_raw.C", "hmpid_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 SPD", "primary_vertex.C", "primary_vertex_spd", "", kTRUE));
105 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse SPD", "primary_vertex.C", "primary_vertex_ellipse_spd", "", kTRUE));
106 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box SPD", "primary_vertex.C", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
107 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX TPC", "primary_vertex.C", "primary_vertex_tpc", "", kFALSE));
108 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse TPC", "primary_vertex.C", "primary_vertex_ellipse_tpc", "", kFALSE));
109 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box TPC", "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"));
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"));
118
119 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks", "esd_tracks.C", "esd_tracks", "", kFALSE));
120 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks ITS standalone", "esd_tracks.C", "esd_tracks_ITS_standalone", "", kFALSE));
121 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks ITS", "esd_tracks.C", "esd_tracks_ITS", "", kFALSE));
122 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks TPC", "esd_tracks.C", "esd_tracks_TPC", "", kFALSE));
123 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MI", "esd_tracks.C", "esd_tracks_MI", "", kFALSE));
124 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by category", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
125 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by anal cuts", "esd_tracks.C", "esd_tracks_by_anal_cuts", "", kFALSE));
126 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks Lego", "lego.C", "lego", "", kFALSE));
127 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks Beams Info", "beams_info.C", "beams_info", "", kFALSE));
128
129 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklets SPD", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kTRUE));
130
131 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC", "esd_zdc.C", "esd_zdc", "", kFALSE));
132
133 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters", "clusters.C", "clusters", "", kFALSE));
134 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters ITS", "its_clusters.C", "its_clusters"));
135 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TPC", "tpc_clusters.C", "tpc_clusters"));
136 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TRD", "trd_clusters.C", "trd_clusters"));
137 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TOF", "tof_clusters.C", "tof_clusters"));
138 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters HMPID", "hmpid_clusters.C", "hmpid_clusters"));
139 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters PHOS", "phos_clusters.C", "phos_clusters"));
140
141 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TPC", "vplot_tpc.C", "vplot_tpc", "", kFALSE));
142
143 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA HF", "aod_HF.C", "aod_HF", "", kFALSE));
144 exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
145
146 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "DUMP VZERO", "vzero_dump.C", "vzero_dump", "", kFALSE));
147 /*
148 if (showMuon)
149 {
150 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM TrackRef MUON", "muon_trackRefs.C", "muon_trackRefs", "kTRUE", kFALSE));
151 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON", "muon_raw.C", "muon_raw", "", kFALSE));
152 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG MUON", "muon_digits.C", "muon_digits", "", kFALSE));
153 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters MUON", "muon_clusters.C", "muon_clusters", "", kTRUE));
154 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MUON", "esd_muon_tracks.C", "esd_muon_tracks", "kTRUE,kFALSE", kTRUE));
155 }
156 */
157
158 //==============================================================================
159 // Additional GUI components
160 //==============================================================================
161
162 // Macro / data selection
163 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
164 slot->StartEmbedding();
165 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
166 slot->StopEmbedding("DataSelection");
167 exewin->PopulateMacros();
168
169 // Event selection tab
170 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
171 slot->StartEmbedding();
172 new AliEveEventSelectorWindow(gClient->GetRoot(), 600, 400, AliEveEventManager::GetMaster()->GetEventSelector());
173 slot->StopEmbedding("Selections");
174
175 // QA viewer
176/*
177 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
178 slot->StartEmbedding();
179 new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
180 slot->StopEmbedding("QA histograms");
181
182 browser->GetTabRight()->SetTab(1);
183*/
184 browser->StartEmbedding(TRootBrowser::kBottom);
185 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
186 browser->StopEmbedding("EventCtrl");
187
188 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
189 TEveWindowTab *store_tab = slot->MakeTab();
190 store_tab->SetElementNameTitle("WindowStore",
191 "Undocked windows whose previous container is not known\n"
192 "are placed here when the main-frame is closed.");
193 gEve->GetWindowManager()->SetDefaultContainer(store_tab);
194
195
196 //==============================================================================
197 // AliEve objects - global tools
198 //==============================================================================
199
200 AliEveTrackFitter* fitter = new AliEveTrackFitter();
201 gEve->AddToListTree(fitter, 1);
202 gEve->AddElement(fitter, gEve->GetEventScene());
203
204 AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
205 gEve->AddToListTree(g_trkcnt, kFALSE);
206
207
208
209
210printf("================================ Connecting to Server ...\n");
211
212AliEveEventManager::GetMaster()->ConnectToServer("tcp://*",5024);
213
214zmq::socket_t* subscriber = AliEveEventManager::GetMaster()->AssertSubscriber();
215
216if(subscriber ==0) {
217 printf("===================== Not connected! ====================\n");
218}
219
220
221 //==============================================================================
222 // Final stuff
223 //==============================================================================
224
225 // A refresh to show proper window.
226 gEve->GetViewers()->SwitchColorSet();
227 gEve->Redraw3D(kTRUE);
228 gSystem->ProcessEvents();
229
230 // Register command to call on each event.
231 AliEveEventManager::GetMaster()->AddNewEventCommand("on_new_event();");
232 AliEveEventManager::GetMaster()->GotoEvent(0);
233
234 gEve->EditElement(g_trkcnt);
235 gEve->Redraw3D(kTRUE);
236}
237
238
239/******************************************************************************/
240
241void on_new_event()
242{
243 Double_t x[3] = { 0, 0, 0 };
244
245 if (AliEveEventManager::HasESD())
246 {
247 AliESDEvent* esd = AliEveEventManager::AssertESD();
248 esd->GetPrimaryVertex()->GetXYZ(x);
249
250 TTimeStamp ts(esd->GetTimeStamp());
251 TString win_title("Eve Main Window -- Timestamp: ");
252 win_title += ts.AsString("s");
253 win_title += "; Event # in ESD file: ";
254 win_title += esd->GetEventNumberInFile();
255 gEve->GetBrowser()->SetWindowName(win_title);
256 }
257
258 TEveElement* top = gEve->GetCurrentEvent();
259
260 AliEveMultiView *mv = AliEveMultiView::Instance();
261
262 //mv->DestroyEventRPhi();
263 if (gCenterProjectionsAtPrimaryVertex)
264 mv->SetCenterRPhi(x[0], x[1], x[2]);
265 mv->ImportEventRPhi(top);
266
267 //mv->DestroyEventRhoZ();
268 if (gCenterProjectionsAtPrimaryVertex)
269 mv->SetCenterRhoZ(x[0], x[1], x[2]);
270 mv->ImportEventRhoZ(top);
271}
272
273
274Int_t g_pic_id = 0;
275Int_t g_pic_max = 100;
276TTimeStamp g_pic_prev(0, 0);
277
278
279void alieve_init_import_macros()
280{
281 // Put macros in the list of browsables, add a macro browser to
282 // top-level GUI.
283
284 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
285 gSystem->ExpandPathName(macdir);
286
287 TFolder* f = gEve->GetMacroFolder();
288 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
289 if (dirhandle != 0)
290 {
291 char* filename;
292 TPMERegexp re("\\.C$");
293 TObjArray names;
294 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
295 {
296 if (re.Match(filename))
297 names.AddLast(new TObjString(filename));
298 }
299 names.Sort();
300
301 for (Int_t ii=0; ii<names.GetEntries(); ++ii)
302 {
303 TObjString * si = (TObjString*) names.At(ii);
304 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
305 }
306 }
307 gSystem->FreeDirectory(dirhandle);
308
309 gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
310
311 {
312 TEveBrowser *br = gEve->GetBrowser();
313 TGFileBrowser *fb = 0;
314 fb = br->GetFileBrowser();
315 fb->GotoDir(macdir);
316 {
317 br->StartEmbedding(0);
318 fb = br->MakeFileBrowser();
319 fb->BrowseObj(f);
320 fb->Show();
321 br->StopEmbedding();
322 br->SetTabTitle("Macros", 0);
323 br->SetTab(0, 0);
324 }
325 }
326}