]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/clusters.C
Geometry for MFT (Brigitte)
[u/mrichter/AliRoot.git] / EVE / alice-macros / clusters.C
1 #ifndef __CINT__
2 #include <TEveManager.h>
3 #include <TEvePointSet.h>
4 #include <TGeoManager.h>
5 #include <EveBase/AliEveEventManager.h>
6
7 #include "AliRunLoader.h"
8 #include "AliCluster.h"
9 #include "AliTracker.h"
10 #include "AliReconstruction.h"
11 #include "AliESDEvent.h"
12 #include "AliESDtrack.h"
13 #include "AliESDfriend.h"
14
15 #include "AliITSRecoParam.h"
16 #endif
17
18 void clusters()
19 {
20   AliEveEventManager::AssertGeometry();
21
22   AliRunLoader *rl        = AliEveEventManager::AssertRunLoader();
23   AliESDEvent  *esd       = AliEveEventManager::AssertESD();
24   AliEveEventManager::AssertESDfriend();
25   AliEveEventManager::AssertMagField();
26
27   const char* detNames[] = { "ITS", "TPC", /*"TRD",*/ "TOF", "HMPID" };
28   const Int_t detIds[]   = {   0,     1,   /*  2,  */   3,     5   };
29   const Int_t detN       = sizeof(detNames)/sizeof(char*);
30
31   // Hack - AliReconstruction does wonders with gGeoManager.
32   TGeoManager* xxx = gGeoManager; gGeoManager = 0;
33   AliReconstruction* reco = new AliReconstruction;
34   gGeoManager = xxx;
35
36   // Hack for ITS - it requires RecoParams outside event-loop!
37   reco->SetRecoParam("ITS", AliITSRecoParam::GetLowFluxParam());
38
39   reco->ImportRunLoader(rl);
40   {
41     TString alldets;
42     for (Int_t i = 0; i < detN; ++i) {
43       alldets += detNames[i];
44       alldets += " ";
45     }
46     reco->CreateTrackers(alldets);
47   }
48
49   TObjArray* clarr = new TObjArray();
50
51   // Load clusters, fill them into clarr.
52
53   for (Int_t i = 0; i < detN; ++i)
54   {
55     Int_t det = detIds[i];
56     rl->LoadRecPoints(detNames[i]);
57
58     TTree *cTree = rl->GetTreeR(detNames[i], false);
59     if (cTree == 0)
60       continue;
61
62     AliTracker* tracker = reco->GetTracker(det);
63     if (tracker == 0) continue;
64     tracker->LoadClusters(cTree);
65     tracker->FillClusterArray(clarr);
66   }
67
68   // Loop over tracks and friends, tag used clusters.
69
70   for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
71   {
72     AliESDtrack* at = esd->GetTrack(n);
73
74     Int_t idx[200];
75     for (Int_t i = 0; i < detN; ++i)
76     {
77       Int_t det = detIds[i];
78       AliTracker* tracker = reco->GetTracker(det);
79       if (tracker == 0) continue;
80       Int_t nclusters = at->GetClusters(det, idx);
81       Int_t p=0;
82       for (Int_t c = 0; c < nclusters; )
83       {
84         Int_t index = idx[p++];
85         if (index < 0) continue;
86         c++;
87         AliCluster* cluster = tracker->GetCluster(index);
88         if (cluster) cluster->IncreaseClusterUsage();
89         //else printf("Zero cluster pointer for detector: %s\n",detNames[i]);
90       }
91     }
92   }
93
94   for (Int_t i = 0; i < detN; ++i)
95     rl->UnloadRecPoints(detNames[i]);
96
97   // Fill visualization structs
98
99   TEveElementList* list = new TEveElementList("Clusters");
100   gEve->AddElement(list);
101
102   TEvePointSet* shared = new TEvePointSet("Shared Clusters");
103   shared->SetMainColor(2);
104   shared->SetMarkerSize(0.4);
105   shared->SetMarkerStyle(2);
106   list->AddElement(shared);
107
108   TEvePointSet* used = new TEvePointSet("Single-used Clusters");
109   used->SetMainColor(3);
110   used->SetMarkerSize(0.4);
111   used->SetMarkerStyle(2);
112   list->AddElement(used);
113
114   TEvePointSet* nonused = new TEvePointSet("Not-used Clusters");
115   nonused->SetMainColor(4);
116   nonused->SetMarkerSize(0.4);
117   nonused->SetMarkerStyle(2);
118   list->AddElement(nonused);
119
120   // Loop over all clusters, fill appropriate container based
121   // on shared/used information.
122
123   Int_t ncl = clarr->GetEntriesFast();
124   for (Int_t i = 0; i < ncl; ++i)
125   {
126     AliCluster   *cluster = (AliCluster*) clarr->UncheckedAt(i);
127     TEvePointSet *dest    = 0;
128     if (cluster->IsClusterShared())
129       dest = shared;
130     else if (cluster->IsClusterUsed())
131       dest = used;
132     else
133       dest = nonused;
134
135     Float_t g[3]; //global coordinates
136     cluster->GetGlobalXYZ(g);
137     dest->SetNextPoint(g[0], g[1], g[2]);
138     dest->SetPointId(cluster);
139   }
140
141   delete clarr;
142
143   // ??? What to do with trackers ???
144   // I'd propose: have global reconstruction that owns them.
145   // AliEveEventManager::AssertAliReconstruction();
146   // do we have bit-field for detectors, like
147   // enum AliDetectors_e {
148   //    kITS = BIT(0),
149   //    kTPC = BIT(1),
150   //    ...
151   //    kCentralTracking = kITS | kTPC | kTRD | kTOF,
152   //    ...
153   //  };
154
155   gEve->Redraw3D();
156 }