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