From $ROOTSYS/tutorials/eve/jetcone.C

// Demonstrates usage of TEveJetCone class.
// Author: Jochen Thaeder

const char* esd_geom_file_name =
   "http://root.cern.ch/files/alice_ESDgeometry.root";

TEveVector GetTEveVector(Float_t eta, Float_t phi);
void       geomGentleTPC();

void jetcone()
{
   TEveManager::Create();

   using namespace TMath;

   TRandom r(0);

   // -- Set Constants
   Int_t nCones  = 10;
   Int_t nTracks = 200;

   Float_t coneRadius = 0.4;
   Float_t length = 300.;

   // -- Define palette
   gStyle->SetPalette(1, 0);
   TEveRGBAPalette* pal = new TEveRGBAPalette(0, 500);

   // -----------------------------------------------------------------------
   // -- Line sets
   // -----------------------------------------------------------------------

   // -- Define cone center
   TEveStraightLineSet* axis = new TEveStraightLineSet("Cone Axis");
   axis->SetLineColor(kGreen);
   axis->SetLineWidth(2);

   TEveStraightLineSet* tracksXYZ = new TEveStraightLineSet("StraightLinesXYZ");
   tracksXYZ->SetLineColor(kRed);
   tracksXYZ->SetLineWidth(2);

   TEveStraightLineSet* tracksEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhi");
   tracksEtaPhi->SetLineColor(kYellow);
   tracksEtaPhi->SetLineWidth(2);

   TEveStraightLineSet* tracksSeedEtaPhi = new TEveStraightLineSet("StraightLinesEtaPhiSeed");
   tracksSeedEtaPhi->SetLineColor(kBlue);
   tracksSeedEtaPhi->SetLineWidth(2);

   // -----------------------------------------------------------------------
   // -- Draw track distribution in XYZ in TPC Volume +/-250, +/-250, +/-250
   // -----------------------------------------------------------------------

   for ( Int_t track=0; track < nTracks ; track++ ) {

      Float_t trackX = r.Uniform(-250.0, 250.0);
      Float_t trackY = r.Uniform(-250.0, 250.0);
      Float_t trackZ = r.Uniform(-250.0, 250.0);
      Float_t trackR = Sqrt(trackX*trackX + trackY*trackY + trackZ*trackZ);

      TEveVector trackDir(trackX/trackR, trackY/trackR ,trackZ/trackR);
      TEveVector trackEnd = trackDir * length;
      tracksXYZ->AddLine(0., 0., 0., trackEnd.fX, trackEnd.fY, trackEnd.fZ );
   }

   // -----------------------------------------------------------------------
   // -- Draw track distribution in eta phi in TPC Volume +/-0.9, {0, 2Pi}
   // -----------------------------------------------------------------------

   for ( Int_t track=0; track < nTracks ; track++ ) {

      Float_t trackEta = r.Uniform(-0.9, 0.9);
      Float_t trackPhi = r.Uniform(0.0, TwoPi());

      TEveVector trackDir( GetTEveVector(trackEta, trackPhi) );
      TEveVector trackEnd = trackDir * length;

      if ( trackEta > coneRadius || trackEta < -coneRadius )
         tracksEtaPhi->AddLine(0., 0., 0.,
                               trackEnd.fX, trackEnd.fY, trackEnd.fZ);
      else
         tracksSeedEtaPhi->AddLine(0., 0., 0.,
                                   trackEnd.fX, trackEnd.fY, trackEnd.fZ);
   }

   // -----------------------------------------------------------------------
   // -- Draw cones
   // -----------------------------------------------------------------------

   for ( Int_t iter = 0; iter < nCones; ++iter ) {

      // -- Get Random ( eta ,phi )
      Float_t coneEta = r.Uniform(-0.9, 0.9);
      Float_t conePhi = r.Uniform(0.0, TwoPi() );

      // -- Primary vertx as origin
      TEveVector coneOrigin(0.0,0.0,0.0);

      // -- Get Cone Axis - axis line 10% longer than cone height
      TEveVector coneAxis ( GetTEveVector( coneEta, conePhi) );
      coneAxis *= length * 1.1;

      axis->AddLine( 0., 0., 0., coneAxis.fX, coneAxis.fY, coneAxis.fZ );

      // -- Draw jet cone
      TEveJetCone* jetCone = new TEveJetCone("JetCone");
      jetCone->SetPickable(kTRUE);
      jetCone->SetCylinder( 250., 250. );
      if ( (jetCone->AddCone( coneEta, conePhi, coneRadius   ) ) != -1)
         gEve->AddElement( jetCone );
   }

   // -----------------------------------------------------------------------

   // -- Add cone axis
   gEve->AddElement(axis);

   // -- Add lines
   //  gEve->AddElement(tracksXYZ);
   gEve->AddElement(tracksSeedEtaPhi);
   gEve->AddElement(tracksEtaPhi);

   // -- Load TPC geometry
   geomGentleTPC();

   gEve->Redraw3D(kTRUE);

   return;
}

//___________________________________________________________________________
TEveVector GetTEveVector(Float_t eta, Float_t phi)
{
  using namespace TMath;

  TEveVector vec( (Float_t) Cos ( (Double_t) phi)/ CosH( (Double_t) eta ),
		  (Float_t) Sin ( (Double_t) phi)/ CosH( (Double_t) eta ),
		  (Float_t) TanH( (Double_t) eta ) );
  return vec;
}

//__________________________________________________________________________
void geomGentleTPC()
{
   // Simple geometry
   TFile::SetCacheFileDir(".");
   TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
   if (!geom)
      return;

   TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
   TEveGeoShape* gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
   geom->Close();
   delete geom;

   gEve->AddGlobalElement(gsre);

   TEveElement* elTRD = gsre->FindChild("TRD+TOF");
   elTRD->SetRnrState(kFALSE);

   TEveElement* elPHOS = gsre->FindChild("PHOS");
   elPHOS->SetRnrState(kFALSE);

   TEveElement* elHMPID = gsre->FindChild("HMPID");
   elHMPID->SetRnrState(kFALSE);
}
 jetcone.C:1
 jetcone.C:2
 jetcone.C:3
 jetcone.C:4
 jetcone.C:5
 jetcone.C:6
 jetcone.C:7
 jetcone.C:8
 jetcone.C:9
 jetcone.C:10
 jetcone.C:11
 jetcone.C:12
 jetcone.C:13
 jetcone.C:14
 jetcone.C:15
 jetcone.C:16
 jetcone.C:17
 jetcone.C:18
 jetcone.C:19
 jetcone.C:20
 jetcone.C:21
 jetcone.C:22
 jetcone.C:23
 jetcone.C:24
 jetcone.C:25
 jetcone.C:26
 jetcone.C:27
 jetcone.C:28
 jetcone.C:29
 jetcone.C:30
 jetcone.C:31
 jetcone.C:32
 jetcone.C:33
 jetcone.C:34
 jetcone.C:35
 jetcone.C:36
 jetcone.C:37
 jetcone.C:38
 jetcone.C:39
 jetcone.C:40
 jetcone.C:41
 jetcone.C:42
 jetcone.C:43
 jetcone.C:44
 jetcone.C:45
 jetcone.C:46
 jetcone.C:47
 jetcone.C:48
 jetcone.C:49
 jetcone.C:50
 jetcone.C:51
 jetcone.C:52
 jetcone.C:53
 jetcone.C:54
 jetcone.C:55
 jetcone.C:56
 jetcone.C:57
 jetcone.C:58
 jetcone.C:59
 jetcone.C:60
 jetcone.C:61
 jetcone.C:62
 jetcone.C:63
 jetcone.C:64
 jetcone.C:65
 jetcone.C:66
 jetcone.C:67
 jetcone.C:68
 jetcone.C:69
 jetcone.C:70
 jetcone.C:71
 jetcone.C:72
 jetcone.C:73
 jetcone.C:74
 jetcone.C:75
 jetcone.C:76
 jetcone.C:77
 jetcone.C:78
 jetcone.C:79
 jetcone.C:80
 jetcone.C:81
 jetcone.C:82
 jetcone.C:83
 jetcone.C:84
 jetcone.C:85
 jetcone.C:86
 jetcone.C:87
 jetcone.C:88
 jetcone.C:89
 jetcone.C:90
 jetcone.C:91
 jetcone.C:92
 jetcone.C:93
 jetcone.C:94
 jetcone.C:95
 jetcone.C:96
 jetcone.C:97
 jetcone.C:98
 jetcone.C:99
 jetcone.C:100
 jetcone.C:101
 jetcone.C:102
 jetcone.C:103
 jetcone.C:104
 jetcone.C:105
 jetcone.C:106
 jetcone.C:107
 jetcone.C:108
 jetcone.C:109
 jetcone.C:110
 jetcone.C:111
 jetcone.C:112
 jetcone.C:113
 jetcone.C:114
 jetcone.C:115
 jetcone.C:116
 jetcone.C:117
 jetcone.C:118
 jetcone.C:119
 jetcone.C:120
 jetcone.C:121
 jetcone.C:122
 jetcone.C:123
 jetcone.C:124
 jetcone.C:125
 jetcone.C:126
 jetcone.C:127
 jetcone.C:128
 jetcone.C:129
 jetcone.C:130
 jetcone.C:131
 jetcone.C:132
 jetcone.C:133
 jetcone.C:134
 jetcone.C:135
 jetcone.C:136
 jetcone.C:137
 jetcone.C:138
 jetcone.C:139
 jetcone.C:140
 jetcone.C:141
 jetcone.C:142
 jetcone.C:143
 jetcone.C:144
 jetcone.C:145
 jetcone.C:146
 jetcone.C:147
 jetcone.C:148
 jetcone.C:149
 jetcone.C:150
 jetcone.C:151
 jetcone.C:152
 jetcone.C:153
 jetcone.C:154
 jetcone.C:155
 jetcone.C:156
 jetcone.C:157
 jetcone.C:158
 jetcone.C:159
 jetcone.C:160
 jetcone.C:161
 jetcone.C:162
 jetcone.C:163
 jetcone.C:164
 jetcone.C:165
 jetcone.C:166
 jetcone.C:167