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 // 26 // 27 /// \file field/field04/src/F04Trajectory.cc 27 /// \file field/field04/src/F04Trajectory.cc 28 /// \brief Implementation of the F04Trajectory 28 /// \brief Implementation of the F04Trajectory class 29 // 29 // 30 30 31 #include "F04Trajectory.hh" << 32 << 33 #include "F04TrajectoryPoint.hh" << 34 << 35 #include "G4AttDef.hh" 31 #include "G4AttDef.hh" 36 #include "G4AttDefStore.hh" << 37 #include "G4AttValue.hh" 32 #include "G4AttValue.hh" 38 #include "G4ParticleTable.hh" << 33 #include "G4AttDefStore.hh" >> 34 39 #include "G4UIcommand.hh" 35 #include "G4UIcommand.hh" 40 #include "G4UnitsTable.hh" 36 #include "G4UnitsTable.hh" 41 37 42 // #define G4ATTDEBUG << 38 #include "F04Trajectory.hh" >> 39 #include "F04TrajectoryPoint.hh" >> 40 #include "G4ParticleTable.hh" >> 41 >> 42 //#define G4ATTDEBUG 43 #ifdef G4ATTDEBUG 43 #ifdef G4ATTDEBUG 44 # include "G4AttCheck.hh" << 44 #include "G4AttCheck.hh" 45 #endif 45 #endif 46 46 47 G4ThreadLocal G4Allocator<F04Trajectory>* F04T << 47 G4ThreadLocal G4Allocator<F04Trajectory>* F04TrajectoryAllocator=0; 48 48 49 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 50 51 F04Trajectory::F04Trajectory() {} << 51 F04Trajectory::F04Trajectory() >> 52 : fpPointsContainer(0), fTrackID(0), fParentID(0), >> 53 fPDGCharge(0.0), fPDGEncoding(0), fParticleName(""), >> 54 fInitialMomentum(G4ThreeVector()) {;} 52 55 53 //....oooOO0OOooo........oooOO0OOooo........oo 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 57 55 F04Trajectory::F04Trajectory(const G4Track* aT 58 F04Trajectory::F04Trajectory(const G4Track* aTrack) 56 { 59 { 57 G4ParticleDefinition* particleDefinition = a << 60 G4ParticleDefinition * particleDefinition = aTrack->GetDefinition(); 58 fParticleName = particleDefinition->GetParti << 61 fParticleName = particleDefinition->GetParticleName(); 59 fPDGCharge = particleDefinition->GetPDGCharg << 62 fPDGCharge = particleDefinition->GetPDGCharge(); 60 fPDGEncoding = particleDefinition->GetPDGEnc << 63 fPDGEncoding = particleDefinition->GetPDGEncoding(); 61 fTrackID = aTrack->GetTrackID(); << 64 fTrackID = aTrack->GetTrackID(); 62 fParentID = aTrack->GetParentID(); << 65 fParentID = aTrack->GetParentID(); 63 fInitialMomentum = aTrack->GetMomentum(); << 66 fInitialMomentum = aTrack->GetMomentum(); 64 fpPointsContainer = new TrajectoryPointConta << 67 fpPointsContainer = new TrajectoryPointContainer(); 65 // Following is for the first trajectory poi << 68 // Following is for the first trajectory point 66 fpPointsContainer->push_back(new F04Trajecto << 69 fpPointsContainer->push_back(new F04TrajectoryPoint(aTrack)); 67 } 70 } 68 71 69 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 70 73 71 F04Trajectory::F04Trajectory(F04Trajectory& ri << 74 F04Trajectory::F04Trajectory(F04Trajectory & right) : G4VTrajectory() 72 { << 75 { 73 fParticleName = right.fParticleName; << 76 fParticleName = right.fParticleName; 74 fPDGCharge = right.fPDGCharge; << 77 fPDGCharge = right.fPDGCharge; 75 fPDGEncoding = right.fPDGEncoding; << 78 fPDGEncoding = right.fPDGEncoding; 76 fTrackID = right.fTrackID; << 79 fTrackID = right.fTrackID; 77 fParentID = right.fParentID; << 80 fParentID = right.fParentID; 78 fInitialMomentum = right.fInitialMomentum; << 81 fInitialMomentum = right.fInitialMomentum; 79 fpPointsContainer = new TrajectoryPointConta << 82 fpPointsContainer = new TrajectoryPointContainer(); 80 << 83 81 for (size_t i = 0; i < right.fpPointsContain << 84 for(size_t i=0;i<right.fpPointsContainer->size();++i) { 82 auto rightPoint = (F04TrajectoryPoint*)((* << 85 F04TrajectoryPoint* rightPoint 83 fpPointsContainer->push_back(new F04Trajec << 86 = (F04TrajectoryPoint*)((*(right.fpPointsContainer))[i]); 84 } << 87 fpPointsContainer->push_back(new F04TrajectoryPoint(*rightPoint)); >> 88 } 85 } 89 } 86 90 87 //....oooOO0OOooo........oooOO0OOooo........oo 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 92 89 F04Trajectory::~F04Trajectory() 93 F04Trajectory::~F04Trajectory() 90 { 94 { 91 for (size_t i = 0; i < fpPointsContainer->si << 95 for(size_t i=0;i<fpPointsContainer->size();++i){ 92 delete (*fpPointsContainer)[i]; << 96 delete (*fpPointsContainer)[i]; 93 } << 97 } 94 fpPointsContainer->clear(); << 98 fpPointsContainer->clear(); 95 99 96 delete fpPointsContainer; << 100 delete fpPointsContainer; 97 } 101 } 98 102 99 //....oooOO0OOooo........oooOO0OOooo........oo 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 100 104 101 void F04Trajectory::ShowTrajectory(std::ostrea 105 void F04Trajectory::ShowTrajectory(std::ostream& os) const 102 { 106 { 103 // Invoke the default implementation in G4VT << 107 // Invoke the default implementation in G4VTrajectory... 104 G4VTrajectory::ShowTrajectory(os); << 108 G4VTrajectory::ShowTrajectory(os); 105 // ... or override with your own code here. << 109 // ... or override with your own code here. 106 } 110 } 107 111 108 //....oooOO0OOooo........oooOO0OOooo........oo 112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 109 113 110 void F04Trajectory::AppendStep(const G4Step* a 114 void F04Trajectory::AppendStep(const G4Step* aStep) 111 { 115 { 112 fpPointsContainer->push_back(new F04Trajecto << 116 fpPointsContainer->push_back(new F04TrajectoryPoint(aStep)); 113 } 117 } 114 118 115 //....oooOO0OOooo........oooOO0OOooo........oo 119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 120 117 G4ParticleDefinition* F04Trajectory::GetPartic 121 G4ParticleDefinition* F04Trajectory::GetParticleDefinition() 118 { 122 { 119 return (G4ParticleTable::GetParticleTable()- << 123 return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName)); 120 } 124 } 121 125 122 //....oooOO0OOooo........oooOO0OOooo........oo 126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 123 127 124 void F04Trajectory::MergeTrajectory(G4VTraject 128 void F04Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) 125 { 129 { 126 if (!secondTrajectory) return; << 130 if(!secondTrajectory) return; 127 131 128 auto second = (F04Trajectory*)secondTrajecto << 132 F04Trajectory* second = (F04Trajectory*)secondTrajectory; 129 G4int ent = second->GetPointEntries(); << 133 G4int ent = second->GetPointEntries(); 130 // initial point of the second trajectory sh << 134 // initial point of the second trajectory should not be merged 131 for (G4int i = 1; i < ent; ++i) { << 135 for(G4int i=1; i<ent; ++i) { 132 fpPointsContainer->push_back((*(second->fp << 136 fpPointsContainer->push_back((*(second->fpPointsContainer))[i]); 133 } << 137 } 134 delete (*second->fpPointsContainer)[0]; << 138 delete (*second->fpPointsContainer)[0]; 135 second->fpPointsContainer->clear(); << 139 second->fpPointsContainer->clear(); 136 } 140 } 137 141 138 //....oooOO0OOooo........oooOO0OOooo........oo 142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 139 143 140 const std::map<G4String, G4AttDef>* F04Traject << 144 const std::map<G4String,G4AttDef>* F04Trajectory::GetAttDefs() const 141 { 145 { 142 G4bool isNew; << 146 G4bool isNew; 143 std::map<G4String, G4AttDef>* store = G4AttD << 147 std::map<G4String,G4AttDef>* store >> 148 = G4AttDefStore::GetInstance("Trajectory",isNew); >> 149 >> 150 if (isNew) { >> 151 >> 152 G4String ID("ID"); >> 153 (*store)[ID] = G4AttDef(ID,"Track ID","Bookkeeping","","G4int"); 144 154 145 if (isNew) { << 155 G4String PID("PID"); 146 G4String ID("ID"); << 156 (*store)[PID] = G4AttDef(PID,"Parent ID","Bookkeeping","","G4int"); 147 (*store)[ID] = G4AttDef(ID, "Track ID", "B << 148 157 149 G4String PID("PID"); << 158 G4String PN("PN"); 150 (*store)[PID] = G4AttDef(PID, "Parent ID", << 159 (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String"); 151 160 152 G4String PN("PN"); << 161 G4String Ch("Ch"); 153 (*store)[PN] = G4AttDef(PN, "Particle Name << 162 (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double"); 154 163 155 G4String Ch("Ch"); << 164 G4String PDG("PDG"); 156 (*store)[Ch] = G4AttDef(Ch, "Charge", "Phy << 165 (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int"); 157 166 158 G4String PDG("PDG"); << 167 G4String IMom("IMom"); 159 (*store)[PDG] = G4AttDef(PDG, "PDG Encodin << 168 (*store)[IMom] = G4AttDef(IMom, >> 169 "Momentum of track at start of trajectory", >> 170 "Physics","G4BestUnit","G4ThreeVector"); 160 171 161 G4String IMom("IMom"); << 172 G4String IMag("IMag"); 162 (*store)[IMom] = G4AttDef(IMom, "Momentum << 173 (*store)[IMag] = G4AttDef(IMag, 163 "G4BestUnit", "G << 174 "Magnitude of momentum of track at start of trajectory", >> 175 "Physics","G4BestUnit","G4double"); 164 176 165 G4String IMag("IMag"); << 177 G4String NTP("NTP"); 166 (*store)[IMag] = G4AttDef(IMag, "Magnitude << 178 (*store)[NTP] = G4AttDef(NTP,"No. of points","Bookkeeping","","G4int"); 167 "Physics", "G4Be << 168 179 169 G4String NTP("NTP"); << 180 } 170 (*store)[NTP] = G4AttDef(NTP, "No. of poin << 181 return store; 171 } << 172 return store; << 173 } 182 } 174 183 175 //....oooOO0OOooo........oooOO0OOooo........oo 184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 176 185 177 std::vector<G4AttValue>* F04Trajectory::Create 186 std::vector<G4AttValue>* F04Trajectory::CreateAttValues() const 178 { 187 { 179 auto values = new std::vector<G4AttValue>; << 188 std::vector<G4AttValue>* values = new std::vector<G4AttValue>; 180 189 181 values->push_back(G4AttValue("ID", G4UIcomma << 190 values->push_back >> 191 (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),"")); 182 192 183 values->push_back(G4AttValue("PID", G4UIcomm << 193 values->push_back >> 194 (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),"")); 184 195 185 values->push_back(G4AttValue("PN", fParticle << 196 values->push_back(G4AttValue("PN",fParticleName,"")); 186 197 187 values->push_back(G4AttValue("Ch", G4UIcomma << 198 values->push_back >> 199 (G4AttValue("Ch",G4UIcommand::ConvertToString(fPDGCharge),"")); 188 200 189 values->push_back(G4AttValue("PDG", G4UIcomm << 201 values->push_back >> 202 (G4AttValue("PDG",G4UIcommand::ConvertToString(fPDGEncoding),"")); 190 203 191 values->push_back(G4AttValue("IMom", G4BestU << 204 values->push_back >> 205 (G4AttValue("IMom",G4BestUnit(fInitialMomentum,"Energy"),"")); 192 206 193 values->push_back(G4AttValue("IMag", G4BestU << 207 values->push_back >> 208 (G4AttValue("IMag",G4BestUnit(fInitialMomentum.mag(),"Energy"),"")); 194 209 195 values->push_back(G4AttValue("NTP", G4UIcomm << 210 values->push_back >> 211 (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),"")); 196 212 197 #ifdef G4ATTDEBUG 213 #ifdef G4ATTDEBUG 198 G4cout << G4AttCheck(values, GetAttDefs()); << 214 G4cout << G4AttCheck(values,GetAttDefs()); 199 #endif 215 #endif 200 return values; << 216 return values; 201 } 217 } 202 218