ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LXeTrajectory.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LXeTrajectory.cc
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 //
29 //
30 //
31 #include "LXeTrajectory.hh"
32 #include "G4TrajectoryPoint.hh"
33 #include "G4Trajectory.hh"
34 #include "G4ParticleTable.hh"
35 #include "G4ParticleTypes.hh"
36 #include "G4ThreeVector.hh"
37 #include "G4Polyline.hh"
38 #include "G4Circle.hh"
39 #include "G4Colour.hh"
40 #include "G4VisAttributes.hh"
41 #include "G4VVisManager.hh"
42 #include "G4Polymarker.hh"
43 
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49  :G4Trajectory(),fWls(false),fDrawit(false),
50  fForceNoDraw(false),fForceDraw(false)
51 {
52  fParticleDefinition = nullptr;
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58  :G4Trajectory(aTrack),fWls(false),fDrawit(false)
59 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66  :G4Trajectory(right),fWls(right.fWls),fDrawit(right.fDrawit)
67 {
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 
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 }