Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
jetcone.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of TEveJetCone class.
4///
5/// \image html eve_jetcone.png
6/// \macro_code
7///
8/// \author Jochen Thaeder
9
10const char* esd_geom_file_name =
11 "http://root.cern.ch/files/alice_ESDgeometry.root";
12
13TEveVector GetTEveVector(Float_t eta, Float_t phi);
14void geomGentleTPC();
15
16void jetcone()
17{
19
20 using namespace TMath;
21
22 TRandom r(0);
23
24 // -- Set Constants
25 Int_t nCones = 10;
26 Int_t nTracks = 200;
27
28 Float_t coneRadius = 0.4;
29 Float_t length = 300.;
30
31 // -- Define palette
32 auto pal = new TEveRGBAPalette(0, 500);
33
34 // -----------------------------------------------------------------------
35 // -- Line sets
36 // -----------------------------------------------------------------------
37
38 // -- Define cone center
39 auto axis = new TEveStraightLineSet("Cone Axis");
40 axis->SetLineColor(kGreen);
41 axis->SetLineWidth(2);
42
43 auto tracksXYZ = new TEveStraightLineSet("StraightLinesXYZ");
44 tracksXYZ->SetLineColor(kRed);
45 tracksXYZ->SetLineWidth(2);
46
47 auto tracksEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhi");
48 tracksEtaPhi->SetLineColor(kYellow);
49 tracksEtaPhi->SetLineWidth(2);
50
51 auto tracksSeedEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhiSeed");
52 tracksSeedEtaPhi->SetLineColor(kBlue);
53 tracksSeedEtaPhi->SetLineWidth(2);
54
55 // -----------------------------------------------------------------------
56 // -- Draw track distribution in XYZ in TPC Volume +/-250, +/-250, +/-250
57 // -----------------------------------------------------------------------
58
59 for ( Int_t track=0; track < nTracks ; track++ ) {
60
61 Float_t trackX = r.Uniform(-250.0, 250.0);
62 Float_t trackY = r.Uniform(-250.0, 250.0);
63 Float_t trackZ = r.Uniform(-250.0, 250.0);
64 Float_t trackR = Sqrt(trackX*trackX + trackY*trackY + trackZ*trackZ);
65
66 TEveVector trackDir(trackX/trackR, trackY/trackR ,trackZ/trackR);
67 TEveVector trackEnd = trackDir * length;
68 tracksXYZ->AddLine(0., 0., 0., trackEnd.fX, trackEnd.fY, trackEnd.fZ );
69 }
70
71 // -----------------------------------------------------------------------
72 // -- Draw track distribution in eta phi in TPC Volume +/-0.9, {0, 2Pi}
73 // -----------------------------------------------------------------------
74
75 for ( Int_t track=0; track < nTracks ; track++ ) {
76
77 Float_t trackEta = r.Uniform(-0.9, 0.9);
78 Float_t trackPhi = r.Uniform(0.0, TwoPi());
79
80 TEveVector trackDir( GetTEveVector(trackEta, trackPhi) );
81 TEveVector trackEnd = trackDir * length;
82
83 if ( trackEta > coneRadius || trackEta < -coneRadius )
84 tracksEtaPhi->AddLine(0., 0., 0.,
85 trackEnd.fX, trackEnd.fY, trackEnd.fZ);
86 else
87 tracksSeedEtaPhi->AddLine(0., 0., 0.,
88 trackEnd.fX, trackEnd.fY, trackEnd.fZ);
89 }
90
91 // -----------------------------------------------------------------------
92 // -- Draw cones
93 // -----------------------------------------------------------------------
94
95 for ( Int_t iter = 0; iter < nCones; ++iter ) {
96
97 // -- Get Random ( eta ,phi )
98 Float_t coneEta = r.Uniform(-0.9, 0.9);
99 Float_t conePhi = r.Uniform(0.0, TwoPi() );
100
101 // -- Primary vertex as origin
102 TEveVector coneOrigin(0.0,0.0,0.0);
103
104 // -- Get Cone Axis - axis line 10% longer than cone height
105 TEveVector coneAxis ( GetTEveVector( coneEta, conePhi) );
106 coneAxis *= length * 1.1;
107
108 axis->AddLine( 0., 0., 0., coneAxis.fX, coneAxis.fY, coneAxis.fZ );
109
110 // -- Draw jet cone
111 auto jetCone = new TEveJetCone("JetCone");
112 jetCone->SetPickable(kTRUE);
113 jetCone->SetCylinder( 250., 250. );
114 if ( (jetCone->AddCone( coneEta, conePhi, coneRadius ) ) != -1)
115 gEve->AddElement( jetCone );
116 }
117
118 // -----------------------------------------------------------------------
119
120 // -- Add cone axis
121 gEve->AddElement(axis);
122
123 // -- Add lines
124 // gEve->AddElement(tracksXYZ);
125 gEve->AddElement(tracksSeedEtaPhi);
126 gEve->AddElement(tracksEtaPhi);
127
128 // -- Load TPC geometry
129 geomGentleTPC();
130
132
133 return;
134}
135
136//___________________________________________________________________________
137TEveVector GetTEveVector(Float_t eta, Float_t phi)
138{
139 using namespace TMath;
140
141 TEveVector vec( (Float_t) Cos ( (Double_t) phi)/ CosH( (Double_t) eta ),
142 (Float_t) Sin ( (Double_t) phi)/ CosH( (Double_t) eta ),
143 (Float_t) TanH( (Double_t) eta ) );
144 return vec;
145}
146
147//__________________________________________________________________________
148void geomGentleTPC()
149{
150 // Simple geometry
152 TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
153 if (!geom)
154 return;
155
156 TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
158 geom->Close();
159 delete geom;
160
161 gEve->AddGlobalElement(gsre);
162
163 TEveElement* elTRD = gsre->FindChild("TRD+TOF");
164 elTRD->SetRnrState(kFALSE);
165
166 TEveElement* elPHOS = gsre->FindChild("PHOS");
167 elPHOS->SetRnrState(kFALSE);
168
169 TEveElement* elHMPID = gsre->FindChild("HMPID");
170 elHMPID->SetRnrState(kFALSE);
171}
ROOT::R::TRInterface & r
Definition Object.C:4
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:100
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
R__EXTERN TEveManager * gEve
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
virtual Bool_t SetRnrState(Bool_t rnr)
Set render state of this element and of its children to the same value.
TEveElement * FindChild(const TString &name, const TClass *cls=0)
Find the first child with given name.
Globally positioned TGeoShape with rendering attributes and an optional list of daughter shape-extrac...
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
static TEveGeoShape * ImportShapeExtract(TEveGeoShapeExtract *gse, TEveElement *parent=0)
Import a shape extract 'gse' under element 'parent'.
Draws a jet cone with leading particle is specified in (eta,phi) and cone radius is given.
Definition TEveJetCone.h:24
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Set of straight lines with optional markers along the lines.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Definition TFile.h:326
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4025
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:899
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Double_t Sqrt(Double_t x)
TMath.
Definition TMathBase.h:35
Double_t CosH(Double_t)
Definition TMath.h:605
Double_t TanH(Double_t)
Definition TMath.h:609
constexpr Double_t TwoPi()
Definition TMath.h:44