Move initialization macros from alice-macros to macros.
[u/mrichter/AliRoot.git] / EVE / macros / NLT_trackcount_init.C
CommitLineData
d810d0de 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
9
84aff7a4 10class TEveProjectionManager;
11class TEveGeoShape;
d810d0de 12class TEveUtil;
32e219c2 13
a15e6d7d 14TEveProjectionManager *proj = 0;
15TEveGeoShape *geom = 0;
32e219c2 16
17void NLT_trackcount_init()
18{
84aff7a4 19 TEveUtil::LoadMacro("alieve_init.C");
32e219c2 20 alieve_init(".", -1);
21
84aff7a4 22 TEveUtil::LoadMacro("geom_gentle.C");
32e219c2 23
84aff7a4 24 TEveUtil::LoadMacro("primary_vertex.C");
25 TEveUtil::LoadMacro("esd_tracks.C");
26 TEveUtil::LoadMacro("its_clusters.C+");
27 TEveUtil::LoadMacro("tpc_clusters.C+");
32e219c2 28
84aff7a4 29 TEveViewer* nv = gEve->SpawnNewViewer("NLT Projected");
51346b82 30 TEveScene* ns = gEve->SpawnNewScene("NLT");
7f690e88 31 nv->AddScene(ns);
32 TGLViewer* v = nv->GetGLViewer();
32e219c2 33 v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
34 TGLCameraMarkupStyle* mup = v->GetCameraMarkup();
35 if(mup) mup->SetShow(kFALSE);
36
2be943d0 37 AliEveTrackFitter* fitter = new AliEveTrackFitter();
38 gEve->AddToListTree(fitter, 1);
39 gEve->AddElement(fitter, gEve->GetEventScene());
40
84aff7a4 41 TEveTrackCounter* g_trkcnt = new TEveTrackCounter("Primary Counter");
42 gEve->AddToListTree(g_trkcnt, kFALSE);
32e219c2 43
a15e6d7d 44 TEveProjectionManager* pm = new TEveProjectionManager();
45 proj = pm;
46 gEve->AddToListTree(proj, kTRUE);
84aff7a4 47 gEve->AddElement(proj, ns);
a15e6d7d 48
49 TEveProjectionAxes* axes = new TEveProjectionAxes(proj);
50 axes->SetText("Projected Track-Count");
51 axes->SetFontFile("comicbd");
52 axes->SetFontSize(20);
53 gEve->AddElement(axes, ns);
54 gEve->AddToListTree(axes, kTRUE);
32e219c2 55
56 // geometry
84aff7a4 57 TEveGeoShape* gg = geom_gentle();
32e219c2 58 geom = gg;
59
60 // event
a15e6d7d 61 gAliEveEvent->AddNewEventCommand("on_new_event();");
62 gAliEveEvent->GotoEvent(0);
32e219c2 63
84aff7a4 64 gEve->Redraw3D(kTRUE);
32e219c2 65}
66
57ffa5fb 67/******************************************************************************/
32e219c2 68
69void on_new_event()
70{
e156585b 71 try {
84aff7a4 72 TEvePointSet* itsc = its_clusters();
e156585b 73 itsc->SetMarkerColor(5);
32e219c2 74
84aff7a4 75 TEvePointSet* tpcc = tpc_clusters();
e156585b 76 tpcc->SetMarkerColor(4);
77 }
84aff7a4 78 catch(TEveException& exc) {
e156585b 79 printf("Exception loading ITS/TPC clusters: %s\n", exc.Data());
80 }
32e219c2 81
82 primary_vertex(1, 1);
83
84aff7a4 84 TEveElementList* cont = esd_tracks_vertex_cut();
32e219c2 85
84aff7a4 86 // Here we expect five TEveTrackList containers.
32e219c2 87 // First two have reasonable primaries (sigma-to-prim-vertex < 5).
88 // Other three are almost certainly secondaries.
89 Int_t count = 1;
84aff7a4 90 TEveTrackCounter* g_trkcnt = TEveTrackCounter::fgInstance;
32e219c2 91 g_trkcnt->Reset();
a15e6d7d 92 g_trkcnt->SetEventId(gAliEveEvent->GetEventId());
84aff7a4 93 TEveElement::List_i i = cont->BeginChildren();
32e219c2 94 while (i != cont->EndChildren()) {
84aff7a4 95 TEveTrackList* l = dynamic_cast<TEveTrackList*>(*i);
32e219c2 96 if (l != 0) {
97 l->SetLineWidth(2);
98 g_trkcnt->RegisterTracks(l, (count <= 2));
99 ++count;
100 }
101 ++i;
102 }
84aff7a4 103 TEveElement* top = gEve->GetCurrentEvent();
32e219c2 104 proj->DestroyElements();
d810d0de 105 AliESDEvent* esd = AliEveEventManager::AssertESD();
3ddd3de5 106 Double_t x[3];
107 esd->GetPrimaryVertex()->GetXYZ(x);
108 proj->SetCenter(x[0], x[1], x[2]);
109
32e219c2 110 // geom
111 proj->ImportElements(geom);
112 // event
113 proj->ImportElements(top);
114 // top->SetRnrState(kFALSE);
115}
116
57ffa5fb 117/******************************************************************************/
32e219c2 118
119TParticle* id(Int_t label=0, Bool_t showParents=kTRUE)
120{
d810d0de 121 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
32e219c2 122 rl->LoadKinematics();
123 AliStack* stack = rl->Stack();
124
125 printf("Number primaries %d, all particles %d, label %d\n",
126 stack->GetNprimary(), stack->GetNtrack(), label);
127 if (label < 0 || label >= stack->GetNtrack()) {
128 printf(" Label exceeds available range.\n");
129 return 0;
130 }
131
132 TParticle* part = stack->Particle(label);
84aff7a4 133 if (part != 0) {
32e219c2 134 part->Print();
84aff7a4 135 if (showParents) {
136 while (part->GetMother(0) >= 0) {
32e219c2 137 part = stack->Particle(part->GetMother(0));
138 part->Print();
139 }
140 }
141 }
142 return stack->Particle(label);
143}