]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/macros/alieve_online.C
Use TTimeStamp instead of TTime -- it is overflowing on 32-bit machines.
[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 class TEveProjectionManager;
8 class TEveGeoShape;
9 class TEveUtil;
10
11 Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
12
13
14 void alieve_online_init()
15 {
16   if (gROOT->LoadMacro("MultiView.C++") != 0)
17   {
18     gEnv->SetValue("Root.Stacktrace", "no");
19     Fatal("alieve_online.C", "Failed loading MultiView.C in compiled mode.");
20   }
21
22   TEveUtil::AssertMacro("VizDB_scan.C");
23
24   TEveBrowser *browser = gEve->GetBrowser();
25   browser->ShowCloseTab(kFALSE);
26
27   // Gentle-geom loading changes gGeoManager.
28   TEveGeoManagerHolder mgrRestore;
29
30   gMultiView = new MultiView;
31
32   TEveUtil::LoadMacro("geom_gentle.C");
33   gMultiView->InitGeomGentle(geom_gentle(),
34                              geom_gentle_rphi(), 
35                              geom_gentle_rhoz());
36
37   // See visscan_init.C for how to add TRD / MUON geometry.
38
39   //============================================================================
40   // Standard macros to execute -- not all are enabled by default.
41   //============================================================================
42
43   AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
44
45   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex",             "",                kTRUE));
46   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse",     "",                kTRUE));
47   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box",         "kFALSE, 3, 3, 3", kFALSE));
48   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_spd",         "",                kTRUE));
49   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "",                kTRUE));
50   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_spd",     "kFALSE, 3, 3, 3", kFALSE));
51   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_tpc",         "",                kFALSE));
52   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "",                kFALSE));
53   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_tpc",     "kFALSE, 3, 3, 3", kFALSE));
54
55   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS",   "its_clusters.C++",   "its_clusters"));
56   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC",   "tpc_clusters.C++",   "tpc_clusters"));
57   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF",   "tof_clusters.C++",   "tof_clusters"));
58   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus HMPID", "hmpid_clusters.C++", "hmpid_clusters"));
59
60   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF",   "emcal_digits.C++",   "emcal_digits"));
61
62   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS",     "its_raw.C",     "its_raw"));
63   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC",     "tpc_raw.C",     "tpc_raw"));
64   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF",     "tof_raw.C",     "tof_raw"));
65   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO",   "vzero_raw.C",   "vzero_raw"));
66   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE",  "acorde_raw.C",  "acorde_raw"));
67
68   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks",             "", kFALSE));
69   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI",          "", kFALSE));
70   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
71
72   // ???
73   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC TRD", "trd_detectors.C++", "trd_detectors",         "", kFALSE));
74   // trd_tracks disabled due to memory leaks
75
76   //----------------------------------------------------------------------------
77
78   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
79   slot->StartEmbedding();
80   AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
81   slot->StopEmbedding("DataSelection");
82   exewin->PopulateMacros();
83
84   //============================================================================
85   // Final GUI setup
86   //============================================================================
87
88   browser->GetTabRight()->SetTab(1);
89
90   browser->StartEmbedding(TRootBrowser::kBottom);
91   new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
92   browser->StopEmbedding("EventCtrl");
93
94   browser->MoveResize(0, 0, gClient->GetDisplayWidth(),
95                       gClient->GetDisplayHeight() - 32);
96
97   gEve->GetViewers()->SwitchColorSet();
98
99   TString autoRun(gSystem->Getenv("ONLINERECO_AUTORUN"));
100   if (autoRun == "1" || autoRun.CompareTo("true", TString::kIgnoreCase) == 0)
101   {
102     AliEveEventManager::GetMaster()->SetAutoLoad(kTRUE);
103   }
104
105   {
106     TGTab *tab = gEve->GetBrowser()->GetTab(2);
107
108     TGHorizontalFrame *hf = (TGHorizontalFrame*) tab->GetParent();
109     TGVerticalFrame   *vf = (TGVerticalFrame*)   hf ->GetParent();
110
111     hf->Resize(hf->GetWidth(), hf->GetHeight() + 80);
112     vf->Layout();
113   }
114
115   gEve->FullRedraw3D(kTRUE);
116
117   TGLViewer *glv = gMultiView->f3DView->GetGLViewer();
118   glv->CurrentCamera().RotateRad(-0.4, 1);
119   glv->DoDraw();
120 }
121
122
123 Int_t      g_pic_id  = 0;
124 Int_t      g_pic_max = 10;
125 TTimeStamp g_pic_prev(0, 0);
126
127 void alieve_online_on_new_event()
128 {
129   AliESDEvent* esd = AliEveEventManager::AssertESD();
130   Double_t x[3];
131   esd->GetPrimaryVertex()->GetXYZ(x);
132
133   TEveElement* top = gEve->GetCurrentEvent();
134
135   gMultiView->DestroyEventRPhi();
136   if (gCenterProjectionsAtPrimaryVertex)
137     gMultiView->SetCenterRPhi(x[0], x[1], x[2]);
138   gMultiView->ImportEventRPhi(top);
139
140   gMultiView->DestroyEventRhoZ();
141   if (gCenterProjectionsAtPrimaryVertex)
142     gMultiView->SetCenterRhoZ(x[0], x[1], x[2]);
143   gMultiView->ImportEventRhoZ(top);
144
145   // Register image to amore.
146   const TString pichost("aldaqacrs3");
147   TTimeStamp now;
148   Double_t delta = now.AsDouble() - g_pic_prev.AsDouble();
149
150   printf("Pre image dump: host='%s', delta=%f.\n",
151          gSystem->HostName(), delta);
152
153   if (pichost == gSystem->HostName() && delta >= 30)
154   {
155     TString id;      id.Form("online-viz-%03d", g_pic_id);
156     TString pic(id); pic += ".png";
157
158     printf("In image dump: file='%s'.\n", pic.Data());
159
160     gEve->GetBrowser()->RaiseWindow();
161     gEve->FullRedraw3D();
162     gSystem->ProcessEvents();
163
164     Int_t status;
165
166     status = gSystem->Exec(TString::Format("xwd -id %u | convert - %s",
167                            gEve->GetBrowser()->GetId(), pic.Data()));
168
169     printf("Post capture -- status=%d.\n", status);
170
171     status = gSystem->Exec(TString::Format("SendImageToAmore %s %s %d",
172                           id.Data(), pic.Data(),
173                           AliEveEventManager::AssertRawReader()->GetRunNumber()));
174
175     printf("Post AMORE reg -- status=%d, run=%d.\n", status,
176            AliEveEventManager::AssertRawReader()->GetRunNumber());
177
178     if (++g_pic_id >= g_pic_max)
179       g_pic_id = 0;
180     g_pic_prev.Set();
181   }
182 }