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/RE04/src/RE04Trajectory. 26 /// \file runAndEvent/RE04/src/RE04Trajectory.cc 27 /// \brief Implementation of the RE04Trajector 27 /// \brief Implementation of the RE04Trajectory class 28 // 28 // >> 29 // $Id: $ 29 // 30 // 30 #include "RE04Trajectory.hh" 31 #include "RE04Trajectory.hh" 31 << 32 #include "RE04TrajectoryPoint.hh" 32 #include "RE04TrajectoryPoint.hh" 33 << 33 #include "G4ParticleTable.hh" 34 #include "G4AttDef.hh" << 35 #include "G4AttDefStore.hh" 34 #include "G4AttDefStore.hh" >> 35 #include "G4AttDef.hh" 36 #include "G4AttValue.hh" 36 #include "G4AttValue.hh" 37 #include "G4ParticleTable.hh" << 38 #include "G4UIcommand.hh" 37 #include "G4UIcommand.hh" 39 #include "G4UnitsTable.hh" 38 #include "G4UnitsTable.hh" 40 39 41 // #define G4ATTDEBUG << 40 //#define G4ATTDEBUG 42 #ifdef G4ATTDEBUG 41 #ifdef G4ATTDEBUG 43 # include "G4AttCheck.hh" << 42 #include "G4AttCheck.hh" 44 #endif 43 #endif 45 44 46 G4ThreadLocal G4Allocator<RE04Trajectory>* faT << 45 G4ThreadLocal G4Allocator<RE04Trajectory> * faTrajAllocator = 0; 47 46 48 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 RE04Trajectory::RE04Trajectory() 48 RE04Trajectory::RE04Trajectory() 50 : G4VTrajectory(), << 49 : G4VTrajectory(), 51 fPositionRecord(0), << 50 fPositionRecord(0), fTrackID(0), fParentID(0), 52 fTrackID(0), << 51 fPDGEncoding( 0 ), fPDGCharge(0.0), fParticleName(""), 53 fParentID(0), << 52 fInitialKineticEnergy( 0. ), fInitialMomentum( G4ThreeVector() ) 54 fPDGEncoding(0), << 53 {;} 55 fPDGCharge(0.0), << 56 fParticleName(""), << 57 fInitialKineticEnergy(0.), << 58 fInitialMomentum(G4ThreeVector()) << 59 { << 60 ; << 61 } << 62 54 63 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 RE04Trajectory::RE04Trajectory(const G4Track* 56 RE04Trajectory::RE04Trajectory(const G4Track* aTrack) 65 { 57 { 66 G4ParticleDefinition* fpParticleDefinition = << 58 G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition(); 67 fParticleName = fpParticleDefinition->GetPar << 59 fParticleName = fpParticleDefinition->GetParticleName(); 68 fPDGCharge = fpParticleDefinition->GetPDGCha << 60 fPDGCharge = fpParticleDefinition->GetPDGCharge(); 69 fPDGEncoding = fpParticleDefinition->GetPDGE << 61 fPDGEncoding = fpParticleDefinition->GetPDGEncoding(); 70 fTrackID = aTrack->GetTrackID(); << 62 fTrackID = aTrack->GetTrackID(); 71 fParentID = aTrack->GetParentID(); << 63 fParentID = aTrack->GetParentID(); 72 fInitialKineticEnergy = aTrack->GetKineticEn << 64 fInitialKineticEnergy = aTrack->GetKineticEnergy(); 73 fInitialMomentum = aTrack->GetMomentum(); << 65 fInitialMomentum = aTrack->GetMomentum(); 74 fPositionRecord = new TrajectoryPointContain << 66 fPositionRecord = new TrajectoryPointContainer(); 75 // Following is for the first trajectory poi << 67 // Following is for the first trajectory point 76 fPositionRecord->push_back(new RE04Trajector << 68 fPositionRecord->push_back(new RE04TrajectoryPoint( >> 69 aTrack->GetPosition(),aTrack->GetMaterial())); 77 } 70 } 78 71 79 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 80 RE04Trajectory::RE04Trajectory(RE04Trajectory& << 73 RE04Trajectory::RE04Trajectory(RE04Trajectory & right):G4VTrajectory() 81 { 74 { 82 fParticleName = right.fParticleName; 75 fParticleName = right.fParticleName; 83 fPDGCharge = right.fPDGCharge; 76 fPDGCharge = right.fPDGCharge; 84 fPDGEncoding = right.fPDGEncoding; 77 fPDGEncoding = right.fPDGEncoding; 85 fTrackID = right.fTrackID; 78 fTrackID = right.fTrackID; 86 fParentID = right.fParentID; 79 fParentID = right.fParentID; 87 fInitialKineticEnergy = right.fInitialKineti 80 fInitialKineticEnergy = right.fInitialKineticEnergy; 88 fInitialMomentum = right.fInitialMomentum; 81 fInitialMomentum = right.fInitialMomentum; 89 fPositionRecord = new TrajectoryPointContain 82 fPositionRecord = new TrajectoryPointContainer(); 90 83 91 for (size_t i = 0; i < right.fPositionRecord << 84 for(size_t i=0;i<right.fPositionRecord->size();i++) 92 RE04TrajectoryPoint* rightPoint = (RE04Tra << 85 { >> 86 RE04TrajectoryPoint* rightPoint >> 87 = (RE04TrajectoryPoint*)((*(right.fPositionRecord))[i]); 93 fPositionRecord->push_back(new RE04Traject 88 fPositionRecord->push_back(new RE04TrajectoryPoint(*rightPoint)); 94 } 89 } 95 } 90 } 96 91 97 //....oooOO0OOooo........oooOO0OOooo........oo 92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 98 RE04Trajectory::~RE04Trajectory() 93 RE04Trajectory::~RE04Trajectory() 99 { 94 { 100 if (fPositionRecord) { 95 if (fPositionRecord) { 101 // fPositionRecord->clearAndDestroy(); 96 // fPositionRecord->clearAndDestroy(); 102 size_t i; 97 size_t i; 103 for (i = 0; i < fPositionRecord->size(); i << 98 for(i=0;i<fPositionRecord->size();i++){ 104 delete (*fPositionRecord)[i]; << 99 delete (*fPositionRecord)[i]; 105 } 100 } 106 fPositionRecord->clear(); 101 fPositionRecord->clear(); 107 delete fPositionRecord; 102 delete fPositionRecord; 108 } 103 } 109 } 104 } 110 105 111 //....oooOO0OOooo........oooOO0OOooo........oo 106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 112 void RE04Trajectory::ShowTrajectory(std::ostre 107 void RE04Trajectory::ShowTrajectory(std::ostream& os) const 113 { 108 { 114 // Invoke the default implementation in G4VT 109 // Invoke the default implementation in G4VTrajectory... 115 G4VTrajectory::ShowTrajectory(os); 110 G4VTrajectory::ShowTrajectory(os); 116 // ... or override with your own code here. 111 // ... or override with your own code here. 117 } 112 } 118 113 119 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 120 void RE04Trajectory::DrawTrajectory() const 115 void RE04Trajectory::DrawTrajectory() const 121 { 116 { 122 // Invoke the default implementation in G4VT 117 // Invoke the default implementation in G4VTrajectory... 123 G4VTrajectory::DrawTrajectory(); 118 G4VTrajectory::DrawTrajectory(); 124 // ... or override with your own code here. 119 // ... or override with your own code here. 125 } 120 } 126 121 127 //....oooOO0OOooo........oooOO0OOooo........oo 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 128 const std::map<G4String, G4AttDef>* RE04Trajec << 123 const std::map<G4String,G4AttDef>* RE04Trajectory::GetAttDefs() const 129 { 124 { 130 G4bool isNew; 125 G4bool isNew; 131 std::map<G4String, G4AttDef>* store = G4AttD << 126 std::map<G4String,G4AttDef>* store >> 127 = G4AttDefStore::GetInstance("RE04Trajectory",isNew); 132 if (isNew) { 128 if (isNew) { >> 129 133 G4String id("ID"); 130 G4String id("ID"); 134 (*store)[id] = G4AttDef(id, "Track ID", "P << 131 (*store)[id] = G4AttDef(id,"Track ID","Physics","","G4int"); 135 132 136 G4String pid("PID"); 133 G4String pid("PID"); 137 (*store)[pid] = G4AttDef(pid, "Parent ID", << 134 (*store)[pid] = G4AttDef(pid,"Parent ID","Physics","","G4int"); 138 135 139 G4String pn("PN"); 136 G4String pn("PN"); 140 (*store)[pn] = G4AttDef(pn, "Particle Name << 137 (*store)[pn] = G4AttDef(pn,"Particle Name","Physics","","G4String"); 141 138 142 G4String ch("Ch"); 139 G4String ch("Ch"); 143 (*store)[ch] = G4AttDef(ch, "Charge", "Phy << 140 (*store)[ch] = G4AttDef(ch,"Charge","Physics","e+","G4double"); 144 141 145 G4String pdg("PDG"); 142 G4String pdg("PDG"); 146 (*store)[pdg] = G4AttDef(pdg, "PDG Encodin << 143 (*store)[pdg] = G4AttDef(pdg,"PDG Encoding","Physics","","G4int"); 147 144 148 G4String ike("IKE"); 145 G4String ike("IKE"); 149 (*store)[ike] = G4AttDef(ike, "Initial kin << 146 (*store)[ike] = >> 147 G4AttDef(ike, "Initial kinetic energy", >> 148 "Physics","G4BestUnit","G4double"); 150 149 151 G4String iMom("IMom"); 150 G4String iMom("IMom"); 152 (*store)[iMom] = G4AttDef(iMom, "Initial m << 151 (*store)[iMom] = G4AttDef(iMom, "Initial momentum", >> 152 "Physics","G4BestUnit","G4ThreeVector"); 153 153 154 G4String iMag("IMag"); 154 G4String iMag("IMag"); 155 (*store)[iMag] = << 155 (*store)[iMag] = 156 G4AttDef(iMag, "Initial momentum magnitu << 156 G4AttDef(iMag, "Initial momentum magnitude", >> 157 "Physics","G4BestUnit","G4double"); 157 158 158 G4String ntp("NTP"); 159 G4String ntp("NTP"); 159 (*store)[ntp] = G4AttDef(ntp, "No. of poin << 160 (*store)[ntp] = G4AttDef(ntp,"No. of points","Physics","","G4int"); >> 161 160 } 162 } 161 return store; 163 return store; 162 } 164 } 163 165 164 //....oooOO0OOooo........oooOO0OOooo........oo 166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 165 std::vector<G4AttValue>* RE04Trajectory::Creat 167 std::vector<G4AttValue>* RE04Trajectory::CreateAttValues() const 166 { 168 { 167 std::vector<G4AttValue>* values = new std::v 169 std::vector<G4AttValue>* values = new std::vector<G4AttValue>; 168 170 169 values->push_back(G4AttValue("ID", G4UIcomma << 171 values->push_back >> 172 (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),"")); 170 173 171 values->push_back(G4AttValue("PID", G4UIcomm << 174 values->push_back >> 175 (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),"")); 172 176 173 values->push_back(G4AttValue("PN", fParticle << 177 values->push_back(G4AttValue("PN",fParticleName,"")); 174 178 175 values->push_back(G4AttValue("Ch", G4UIcomma << 179 values->push_back >> 180 (G4AttValue("Ch",G4UIcommand::ConvertToString(fPDGCharge),"")); 176 181 177 values->push_back(G4AttValue("PDG", G4UIcomm << 182 values->push_back >> 183 (G4AttValue("PDG",G4UIcommand::ConvertToString(fPDGEncoding),"")); 178 184 179 values->push_back(G4AttValue("IKE", G4BestUn << 185 values->push_back >> 186 (G4AttValue("IKE",G4BestUnit(fInitialKineticEnergy,"Energy"),"")); 180 187 181 values->push_back(G4AttValue("IMom", G4BestU << 188 values->push_back >> 189 (G4AttValue("IMom",G4BestUnit(fInitialMomentum,"Energy"),"")); 182 190 183 values->push_back(G4AttValue("IMag", G4BestU << 191 values->push_back >> 192 (G4AttValue("IMag",G4BestUnit(fInitialMomentum.mag(),"Energy"),"")); 184 193 185 values->push_back(G4AttValue("NTP", G4UIcomm << 194 values->push_back >> 195 (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),"")); 186 196 187 #ifdef G4ATTDEBUG 197 #ifdef G4ATTDEBUG 188 G4cout << G4AttCheck(values, GetAttDefs()); << 198 G4cout << G4AttCheck(values,GetAttDefs()); 189 #endif 199 #endif 190 200 191 return values; 201 return values; 192 } 202 } 193 203 194 //....oooOO0OOooo........oooOO0OOooo........oo 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 195 void RE04Trajectory::AppendStep(const G4Step* 205 void RE04Trajectory::AppendStep(const G4Step* aStep) 196 { 206 { 197 fPositionRecord->push_back(new RE04Trajector << 207 fPositionRecord->push_back( new RE04TrajectoryPoint( 198 << 208 aStep->GetPostStepPoint()->GetPosition(), >> 209 aStep->GetPreStepPoint()->GetMaterial() )); 199 } 210 } 200 << 211 201 //....oooOO0OOooo........oooOO0OOooo........oo 212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 202 G4ParticleDefinition* RE04Trajectory::GetParti 213 G4ParticleDefinition* RE04Trajectory::GetParticleDefinition() 203 { 214 { 204 return (G4ParticleTable::GetParticleTable()- << 215 return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName)); 205 } 216 } 206 217 207 //....oooOO0OOooo........oooOO0OOooo........oo 218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 208 void RE04Trajectory::MergeTrajectory(G4VTrajec 219 void RE04Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) 209 { 220 { 210 if (!secondTrajectory) return; << 221 if(!secondTrajectory) return; 211 222 212 RE04Trajectory* seco = (RE04Trajectory*)seco 223 RE04Trajectory* seco = (RE04Trajectory*)secondTrajectory; 213 G4int ent = seco->GetPointEntries(); 224 G4int ent = seco->GetPointEntries(); 214 for (G4int i = 1; i < ent; i++) // initial << 225 for(G4int i=1;i<ent;i++) // initial point of the second trajectory 215 // should n << 226 // should not be merged 216 { << 227 { 217 fPositionRecord->push_back((*(seco->fPosit 228 fPositionRecord->push_back((*(seco->fPositionRecord))[i]); 218 // fPositionRecord->push_back(seco->fPo 229 // fPositionRecord->push_back(seco->fPositionRecord->removeAt(1)); 219 } 230 } 220 delete (*seco->fPositionRecord)[0]; 231 delete (*seco->fPositionRecord)[0]; 221 seco->fPositionRecord->clear(); 232 seco->fPositionRecord->clear(); 222 } 233 } >> 234 >> 235 223 236