Public Member Functions | Private Attributes | List of all members
EDep::TTrajectoryChangeHandler Class Reference

Handle drawing the trajectories. More...

#include <TTrajectoryChangeHandler.hxx>

Inheritance diagram for EDep::TTrajectoryChangeHandler:
EDep::TVEventChangeHandler

Public Member Functions

 TTrajectoryChangeHandler ()
 
 ~TTrajectoryChangeHandler ()
 
virtual void Apply ()
 Draw the trajectories into the current scene. More...
 
- Public Member Functions inherited from EDep::TVEventChangeHandler
 TVEventChangeHandler ()
 
virtual ~TVEventChangeHandler ()
 

Private Attributes

TEveElementList * fTrajectoryList
 The trajectories to draw in the event. More...
 

Detailed Description

Handle drawing the trajectories.

Definition at line 13 of file TTrajectoryChangeHandler.hxx.

Constructor & Destructor Documentation

EDep::TTrajectoryChangeHandler::TTrajectoryChangeHandler ( )

Definition at line 19 of file TTrajectoryChangeHandler.cxx.

19  {
20  fTrajectoryList = new TEveElementList("g4Trajectories",
21  "Geant4 Trajectories");
22  fTrajectoryList->SetMainColor(kRed);
23  fTrajectoryList->SetMainAlpha(1.0);
24  gEve->AddElement(fTrajectoryList);
25 }
TEveElementList * fTrajectoryList
The trajectories to draw in the event.
EDep::TTrajectoryChangeHandler::~TTrajectoryChangeHandler ( )

Definition at line 27 of file TTrajectoryChangeHandler.cxx.

27  {
28 }

Member Function Documentation

void EDep::TTrajectoryChangeHandler::Apply ( )
virtual

Draw the trajectories into the current scene.

Implements EDep::TVEventChangeHandler.

Definition at line 30 of file TTrajectoryChangeHandler.cxx.

30  {
31 
32  fTrajectoryList->DestroyElements();
33 
34  if (!EDep::TEventDisplay::Get().GUI().GetShowTrajectoriesButton()->IsOn()) {
35  return;
36  }
37 
38  std::cout <<"Handle the trajectories" << std::endl;
39 
41  = gEDepSimEvent->Trajectories.begin();
42  traj != gEDepSimEvent->Trajectories.end();
43  ++traj) {
44  const TG4Trajectory::TrajectoryPoints& points = traj->Points;
45 
46  std::ostringstream label;
47  label << traj->GetName()
48  << " (" << traj->GetInitialMomentum().E() << " MeV)";
49 
50  if (traj->GetParentId() < 1) {
51  std::cout << "Primary " << traj->GetTrackId()
52  << " " << traj->GetName()
53  << " " << traj->GetInitialMomentum().P() << " MeV/c"
54  << " w/ points " << points.size()
55  << std::endl;
56  }
57 
58  bool charged = false;
59  std::string particleClass("none");
60  TParticlePDG* particle
61  = TDatabasePDG::Instance()->GetParticle(traj->GetPDGCode());
62  if (particle) {
63  if (std::abs(particle->Charge()) > 0.01) charged = true;
64  particleClass = particle->ParticleClass();
65  }
66 
67  TEveLine *track = new TEveLine();
68  track->SetName("trajectory");
69  track->SetTitle(label.str().c_str());
70 
71  if (particleClass == "Lepton") track->SetLineColor(kMagenta);
72  else if (particleClass == "Baryon") track->SetLineColor(kOrange);
73  else if (particleClass == "Meson") track->SetLineColor(kGreen);
74  else if (particleClass == "GaugeBoson") track->SetLineColor(kCyan);
75  else track->SetLineColor(kRed);
76 
77  if (charged) track->SetLineStyle(3);
78  else track->SetLineStyle(4);
79 
80  for (std::size_t p = 0; p < points.size(); ++p) {
81  track->SetPoint(p,
82  points[p].GetPosition().X(),
83  points[p].GetPosition().Y(),
84  points[p].GetPosition().Z());
85  }
86  fTrajectoryList->AddElement(track);
87  }
88 }
intermediate_table::iterator iterator
std::vector< TG4TrajectoryPoint > TrajectoryPoints
Definition: TG4Trajectory.h:29
std::string string
Definition: nybbler.cc:12
TG4TrajectoryContainer Trajectories
Definition: TG4Event.h:35
T abs(T value)
TEveElementList * fTrajectoryList
The trajectories to draw in the event.
p
Definition: test.py:223
static TEventDisplay & Get(void)
TG4Event * gEDepSimEvent
The event being displayed.
QTextStream & endl(QTextStream &s)

Member Data Documentation

TEveElementList* EDep::TTrajectoryChangeHandler::fTrajectoryList
private

The trajectories to draw in the event.

Definition at line 24 of file TTrajectoryChangeHandler.hxx.


The documentation for this class was generated from the following files: