Geometry for MFT (Brigitte)
[u/mrichter/AliRoot.git] / EVE / alice-macros / trd_gtutracks.C
CommitLineData
ba978640 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TClonesArray.h>
3#include <TParticlePDG.h>
4#include <TEveLine.h>
5#include <TEveStraightLineSet.h>
6#include <TEveManager.h>
7#include <TEveElement.h>
a1d14acd 8
6c49a8e1 9#include <AliRunLoader.h>
10#include <AliLoader.h>
11#include <AliDataLoader.h>
12#include <AliTreeLoader.h>
13#include <AliTRDarrayADC.h>
14#include <AliTRDgeometry.h>
15#include <AliTRDtrackletWord.h>
16#include <AliTRDtrackletMCM.h>
17#include <AliTRDtrackGTU.h>
18#include <AliTRDtrackletGTU.h>
19#include <AliEveEventManager.h>
20#include <AliEveTRDData.h>
a1d14acd 21#endif
98b9b8b2 22
23TEveElementList *
24trd_gtutracks()
25{
a1d14acd 26 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
27 AliLoader *loader = rl->GetLoader("TRDLoader");
28 AliDataLoader *dl = loader->GetDataLoader("gtutracks");
29 if (!dl) {
30 dl = new AliDataLoader("TRD.GtuTracks.root","gtutracks", "gtutracks");
31 rl->GetLoader("TRDLoader")->AddDataLoader(dl);
32 }
98b9b8b2 33
a1d14acd 34 dl->Load();
35 TTree *trktree = dl->Tree();
36 if (!trktree) {
37 printf("No GTU track tree");
38 return 0x0;
39 }
98b9b8b2 40 AliTRDtrackGTU *trk = 0x0;
a1d14acd 41 trktree->SetBranchAddress("TRDtrackGTU", &trk);
42
98b9b8b2 43 gEve->DisableRedraw();
44 TEveElementList* listOfTracks = new TEveElementList("GTU Tracks");
45 gEve->AddElement(listOfTracks);
46
47 AliTRDgeometry *geo = new AliTRDgeometry;
a1d14acd 48
49 // printf("found %i tracks\n", trktree->GetEntriesFast());
98b9b8b2 50 for (Int_t i = 0; i < trktree->GetEntriesFast(); i++) {
51 trktree->GetEntry(i);
52 if (!trk)
53 continue;
54 Int_t sector = trk->GetSector();
55 Double_t *x = new Double_t[3];
56 Double_t *p = new Double_t[3];
57 Double_t *p2 = new Double_t[3];
58 x[0] = x[1] = x[2] = 0;
59 x[1] = trk->GetA() / 2 * 160e-4;
60 geo->RotateBack(sector*30, x, p);
98b9b8b2 61 x[0] = 400;
62 x[1] = x[0] * trk->GetB() + trk->GetA() / 2 * 160e-4;
63 x[2] = -1 * x[0] * trk->GetC() / TMath::Tan( -2.0 / 180.0 * TMath::Pi() );
64 geo->RotateBack(sector*30, x, p2);
98b9b8b2 65 TEveLine *track = new TEveLine(Form("GTU track pt: %4.2f (%i)", trk->GetPt(), trk->GetLabel()));
66 track->SetMainColor((Color_t) 4);
67 track->SetNextPoint(p[0], p[1], p[2]);
68 track->SetNextPoint(p2[0], p2[1], p2[2]);
69 gEve->AddElement(track, listOfTracks);
70 delete[] x;
71 delete[] p;
72 delete[] p2;
a1d14acd 73// TEveStraightLineSet* trkl = new TEveStraightLineSet("TRD Tracklets");
74// trkl->SetMainColor((Color_t) 2);
75// gEve->AddElement(trkl, track);
76// Int_t det = trk->GetSector() * 30 + trk->GetStack() * 6;
77// printf("Track in SM: %i, Stack: %i => Det: %i\n", trk->GetSector(), trk->GetStack(), det);
78// for (Int_t layer = 0; layer < 6; layer++) {
79// printf("checking for tracklet in layer %i\n", layer);
80// if (trk->IsTrackletInLayer(layer)) {
81// printf("tracklet in layer %i\n", layer);
82// AliTRDtrackletGTU *trklet = trk->GetTracklet(layer);
83// Double_t *x = new Double_t[3];
84// x[0] = geo->GetTime0(layer);
85// AliTRDpadPlane *pp = geo->GetPadPlane(layer, trk->GetStack());
86// x[1] = trklet->GetYbin() * 0.0160;
87// x[2] = pp->GetRowPos(trklet->GetZbin()) - pp->GetRowSize(trklet->GetZbin())/2;
88// Double_t *p = new Double_t[3];
89// Double_t *p2 = new Double_t[3];
90// geo->RotateBack(det, x, p);
91// x[0] -= 10;
92// x[1] += 10 * trklet->GetdYdX();
93// x[2] *= x[0]/(x[0]+10);
94// geo->RotateBack(det, x, p2);
95// trkl->AddLine(p[0], p[1], p[2], p2[0], p2[1], p2[2]);
96// delete[] x;
97// delete[] p;
98// delete[] p2;
99//
100// }
101// }
98b9b8b2 102 }
103
104 gEve->EnableRedraw();
105 gEve->Redraw3D();
106
107 return listOfTracks;
108}
109