Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / EVE / macros / alieve_online.C
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 <../../MONITOR/AliSocket.h>
8
9 class TEveProjectionManager;
10 class TEveGeoShape;
11 class TEveUtil;
12 class AliTriggerAnalysis;
13 class AliSysInfo;
14
15 TH2D* V0StateHistogram;
16
17 Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
18
19 void alieve_online()
20 {
21     printf("alieve_online_init() ...\n");
22  printf("================================ Correct macro r ...\n");
23  
24         if (gSystem->Getenv("ALICE_ROOT") != 0)
25   {
26     gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
27     gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
28   }
29   
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   
42   TEveUtil::AssertMacro("VizDB_scan.C");
43   
44   gSystem->ProcessEvents();
45    
46   
47   
48  
49   
50   AliEveMacroExecutor *exec  = AliEveEventManager::GetMaster()->GetExecutor();
51   TEveBrowser         *browser = gEve->GetBrowser();
52   browser->ShowCloseTab(kFALSE);
53   
54
55   // Gentle-geom loading changes gGeoManager.
56   //TEveGeoManagerHolder mgrRestore;
57
58   AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
59
60   TEveUtil::LoadMacro("geom_gentle.C");
61   multiView->InitGeomGentle(geom_gentle(),
62                              geom_gentle_rphi(), 
63                              geom_gentle_rhoz(),
64                              geom_gentle_rhoz());
65
66   TEveUtil::LoadMacro("geom_gentle_trd.C");
67   multiView->InitGeomGentleTrd(geom_gentle_trd());
68
69   TEveUtil::LoadMacro("geom_gentle_muon.C");
70   multiView->InitGeomGentleMuon(geom_gentle_muon(), kFALSE, kFALSE, kTRUE);
71
72   //============================================================================
73   // Standard macros to execute -- not all are enabled by default.
74   //============================================================================
75
76   
77    printf("============ Setting macro executor\n");
78
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
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"));
97
98   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG EMCAL",   "emcal_digits.C",   "emcal_digits"));
99
100   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS",     "its_raw.C",     "its_raw"));
101   //  exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC",     "tpc_raw.C",     "tpc_raw"));
102   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF",     "tof_raw.C",     "tof_raw"));
103   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO",   "vzero_raw.C",   "vzero_raw", "", kFALSE));
104   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE",  "acorde_raw.C",  "acorde_raw", "", kFALSE));
105   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON",    "muon_raw.C",  "muon_raw"));
106   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD",     "fmd_raw.C",     "fmd_raw"));
107
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));
112   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC FMD",        "fmd_esd.C",           "fmd_esd",                "", kTRUE));
113
114   // ???
115   // exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC TRD", "trd_detectors.C", "trd_detectors",         "", kFALSE));
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
130   browser->GetTabRight()->SetTab(1);
131
132   browser->StartEmbedding(TRootBrowser::kBottom);
133   new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
134   browser->StopEmbedding("EventCtrl");
135
136   browser->MoveResize(0, 0, gClient->GetDisplayWidth(),
137                       gClient->GetDisplayHeight() - 32);
138
139   gEve->GetViewers()->SwitchColorSet();
140   gEve->FullRedraw3D(kTRUE);
141         gSystem->ProcessEvents();
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();
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     }
171
172   
173
174   gEve->Redraw3D(kTRUE);
175     
176 }
177
178
179 Int_t      g_pic_id  = 0;
180 Int_t      g_pic_max = 100;
181 TTimeStamp g_pic_prev(0, 0);
182
183 void alieve_online_on_new_event()
184 {
185   AliSysInfo::AddStamp("on_new_event_start");
186  
187         AliSysInfo::AddStamp("on_new_event_end");
188 }
189
190 void alieve_init_import_macros()
191 {
192   // Put macros in the list of browsables, add a macro browser to
193   // top-level GUI.
194
195   TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
196   gSystem->ExpandPathName(macdir);
197
198   TFolder* f = gEve->GetMacroFolder();
199   void* dirhandle = gSystem->OpenDirectory(macdir.Data());
200   if (dirhandle != 0)
201   {
202     char* filename;
203     TPMERegexp re("\\.C$");
204     TObjArray names;
205     while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
206     {
207       if (re.Match(filename))
208         names.AddLast(new TObjString(filename));
209     }
210     names.Sort();
211
212     for (Int_t ii=0; ii<names.GetEntries(); ++ii)
213     {
214       TObjString * si = (TObjString*) names.At(ii);
215        f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
216     }
217   }
218   gSystem->FreeDirectory(dirhandle);
219
220   gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
221
222   {
223     TEveBrowser   *br = gEve->GetBrowser();
224     TGFileBrowser *fb = 0;
225     fb = br->GetFileBrowser();
226     fb->GotoDir(macdir);
227     {
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);
235     }
236   }
237 }