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