Update master to aliroot
[u/mrichter/AliRoot.git] / EVE / macros / muon_init.C
CommitLineData
39d6561a 1// $Id$
2
3/**************************************************************************
4 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
5 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
6 * full copyright notice. *
7 **************************************************************************/
8
25b4bdb2 9/// \ingroup evemacros
10/// \file muon_init.C
11///
12/// \author P. Pillot, L. Aphecetche; Subatech
13
39d6561a 14class AliEveMacroExecutor;
15class TEveProjectionManager;
16class TEveGeoShape;
17class TEveUtil;
18class TSystem;
19class TInterpreter;
20
21Bool_t gShowMuonRPhi = kFALSE;
22Bool_t gShowMuonRhoZ = kTRUE;
a9c27e9a 23Bool_t gShowMuon = kTRUE;
39d6561a 24
25Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
26
27
28void muon_init(const TString& cdburi = "",
d4731f84 29 const TString& path = ".",
2c21985b 30 Bool_t showBarrel = kFALSE)
39d6561a 31{
32 if (gSystem->Getenv("ALICE_ROOT") != 0)
33 {
34 gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
35 gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
36 }
37
38 if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
39 {
40 gEnv->SetValue("Root.Stacktrace", "no");
41 Fatal("muon_init.C", "OCDB path MUST be specified as the first argument.");
42 }
43
44 TEveUtil::LoadMacro("alieve_init.C");
d4731f84 45 path.Remove(TString::kTrailing, '/');
39d6561a 46 if (path.BeginsWith("alien:")) AliEveEventManager::SearchRawForCentralReconstruction();
47 alieve_init(cdburi, path, -1);
48
49 TEveUtil::AssertMacro("VizDB_scan.C");
50
51 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
52 TEveBrowser *browser = gEve->GetBrowser();
53 browser->ShowCloseTab(kFALSE);
54
55
56 //==============================================================================
57 // Geometry, scenes, projections and viewers
58 //==============================================================================
59
60 AliEveMultiView *mv = new AliEveMultiView;
61
62 mv->SetDepth(-10);
63
64 TEveUtil::LoadMacro("geom_gentle.C");
2c21985b 65 TEveUtil::LoadMacro("geom_gentle_muon.C+");
a9c27e9a 66
67 mv->InitGeomGentle(geom_gentle(), geom_gentle_rphi(), geom_gentle_rhoz(), geom_gentle_muon(kFALSE));
68
69 mv->InitGeomGentleMuon(geom_gentle_muon(kFALSE), gShowMuonRPhi, gShowMuonRhoZ, gShowMuon);
39d6561a 70
71 mv->SetDepth(0);
72
73 //==============================================================================
74 // Registration of per-event macros
75 //==============================================================================
76
77 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track","kine_tracks.C+", "kine_tracks", "", kFALSE));
78
2c21985b 79 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM TrackRef","muon_trackRefs.C+","muon_trackRefs","kTRUE", kTRUE));
39d6561a 80
81 exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON", "muon_raw.C+", "muon_raw", "", kTRUE));
82
83 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG MUON", "muon_digits.C+", "muon_digits", "", kFALSE));
84
85 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "CLU MUON", "muon_clusters.C+","muon_clusters","", kTRUE));
86
87 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_muon_tracks.C+", "esd_muon_tracks","kTRUE,kTRUE", kTRUE));
88
d4731f84 89 if (showBarrel) {
90 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX", "primary_vertex.C+", "primary_vertex", "", kTRUE));
91 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX SPD", "primary_vertex.C+", "primary_vertex_spd", "", kTRUE));
92 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by category", "esd_tracks.C+", "esd_tracks_by_category", "", kTRUE));
93 }
94
39d6561a 95 //==============================================================================
96 // Additional GUI components
97 //==============================================================================
98
99 // Macro / data selection
100 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
101 slot->StartEmbedding();
102 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
103 slot->StopEmbedding("DataSelection");
104 exewin->PopulateMacros();
105
106 // Event selection tab
107 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
108 slot->StartEmbedding();
109 new AliEveEventSelectorWindow(gClient->GetRoot(), 600, 400, AliEveEventManager::GetMaster()->GetEventSelector());
110 slot->StopEmbedding("Selections");
111
112 // QA viewer
113 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
114 slot->StartEmbedding();
115 new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
116 slot->StopEmbedding("QA histograms");
117
118 browser->GetTabRight()->SetTab(1);
119
120 browser->StartEmbedding(TRootBrowser::kBottom);
121 new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
122 browser->StopEmbedding("EventCtrl");
123
124 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
125 TEveWindowTab *store_tab = slot->MakeTab();
126 store_tab->SetElementNameTitle("WindowStore",
127 "Undocked windows whose previous container is not known\n"
128 "are placed here when the main-frame is closed.");
129 gEve->GetWindowManager()->SetDefaultContainer(store_tab);
130
131
132 //==============================================================================
133 // AliEve objects - global tools
134 //==============================================================================
135
39d6561a 136 AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
137 gEve->AddToListTree(g_trkcnt, kFALSE);
138
139
140 //==============================================================================
141 // Final stuff
142 //==============================================================================
143
144 // A refresh to show proper window.
145 //gEve->GetViewers()->SwitchColorSet();
146 gEve->Redraw3D(kTRUE);
147 gSystem->ProcessEvents();
148
149 // Register command to call on each event.
150 AliEveEventManager::GetMaster()->AddNewEventCommand("on_new_event();");
151 AliEveEventManager::GetMaster()->GotoEvent(0);
152
153 gEve->EditElement(g_trkcnt);
154
155 gEve->Redraw3D(kTRUE);
d4731f84 156
157 // Assure 3D view rotates around the origin.
158 gSystem->ProcessEvents();
159 AliEveMultiView::Instance()->Get3DView()->GetGLViewer()->CurrentCamera().SetCenterVec(0,0,0);
160 AliEveMultiView::Instance()->Get3DView()->GetGLViewer()->RequestDraw();
39d6561a 161}
162
163/******************************************************************************/
164
165void on_new_event()
166{
167 Double_t x[3] = { 0, 0, 0 };
168
169 if (AliEveEventManager::HasESD())
170 {
171 AliESDEvent* esd = AliEveEventManager::AssertESD();
172 esd->GetPrimaryVertex()->GetXYZ(x);
173
174 TTimeStamp ts(esd->GetTimeStamp());
175 TString win_title("Eve Main Window -- Timestamp: ");
176 win_title += ts.AsString("s");
177 win_title += "; Event # in ESD file: ";
178 win_title += esd->GetEventNumberInFile();
179 gEve->GetBrowser()->SetWindowName(win_title);
180 }
181
182 TEveElement* top = gEve->GetCurrentEvent();
183
184 AliEveMultiView *mv = AliEveMultiView::Instance();
185
186 mv->DestroyEventRPhi();
187 if (gCenterProjectionsAtPrimaryVertex)
188 mv->SetCenterRPhi(x[0], x[1], x[2]);
189 mv->ImportEventRPhi(top);
190
191 mv->DestroyEventRhoZ();
192 if (gCenterProjectionsAtPrimaryVertex)
193 mv->SetCenterRhoZ(x[0], x[1], x[2]);
194 mv->ImportEventRhoZ(top);
195}