Prototype for visualization-macro manager and gui.
[u/mrichter/AliRoot.git] / EVE / macros / anyscan_init.C
CommitLineData
f6afd0e1 1// $Id: NLT_trackcount_init.C 24927 2008-04-04 13:46:04Z mtadel $
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
10class AliEveMacroExecutor;
11
12class TEveProjectionManager;
13class TEveGeoShape;
14class TEveUtil;
15
16R__EXTERN TEveProjectionManager *gRPhiMgr;
17R__EXTERN TEveProjectionManager *gRhoZMgr;
18
19TEveGeoShape *gGeomGentle = 0;
20TEveGeoShape *gGeomGentleTRD = 0;
21
22Bool_t gShowTRD = kFALSE;
23
24void anyscan_init()
25{
26 TEveUtil::LoadMacro("alieve_init.C");
27 alieve_init(".", -1);
28
29 TEveLine::SetDefaultSmooth(1);
30
31 TEveUtil::AssertMacro("VizDB_scan.C");
32
33
34 AliEveTrackFitter* fitter = new AliEveTrackFitter();
35 gEve->AddToListTree(fitter, 1);
36 gEve->AddElement(fitter, gEve->GetEventScene());
37
38 AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
39 gEve->AddToListTree(g_trkcnt, kFALSE);
40
41
42 gROOT->ProcessLine(".L SplitGLView.C+");
43 TEveBrowser* browser = gEve->GetBrowser();
44 browser->ExecPlugin("SplitGLView", 0, "new SplitGLView(gClient->GetRoot(), 600, 450, kTRUE)");
45
46 if (gRPhiMgr) {
47 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);
48 a->SetNumTickMarks(3);
49 a->SetText("R-Phi");
50 a->SetFontFile("comicbd");
51 a->SetFontSize(10);
52 gEve->GetScenes()->FindChild("R-Phi Projection")->AddElement(a);
53 }
54 if (gRhoZMgr) {
55 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);
56 a->SetNumTickMarks(3);
57 a->SetText("Rho-Z");
58 a->SetFontFile("comicbd");
59 a->SetFontSize(10);
60 gEve->GetScenes()->FindChild("Rho-Z Projection")->AddElement(a);
61 }
62
63 // geometry
64 TEveUtil::LoadMacro("geom_gentle.C");
65 gGeomGentle = geom_gentle();
66 if (gShowTRD) {
67 TEveUtil::LoadMacro("geom_gentle_trd.C");
68 gGeomGentleTRD = geom_gentle_trd();
69 }
70
71
72 AliEveMacroExecutor *exec = gAliEveEvent->GetExecutor();
73
74 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "primary_vertex.C", "primary_vertex"));
75 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "esd_V0_points.C", "esd_V0_points"));
76 exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "esd_V0.C", "esd_V0"));
77 // exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "esd_tracks.C", ""));
78 TEveUtil::LoadMacro("esd_tracks.C");
79
80 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "its_clusters.C+", "its_clusters"));
81 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "tpc_clusters.C+", "tpc_clusters"));
82 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "trd_clusters.C+", "trd_clusters"));
83 exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "tof_clusters.C+", "tof_clusters"));
84
85 TEveBrowser* browser = gEve->GetBrowser();
86
87 browser->StartEmbedding(TRootBrowser::kRight);
88 AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
89 browser->StopEmbedding("DataSelection");
90 exewin->PopulateMacros();
91
92 browser->GetTabRight()->SetTab(1);
93
94 browser->StartEmbedding(TRootBrowser::kBottom);
95 new AliEveEventManagerWindow;
96 browser->StopEmbedding("EventCtrl");
97
98 // event
99 gAliEveEvent->AddNewEventCommand("on_new_event();");
100 gAliEveEvent->GotoEvent(0);
101
102 gEve->EditElement(g_trkcnt);
103
104 gEve->Redraw3D(kTRUE);
105}
106
107/******************************************************************************/
108
109void on_new_event()
110{
111 printf("on_new_event() entered ...\n");
112
113 TEveElementList* cont = esd_tracks_vertex_cut();
114
115 // Here we expect five TEveTrackList containers.
116 // First two have reasonable primaries (sigma-to-prim-vertex < 5).
117 // Other three are almost certainly secondaries.
118 Int_t count = 1;
119 AliEveTrackCounter* g_trkcnt = AliEveTrackCounter::fgInstance;
120 g_trkcnt->Reset();
121 g_trkcnt->SetEventId(gAliEveEvent->GetEventId());
122 TEveElement::List_i i = cont->BeginChildren();
123 while (i != cont->EndChildren()) {
124 TEveTrackList* l = dynamic_cast<TEveTrackList*>(*i);
125 if (l != 0) {
126 // l->SetLineWidth(2);
127 g_trkcnt->RegisterTracks(l, (count <= 2));
128 ++count;
129 }
130 ++i;
131 }
132
133 AliESDEvent* esd = AliEveEventManager::AssertESD();
134 {
135 TTimeStamp ts(esd->GetTimeStamp());
136 TString win_title("Eve Main Window -- Timestamp: ");
137 win_title += ts.AsString("s");
138 win_title += "; Event # in ESD file: ";
139 win_title += esd->GetEventNumberInFile();
140 gEve->GetBrowser()->SetWindowName(win_title);
141 }
142 Double_t x[3];
143 esd->GetPrimaryVertex()->GetXYZ(x);
144
145 TEveElement* top = gEve->GetCurrentEvent();
146
147 if (gRPhiMgr && top) {
148 gRPhiMgr->DestroyElements();
149 gRPhiMgr->SetCenter(x[0], x[1], x[2]);
150 gRPhiMgr->ImportElements(gGeomGentle);
151 if (gShowTRD) gRPhiMgr->ImportElements(gGeomGentleTRD);
152 gRPhiMgr->ImportElements(top);
153 }
154 if (gRhoZMgr && top) {
155 gRhoZMgr->DestroyElements();
156 gRhoZMgr->SetCenter(x[0], x[1], x[2]);
157 gRhoZMgr->ImportElements(gGeomGentle);
158 if (gShowTRD) gRhoZMgr->ImportElements(gGeomGentleTRD);
159 gRhoZMgr->ImportElements(top);
160 }
161
162 gROOT->ProcessLine("SplitGLView::UpdateSummary()");
163}
164
165/******************************************************************************/
166
167TParticle* id(Int_t label=0, Bool_t showParents=kTRUE)
168{
169 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
170 rl->LoadKinematics();
171 AliStack* stack = rl->Stack();
172
173 printf("Number primaries %d, all particles %d, label %d\n",
174 stack->GetNprimary(), stack->GetNtrack(), label);
175 if (label < 0 || label >= stack->GetNtrack()) {
176 printf(" Label exceeds available range.\n");
177 return 0;
178 }
179
180 TParticle* part = stack->Particle(label);
181 if (part != 0) {
182 part->Print();
183 if (showParents) {
184 while (part->GetMother(0) >= 0) {
185 part = stack->Particle(part->GetMother(0));
186 part->Print();
187 }
188 }
189 }
190 return stack->Particle(label);
191}