[807] | 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: A01Trajectory.cc,v 1.6 2006/06/29 16:33:11 gunter Exp $ |
---|
| 27 | // -------------------------------------------------------------- |
---|
| 28 | // |
---|
| 29 | |
---|
| 30 | #include "A01Trajectory.hh" |
---|
| 31 | #include "G4TrajectoryPoint.hh" |
---|
| 32 | #include "G4ParticleTable.hh" |
---|
| 33 | #include "G4ParticleTypes.hh" |
---|
| 34 | #include "G4ThreeVector.hh" |
---|
| 35 | #include "G4Polyline.hh" |
---|
| 36 | #include "G4Circle.hh" |
---|
| 37 | #include "G4Colour.hh" |
---|
| 38 | #include "G4VisAttributes.hh" |
---|
| 39 | #include "G4VVisManager.hh" |
---|
| 40 | |
---|
| 41 | G4Allocator<A01Trajectory> myTrajectoryAllocator; |
---|
| 42 | |
---|
| 43 | A01Trajectory::A01Trajectory() |
---|
| 44 | { |
---|
| 45 | fpParticleDefinition = 0; |
---|
| 46 | ParticleName = ""; |
---|
| 47 | PDGCharge = 0; |
---|
| 48 | PDGEncoding = 0; |
---|
| 49 | fTrackID = 0; |
---|
| 50 | fParentID = 0; |
---|
| 51 | positionRecord = 0; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | A01Trajectory::A01Trajectory(const G4Track* aTrack) |
---|
| 55 | { |
---|
| 56 | fpParticleDefinition = aTrack->GetDefinition(); |
---|
| 57 | ParticleName = fpParticleDefinition->GetParticleName(); |
---|
| 58 | PDGCharge = fpParticleDefinition->GetPDGCharge(); |
---|
| 59 | PDGEncoding = fpParticleDefinition->GetPDGEncoding(); |
---|
| 60 | fTrackID = aTrack->GetTrackID(); |
---|
| 61 | fParentID = aTrack->GetParentID(); |
---|
| 62 | positionRecord = new A01TrajectoryPointContainer(); |
---|
| 63 | positionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition())); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | A01Trajectory::A01Trajectory(A01Trajectory & right) |
---|
| 67 | : G4VTrajectory() |
---|
| 68 | { |
---|
| 69 | ParticleName = right.ParticleName; |
---|
| 70 | fpParticleDefinition = right.fpParticleDefinition; |
---|
| 71 | PDGCharge = right.PDGCharge; |
---|
| 72 | PDGEncoding = right.PDGEncoding; |
---|
| 73 | fTrackID = right.fTrackID; |
---|
| 74 | fParentID = right.fParentID; |
---|
| 75 | positionRecord = new A01TrajectoryPointContainer(); |
---|
| 76 | for(int i=0;i<(int)right.positionRecord->size();i++) |
---|
| 77 | { |
---|
| 78 | G4TrajectoryPoint* rightPoint = (G4TrajectoryPoint*)((*(right.positionRecord))[i]); |
---|
| 79 | positionRecord->push_back(new G4TrajectoryPoint(*rightPoint)); |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | A01Trajectory::~A01Trajectory() |
---|
| 84 | { |
---|
| 85 | size_t i; |
---|
| 86 | for(i=0;i<positionRecord->size();i++){ |
---|
| 87 | delete (*positionRecord)[i]; |
---|
| 88 | } |
---|
| 89 | positionRecord->clear(); |
---|
| 90 | |
---|
| 91 | delete positionRecord; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | void A01Trajectory::ShowTrajectory() const |
---|
| 95 | { |
---|
| 96 | G4cout << G4endl << "TrackID =" << fTrackID |
---|
| 97 | << ":ParentID=" << fParentID << G4endl; |
---|
| 98 | G4cout << "Particle name : " << ParticleName |
---|
| 99 | << " Charge : " << PDGCharge << G4endl; |
---|
| 100 | G4cout << " Current trajectory has " << positionRecord->size() |
---|
| 101 | << " points." << G4endl; |
---|
| 102 | |
---|
| 103 | for( size_t i=0 ; i < positionRecord->size() ; i++){ |
---|
| 104 | G4TrajectoryPoint* aTrajectoryPoint = (G4TrajectoryPoint*)((*positionRecord)[i]); |
---|
| 105 | G4cout << "Point[" << i << "]" |
---|
| 106 | << " Position= " << aTrajectoryPoint->GetPosition() << G4endl; |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | void A01Trajectory::ShowTrajectory(std::ostream& o) const |
---|
| 111 | { |
---|
| 112 | G4VTrajectory::ShowTrajectory(o); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | void A01Trajectory::DrawTrajectory(G4int /*i_mode*/) const |
---|
| 117 | { |
---|
| 118 | |
---|
| 119 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); |
---|
| 120 | G4ThreeVector pos; |
---|
| 121 | |
---|
| 122 | G4Polyline pPolyline; |
---|
| 123 | for (int i = 0; i < (int)positionRecord->size() ; i++) { |
---|
| 124 | G4TrajectoryPoint* aTrajectoryPoint = (G4TrajectoryPoint*)((*positionRecord)[i]); |
---|
| 125 | pos = aTrajectoryPoint->GetPosition(); |
---|
| 126 | pPolyline.push_back( pos ); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | G4Colour colour(0.75,0.75,0.75); // LightGray |
---|
| 130 | if(fpParticleDefinition==G4Gamma::GammaDefinition()) |
---|
| 131 | colour = G4Colour(0.,1.,1.); // Cyan |
---|
| 132 | else if(fpParticleDefinition==G4Electron::ElectronDefinition() |
---|
| 133 | ||fpParticleDefinition==G4Positron::PositronDefinition()) |
---|
| 134 | colour = G4Colour(1.,1.,0.); // Yellow |
---|
| 135 | else if(fpParticleDefinition==G4MuonMinus::MuonMinusDefinition() |
---|
| 136 | ||fpParticleDefinition==G4MuonPlus::MuonPlusDefinition()) |
---|
| 137 | colour = G4Colour(1.,0.,1.); // Magenta |
---|
| 138 | else if(fpParticleDefinition->GetParticleType()=="meson") |
---|
| 139 | { |
---|
| 140 | if(PDGCharge!=0.) |
---|
| 141 | colour = G4Colour(1.,0.,0.); // Red |
---|
| 142 | else |
---|
| 143 | colour = G4Colour(0.5,0.,0.); // HalfRed |
---|
| 144 | } |
---|
| 145 | else if(fpParticleDefinition->GetParticleType()=="baryon") |
---|
| 146 | { |
---|
| 147 | if(PDGCharge!=0.) |
---|
| 148 | colour = G4Colour(1.,0.78,0.); // Orange |
---|
| 149 | else |
---|
| 150 | colour = G4Colour(0.5,0.39,0.);// HalfOrange |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | G4VisAttributes attribs(colour); |
---|
| 154 | pPolyline.SetVisAttributes(attribs); |
---|
| 155 | if(pVVisManager) pVVisManager->Draw(pPolyline); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | void A01Trajectory::AppendStep(const G4Step* aStep) |
---|
| 159 | { |
---|
| 160 | positionRecord->push_back( new G4TrajectoryPoint(aStep->GetPostStepPoint()-> |
---|
| 161 | GetPosition() )); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | G4ParticleDefinition* A01Trajectory::GetParticleDefinition() |
---|
| 165 | { |
---|
| 166 | return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName)); |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | void A01Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) |
---|
| 170 | { |
---|
| 171 | if(!secondTrajectory) return; |
---|
| 172 | |
---|
| 173 | A01Trajectory* seco = (A01Trajectory*)secondTrajectory; |
---|
| 174 | G4int ent = seco->GetPointEntries(); |
---|
| 175 | for(int i=1;i<ent;i++) // initial point of the second trajectory should not be merged |
---|
| 176 | { |
---|
| 177 | positionRecord->push_back((*(seco->positionRecord))[i]); |
---|
| 178 | } |
---|
| 179 | delete (*seco->positionRecord)[0]; |
---|
| 180 | seco->positionRecord->clear(); |
---|
| 181 | |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | |
---|