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 **************************************************************************/
7 #include "AliEveEventManager.h"
8 #include "AliEveEventManagerEditor.h"
9 #include "AliEveMultiView.h"
10 #include "AliEveMacroExecutor.h"
11 #include "AliEveMacro.h"
12 #include "AliSysInfo.h"
15 #include <TTimeStamp.h>
17 #include <TEveManager.h>
18 #include <TEveBrowser.h>
19 #include <TEveMacro.h>
21 #include <TGFileBrowser.h>
22 #include <TInterpreter.h>
27 #include <TSystemDirectory.h>
34 class TEveProjectionManager;
37 class AliTriggerAnalysis;
40 TH2D *V0StateHistogram;
41 Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
44 Int_t g_pic_max = 100;
45 TTimeStamp g_pic_prev(0, 0);
47 void alieve_init_import_macros();
49 void alieve_online_new()
52 //AliEveEventManager::SetCdbUri("local://$ALICE_ROOT/OCDB"); // default OCDB from aliroot
53 //AliEveEventManager::SetCdbUri("local:///local/OCDB/2013"); // OCDB snapshot for particular run
54 AliEveEventManager::SetCdbUri("local:///local/cdb"); // current OCDB snapshot
55 //AliEveEventManager::SetCdbUri("raw://"); // reading OCDB from alien
57 cout<<"Creating multiview...";
58 AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
59 cout<<"created"<<endl;
61 Info("alieve_init", "Adding standard macros.");
62 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
63 alieve_init_import_macros();
64 gSystem->cd(Form("%s/../src/",gSystem->Getenv("ALICE_ROOT")));
65 gROOT->ProcessLine(".L saveViews.C+");
66 gROOT->ProcessLine(".L geom_gentle.C+");
67 gROOT->ProcessLine(".L geom_gentle_trd.C+");
68 gROOT->ProcessLine(".L geom_gentle_muon.C+");
69 TEveUtil::LoadMacro("saveViews.C");
71 cout<<"Standard macros added"<<endl;
74 new AliEveEventManager("online", -1);
75 gEve->AddEvent(AliEveEventManager::GetMaster());
76 cout<<"Event manager created"<<endl;
78 TEveUtil::AssertMacro("VizDB_scan.C");
79 gSystem->ProcessEvents();
80 cout<<"VizDB_scan loaded"<<endl;
81 TEveBrowser *browser = gEve->GetBrowser();
82 browser->ShowCloseTab(kFALSE);
83 cout<<"browser created"<<endl;
85 TEveUtil::LoadMacro("geom_gentle.C");
86 cout<<"geom gentle loaded"<<endl;
88 multiView->InitGeomGentle(geom_gentle(),
92 cout<<"geom gentl inited"<<endl;
94 TEveUtil::LoadMacro("geom_gentle_trd.C");
95 multiView->InitGeomGentleTrd(geom_gentle_trd());
97 TEveUtil::LoadMacro("geom_gentle_muon.C");
98 multiView->InitGeomGentleMuon(geom_gentle_muon(), kFALSE, kFALSE, kTRUE);
100 //============================================================================
101 // Standard macros to execute -- not all are enabled by default.
102 //============================================================================
104 printf("============ Setting macro executor ============\n");
106 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
107 printf("exec created\n");
109 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex", "", kTRUE));
110 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse", "", kTRUE));
111 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box", "kFALSE, 3, 3, 3", kFALSE));
112 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_spd", "", kTRUE));
113 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "", kTRUE));
114 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
115 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_tpc", "", kFALSE));
116 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "", kFALSE));
117 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_tpc", "kFALSE, 3, 3, 3", kFALSE));
118 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks", "", kFALSE));
119 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI", "", kFALSE));
120 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track MUON", "esd_muon_tracks.C", "esd_muon_tracks", "kTRUE,kFALSE", kTRUE));
122 // these macros were leaking:
123 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track","esd_tracks.C", "esd_tracks_by_category", "", kTRUE));// just a little
124 //exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC FMD", "fmd_esd.C", "fmd_esd", "", kTRUE));//huge leak
128 // exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC TRD", "trd_detectors.C", "trd_detectors", "", kFALSE));
129 // trd_tracks disabled due to memory leaks
130 cout<<"macros added to exec"<<endl;
132 //----------------------------------------------------------------------------
133 /* something is wrong here:
134 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
135 slot->StartEmbedding();
136 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
137 slot->StopEmbedding("DataSelection");
138 exewin->PopulateMacros();
140 //============================================================================
142 //============================================================================
144 browser->GetTabRight()->SetTab(1);
145 browser->StartEmbedding(TRootBrowser::kBottom);
146 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
147 browser->StopEmbedding("EventCtrl");
149 browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
151 gEve->FullRedraw3D(kTRUE);
152 gSystem->ProcessEvents();
154 // move and rotate sub-views
155 TGLViewer *glv1 = multiView->Get3DView()->GetGLViewer();
156 TGLViewer *glv2 = multiView->GetRPhiView()->GetGLViewer();
157 TGLViewer *glv3 = multiView->GetRhoZView()->GetGLViewer();
158 TGLViewer *glv4 = multiView->GetMuonView()->GetGLViewer();
160 glv1->CurrentCamera().RotateRad(-0.4, 0.6);
161 glv2->CurrentCamera().Dolly(90, kFALSE, kFALSE);
162 glv3->CurrentCamera().Dolly(2300, kFALSE, kFALSE);
163 glv4->CurrentCamera().Dolly(1, kFALSE, kFALSE);
165 AliEveEventManager::GetMaster()->AddNewEventCommand("alieve_online_on_new_event();");
166 gEve->FullRedraw3D();
167 gSystem->ProcessEvents();
168 gEve->Redraw3D(kTRUE);
170 // set autoload by default
171 AliEveEventManager::GetMaster()->SetAutoLoad(true);
174 void alieve_online_on_new_event()
176 if (AliEveEventManager::HasESD())
178 Double_t x[3] = { 0, 0, 0 };
180 AliESDEvent* esd = AliEveEventManager::AssertESD();
181 esd->GetPrimaryVertex()->GetXYZ(x);
183 TTimeStamp ts(esd->GetTimeStamp());
184 TString win_title("Eve Main Window -- Timestamp: ");
185 win_title += ts.AsString("s");
186 win_title += "; Event # in ESD file: ";
187 win_title += esd->GetEventNumberInFile();
188 gEve->GetBrowser()->SetWindowName(win_title);
191 TEveElement* top = gEve->GetCurrentEvent();
193 AliEveMultiView *mv = AliEveMultiView::Instance();
195 mv->DestroyEventRPhi();
196 if (gCenterProjectionsAtPrimaryVertex){
197 mv->SetCenterRPhi(x[0], x[1], x[2]);
199 mv->ImportEventRPhi(top);
201 mv->DestroyEventRhoZ();
202 if (gCenterProjectionsAtPrimaryVertex){
203 mv->SetCenterRhoZ(x[0], x[1], x[2]);
205 mv->ImportEventRhoZ(top);
207 if (gCenterProjectionsAtPrimaryVertex)
208 mv->SetCenterMuon(x[0], x[1], x[2]);
209 mv->ImportEventMuon(top);
212 // Register image to amore.
213 TString id; id.Form("online-viz-%03d", g_pic_id);
214 TString pic(id); pic += ".png";
216 //printf("In image dump: file='%s'.\n", pic.Data());
218 gEve->GetBrowser()->RaiseWindow();
219 gEve->FullRedraw3D();
220 gSystem->ProcessEvents();
222 // create screenshots from OpenGL views
223 saveViews(pic.Data());
225 // send screenshot to AMORE
226 int status = gSystem->Exec(Form("SendImageToAmore %s %s %d",id.Data(),pic.Data(),esd->GetRunNumber()));
227 printf("Post AMORE reg -- status=%d, run=%d.\n", status, esd->GetRunNumber());
229 if (++g_pic_id >= g_pic_max) g_pic_id = 0;
234 void alieve_init_import_macros()
236 // Put macros in the list of browsables, add a macro browser to
239 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
241 if (gSystem->Getenv("ALICE_ROOT") != 0)
243 gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
244 gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
245 gSystem->ExpandPathName(macdir);
249 TFolder* f = gEve->GetMacroFolder();
250 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
254 TPMERegexp re("\\.C$");
256 while ((filename = (char*)(gSystem->GetDirEntry(dirhandle))) != 0)
258 if (re.Match(filename))
259 names.AddLast(new TObjString(filename));
263 for (Int_t ii=0; ii<names.GetEntries(); ++ii)
265 TObjString * si = (TObjString*) names.At(ii);
266 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
269 gSystem->FreeDirectory(dirhandle);
271 gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
274 TEveBrowser *br = gEve->GetBrowser();
275 TGFileBrowser *fb = 0;
276 fb = br->GetFileBrowser();
279 br->StartEmbedding(0);
280 fb = br->MakeFileBrowser();
284 br->SetTabTitle("Macros", 0);