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