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