]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/macros/visscan_init.C
From Antonin:
[u/mrichter/AliRoot.git] / EVE / macros / visscan_init.C
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 class AliEveMacroExecutor;
11
12 class TEveProjectionManager;
13 class TEveGeoShape;
14 class TEveUtil;
15
16 TEveGeoShape *gGeomGentle     = 0;
17 TEveGeoShape *gGeomGentleRPhi = 0;
18 TEveGeoShape *gGeomGentleRhoZ = 0;
19 TEveGeoShape *gGeomGentleTRD  = 0;
20 TEveGeoShape *gGeomGentleMUON = 0;
21
22 TEveScene *gRPhiGeomScene  = 0;
23 TEveScene *gRhoZGeomScene  = 0;
24 TEveScene *gRPhiEventScene = 0;
25 TEveScene *gRhoZEventScene = 0;
26
27 TEveProjectionManager *gRPhiMgr = 0;
28 TEveProjectionManager *gRhoZMgr = 0;
29
30 TEveViewer *g3DView   = 0;
31 TEveViewer *gRPhiView = 0;
32 TEveViewer *gRhoZView = 0;
33
34 Bool_t gShowTRD      = kFALSE;
35 Bool_t gShowMUON     = kTRUE;
36 Bool_t gShowMUONRPhi = kFALSE;
37 Bool_t gShowMUONRhoZ = kTRUE;
38
39 Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
40
41 void visscan_init(Bool_t show_extra_geo=kFALSE)
42 {
43   if (!show_extra_geo)
44   {
45     gShowTRD = gShowMUON = gShowMUONRPhi = gShowMUONRhoZ = kFALSE;
46   }
47
48   TEveUtil::LoadMacro("alieve_init.C");
49   alieve_init(".", -1);
50
51   // TEveLine::SetDefaultSmooth(1);
52
53   TEveUtil::AssertMacro("VizDB_scan.C");
54
55   AliEveMacroExecutor *exec    = AliEveEventManager::GetMaster()->GetExecutor();
56   TEveBrowser         *browser = gEve->GetBrowser();
57
58   //==============================================================================
59   // Geometry, scenes, projections and viewers
60   //==============================================================================
61
62   browser->ShowCloseTab(kFALSE);
63
64   // Geometry
65
66   TEveUtil::LoadMacro("geom_gentle.C");
67   gGeomGentle = geom_gentle();
68   gGeomGentleRPhi = geom_gentle_rphi(); gGeomGentleRPhi->IncDenyDestroy();
69   gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();
70   if (gShowTRD) {
71     TEveUtil::LoadMacro("geom_gentle_trd.C");
72     gGeomGentleTRD = geom_gentle_trd();
73   }
74   if (gShowMUON) {
75     TEveUtil::LoadMacro("geom_gentle_muon.C");
76     gGeomGentleMUON = geom_gentle_muon();
77   }
78
79   // Scenes
80
81   gRPhiGeomScene  = gEve->SpawnNewScene("RPhi Geometry",
82                     "Scene holding projected geometry for the RPhi view.");
83   gRhoZGeomScene  = gEve->SpawnNewScene("RhoZ Geometry",
84                     "Scene holding projected geometry for the RhoZ view.");
85   gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
86                     "Scene holding projected geometry for the RPhi view.");
87   gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
88                     "Scene holding projected geometry for the RhoZ view.");
89
90   // Projection managers
91
92   gRPhiMgr = new TEveProjectionManager();
93   gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);
94   gEve->AddToListTree(gRPhiMgr, kFALSE);
95   {
96     TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);
97     a->SetMainColor(kWhite);
98     a->SetTitle("R-Phi");
99     a->SetTitleSize(0.05);
100     a->SetTitleFont(102);
101     a->SetLabelSize(0.025);
102     a->SetLabelFont(102);
103     gRPhiGeomScene->AddElement(a);
104   }
105   gRPhiMgr->SetCurrentDepth(-10);
106   gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);
107   gRPhiMgr->SetCurrentDepth(0);
108   if (gShowTRD)      gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);
109   if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);
110
111   gRhoZMgr = new TEveProjectionManager();
112   gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);
113   gEve->AddToListTree(gRhoZMgr, kFALSE);
114   {
115     TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);
116     a->SetMainColor(kWhite);
117     a->SetTitle("Rho-Z");
118     a->SetTitleSize(0.05);
119     a->SetTitleFont(102);
120     a->SetLabelSize(0.025);
121     a->SetLabelFont(102);
122     gRhoZGeomScene->AddElement(a);
123   }
124   gRhoZMgr->SetCurrentDepth(-10);
125   gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);
126   gRhoZMgr->SetCurrentDepth(0);
127   if (gShowTRD)      gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);
128   if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);
129
130   // Viewers
131
132   TEveWindowSlot *slot = 0;
133   TEveWindowPack *pack = 0;
134
135   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
136   pack = slot->MakePack();
137   pack->SetElementName("Multi View");
138   pack->SetHorizontal();
139   pack->SetShowTitleBar(kFALSE);
140   pack->NewSlot()->MakeCurrent();
141   g3DView = gEve->SpawnNewViewer("3D View", "");
142   g3DView->AddScene(gEve->GetGlobalScene());
143   g3DView->AddScene(gEve->GetEventScene());
144
145   pack = pack->NewSlot()->MakePack();
146   pack->SetShowTitleBar(kFALSE);
147   pack->NewSlot()->MakeCurrent();
148   gRPhiView = gEve->SpawnNewViewer("RPhi View", "");
149   gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
150   gRPhiView->AddScene(gRPhiGeomScene);
151   gRPhiView->AddScene(gRPhiEventScene);
152
153   pack->NewSlot()->MakeCurrent();
154   gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
155   gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
156   gRhoZView->AddScene(gRhoZGeomScene);
157   gRhoZView->AddScene(gRhoZEventScene);
158
159
160   //==============================================================================
161   // Registration of per-event macros
162   //==============================================================================
163
164   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track",   "kine_tracks.C", "kine_tracks", "", kFALSE));
165
166   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit ITS", "its_hits.C",    "its_hits",    "", kFALSE));
167   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit TPC", "tpc_hits.C",    "tpc_hits",    "", kFALSE));
168   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit T0",  "t0_hits.C",     "t0_hits",     "", kFALSE));
169   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit FMD", "fmd_hits.C",    "fmd_hits",    "", kFALSE));
170
171   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD",     "fmd_digits.C",  "fmd_digits",  "", kFALSE));
172
173   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC",     "tpc_raw.C",     "tpc_raw",     "", kFALSE));
174   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW T0",      "t0_raw.C",      "t0_raw",      "", kFALSE));
175   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD",     "fmd_raw.C",     "fmd_raw",     "", kFALSE));
176   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO",   "vzero_raw.C",   "vzero_raw",   "", kFALSE));
177   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE",  "acorde_raw.C",  "acorde_raw",  "", kFALSE));
178
179   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex",             "",                kTRUE));
180   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse",     "",                kTRUE));
181   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box",         "kFALSE, 3, 3, 3", kFALSE));
182   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_spd",         "",                kTRUE));
183   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "",                kTRUE));
184   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_spd",     "kFALSE, 3, 3, 3", kFALSE));
185   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_tpc",         "",                kFALSE));
186   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "",                kFALSE));
187   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_tpc",     "kFALSE, 3, 3, 3", kFALSE));
188
189   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0_points.C",       "esd_V0_points_onfly"));
190   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0_points.C",       "esd_V0_points_offline"));
191   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0.C",              "esd_V0"));
192   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade_points.C",  "esd_cascade_points"));
193   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade.C",         "esd_cascade"));
194   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink_points.C",     "esd_kink_points"));
195   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink.C",            "esd_kink"));
196
197   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks",             "", kFALSE));
198   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI",          "", kFALSE));
199   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
200
201   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklet", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kFALSE));
202
203   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC",      "esd_zdc.C", "esd_zdc", "", kFALSE));
204
205   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus",     "clusters.C+",     "clusters", "", kFALSE));
206   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS", "its_clusters.C+", "its_clusters"));
207   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "tpc_clusters.C+", "tpc_clusters"));
208   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TRD", "trd_clusters.C+", "trd_clusters"));
209   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF", "tof_clusters.C+", "tof_clusters"));
210
211   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "vplot_tpc.C+",    "vplot_tpc", "", kFALSE));
212
213   exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
214
215   //==============================================================================
216   // Additional GUI components
217   //==============================================================================
218
219   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
220   slot->StartEmbedding();
221   AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
222   slot->StopEmbedding("DataSelection");
223   exewin->PopulateMacros();
224
225   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
226   slot->StartEmbedding();
227   new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
228   slot->StopEmbedding("QA histograms");
229
230   browser->GetTabRight()->SetTab(1);
231
232   browser->StartEmbedding(TRootBrowser::kBottom);
233   new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
234   browser->StopEmbedding("EventCtrl");
235
236   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
237   TEveWindowTab *store_tab = slot->MakeTab();
238   store_tab->SetElementNameTitle("WindowStore",
239     "Undocked windows whose previous container is not known\n"
240     "are placed here when the main-frame is closed.");
241   gEve->GetWindowManager()->SetDefaultContainer(store_tab);
242
243   //==============================================================================
244   // AliEve objects - global tools
245   //==============================================================================
246
247   AliEveTrackFitter* fitter = new AliEveTrackFitter();
248   gEve->AddToListTree(fitter, 1);
249   gEve->AddElement(fitter, gEve->GetEventScene());
250
251   AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
252   gEve->AddToListTree(g_trkcnt, kFALSE);
253
254
255   //==============================================================================
256   // Final stuff
257   //==============================================================================
258
259   // A refresh to show proper window.
260   gEve->Redraw3D(kTRUE);
261   gSystem->ProcessEvents();
262
263   // Register command to call on each event.
264   AliEveEventManager::GetMaster()->AddNewEventCommand("on_new_event();");
265   AliEveEventManager::GetMaster()->GotoEvent(0);
266
267   gEve->EditElement(g_trkcnt);
268
269   gEve->Redraw3D(kTRUE);
270 }
271
272 /******************************************************************************/
273
274 void on_new_event()
275 {
276   AliEveTrackCounter* g_trkcnt = AliEveTrackCounter::fgInstance;
277   g_trkcnt->Reset();
278   g_trkcnt->SetEventId(AliEveEventManager::GetMaster()->GetEventId());
279
280   if (g_esd_tracks_by_category_container != 0)
281   {
282     TEveElementList* cont = g_esd_tracks_by_category_container;
283
284     // Here we expect several TEveTrackList containers.
285     // First two have reasonable primaries (sigma-to-prim-vertex < 5).
286     // Others are almost certainly secondaries.
287     Int_t count = 1;
288     TEveElement::List_i i = cont->BeginChildren();
289     while (i != cont->EndChildren())
290     {
291       TEveTrackList* l = dynamic_cast<TEveTrackList*>(*i);
292       if (l != 0)
293       {
294         g_trkcnt->RegisterTracks(l, (count <= 2));
295         ++count;
296       }
297       ++i;
298     }
299
300     // Set it to zero, so that we do not reuse an old one.
301     g_esd_tracks_by_category_container = 0;
302   }
303   else
304   {
305     Warning("on_new_event", "g_esd_tracks_by_category_container not initialized.");
306   }
307
308   Double_t x[3] = { 0, 0, 0 };
309
310   if (AliEveEventManager::HasESD())
311   {
312     AliESDEvent* esd = AliEveEventManager::AssertESD();
313     esd->GetPrimaryVertex()->GetXYZ(x);
314
315     TTimeStamp ts(esd->GetTimeStamp());
316     TString win_title("Eve Main Window -- Timestamp: ");
317     win_title += ts.AsString("s");
318     win_title += "; Event # in ESD file: ";
319     win_title += esd->GetEventNumberInFile();
320     gEve->GetBrowser()->SetWindowName(win_title);
321   }
322
323   TEveElement* top = gEve->GetCurrentEvent();
324
325   if (gRPhiMgr && top)
326   {
327     gRPhiEventScene->DestroyElements();
328     if (gCenterProjectionsAtPrimaryVertex)
329       gRPhiMgr->SetCenter(x[0], x[1], x[2]);
330     gRPhiMgr->ImportElements(top, gRPhiEventScene);
331   }
332   if (gRhoZMgr && top)
333   {
334     gRhoZEventScene->DestroyElements();
335     if (gCenterProjectionsAtPrimaryVertex)
336       gRhoZMgr->SetCenter(x[0], x[1], x[2]);
337     gRhoZMgr->ImportElements(top, gRhoZEventScene);
338   }
339 }