Merging STORAGE-dev to master
[u/mrichter/AliRoot.git] / EVE / macros / alieve_online.C
CommitLineData
319f3084 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
164d3d29 7#include <../../MONITOR/AliSocket.h>
8
2a6fc1f9 9class TEveProjectionManager;
10class TEveGeoShape;
11class TEveUtil;
e6f9543d 12class AliTriggerAnalysis;
2be6d65c 13class AliSysInfo;
e6f9543d 14
15TH2D* V0StateHistogram;
2a6fc1f9 16
2a6fc1f9 17Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
18
164d3d29 19void alieve_online()
319f3084 20{
7e0cf530 21 printf("alieve_online_init() ...\n");
164d3d29 22 printf("================================ Correct macro r ...\n");
23
24 if (gSystem->Getenv("ALICE_ROOT") != 0)
89b6d213 25 {
26 gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
27 gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
28 }
29
164d3d29 30 AliEveEventManager::SetCdbUri("local://$ALICE_ROOT/OCDB");
31
32 Info("alieve_init", "Adding standard macros.");
33 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
34 alieve_init_import_macros();
35 gSystem->cd(hack);
36
37 new AliEveEventManager("online", -1);
38 //AliEveEventManager::GetMaster()->AddNewEventCommand("alieve_online_on_new_event()");
39 gEve->AddEvent(AliEveEventManager::GetMaster());
40
41
a9e18d1c 42 TEveUtil::AssertMacro("VizDB_scan.C");
164d3d29 43
44 gSystem->ProcessEvents();
45
46
47
48
49
50 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
51 TEveBrowser *browser = gEve->GetBrowser();
2a6fc1f9 52 browser->ShowCloseTab(kFALSE);
164d3d29 53
2a6fc1f9 54
3545fba9 55 // Gentle-geom loading changes gGeoManager.
164d3d29 56 //TEveGeoManagerHolder mgrRestore;
2a6fc1f9 57
5f4e9982 58 AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
3545fba9 59
60 TEveUtil::LoadMacro("geom_gentle.C");
d2a137c1 61 multiView->InitGeomGentle(geom_gentle(),
9cd7053b 62 geom_gentle_rphi(),
5f4e9982 63 geom_gentle_rhoz(),
9cd7053b 64 geom_gentle_rhoz());
3545fba9 65
e2673345 66 TEveUtil::LoadMacro("geom_gentle_trd.C");
67 multiView->InitGeomGentleTrd(geom_gentle_trd());
68
89b6d213 69 TEveUtil::LoadMacro("geom_gentle_muon.C");
5f4e9982 70 multiView->InitGeomGentleMuon(geom_gentle_muon(), kFALSE, kFALSE, kTRUE);
2a6fc1f9 71
c027b127 72 //============================================================================
73 // Standard macros to execute -- not all are enabled by default.
74 //============================================================================
75
164d3d29 76
77 printf("============ Setting macro executor\n");
78
c027b127 79 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
80
81 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex", "", kTRUE));
82 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse", "", kTRUE));
83 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box", "kFALSE, 3, 3, 3", kFALSE));
84 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_spd", "", kTRUE));
85 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "", kTRUE));
86 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
87 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_tpc", "", kFALSE));
88 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "", kFALSE));
89 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_tpc", "kFALSE, 3, 3, 3", kFALSE));
90
164d3d29 91 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS", "its_clusters.C", "its_clusters"));
92 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "tpc_clusters.C", "tpc_clusters"));
93 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TRD", "trd_clusters.C", "trd_clusters"));
94 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF", "tof_clusters.C", "tof_clusters"));
95 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus HMPID", "hmpid_clusters.C", "hmpid_clusters"));
96 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus MUON", "muon_clusters.C", "muon_clusters"));
c027b127 97
164d3d29 98 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG EMCAL", "emcal_digits.C", "emcal_digits"));
c027b127 99
100 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS", "its_raw.C", "its_raw"));
2be6d65c 101 // exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC", "tpc_raw.C", "tpc_raw"));
c027b127 102 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF", "tof_raw.C", "tof_raw"));
2608fef9 103 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO", "vzero_raw.C", "vzero_raw", "", kFALSE));
c14ef7a5 104 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE", "acorde_raw.C", "acorde_raw", "", kFALSE));
164d3d29 105 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON", "muon_raw.C", "muon_raw"));
74155242 106 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD", "fmd_raw.C", "fmd_raw"));
c027b127 107
164d3d29 108 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks", "", kFALSE));
109 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI", "", kFALSE));
110 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
111 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track MUON", "esd_muon_tracks.C", "esd_muon_tracks", "kTRUE,kFALSE", kTRUE));
74155242 112 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC FMD", "fmd_esd.C", "fmd_esd", "", kTRUE));
c027b127 113
114 // ???
164d3d29 115 // exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC TRD", "trd_detectors.C", "trd_detectors", "", kFALSE));
c027b127 116 // trd_tracks disabled due to memory leaks
117
118 //----------------------------------------------------------------------------
119
120 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
121 slot->StartEmbedding();
122 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
123 slot->StopEmbedding("DataSelection");
124 exewin->PopulateMacros();
125
126 //============================================================================
127 // Final GUI setup
128 //============================================================================
129
14a4b686 130 browser->GetTabRight()->SetTab(1);
de33999e 131
47aab29b 132 browser->StartEmbedding(TRootBrowser::kBottom);
4d62585e 133 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
47aab29b 134 browser->StopEmbedding("EventCtrl");
135
06f4984c 136 browser->MoveResize(0, 0, gClient->GetDisplayWidth(),
137 gClient->GetDisplayHeight() - 32);
138
139 gEve->GetViewers()->SwitchColorSet();
5f4e9982 140 gEve->FullRedraw3D(kTRUE);
164d3d29 141 gSystem->ProcessEvents();
2608fef9 142
143 TGLViewer *glv1 = multiView->Get3DView()->GetGLViewer();
144 TGLViewer *glv2 = multiView->GetRPhiView()->GetGLViewer();
145 TGLViewer *glv3 = multiView->GetRhoZView()->GetGLViewer();
146
147 glv1->CurrentCamera().RotateRad(-0.4, -1.8);
148 glv2->CurrentCamera().Dolly(450, kFALSE, kFALSE);
149 glv3->CurrentCamera().Dolly(1500, kFALSE, kFALSE);
150
151 gEve->FullRedraw3D();
164d3d29 152 gSystem->ProcessEvents();
153
154 // Register command to call on each event.
155 // AliEveEventManager::GetMaster()->AddNewEventCommand("alieve_online_on_new_event();");
156 //AliEveEventManager::GetMaster()->GotoEvent(-1);
157
158 printf("================================ Connecting to Server ...\n");
159
160 //AliEveEventManager::ConnectToServer("tcp://137.138.55.173", 5024);
161 if(AliEveEventManager::ConnectToServer("tcp://137.138.93.150", 5024))
162 {
163 printf("\nconnected\n");
164 } else printf("not connected\n");
165
166 AliSocket* subscriber = AliEveEventManager::AssertSubscriber();
167
168 if(subscriber ==0) {
169 printf("===================== Not connected! ====================\n");
170 }
5f4e9982 171
164d3d29 172
173
174 gEve->Redraw3D(kTRUE);
175
de33999e 176}
177
164d3d29 178
9cd7053b 179Int_t g_pic_id = 0;
08bc045d 180Int_t g_pic_max = 100;
9cd7053b 181TTimeStamp g_pic_prev(0, 0);
44854372 182
de33999e 183void alieve_online_on_new_event()
184{
2be6d65c 185 AliSysInfo::AddStamp("on_new_event_start");
6aafad45 186
164d3d29 187 AliSysInfo::AddStamp("on_new_event_end");
188}
2608fef9 189
164d3d29 190void alieve_init_import_macros()
191{
192 // Put macros in the list of browsables, add a macro browser to
193 // top-level GUI.
2608fef9 194
164d3d29 195 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
196 gSystem->ExpandPathName(macdir);
2608fef9 197
164d3d29 198 TFolder* f = gEve->GetMacroFolder();
199 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
200 if (dirhandle != 0)
2608fef9 201 {
164d3d29 202 char* filename;
203 TPMERegexp re("\\.C$");
204 TObjArray names;
205 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
2608fef9 206 {
164d3d29 207 if (re.Match(filename))
208 names.AddLast(new TObjString(filename));
2608fef9 209 }
164d3d29 210 names.Sort();
2608fef9 211
164d3d29 212 for (Int_t ii=0; ii<names.GetEntries(); ++ii)
2608fef9 213 {
164d3d29 214 TObjString * si = (TObjString*) names.At(ii);
215 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
2608fef9 216 }
217 }
164d3d29 218 gSystem->FreeDirectory(dirhandle);
219
220 gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
2608fef9 221
2608fef9 222 {
164d3d29 223 TEveBrowser *br = gEve->GetBrowser();
224 TGFileBrowser *fb = 0;
225 fb = br->GetFileBrowser();
226 fb->GotoDir(macdir);
2608fef9 227 {
164d3d29 228 br->StartEmbedding(0);
229 fb = br->MakeFileBrowser();
230 fb->BrowseObj(f);
231 fb->Show();
232 br->StopEmbedding();
233 br->SetTabTitle("Macros", 0);
234 br->SetTab(0, 0);
2608fef9 235 }
236 }
319f3084 237}