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