Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file runAndEvent/RE01/src/RE01Trajectory. 26 /// \file runAndEvent/RE01/src/RE01Trajectory.cc 27 /// \brief Implementation of the RE01Trajector 27 /// \brief Implementation of the RE01Trajectory class 28 // 28 // 29 // 29 // >> 30 // $Id$ 30 // 31 // 31 32 32 #include "RE01Trajectory.hh" 33 #include "RE01Trajectory.hh" 33 << 34 #include "RE01TrackInformation.hh" << 35 << 36 #include "G4AttDef.hh" << 37 #include "G4AttDefStore.hh" << 38 #include "G4AttValue.hh" << 39 #include "G4Circle.hh" << 40 #include "G4Colour.hh" << 41 #include "G4DynamicParticle.hh" << 42 #include "G4ParticleTable.hh" 34 #include "G4ParticleTable.hh" 43 #include "G4ParticleTypes.hh" 35 #include "G4ParticleTypes.hh" 44 #include "G4Polyline.hh" 36 #include "G4Polyline.hh" 45 #include "G4PrimaryParticle.hh" << 37 #include "G4Circle.hh" >> 38 #include "G4Colour.hh" >> 39 #include "G4AttDefStore.hh" >> 40 #include "G4AttDef.hh" >> 41 #include "G4AttValue.hh" 46 #include "G4UIcommand.hh" 42 #include "G4UIcommand.hh" 47 #include "G4UnitsTable.hh" << 48 #include "G4VVisManager.hh" << 49 #include "G4VisAttributes.hh" 43 #include "G4VisAttributes.hh" >> 44 #include "G4VVisManager.hh" >> 45 #include "G4UnitsTable.hh" >> 46 #include "G4DynamicParticle.hh" >> 47 #include "G4PrimaryParticle.hh" >> 48 #include "RE01TrackInformation.hh" 50 49 51 G4ThreadLocal G4Allocator<RE01Trajectory>* myT << 50 G4Allocator<RE01Trajectory> myTrajectoryAllocator; 52 51 53 //....oooOO0OOooo........oooOO0OOooo........oo << 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 RE01Trajectory::RE01Trajectory(const G4Track* 53 RE01Trajectory::RE01Trajectory(const G4Track* aTrack) 55 : G4VTrajectory(), fPositionRecord(0), fPart << 54 :G4VTrajectory() 56 { 55 { 57 fParticleDefinition = aTrack->GetDefinition( << 56 fParticleDefinition = aTrack->GetDefinition(); 58 fParticleName = fParticleDefinition->GetPart << 57 fParticleName = fParticleDefinition->GetParticleName(); 59 fPDGCharge = fParticleDefinition->GetPDGChar << 58 fPDGCharge = fParticleDefinition->GetPDGCharge(); 60 fPDGEncoding = fParticleDefinition->GetPDGEn << 59 fPDGEncoding = fParticleDefinition->GetPDGEncoding(); 61 if (fParticleName == "unknown") { << 60 if(fParticleName=="unknown") 62 G4PrimaryParticle* pp = aTrack->GetDynamic << 61 { 63 if (pp) { << 62 G4PrimaryParticle*pp = aTrack->GetDynamicParticle()->GetPrimaryParticle(); 64 if (pp->GetCharge() < DBL_MAX) fPDGCharg << 63 if(pp) 65 fPDGEncoding = pp->GetPDGcode(); << 64 { 66 if (pp->GetG4code() != 0) { << 65 if(pp->GetCharge()<DBL_MAX) fPDGCharge = pp->GetCharge(); 67 fParticleName += " : "; << 66 fPDGEncoding = pp->GetPDGcode(); 68 fParticleName += pp->GetG4code()->GetP << 67 if(pp->GetG4code()!=0) 69 } << 68 { 70 } << 69 fParticleName += " : "; 71 } << 70 fParticleName += pp->GetG4code()->GetParticleName(); 72 fTrackID = aTrack->GetTrackID(); << 71 } 73 RE01TrackInformation* trackInfo = (RE01Track << 72 } 74 fTrackStatus = trackInfo->GetTrackingStatus( << 73 } 75 if (fTrackStatus == 1) { << 74 fTrackID = aTrack->GetTrackID(); 76 fParentID = aTrack->GetParentID(); << 75 RE01TrackInformation* trackInfo 77 } << 76 = (RE01TrackInformation*)(aTrack->GetUserInformation()); 78 else if (fTrackStatus == 2) { << 77 fTrackStatus = trackInfo->GetTrackingStatus(); 79 fParentID = trackInfo->GetSourceTrackID(); << 78 if(fTrackStatus == 1) 80 } << 79 { fParentID = aTrack->GetParentID(); } 81 else { << 80 else if(fTrackStatus == 2) 82 fParentID = -1; << 81 { fParentID = trackInfo->GetSourceTrackID(); } 83 } << 82 else 84 fPositionRecord = new RE01TrajectoryPointCon << 83 { fParentID = -1; } 85 fPositionRecord->push_back(new G4TrajectoryP << 84 fPositionRecord = new RE01TrajectoryPointContainer(); 86 fMomentum = aTrack->GetMomentum(); << 85 fPositionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition())); 87 fVertexPosition = aTrack->GetPosition(); << 86 fMomentum = aTrack->GetMomentum(); 88 fGlobalTime = aTrack->GetGlobalTime(); << 87 fVertexPosition = aTrack->GetPosition(); >> 88 fGlobalTime = aTrack->GetGlobalTime(); 89 } 89 } 90 90 91 //....oooOO0OOooo........oooOO0OOooo........oo << 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 92 RE01Trajectory::~RE01Trajectory() 92 RE01Trajectory::~RE01Trajectory() 93 { 93 { 94 size_t i; 94 size_t i; 95 for (i = 0; i < fPositionRecord->size(); i++ << 95 for(i=0;i<fPositionRecord->size();i++){ 96 delete (*fPositionRecord)[i]; << 96 delete (*fPositionRecord)[i]; 97 } 97 } 98 fPositionRecord->clear(); 98 fPositionRecord->clear(); 99 99 100 delete fPositionRecord; 100 delete fPositionRecord; 101 } 101 } 102 102 103 //....oooOO0OOooo........oooOO0OOooo........oo << 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 104 void RE01Trajectory::ShowTrajectory(std::ostre 104 void RE01Trajectory::ShowTrajectory(std::ostream& os) const 105 { 105 { 106 os << G4endl << "TrackID =" << fTrackID << " << 106 os << G4endl << "TrackID =" << fTrackID 107 << " : TrackStatus=" << fTrackStatus << G << 107 << " : ParentID=" << fParentID << " : TrackStatus=" << fTrackStatus << G4endl; 108 os << "Particle name : " << fParticleName << << 108 os << "Particle name : " << fParticleName << " PDG code : " << fPDGEncoding 109 << " Charge : " << fPDGCharge << G4endl; << 109 << " Charge : " << fPDGCharge << G4endl; 110 os << "Original momentum : " << G4BestUnit(f << 110 os << "Original momentum : " << 111 os << "Vertex : " << G4BestUnit(fVertexPosit << 111 G4BestUnit(fMomentum,"Energy") << G4endl; 112 << " Global time : " << G4BestUnit(fGlob << 112 os << "Vertex : " << G4BestUnit(fVertexPosition,"Length") 113 os << " Current trajectory has " << fPositi << 113 << " Global time : " << G4BestUnit(fGlobalTime,"Time") << G4endl; 114 << 114 os << " Current trajectory has " << fPositionRecord->size() 115 for (size_t i = 0; i < fPositionRecord->size << 115 << " points." << G4endl; 116 G4TrajectoryPoint* aTrajectoryPoint = (G4T << 116 117 os << "Point[" << i << "]" << 117 for( size_t i=0 ; i < fPositionRecord->size() ; i++){ 118 << " Position= " << aTrajectoryPoint->G << 118 G4TrajectoryPoint* aTrajectoryPoint = 119 } << 119 (G4TrajectoryPoint*)((*fPositionRecord)[i]); 120 } << 120 os << "Point[" << i << "]" 121 << 121 << " Position= " << aTrajectoryPoint->GetPosition() << G4endl; 122 //....oooOO0OOooo........oooOO0OOooo........oo << 122 } 123 void RE01Trajectory::DrawTrajectory() const << 123 } 124 { << 124 125 G4VVisManager* pVVisManager = G4VVisManager: << 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 126 G4ThreeVector pos; << 126 void RE01Trajectory::DrawTrajectory(G4int /*i_mode*/) const 127 << 127 { 128 G4Polyline pPolyline; << 128 129 for (size_t i = 0; i < fPositionRecord->size << 129 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); 130 G4TrajectoryPoint* aTrajectoryPoint = (G4T << 130 G4ThreeVector pos; 131 pos = aTrajectoryPoint->GetPosition(); << 131 132 pPolyline.push_back(pos); << 132 G4Polyline pPolyline; 133 } << 133 for (size_t i = 0; i < fPositionRecord->size() ; i++) { 134 << 134 G4TrajectoryPoint* aTrajectoryPoint = 135 G4Colour colour(0.2, 0.2, 0.2); << 135 (G4TrajectoryPoint*)((*fPositionRecord)[i]); 136 if (fParticleDefinition == G4Gamma::GammaDef << 136 pos = aTrajectoryPoint->GetPosition(); 137 colour = G4Colour(0., 0., 1.); << 137 pPolyline.push_back( pos ); 138 else if (fParticleDefinition == G4Electron:: << 138 } 139 || fParticleDefinition == G4Positro << 139 140 colour = G4Colour(1., 1., 0.); << 140 G4Colour colour(0.2,0.2,0.2); 141 else if (fParticleDefinition == G4MuonMinus: << 141 if(fParticleDefinition==G4Gamma::GammaDefinition()) 142 || fParticleDefinition == G4MuonPlu << 142 colour = G4Colour(0.,0.,1.); 143 colour = G4Colour(0., 1., 0.); << 143 else if(fParticleDefinition==G4Electron::ElectronDefinition() 144 else if (fParticleDefinition->GetParticleTyp << 144 ||fParticleDefinition==G4Positron::PositronDefinition()) 145 if (fPDGCharge != 0.) << 145 colour = G4Colour(1.,1.,0.); 146 colour = G4Colour(1., 0., 0.); << 146 else if(fParticleDefinition==G4MuonMinus::MuonMinusDefinition() 147 else << 147 ||fParticleDefinition==G4MuonPlus::MuonPlusDefinition()) 148 colour = G4Colour(0.5, 0., 0.); << 148 colour = G4Colour(0.,1.,0.); 149 } << 149 else if(fParticleDefinition->GetParticleType()=="meson") 150 else if (fParticleDefinition->GetParticleTyp << 150 { 151 if (fPDGCharge != 0.) << 151 if(fPDGCharge!=0.) 152 colour = G4Colour(0., 1., 1.); << 152 colour = G4Colour(1.,0.,0.); 153 else << 153 else 154 colour = G4Colour(0., 0.5, 0.5); << 154 colour = G4Colour(0.5,0.,0.); 155 } << 155 } 156 << 156 else if(fParticleDefinition->GetParticleType()=="baryon") 157 G4VisAttributes attribs(colour); << 157 { 158 pPolyline.SetVisAttributes(attribs); << 158 if(fPDGCharge!=0.) 159 if (pVVisManager) pVVisManager->Draw(pPolyli << 159 colour = G4Colour(0.,1.,1.); >> 160 else >> 161 colour = G4Colour(0.,0.5,0.5); >> 162 } >> 163 >> 164 G4VisAttributes attribs(colour); >> 165 pPolyline.SetVisAttributes(attribs); >> 166 if(pVVisManager) pVVisManager->Draw(pPolyline); 160 } 167 } 161 168 162 //....oooOO0OOooo........oooOO0OOooo........oo << 169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 163 const std::map<G4String, G4AttDef>* RE01Trajec << 170 const std::map<G4String,G4AttDef>* RE01Trajectory::GetAttDefs() const 164 { 171 { 165 G4bool isNew; 172 G4bool isNew; 166 std::map<G4String, G4AttDef>* store = G4AttD << 173 std::map<G4String,G4AttDef>* store >> 174 = G4AttDefStore::GetInstance("RE01Trajectory",isNew); 167 if (isNew) { 175 if (isNew) { >> 176 168 G4String id("ID"); 177 G4String id("ID"); 169 (*store)[id] = G4AttDef(id, "Track ID", "B << 178 (*store)[id] = G4AttDef(id,"Track ID","Bookkeeping","","G4int"); 170 179 171 G4String pid("PID"); 180 G4String pid("PID"); 172 (*store)[pid] = G4AttDef(pid, "Parent ID", << 181 (*store)[pid] = G4AttDef(pid,"Parent ID","Bookkeeping","","G4int"); 173 182 174 G4String status("Status"); 183 G4String status("Status"); 175 (*store)[status] = G4AttDef(status, "Track << 184 (*store)[status] = G4AttDef(status,"Track Status","Bookkeeping","","G4int"); 176 185 177 G4String pn("PN"); 186 G4String pn("PN"); 178 (*store)[pn] = G4AttDef(pn, "Particle Name << 187 (*store)[pn] = G4AttDef(pn,"Particle Name","Bookkeeping","","G4String"); 179 188 180 G4String ch("Ch"); 189 G4String ch("Ch"); 181 (*store)[ch] = G4AttDef(ch, "Charge", "Phy << 190 (*store)[ch] = G4AttDef(ch,"Charge","Physics","e+","G4double"); 182 191 183 G4String pdg("PDG"); 192 G4String pdg("PDG"); 184 (*store)[pdg] = G4AttDef(pdg, "PDG Encodin << 193 (*store)[pdg] = G4AttDef(pdg,"PDG Encoding","Bookkeeping","","G4int"); 185 194 186 G4String imom("IMom"); 195 G4String imom("IMom"); 187 (*store)[imom] = G4AttDef(imom, "Momentum << 196 (*store)[imom] = G4AttDef(imom, "Momentum of track at start of trajectory", 188 "G4BestUnit", "G << 197 "Physics","G4BestUnit","G4ThreeVector"); 189 198 190 G4String imag("IMag"); 199 G4String imag("IMag"); 191 (*store)[imag] = G4AttDef(imag, "Magnitude << 200 (*store)[imag] = 192 "Physics", "G4Be << 201 G4AttDef(imag, "Magnitude of momentum of track at start of trajectory", >> 202 "Physics","G4BestUnit","G4double"); 193 203 194 G4String vtxPos("VtxPos"); 204 G4String vtxPos("VtxPos"); 195 (*store)[vtxPos] = << 205 (*store)[vtxPos] = G4AttDef(vtxPos, "Vertex position", 196 G4AttDef(vtxPos, "Vertex position", "Phy << 206 "Physics","G4BestUnit","G4ThreeVector"); 197 207 198 G4String ntp("NTP"); 208 G4String ntp("NTP"); 199 (*store)[ntp] = G4AttDef(ntp, "No. of poin << 209 (*store)[ntp] = G4AttDef(ntp,"No. of points","Bookkeeping","","G4int"); >> 210 200 } 211 } 201 return store; 212 return store; 202 } 213 } 203 214 204 //....oooOO0OOooo........oooOO0OOooo........oo << 215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 205 std::vector<G4AttValue>* RE01Trajectory::Creat 216 std::vector<G4AttValue>* RE01Trajectory::CreateAttValues() const 206 { 217 { 207 std::vector<G4AttValue>* values = new std::v 218 std::vector<G4AttValue>* values = new std::vector<G4AttValue>; 208 219 209 values->push_back(G4AttValue("ID", G4UIcomma << 220 values->push_back >> 221 (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),"")); 210 222 211 values->push_back(G4AttValue("PID", G4UIcomm << 223 values->push_back >> 224 (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),"")); 212 225 213 values->push_back(G4AttValue("Status", G4UIc << 226 values->push_back >> 227 (G4AttValue("Status",G4UIcommand::ConvertToString(fTrackStatus),"")); 214 228 215 values->push_back(G4AttValue("PN", fParticle << 229 values->push_back(G4AttValue("PN",fParticleName,"")); 216 230 217 values->push_back(G4AttValue("Ch", G4UIcomma << 231 values->push_back >> 232 (G4AttValue("Ch",G4UIcommand::ConvertToString(fPDGCharge),"")); 218 233 219 values->push_back(G4AttValue("PDG", G4UIcomm << 234 values->push_back >> 235 (G4AttValue("PDG",G4UIcommand::ConvertToString(fPDGEncoding),"")); 220 236 221 values->push_back(G4AttValue("IMom", G4BestU << 237 values->push_back >> 238 (G4AttValue("IMom",G4BestUnit(fMomentum,"Energy"),"")); 222 239 223 values->push_back(G4AttValue("IMag", G4BestU << 240 values->push_back >> 241 (G4AttValue("IMag",G4BestUnit(fMomentum.mag(),"Energy"),"")); 224 242 225 values->push_back(G4AttValue("VtxPos", G4Bes << 243 values->push_back >> 244 (G4AttValue("VtxPos",G4BestUnit(fVertexPosition,"Length"),"")); 226 245 227 values->push_back(G4AttValue("NTP", G4UIcomm << 246 values->push_back >> 247 (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),"")); 228 248 229 return values; 249 return values; 230 } 250 } 231 251 232 //....oooOO0OOooo........oooOO0OOooo........oo << 252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 233 void RE01Trajectory::AppendStep(const G4Step* 253 void RE01Trajectory::AppendStep(const G4Step* aStep) 234 { 254 { 235 fPositionRecord->push_back(new G4TrajectoryP << 255 fPositionRecord->push_back( >> 256 new G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition() )); 236 } 257 } 237 << 258 238 //....oooOO0OOooo........oooOO0OOooo........oo << 259 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 239 void RE01Trajectory::MergeTrajectory(G4VTrajec 260 void RE01Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) 240 { 261 { 241 if (!secondTrajectory) return; << 262 if(!secondTrajectory) return; 242 263 243 RE01Trajectory* seco = (RE01Trajectory*)seco 264 RE01Trajectory* seco = (RE01Trajectory*)secondTrajectory; 244 G4int ent = seco->GetPointEntries(); 265 G4int ent = seco->GetPointEntries(); 245 // 266 // 246 // initial point of the second trajectory sh 267 // initial point of the second trajectory should not be merged 247 for (int i = 1; i < ent; i++) { << 268 for(int i=1;i<ent;i++) >> 269 { 248 fPositionRecord->push_back((*(seco->fPosit 270 fPositionRecord->push_back((*(seco->fPositionRecord))[i]); 249 } 271 } 250 delete (*seco->fPositionRecord)[0]; 272 delete (*seco->fPositionRecord)[0]; 251 seco->fPositionRecord->clear(); 273 seco->fPositionRecord->clear(); >> 274 252 } 275 } 253 276