Move initialization macros from alice-macros to macros.
[u/mrichter/AliRoot.git] / EVE / macros / visscan_init.C
CommitLineData
e9b9f7d2 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 TEveProjectionManager;
11class TEveGeoShape;
12class TEveUtil;
13
14R__EXTERN TEveProjectionManager *gRPhiMgr;
15R__EXTERN TEveProjectionManager *gRhoZMgr;
16
503bfbc8 17TEveGeoShape *gGeomGentle = 0;
18TEveGeoShape *gGeomGentleTRD = 0;
19
20Bool_t gShowTRD = kFALSE;
e9b9f7d2 21
22void visscan_init()
23{
24 TEveUtil::LoadMacro("alieve_init.C");
25 alieve_init(".", -1);
26
27 TEveUtil::LoadMacro("geom_gentle.C");
503bfbc8 28 if (gShowTRD) TEveUtil::LoadMacro("geom_gentle_trd.C");
e9b9f7d2 29
30 TEveUtil::LoadMacro("primary_vertex.C");
3a60982a 31 TEveUtil::LoadMacro("esd_V0_points.C");
ca8a6926 32 TEveUtil::LoadMacro("esd_V0.C");
e9b9f7d2 33 TEveUtil::LoadMacro("esd_tracks.C");
34 TEveUtil::LoadMacro("its_clusters.C+");
35 TEveUtil::LoadMacro("tpc_clusters.C+");
503bfbc8 36 TEveUtil::LoadMacro("trd_clusters.C+");
e9b9f7d2 37
38 TEveLine::SetDefaultSmooth(1);
39
40 /*
41 TEveViewer* nv = gEve->SpawnNewViewer("NLT Projected");
42 TEveScene* ns = gEve->SpawnNewScene("NLT");
43 nv->AddScene(ns);
44 TGLViewer* v = nv->GetGLViewer();
45 v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
46 TGLCameraMarkupStyle* mup = v->GetCameraMarkup();
47 if(mup) mup->SetShow(kFALSE);
48 */
49
50 AliEveTrackFitter* fitter = new AliEveTrackFitter();
51 gEve->AddToListTree(fitter, 1);
52 gEve->AddElement(fitter, gEve->GetEventScene());
53
54 TEveTrackCounter* g_trkcnt = new TEveTrackCounter("Primary Counter");
55 gEve->AddToListTree(g_trkcnt, kFALSE);
56
57
58 // geometry
503bfbc8 59 gGeomGentle = geom_gentle();
60 if (gShowTRD) gGeomGentleTRD = geom_gentle_trd();
e9b9f7d2 61
62
63 gROOT->ProcessLine(".L SplitGLView.C+g"); // !!!! debug-mode
64 TEveBrowser* browser = gEve->GetBrowser();
65 browser->ExecPlugin("SplitGLView", 0, "new SplitGLView(gClient->GetRoot(), 600, 450, kTRUE)");
66
67 if (gRPhiMgr) {
68 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);
69 a->SetNumTickMarks(3);
70 a->SetText("R-Phi");
71 a->SetFontFile("comicbd");
72 a->SetFontSize(10);
73 gEve->GetScenes()->FindChild("R-Phi Projection")->AddElement(a);
e9b9f7d2 74 }
75 if (gRhoZMgr) {
76 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);
77 a->SetNumTickMarks(3);
78 a->SetText("Rho-Z");
79 a->SetFontFile("comicbd");
80 a->SetFontSize(10);
81 gEve->GetScenes()->FindChild("Rho-Z Projection")->AddElement(a);
e9b9f7d2 82 }
83
84 // event
85 gAliEveEvent->AddNewEventCommand("on_new_event();");
86 gAliEveEvent->GotoEvent(0);
87
88 gEve->Redraw3D(kTRUE);
89}
90
91/******************************************************************************/
92
93void on_new_event()
94{
95 try {
96 TEvePointSet* itsc = its_clusters();
787c89c5 97 if (itsc) {
98 itsc->SetMarkerColor(5);
99 }
e9b9f7d2 100
101 TEvePointSet* tpcc = tpc_clusters();
787c89c5 102 if (tpcc) {
103 tpcc->SetMarkerColor(4);
104 }
503bfbc8 105
106 TEvePointSet* trdc = trd_clusters();
787c89c5 107 if (trdc) {
108 trdc->SetMarkerColor(7);
109 trdc->SetMarkerStyle(4);
110 trdc->SetMarkerSize(0.5);
111 }
e9b9f7d2 112 }
113 catch(TEveException& exc) {
114 printf("Exception loading ITS/TPC clusters: %s\n", exc.Data());
115 }
116
117 primary_vertex(1, 1);
3a60982a 118 esd_V0_points();
ca8a6926 119 esd_V0();
e9b9f7d2 120
121 TEveElementList* cont = esd_tracks_vertex_cut();
122
123 // Here we expect five TEveTrackList containers.
124 // First two have reasonable primaries (sigma-to-prim-vertex < 5).
125 // Other three are almost certainly secondaries.
126 Int_t count = 1;
127 TEveTrackCounter* g_trkcnt = TEveTrackCounter::fgInstance;
128 g_trkcnt->Reset();
129 g_trkcnt->SetEventId(gAliEveEvent->GetEventId());
130 TEveElement::List_i i = cont->BeginChildren();
131 while (i != cont->EndChildren()) {
132 TEveTrackList* l = dynamic_cast<TEveTrackList*>(*i);
133 if (l != 0) {
134 // l->SetLineWidth(2);
135 g_trkcnt->RegisterTracks(l, (count <= 2));
136 ++count;
137 }
138 ++i;
139 }
140
141 AliESDEvent* esd = AliEveEventManager::AssertESD();
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);
503bfbc8 151 if (gShowTRD) gRPhiMgr->ImportElements(gGeomGentleTRD);
e9b9f7d2 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);
503bfbc8 158 if (gShowTRD) gRhoZMgr->ImportElements(gGeomGentleTRD);
e9b9f7d2 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}