Avoid usage of script-global variables as they get reset on exceptions; rely on stati...
[u/mrichter/AliRoot.git] / EVE / macros / trackcount_init.C
CommitLineData
6f2dc95a 1void trackcount_init()
2{
3 Reve::LoadMacro("alieve_init.C");
4 alieve_init(".", -1);
5
6 {
7 TGLViewer* glv = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->GetViewer3D());
8 glv->SetIgnoreSizesOnUpdate(kTRUE);
9 // The size of ortho cameras can not be set in advance.
10 // glv->SetOrthoCamera(TGLViewer::kCameraOrthoXOY, -0.1, 0.1, 0.1, -0.1);
11 // glv->SetOrthoCamera(TGLViewer::kCameraOrthoZOY, -22, 22, 22, -22);
12 }
13
ad964bd1 14 Reve::TrackCounter* g_trkcnt = new Reve::TrackCounter("Primary Counter");
6f2dc95a 15 gReve->AddGlobalRenderElement(g_trkcnt);
16
17 Alieve::gEvent->AddNewEventCommand("on_new_event();");
18 Alieve::gEvent->GotoEvent(0);
19}
20
21void on_new_event()
22{
23 Reve::LoadMacro("primary_vertex.C");
24 Reve::LoadMacro("esd_tracks.C");
25 Reve::LoadMacro("its_hits.C");
26 Reve::LoadMacro("tpc_hits.C");
27
28 Reve::PointSet* p = its_hits();
29 p->SetMarkerStyle(4);
30
31 primary_vertex(1, 1);
32
33 Reve::RenderElementList* cont = esd_tracks_vertex_cut();
34 TGListTree* lt = gReve->GetListTree();
35 TGListTreeItem* ti = cont->FindListTreeItem(lt);
36 lt->OpenItem(ti);
37
38 // Here we expect five TrackList containers.
39 // First two have reasonable primaries (sigma-to-prim-vertex < 5).
40 // Other three are almost certainly secondaries.
41 Int_t count = 1;
ad964bd1 42 Reve::TrackCounter* g_trkcnt = Reve::TrackCounter::fgInstance;
6f2dc95a 43 g_trkcnt->Reset();
b07ffc74 44 g_trkcnt->SetEventId(Alieve::gEvent->GetEventId());
ae4998fc 45 Reve::RenderElement::List_i i = cont->BeginChildren();
6f2dc95a 46 while (i != cont->EndChildren()) {
47 Reve::TrackList* l = dynamic_cast<Reve::TrackList*>(*i);
48 if (l != 0) {
49 l->SetWidth(2);
50 g_trkcnt->RegisterTracks(l, (count <= 2));
51 ++count;
52 }
53 ++i;
54 }
55}
56
1f373d3e 57TParticle* id(Int_t label=0, Bool_t showParents=kTRUE)
6f2dc95a 58{
59 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
60 rl->LoadKinematics();
61 AliStack* stack = rl->Stack();
62
1f373d3e 63 printf("Number primaries %d, all particles %d, label %d\n",
64 stack->GetNprimary(), stack->GetNtrack(), label);
65 if (label < 0 || label >= stack->GetNtrack()) {
66 printf(" Label exceeds available range.\n");
67 return 0;
68 }
6f2dc95a 69
70 TParticle* part = stack->Particle(label);
71 if(part != 0) {
72 part->Print();
73 if(showParents) {
74 while(part->GetMother(0) >= 0) {
75 part = stack->Particle(part->GetMother(0));
76 part->Print();
77 }
78 }
79 }
1f373d3e 80
81 return stack->Particle(label);
6f2dc95a 82}