Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // << 27 /// \file optical/LXe/src/LXeTrajectory.cc << 28 /// \brief Implementation of the LXeTrajectory << 29 // << 30 // << 31 #include "LXeTrajectory.hh" 23 #include "LXeTrajectory.hh" 32 << 24 #include "G4TrajectoryPoint.hh" 33 #include "G4Circle.hh" << 25 #include "G4Trajectory.hh" 34 #include "G4Colour.hh" << 35 #include "G4ParticleTable.hh" 26 #include "G4ParticleTable.hh" 36 #include "G4ParticleTypes.hh" 27 #include "G4ParticleTypes.hh" 37 #include "G4Polyline.hh" << 38 #include "G4Polymarker.hh" << 39 #include "G4ThreeVector.hh" 28 #include "G4ThreeVector.hh" 40 #include "G4Trajectory.hh" << 29 #include "G4Polyline.hh" 41 #include "G4TrajectoryPoint.hh" << 30 #include "G4Circle.hh" 42 #include "G4VVisManager.hh" << 31 #include "G4Colour.hh" 43 #include "G4VisAttributes.hh" 32 #include "G4VisAttributes.hh" >> 33 #include "G4VVisManager.hh" >> 34 #include "G4Polymarker.hh" 44 35 45 G4ThreadLocal G4Allocator<LXeTrajectory>* LXeT << 36 G4Allocator<LXeTrajectory> LXeTrajectoryAllocator; 46 << 47 //....oooOO0OOooo........oooOO0OOooo........oo << 48 37 49 LXeTrajectory::LXeTrajectory(const G4Track* aT << 38 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ >> 39 LXeTrajectory::LXeTrajectory() >> 40 :G4Trajectory(),wls(false),drawit(false),forceNoDraw(false),forceDraw(false) 50 { 41 { 51 fParticleDefinition = aTrack->GetDefinition( << 42 particleDefinition=0; 52 } 43 } 53 44 54 //....oooOO0OOooo........oooOO0OOooo........oo << 45 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ 55 << 46 LXeTrajectory::LXeTrajectory(const G4Track* aTrack) 56 LXeTrajectory::LXeTrajectory(LXeTrajectory& ri << 47 :G4Trajectory(aTrack),wls(false),drawit(false) 57 : G4Trajectory(right), fWls(right.fWls), fDr << 58 { 48 { 59 fParticleDefinition = right.fParticleDefinit << 49 particleDefinition=aTrack->GetDefinition(); 60 } 50 } 61 51 62 //....oooOO0OOooo........oooOO0OOooo........oo << 52 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ >> 53 LXeTrajectory::LXeTrajectory(LXeTrajectory &right) >> 54 :G4Trajectory(right),wls(right.wls),drawit(right.drawit) >> 55 { >> 56 particleDefinition=right.particleDefinition; >> 57 } 63 58 64 void LXeTrajectory::DrawTrajectory() const << 59 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ >> 60 LXeTrajectory::~LXeTrajectory() 65 { 61 { 66 // Taken from G4VTrajectory and modified to << 67 // type and to selectively eliminate drawing << 68 62 69 if (!fForceDraw && (!fDrawit || fForceNoDraw << 63 } 70 64 >> 65 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ >> 66 void LXeTrajectory::DrawTrajectory(G4int i_mode) const{ >> 67 //Taken from G4VTrajectory and modified to select colours based on particle >> 68 //type and to selectively eliminate drawing of certain trajectories. >> 69 >> 70 if(!forceDraw && (!drawit || forceNoDraw)) >> 71 return; >> 72 >> 73 // If i_mode>=0, draws a trajectory as a polyline and, if i_mode!=0, >> 74 // adds markers - yellow circles for step points and magenta squares >> 75 // for auxiliary points, if any - whose screen size in pixels is >> 76 // given by std::abs(i_mode)/1000. E.g: i_mode = 5000 gives easily >> 77 // visible markers. >> 78 71 G4VVisManager* pVVisManager = G4VVisManager: 79 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); 72 if (!pVVisManager) return; 80 if (!pVVisManager) return; 73 << 81 74 const G4double markerSize = 0.05; << 82 const G4double markerSize = std::abs(i_mode)/1000; 75 G4bool lineRequired = true; << 83 G4bool lineRequired (i_mode >= 0); 76 G4bool markersRequired = true; << 84 G4bool markersRequired (markerSize > 0.); 77 << 85 78 G4Polyline trajectoryLine; 86 G4Polyline trajectoryLine; 79 G4Polymarker stepPoints; 87 G4Polymarker stepPoints; 80 G4Polymarker auxiliaryPoints; 88 G4Polymarker auxiliaryPoints; 81 << 89 82 for (G4int i = 0; i < GetPointEntries(); ++i << 90 for (G4int i = 0; i < GetPointEntries() ; i++) { 83 G4VTrajectoryPoint* aTrajectoryPoint = Get 91 G4VTrajectoryPoint* aTrajectoryPoint = GetPoint(i); 84 const std::vector<G4ThreeVector>* auxiliar << 92 const std::vector<G4ThreeVector>* auxiliaries >> 93 = aTrajectoryPoint->GetAuxiliaryPoints(); 85 if (auxiliaries) { 94 if (auxiliaries) { 86 for (size_t iAux = 0; iAux < auxiliaries 95 for (size_t iAux = 0; iAux < auxiliaries->size(); ++iAux) { 87 const G4ThreeVector pos((*auxiliaries) << 96 const G4ThreeVector pos((*auxiliaries)[iAux]); 88 if (lineRequired) { << 97 if (lineRequired) { 89 trajectoryLine.push_back(pos); << 98 trajectoryLine.push_back(pos); 90 } << 99 } 91 if (markersRequired) { << 100 if (markersRequired) { 92 auxiliaryPoints.push_back(pos); << 101 auxiliaryPoints.push_back(pos); 93 } << 102 } 94 } 103 } 95 } 104 } 96 const G4ThreeVector pos(aTrajectoryPoint-> 105 const G4ThreeVector pos(aTrajectoryPoint->GetPosition()); 97 if (lineRequired) { 106 if (lineRequired) { 98 trajectoryLine.push_back(pos); 107 trajectoryLine.push_back(pos); 99 } 108 } 100 if (markersRequired) { 109 if (markersRequired) { 101 stepPoints.push_back(pos); 110 stepPoints.push_back(pos); 102 } 111 } 103 } 112 } 104 << 113 105 if (lineRequired) { 114 if (lineRequired) { 106 G4Colour colour; 115 G4Colour colour; 107 << 116 108 if (fParticleDefinition == G4OpticalPhoton << 117 if(particleDefinition==G4OpticalPhoton::OpticalPhotonDefinition()){ 109 if (fWls) // WLS photons are red << 118 if(wls) //WLS photons are red 110 colour = G4Colour(1., 0., 0.); << 119 colour = G4Colour(1.,0.,0.); 111 else { // Scintillation and Cerenkov ph << 120 else{ //Scintillation and Cerenkov photons are green 112 colour = G4Colour(0., 1., 0.); << 121 colour = G4Colour(0.,1.,0.); 113 } 122 } 114 } 123 } 115 else // All other particles are blue << 124 else //All other particles are blue 116 colour = G4Colour(0., 0., 1.); << 125 colour = G4Colour(0.,0.,1.); 117 << 126 118 G4VisAttributes trajectoryLineAttribs(colo 127 G4VisAttributes trajectoryLineAttribs(colour); 119 trajectoryLine.SetVisAttributes(&trajector 128 trajectoryLine.SetVisAttributes(&trajectoryLineAttribs); 120 pVVisManager->Draw(trajectoryLine); 129 pVVisManager->Draw(trajectoryLine); 121 } 130 } 122 if (markersRequired) { 131 if (markersRequired) { 123 auxiliaryPoints.SetMarkerType(G4Polymarker 132 auxiliaryPoints.SetMarkerType(G4Polymarker::squares); 124 auxiliaryPoints.SetScreenSize(markerSize); 133 auxiliaryPoints.SetScreenSize(markerSize); 125 auxiliaryPoints.SetFillStyle(G4VMarker::fi 134 auxiliaryPoints.SetFillStyle(G4VMarker::filled); 126 G4VisAttributes auxiliaryPointsAttribs(G4C << 135 G4VisAttributes auxiliaryPointsAttribs(G4Colour(0.,1.,1.)); // Magenta 127 auxiliaryPoints.SetVisAttributes(&auxiliar 136 auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs); 128 pVVisManager->Draw(auxiliaryPoints); 137 pVVisManager->Draw(auxiliaryPoints); 129 << 138 130 stepPoints.SetMarkerType(G4Polymarker::cir 139 stepPoints.SetMarkerType(G4Polymarker::circles); 131 stepPoints.SetScreenSize(markerSize); 140 stepPoints.SetScreenSize(markerSize); 132 stepPoints.SetFillStyle(G4VMarker::filled) 141 stepPoints.SetFillStyle(G4VMarker::filled); 133 G4VisAttributes stepPointsAttribs(G4Colour << 142 G4VisAttributes stepPointsAttribs(G4Colour(1.,1.,0.)); // Yellow. 134 stepPoints.SetVisAttributes(&stepPointsAtt 143 stepPoints.SetVisAttributes(&stepPointsAttribs); 135 pVVisManager->Draw(stepPoints); 144 pVVisManager->Draw(stepPoints); 136 } 145 } 137 } 146 } >> 147 >> 148 >> 149 >> 150 >> 151 138 152