SM checks if other SM processes are running. ED macros improved a bit.
[u/mrichter/AliRoot.git] / EVE / macros / alieve_online_new.C
CommitLineData
cb175407 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
cb175407 7class TEveProjectionManager;
8class TEveGeoShape;
9class TEveUtil;
10class AliTriggerAnalysis;
11class AliSysInfo;
12
13TH2D* V0StateHistogram;
cb175407 14Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
15
13f4dce0 16Int_t g_pic_id = 0;
17Int_t g_pic_max = 100;
18TTimeStamp g_pic_prev(0, 0);
19
cb175407 20void alieve_online_new()
21{
13f4dce0 22 // set OCDB path:
23 //AliEveEventManager::SetCdbUri("local://$ALICE_ROOT/OCDB"); // default OCDB from aliroot
24 //AliEveEventManager::SetCdbUri("local:///local/OCDB/2013"); // OCDB snapshot for particular run
25 AliEveEventManager::SetCdbUri("local:///local/cdb"); // current OCDB snapshot
26 //AliEveEventManager::SetCdbUri("raw://"); // reading OCDB from alien
27
572d0620 28
572d0620 29 Info("alieve_init", "Adding standard macros.");
30 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
31 alieve_init_import_macros();
13f4dce0 32 gSystem->cd(Form("%s/../src/",gSystem->Getenv("ALICE_ROOT")));
33 gROOT->ProcessLine(".L saveViews.C++");
5c7e574d 34 gROOT->ProcessLine(".L geom_gentle_muon.C++");
35 gROOT->ProcessLine(".L geom_gentle_trd.C++");
13f4dce0 36 TEveUtil::LoadMacro("saveViews.C");
572d0620 37 gSystem->cd(hack);
5c7e574d 38 cout<<"Standard macros added"<<endl;
572d0620 39
40 new AliEveEventManager("online", -1);
41 gEve->AddEvent(AliEveEventManager::GetMaster());
42
43 TEveUtil::AssertMacro("VizDB_scan.C");
44 gSystem->ProcessEvents();
45
13f4dce0 46 TEveBrowser *browser = gEve->GetBrowser();
572d0620 47 browser->ShowCloseTab(kFALSE);
48
5c7e574d 49
50 cout<<"Creating multiview"<<endl;
572d0620 51 AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
52 TEveUtil::LoadMacro("geom_gentle.C");
53 multiView->InitGeomGentle(geom_gentle(),
54 geom_gentle_rphi(),
55 geom_gentle_rhoz(),
56 geom_gentle_rhoz());
57
13f4dce0 58 TEveUtil::LoadMacro("geom_gentle_trd.C");
59 multiView->InitGeomGentleTrd(geom_gentle_trd());
5c7e574d 60
13f4dce0 61 TEveUtil::LoadMacro("geom_gentle_muon.C");
62 multiView->InitGeomGentleMuon(geom_gentle_muon(), kFALSE, kFALSE, kTRUE);
5c7e574d 63
572d0620 64 //============================================================================
65 // Standard macros to execute -- not all are enabled by default.
66 //============================================================================
67
13f4dce0 68 printf("============ Setting macro executor ============\n");
572d0620 69
70 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
71
72 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex", "", kTRUE));
73 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse", "", kTRUE));
74 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box", "kFALSE, 3, 3, 3", kFALSE));
75 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_spd", "", kTRUE));
76 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "", kTRUE));
77 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_spd", "kFALSE, 3, 3, 3", kFALSE));
78 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C", "primary_vertex_tpc", "", kFALSE));
79 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "", kFALSE));
80 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box", "primary_vertex.C", "primary_vertex_box_tpc", "kFALSE, 3, 3, 3", kFALSE));
572d0620 81 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks", "", kFALSE));
82 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI", "", kFALSE));
83 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track MUON", "esd_muon_tracks.C", "esd_muon_tracks", "kTRUE,kFALSE", kTRUE));
84
e339938c 85 // these macros were leaking:
572d0620 86 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));// just a little
87 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC FMD", "fmd_esd.C", "fmd_esd", "", kTRUE));//huge leak
e339938c 88 //
89
572d0620 90 // ???
91 // exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC TRD", "trd_detectors.C", "trd_detectors", "", kFALSE));
92 // trd_tracks disabled due to memory leaks
e339938c 93
572d0620 94 //----------------------------------------------------------------------------
95
96 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
97 slot->StartEmbedding();
98 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
99 slot->StopEmbedding("DataSelection");
100 exewin->PopulateMacros();
101
102 //============================================================================
103 // Final GUI setup
104 //============================================================================
105
572d0620 106 browser->GetTabRight()->SetTab(1);
107 browser->StartEmbedding(TRootBrowser::kBottom);
108 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
109 browser->StopEmbedding("EventCtrl");
110
7dcdaa40 111 browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
572d0620 112
572d0620 113 gEve->FullRedraw3D(kTRUE);
114 gSystem->ProcessEvents();
115
13f4dce0 116 // move and rotate sub-views
572d0620 117 TGLViewer *glv1 = multiView->Get3DView()->GetGLViewer();
118 TGLViewer *glv2 = multiView->GetRPhiView()->GetGLViewer();
119 TGLViewer *glv3 = multiView->GetRhoZView()->GetGLViewer();
120
13f4dce0 121 glv1->CurrentCamera().RotateRad(-0.4, 0.6);
122 glv2->CurrentCamera().Dolly(90, kFALSE, kFALSE);
123 glv3->CurrentCamera().Dolly(1700, kFALSE, kFALSE);
572d0620 124
125 AliEveEventManager::GetMaster()->AddNewEventCommand("alieve_online_on_new_event();");
126 gEve->FullRedraw3D();
127 gSystem->ProcessEvents();
128 gEve->Redraw3D(kTRUE);
129
13f4dce0 130 // set autoload by default
572d0620 131 AliEveEventManager::GetMaster()->SetAutoLoad(true);
cb175407 132}
133
cb175407 134void alieve_online_on_new_event()
135{
572d0620 136 AliSysInfo::AddStamp("on_new_event_start");
137
138 Double_t x[3] = { 0, 0, 0 };
139
140 if (AliEveEventManager::HasESD())
141 {
142 AliESDEvent* esd = AliEveEventManager::AssertESD();
143 esd->GetPrimaryVertex()->GetXYZ(x);
144
145 TTimeStamp ts(esd->GetTimeStamp());
146 TString win_title("Eve Main Window -- Timestamp: ");
147 win_title += ts.AsString("s");
148 win_title += "; Event # in ESD file: ";
149 win_title += esd->GetEventNumberInFile();
150 gEve->GetBrowser()->SetWindowName(win_title);
151 }
152
153 TEveElement* top = gEve->GetCurrentEvent();
154
155 AliEveMultiView *mv = AliEveMultiView::Instance();
156
157 //mv->DestroyEventRPhi();
158 if (gCenterProjectionsAtPrimaryVertex)
159 mv->SetCenterRPhi(x[0], x[1], x[2]);
160 mv->ImportEventRPhi(top);
161
162 //mv->DestroyEventRhoZ();
163 if (gCenterProjectionsAtPrimaryVertex)
164 mv->SetCenterRhoZ(x[0], x[1], x[2]);
165 mv->ImportEventRhoZ(top);
166
167 if (gCenterProjectionsAtPrimaryVertex)
168 mv->SetCenterMuon(x[0], x[1], x[2]);
169 mv->ImportEventMuon(top);
170
f5e8dfd2 171
572d0620 172 // Register image to amore.
173 // const TString pichost("aldaqacrs3");
174 const TString pichost(gEnv->GetValue("AliEve.imageDumpHost", "localhost"));
175 TTimeStamp now;
176 Double_t delta = now.AsDouble() - g_pic_prev.AsDouble();
177
f5e8dfd2 178 printf("Pre image dump: host='%s', delta=%f.\n",gSystem->HostName(), delta);
572d0620 179
180 AliSysInfo::AddStamp("on_new_event_pic");
f5e8dfd2 181 // if (pichost == gSystem->HostName() && delta >= 30)
572d0620 182 {
f5e8dfd2 183 TString id; id.Form("online-viz-%03d", g_pic_id);
184 TString pic(id); pic += ".png";
572d0620 185
f5e8dfd2 186 printf("In image dump: file='%s'.\n", pic.Data());
572d0620 187
f5e8dfd2 188 gEve->GetBrowser()->RaiseWindow();
189 gEve->FullRedraw3D();
190 gSystem->ProcessEvents();
572d0620 191
f5e8dfd2 192 Int_t status;
572d0620 193
f5e8dfd2 194 // create screenshots from OpenGL views
f5e8dfd2 195 saveViews(pic.Data());
572d0620 196
f5e8dfd2 197 // send screenshot to AMORE
198 cout<<"Sending:"<<TString::Format("SendImageToAmore %s %s %d",id.Data(), pic.Data(),AliEveEventManager::AssertESD()->GetRunNumber())<<endl;
199
200 status = gSystem->Exec(TString::Format("SendImageToAmore %s %s %d",
201 id.Data(), pic.Data(),
202 AliEveEventManager::AssertESD()->GetRunNumber()));
572d0620 203
f5e8dfd2 204 printf("Post AMORE reg -- status=%d, run=%d.\n", status,
205 AliEveEventManager::AssertESD()->GetRunNumber());
572d0620 206
f5e8dfd2 207 if (++g_pic_id >= g_pic_max)
208 g_pic_id = 0;
209 g_pic_prev.Set();
210 }
572d0620 211 AliSysInfo::AddStamp("on_new_event_end");
cb175407 212}
213
214void alieve_init_import_macros()
215{
572d0620 216 // Put macros in the list of browsables, add a macro browser to
217 // top-level GUI.
218
13f4dce0 219 if (gSystem->Getenv("ALICE_ROOT") != 0)
220 {
221 gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
222 gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
223 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
224 gSystem->ExpandPathName(macdir);
225 }
226
572d0620 227
228 TFolder* f = gEve->GetMacroFolder();
229 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
230 if (dirhandle != 0)
cb175407 231 {
572d0620 232 char* filename;
233 TPMERegexp re("\\.C$");
234 TObjArray names;
235 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
236 {
237 if (re.Match(filename))
238 names.AddLast(new TObjString(filename));
239 }
240 names.Sort();
241
242 for (Int_t ii=0; ii<names.GetEntries(); ++ii)
243 {
244 TObjString * si = (TObjString*) names.At(ii);
245 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
246 }
cb175407 247 }
572d0620 248 gSystem->FreeDirectory(dirhandle);
249
250 gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
251
cb175407 252 {
572d0620 253 TEveBrowser *br = gEve->GetBrowser();
254 TGFileBrowser *fb = 0;
255 fb = br->GetFileBrowser();
256 fb->GotoDir(macdir);
257 {
258 br->StartEmbedding(0);
259 fb = br->MakeFileBrowser();
260 fb->BrowseObj(f);
261 fb->Show();
262 br->StopEmbedding();
263 br->SetTabTitle("Macros", 0);
264 br->SetTab(0, 0);
265 }
cb175407 266 }
cb175407 267}