Logo ROOT   6.07/09
Reference Guide
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 
10 const char* esd_geom_file_name =
11  "http://root.cern.ch/files/alice_ESDgeometry.root";
12 
13 TEveVector GetTEveVector(Float_t eta, Float_t phi);
14 void geomGentleTPC();
15 
16 void 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  TEveRGBAPalette* pal = new TEveRGBAPalette(0, 500);
33 
34  // -----------------------------------------------------------------------
35  // -- Line sets
36  // -----------------------------------------------------------------------
37 
38  // -- Define cone center
39  TEveStraightLineSet* axis = new TEveStraightLineSet("Cone Axis");
40  axis->SetLineColor(kGreen);
41  axis->SetLineWidth(2);
42 
43  TEveStraightLineSet* tracksXYZ = new TEveStraightLineSet("StraightLinesXYZ");
44  tracksXYZ->SetLineColor(kRed);
45  tracksXYZ->SetLineWidth(2);
46 
47  TEveStraightLineSet* tracksEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhi");
48  tracksEtaPhi->SetLineColor(kYellow);
49  tracksEtaPhi->SetLineWidth(2);
50 
51  TEveStraightLineSet* 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 vertx 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  TEveJetCone* 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 
131  gEve->Redraw3D(kTRUE);
132 
133  return;
134 }
135 
136 //___________________________________________________________________________
137 TEveVector 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 //__________________________________________________________________________
148 void 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 }
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:49
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Double_t TanH(Double_t)
Definition: TMath.h:436
Globally positioned TGeoShape with rendering attributes and an optional list of daughter shape-extrac...
float Float_t
Definition: RtypesCore.h:53
Definition: Rtypes.h:61
void SetPickable(Bool_t p)
Definition: TEveElement.h:340
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual Bool_t SetRnrState(Bool_t rnr)
Set render state of this element and of its children to the same value.
Draws a jet cone with leading particle is specified in (eta,phi) and cone radius is given...
Definition: TEveJetCone.h:23
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
Definition: Rtypes.h:61
Definition: Rtypes.h:61
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3871
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
virtual void SetLineColor(Color_t col)
Set the line color.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Double_t TwoPi()
Definition: TMath.h:45
Int_t AddCone(Float_t eta, Float_t phi, Float_t cone_r, Float_t length=0)
Add jet cone.
Definition: TEveJetCone.cxx:92
TRandom2 r(17)
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
Double_t Cos(Double_t)
Definition: TMath.h:424
double Double_t
Definition: RtypesCore.h:55
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:606
Line_t * AddLine(Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2)
Add a line.
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4391
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
Definition: TEveGeoShape.h:23
Double_t Sin(Double_t)
Definition: TMath.h:421
Definition: Rtypes.h:61
TEveElement * FindChild(const TString &name, const TClass *cls=0)
Find the first child with given name.
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
const Bool_t kTRUE
Definition: Rtypes.h:91
static TEveGeoShape * ImportShapeExtract(TEveGeoShapeExtract *gse, TEveElement *parent=0)
Import a shape extract &#39;gse&#39; under element &#39;parent&#39;.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
Double_t CosH(Double_t)
Definition: TMath.h:433
void SetCylinder(Float_t r, Float_t z)
Definition: TEveJetCone.h:55
Set of straight lines with optional markers along the lines.
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:904