Remove information printout.
[u/mrichter/AliRoot.git] / EVE / test-macros / cone_test.C
CommitLineData
b555e86e 1// Demonstrates usage of TEveJetCone class.
2// Author: Jochen Thaeder
3
4void cone_test() {
5
6 using namespace TMath;
7
8 TRandom r(0);
9
10 // -- Set Constants
11 Int_t nCones = 10;
12 Int_t nTracks = 200;
13
14 Float_t coneRadius = 0.4;
15 Float_t length = 300.;
16
17 // -- Define palette
18 gStyle->SetPalette(1, 0);
19 TEveRGBAPalette* pal = new TEveRGBAPalette(0, 500);
20
21 // -----------------------------------------------------------------------------------
22 // -- Line sets
23 // -----------------------------------------------------------------------------------
24
25 // -- Define cone center
26 TEveStraightLineSet* axis = new TEveStraightLineSet("Cone Axis");
27 axis->SetLineColor(kGreen);
28 axis->SetLineWidth(2);
29
30 TEveStraightLineSet* tracksXYZ = new TEveStraightLineSet("StraightLinesXYZ");
31 tracksXYZ->SetLineColor(kRed);
32 tracksXYZ->SetLineWidth(2);
33
34 TEveStraightLineSet* tracksEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhi");
35 tracksEtaPhi->SetLineColor(kYellow);
36 tracksEtaPhi->SetLineWidth(2);
37
38 TEveStraightLineSet* tracksSeedEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhiSeed");
39 tracksSeedEtaPhi->SetLineColor(kBlue);
40 tracksSeedEtaPhi->SetLineWidth(2);
41
42 // -----------------------------------------------------------------------------------
43 // -- Draw track distribution in XYZ ( in TPC Volume ) ( +/-250, +/-250, +/-250 )
44 // -----------------------------------------------------------------------------------
45
46 for ( Int_t track=0; track < nTracks ; track++ ) {
47
48 Float_t trackX = r.Uniform(-250.0, 250.0);
49 Float_t trackY = r.Uniform(-250.0, 250.0);
50 Float_t trackZ = r.Uniform(-250.0, 250.0);
51 Float_t trackR = (Float_t) Sqrt ( trackX*trackX + trackY*trackY + trackZ*trackZ );
52
53 /*
54 Float_t trackEta = 0.5 * (Float_t) Log( (Double_t)(( trackR+trackZ )/( trackR-trackZ )) );
55 Float_t trackPhi = (Float_t) ATan2( (Double_t) trackY, (Double_t) trackX );
56 if ( trackPhi < 0. ) trackPhi += (Float_t) TwoPi();
57 */
58
59 TEveVector trackDir(trackX/trackR, trackY/trackR ,trackZ/trackR);
60 TEveVector trackEnd = trackDir * length;
61 tracksXYZ->AddLine(0., 0., 0., trackEnd.fX, trackEnd.fY, trackEnd.fZ );
62 }
63
64 // -----------------------------------------------------------------------------------
65 // -- Draw track distribution in eta phi ( in TPC Volume ) ( +/-0.9, {0, 2Pi} )
66 // -----------------------------------------------------------------------------------
67
68 for ( Int_t track=0; track < nTracks ; track++ ) {
69
70 Float_t trackEta = r.Uniform(-0.9, 0.9);
71 Float_t trackPhi = r.Uniform(0.0, TwoPi());
72
73 TEveVector trackDir( GetTEveVector(trackEta, trackPhi) );
74 TEveVector trackEnd = trackDir * length;
75
76 if ( trackEta > coneRadius || trackEta < -coneRadius )
77 tracksEtaPhi->AddLine(0., 0., 0., trackEnd.fX, trackEnd.fY, trackEnd.fZ );
78 else
79 tracksSeedEtaPhi->AddLine(0., 0., 0., trackEnd.fX, trackEnd.fY, trackEnd.fZ );
80 }
81
82 // -----------------------------------------------------------------------------------
83 // -- Draw cones
84 // -----------------------------------------------------------------------------------
85
86 for ( Int_t iter = 0; iter < nCones; ++iter ) {
87
88 // -- Get Random ( eta ,phi )
89 Float_t coneEta = r.Uniform(-0.9, 0.9);
90 Float_t conePhi = r.Uniform(0.0, TwoPi() );
91
92 // -- Primary vertx as origin
93 TEveVector coneOrigin(0.0,0.0,0.0);
94
95 // -- Get Cone Axis - axis line 10% longer than cone height
96 TEveVector coneAxis ( GetTEveVector( coneEta, conePhi) );
97 coneAxis *= length * 1.1;
98
99 axis->AddLine( 0., 0., 0., coneAxis.fX, coneAxis.fY, coneAxis.fZ );
100
101 // -- Draw jet cone
102 TEveJetCone* jetCone = new TEveJetCone("JetCone");
103 jetCone->SetCylinder( 250., 250. );
104 if ( (jetCone->AddCone( coneEta, conePhi, coneRadius ) ) != -1)
105 gEve->AddElement( jetCone );
106 }
107
108 // -----------------------------------------------------------------------------------
109
110 // -- Add cone axis
111 gEve->AddElement(axis);
112
113 // -- Add lines
114 // gEve->AddElement(tracksXYZ);
115 gEve->AddElement(tracksSeedEtaPhi);
116 gEve->AddElement(tracksEtaPhi);
117
118 // -- Load TPC geometry
119 geomGentleTPC();
120
121 gEve->Redraw3D(kTRUE);
122
123 return;
124}
125
126// ################################################################################
127// ################################################################################
128
129// ################################################################################
130TEveVector GetTEveVector( Float_t& eta, Float_t& phi ) {
131
132 TEveVector vec( (Float_t) Cos ( (Double_t) phi)/ CosH( (Double_t) eta ),
133 (Float_t) Sin ( (Double_t) phi)/ CosH( (Double_t) eta ),
134 (Float_t) TanH( (Double_t) eta ) );
135 return vec;
136}
137
138// ################################################################################
139void geomGentleTPC() {
140
141 TFile f("$ALICE_ROOT/EVE/alice-data/gentle_geo.root");
142 TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) f.Get("Gentle");
143 TEveGeoShape* gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
144 gEve->AddGlobalElement(gsre);
145 f.Close();
146
147 TEveElement* elTRD = gsre->FindChild("TRD+TOF");
148 elTRD->SetRnrState(kFALSE);
149
150 TEveElement* elPHOS = gsre->FindChild("PHOS");
151 elPHOS->SetRnrState(kFALSE);
152
153 TEveElement* elHMPID = gsre->FindChild("HMPID");
154 elHMPID->SetRnrState(kFALSE);
155}