Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LXeTrajectory.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: LXeTrajectory.cc 72349 2013-07-16 12:13:16Z gcosmo $
27 //
30 //
31 //
32 #include "LXeTrajectory.hh"
33 #include "G4TrajectoryPoint.hh"
34 #include "G4Trajectory.hh"
35 #include "G4ParticleTable.hh"
36 #include "G4ParticleTypes.hh"
37 #include "G4ThreeVector.hh"
38 #include "G4Polyline.hh"
39 #include "G4Circle.hh"
40 #include "G4Colour.hh"
41 #include "G4VisAttributes.hh"
42 #include "G4VVisManager.hh"
43 #include "G4Polymarker.hh"
44 
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  :G4Trajectory(),fWls(false),fDrawit(false),fForceNoDraw(false),fForceDraw(false)
51 {
52  fParticleDefinition=0;
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58  :G4Trajectory(aTrack),fWls(false),fDrawit(false)
59 {
60  fParticleDefinition=aTrack->GetDefinition();
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66  :G4Trajectory(right),fWls(right.fWls),fDrawit(right.fDrawit)
67 {
68  fParticleDefinition=right.fParticleDefinition;
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  // i_mode is no longer available as an argument of G4VTrajectory.
80  // In this exampple it was always called with an argument of 50.
81  const G4int i_mode = 50;
82  // Consider using commands /vis/modeling/trajectories.
83 
84  //Taken from G4VTrajectory and modified to select colours based on particle
85  //type and to selectively eliminate drawing of certain trajectories.
86 
87  if(!fForceDraw && (!fDrawit || fForceNoDraw))
88  return;
89 
90  // If i_mode>=0, draws a trajectory as a polyline and, if i_mode!=0,
91  // adds markers - yellow circles for step points and magenta squares
92  // for auxiliary points, if any - whose screen size in pixels is
93  // given by std::abs(i_mode)/1000. E.g: i_mode = 5000 gives easily
94  // visible markers.
95 
97  if (!pVVisManager) return;
98 
99  const G4double markerSize = std::abs(i_mode)/1000;
100  G4bool lineRequired (i_mode >= 0);
101  G4bool markersRequired (markerSize > 0.);
102 
103  G4Polyline trajectoryLine;
104  G4Polymarker stepPoints;
105  G4Polymarker auxiliaryPoints;
106 
107  for (G4int i = 0; i < GetPointEntries() ; i++) {
108  G4VTrajectoryPoint* aTrajectoryPoint = GetPoint(i);
109  const std::vector<G4ThreeVector>* auxiliaries
110  = aTrajectoryPoint->GetAuxiliaryPoints();
111  if (auxiliaries) {
112  for (size_t iAux = 0; iAux < auxiliaries->size(); ++iAux) {
113  const G4ThreeVector pos((*auxiliaries)[iAux]);
114  if (lineRequired) {
115  trajectoryLine.push_back(pos);
116  }
117  if (markersRequired) {
118  auxiliaryPoints.push_back(pos);
119  }
120  }
121  }
122  const G4ThreeVector pos(aTrajectoryPoint->GetPosition());
123  if (lineRequired) {
124  trajectoryLine.push_back(pos);
125  }
126  if (markersRequired) {
127  stepPoints.push_back(pos);
128  }
129  }
130 
131  if (lineRequired) {
132  G4Colour colour;
133 
134  if(fParticleDefinition==G4OpticalPhoton::OpticalPhotonDefinition()){
135  if(fWls) //WLS photons are red
136  colour = G4Colour(1.,0.,0.);
137  else{ //Scintillation and Cerenkov photons are green
138  colour = G4Colour(0.,1.,0.);
139  }
140  }
141  else //All other particles are blue
142  colour = G4Colour(0.,0.,1.);
143 
144  G4VisAttributes trajectoryLineAttribs(colour);
145  trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
146  pVVisManager->Draw(trajectoryLine);
147  }
148  if (markersRequired) {
149  auxiliaryPoints.SetMarkerType(G4Polymarker::squares);
150  auxiliaryPoints.SetScreenSize(markerSize);
151  auxiliaryPoints.SetFillStyle(G4VMarker::filled);
152  G4VisAttributes auxiliaryPointsAttribs(G4Colour(0.,1.,1.)); // Magenta
153  auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs);
154  pVVisManager->Draw(auxiliaryPoints);
155 
157  stepPoints.SetScreenSize(markerSize);
158  stepPoints.SetFillStyle(G4VMarker::filled);
159  G4VisAttributes stepPointsAttribs(G4Colour(1.,1.,0.)); // Yellow
160  stepPoints.SetVisAttributes(&stepPointsAttribs);
161  pVVisManager->Draw(stepPoints);
162  }
163 }
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
G4ParticleDefinition * GetDefinition() const
virtual const std::vector< G4ThreeVector > * GetAuxiliaryPoints() const
static G4VVisManager * GetConcreteInstance()
G4ThreadLocal G4Allocator< LXeTrajectory > * LXeTrajectoryAllocator
virtual ~LXeTrajectory()
void SetMarkerType(MarkerType)
void SetFillStyle(FillStyle)
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
virtual int GetPointEntries() const
bool G4bool
Definition: G4Types.hh:79
Definition of the LXeTrajectory class.
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:80
virtual const G4ThreeVector GetPosition() const =0
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
virtual void DrawTrajectory() const
static G4OpticalPhoton * OpticalPhotonDefinition()
double G4double
Definition: G4Types.hh:76
static const G4double pos
void SetScreenSize(G4double)