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 // G4RichTrajectoryPoint class implementation 26 // G4RichTrajectoryPoint class implementation 27 // 27 // 28 // Contact: 28 // Contact: 29 // Questions and comments on G4TrajectoryPoi 29 // Questions and comments on G4TrajectoryPoint, on which this is based, 30 // should be sent to 30 // should be sent to 31 // Katsuya Amako (e-mail: Katsuya.Amako@k 31 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) 32 // Makoto Asai (e-mail: asai@slac.stanf 32 // Makoto Asai (e-mail: asai@slac.stanford.edu) 33 // Takashi Sasaki (e-mail: Takashi.Sasaki@ 33 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) 34 // and on the extended code to: 34 // and on the extended code to: 35 // John Allison (e-mail: John.Allison@ma 35 // John Allison (e-mail: John.Allison@manchester.ac.uk) 36 // Joseph Perl (e-mail: perl@slac.stanf 36 // Joseph Perl (e-mail: perl@slac.stanford.edu) 37 // ------------------------------------------- 37 // -------------------------------------------------------------------- 38 38 39 #include "G4RichTrajectoryPoint.hh" 39 #include "G4RichTrajectoryPoint.hh" 40 40 41 #include "G4AttDef.hh" << 41 #include "G4Track.hh" >> 42 #include "G4Step.hh" >> 43 #include "G4VProcess.hh" >> 44 42 #include "G4AttDefStore.hh" 45 #include "G4AttDefStore.hh" >> 46 #include "G4AttDef.hh" 43 #include "G4AttValue.hh" 47 #include "G4AttValue.hh" 44 #include "G4Step.hh" << 45 #include "G4Track.hh" << 46 #include "G4UIcommand.hh" << 47 #include "G4UnitsTable.hh" 48 #include "G4UnitsTable.hh" 48 #include "G4VProcess.hh" << 49 49 50 // #define G4ATTDEBUG << 50 //#define G4ATTDEBUG 51 #ifdef G4ATTDEBUG 51 #ifdef G4ATTDEBUG 52 # include "G4AttCheck.hh" << 52 #include "G4AttCheck.hh" 53 #endif 53 #endif 54 54 55 #include <sstream> 55 #include <sstream> 56 56 57 G4Allocator<G4RichTrajectoryPoint>*& aRichTraj 57 G4Allocator<G4RichTrajectoryPoint>*& aRichTrajectoryPointAllocator() 58 { 58 { 59 G4ThreadLocalStatic G4Allocator<G4RichTrajec 59 G4ThreadLocalStatic G4Allocator<G4RichTrajectoryPoint>* _instance = nullptr; 60 return _instance; 60 return _instance; 61 } 61 } 62 62 63 G4RichTrajectoryPoint::G4RichTrajectoryPoint() << 63 G4RichTrajectoryPoint::G4RichTrajectoryPoint() >> 64 { >> 65 } 64 66 65 G4RichTrajectoryPoint::G4RichTrajectoryPoint(c 67 G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack) 66 : fPosition(aTrack->GetPosition()), << 68 : G4TrajectoryPoint(aTrack->GetPosition()), 67 fPreStepPointGlobalTime(aTrack->GetGlobalT 69 fPreStepPointGlobalTime(aTrack->GetGlobalTime()), 68 fPostStepPointGlobalTime(aTrack->GetGlobal 70 fPostStepPointGlobalTime(aTrack->GetGlobalTime()), 69 fpPreStepPointVolume(aTrack->GetTouchableH 71 fpPreStepPointVolume(aTrack->GetTouchableHandle()), 70 fpPostStepPointVolume(aTrack->GetNextTouch 72 fpPostStepPointVolume(aTrack->GetNextTouchableHandle()), 71 fPreStepPointWeight(aTrack->GetWeight()), 73 fPreStepPointWeight(aTrack->GetWeight()), 72 fPostStepPointWeight(aTrack->GetWeight()) 74 fPostStepPointWeight(aTrack->GetWeight()) 73 {} << 75 { >> 76 } 74 77 75 G4RichTrajectoryPoint::G4RichTrajectoryPoint(c 78 G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep) 76 : fPosition(aStep->GetPostStepPoint()->GetPo << 79 : G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()), 77 fpAuxiliaryPointVector(aStep->GetPointerTo 80 fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()), 78 fTotEDep(aStep->GetTotalEnergyDeposit()) 81 fTotEDep(aStep->GetTotalEnergyDeposit()) 79 { 82 { 80 G4StepPoint* preStepPoint = aStep->GetPreSte 83 G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); 81 G4StepPoint* postStepPoint = aStep->GetPostS 84 G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); 82 if (aStep->GetTrack()->GetCurrentStepNumber( 85 if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) // First step 83 { 86 { 84 fRemainingEnergy = aStep->GetTrack()->GetK 87 fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy(); 85 } 88 } 86 else { << 89 else >> 90 { 87 fRemainingEnergy = preStepPoint->GetKineti 91 fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep; 88 } 92 } 89 fpProcess = postStepPoint->GetProcessDefined 93 fpProcess = postStepPoint->GetProcessDefinedStep(); 90 fPreStepPointStatus = preStepPoint->GetStepS 94 fPreStepPointStatus = preStepPoint->GetStepStatus(); 91 fPostStepPointStatus = postStepPoint->GetSte 95 fPostStepPointStatus = postStepPoint->GetStepStatus(); 92 fPreStepPointGlobalTime = preStepPoint->GetG 96 fPreStepPointGlobalTime = preStepPoint->GetGlobalTime(); 93 fPostStepPointGlobalTime = postStepPoint->Ge 97 fPostStepPointGlobalTime = postStepPoint->GetGlobalTime(); 94 fpPreStepPointVolume = preStepPoint->GetTouc 98 fpPreStepPointVolume = preStepPoint->GetTouchableHandle(); 95 fpPostStepPointVolume = postStepPoint->GetTo 99 fpPostStepPointVolume = postStepPoint->GetTouchableHandle(); 96 fPreStepPointWeight = preStepPoint->GetWeigh 100 fPreStepPointWeight = preStepPoint->GetWeight(); 97 fPostStepPointWeight = postStepPoint->GetWei 101 fPostStepPointWeight = postStepPoint->GetWeight(); 98 } 102 } 99 103 100 // This is certainly wrong. the fpAuxiliaryPoi << 104 G4RichTrajectoryPoint::G4RichTrajectoryPoint( const G4RichTrajectoryPoint &r ) 101 // and must be deep copied. Note also the copy << 105 : G4TrajectoryPoint(r), 102 // However, G4RichTrajectory requires a copy c << 106 fpAuxiliaryPointVector(r.fpAuxiliaryPointVector), 103 G4RichTrajectoryPoint::G4RichTrajectoryPoint(c << 107 fTotEDep(r.fTotEDep), >> 108 fRemainingEnergy(r.fRemainingEnergy), >> 109 fpProcess(r.fpProcess), >> 110 fPreStepPointStatus(r.fPreStepPointStatus), >> 111 fPostStepPointStatus(r.fPostStepPointStatus), >> 112 fPreStepPointGlobalTime(r.fPreStepPointGlobalTime), >> 113 fPostStepPointGlobalTime(r.fPostStepPointGlobalTime), >> 114 fpPreStepPointVolume(r.fpPreStepPointVolume), >> 115 fpPostStepPointVolume(r.fpPostStepPointVolume), >> 116 fPreStepPointWeight(r.fPreStepPointWeight), >> 117 fPostStepPointWeight(r.fPostStepPointWeight) >> 118 { >> 119 } 104 120 105 G4RichTrajectoryPoint::~G4RichTrajectoryPoint( << 121 G4RichTrajectoryPoint::~G4RichTrajectoryPoint() >> 122 { >> 123 delete fpAuxiliaryPointVector; >> 124 } 106 125 107 const std::map<G4String, G4AttDef>* G4RichTraj << 126 const std::map<G4String,G4AttDef>* G4RichTrajectoryPoint::GetAttDefs() const 108 { 127 { 109 G4bool isNew; 128 G4bool isNew; 110 std::map<G4String, G4AttDef>* store = G4AttD << 129 std::map<G4String,G4AttDef>* store 111 if (isNew) { << 130 = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew); >> 131 if (isNew) >> 132 { >> 133 // Copy base class att defs... >> 134 *store = *(G4TrajectoryPoint::GetAttDefs()); >> 135 112 G4String ID; 136 G4String ID; 113 137 114 ID = "Pos"; << 115 (*store)[ID] = G4AttDef(ID, "Position", "P << 116 ID = "Aux"; 138 ID = "Aux"; 117 (*store)[ID] = << 139 (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position", 118 G4AttDef(ID, "Auxiliary Point Position", << 140 "Physics","G4BestUnit","G4ThreeVector"); 119 ID = "TED"; 141 ID = "TED"; 120 (*store)[ID] = G4AttDef(ID, "Total Energy << 142 (*store)[ID] = G4AttDef(ID,"Total Energy Deposit", >> 143 "Physics","G4BestUnit","G4double"); 121 ID = "RE"; 144 ID = "RE"; 122 (*store)[ID] = G4AttDef(ID, "Remaining Ene << 145 (*store)[ID] = G4AttDef(ID,"Remaining Energy", >> 146 "Physics","G4BestUnit","G4double"); 123 ID = "PDS"; 147 ID = "PDS"; 124 (*store)[ID] = G4AttDef(ID, "Process Defin << 148 (*store)[ID] = G4AttDef(ID,"Process Defined Step", >> 149 "Physics","","G4String"); 125 ID = "PTDS"; 150 ID = "PTDS"; 126 (*store)[ID] = G4AttDef(ID, "Process Type << 151 (*store)[ID] = G4AttDef(ID,"Process Type Defined Step", >> 152 "Physics","","G4String"); 127 ID = "PreStatus"; 153 ID = "PreStatus"; 128 (*store)[ID] = G4AttDef(ID, "Pre-step-poin << 154 (*store)[ID] = G4AttDef(ID,"Pre-step-point status", >> 155 "Physics","","G4String"); 129 ID = "PostStatus"; 156 ID = "PostStatus"; 130 (*store)[ID] = G4AttDef(ID, "Post-step-poi << 157 (*store)[ID] = G4AttDef(ID,"Post-step-point status", >> 158 "Physics","","G4String"); 131 ID = "PreT"; 159 ID = "PreT"; 132 (*store)[ID] = G4AttDef(ID, "Pre-step-poin << 160 (*store)[ID] = G4AttDef(ID,"Pre-step-point global time", >> 161 "Physics","G4BestUnit","G4double"); 133 ID = "PostT"; 162 ID = "PostT"; 134 (*store)[ID] = G4AttDef(ID, "Post-step-poi << 163 (*store)[ID] = G4AttDef(ID,"Post-step-point global time", >> 164 "Physics","G4BestUnit","G4double"); 135 ID = "PreVPath"; 165 ID = "PreVPath"; 136 (*store)[ID] = G4AttDef(ID, "Pre-step Volu << 166 (*store)[ID] = G4AttDef(ID,"Pre-step Volume Path", >> 167 "Physics","","G4String"); 137 ID = "PostVPath"; 168 ID = "PostVPath"; 138 (*store)[ID] = G4AttDef(ID, "Post-step Vol << 169 (*store)[ID] = G4AttDef(ID,"Post-step Volume Path", >> 170 "Physics","","G4String"); 139 ID = "PreW"; 171 ID = "PreW"; 140 (*store)[ID] = G4AttDef(ID, "Pre-step-poin << 172 (*store)[ID] = G4AttDef(ID,"Pre-step-point weight", >> 173 "Physics","","G4double"); 141 ID = "PostW"; 174 ID = "PostW"; 142 (*store)[ID] = G4AttDef(ID, "Post-step-poi << 175 (*store)[ID] = G4AttDef(ID,"Post-step-point weight", >> 176 "Physics","","G4double"); 143 } 177 } 144 return store; 178 return store; 145 } 179 } 146 180 147 static G4String Status(G4StepStatus stps) 181 static G4String Status(G4StepStatus stps) 148 { 182 { 149 G4String status; 183 G4String status; 150 switch (stps) { << 184 switch (stps) 151 case fWorldBoundary: << 185 { 152 status = "fWorldBoundary"; << 186 case fWorldBoundary: status = "fWorldBoundary"; break; 153 break; << 187 case fGeomBoundary: status = "fGeomBoundary"; break; 154 case fGeomBoundary: << 188 case fAtRestDoItProc: status = "fAtRestDoItProc"; break; 155 status = "fGeomBoundary"; << 189 case fAlongStepDoItProc: status = "fAlongStepDoItProc"; break; 156 break; << 190 case fPostStepDoItProc: status = "fPostStepDoItProc"; break; 157 case fAtRestDoItProc: << 191 case fUserDefinedLimit: status = "fUserDefinedLimit"; break; 158 status = "fAtRestDoItProc"; << 192 case fExclusivelyForcedProc: status = "fExclusivelyForcedProc"; break; 159 break; << 193 case fUndefined: status = "fUndefined"; break; 160 case fAlongStepDoItProc: << 194 default: status = "Not recognised"; break; 161 status = "fAlongStepDoItProc"; << 162 break; << 163 case fPostStepDoItProc: << 164 status = "fPostStepDoItProc"; << 165 break; << 166 case fUserDefinedLimit: << 167 status = "fUserDefinedLimit"; << 168 break; << 169 case fExclusivelyForcedProc: << 170 status = "fExclusivelyForcedProc"; << 171 break; << 172 case fUndefined: << 173 status = "fUndefined"; << 174 break; << 175 default: << 176 status = "Not recognised"; << 177 break; << 178 } 195 } 179 return status; 196 return status; 180 } 197 } 181 198 182 static G4String Path(const G4TouchableHandle& 199 static G4String Path(const G4TouchableHandle& th) 183 { 200 { 184 std::ostringstream oss; 201 std::ostringstream oss; 185 G4int depth = th->GetHistoryDepth(); 202 G4int depth = th->GetHistoryDepth(); 186 for (G4int i = depth; i >= 0; --i) { << 203 for (G4int i = depth; i >= 0; --i) 187 oss << th->GetVolume(i)->GetName() << ':' << 204 { >> 205 oss << th->GetVolume(i)->GetName() >> 206 << ':' << th->GetCopyNumber(i); 188 if (i != 0) oss << '/'; 207 if (i != 0) oss << '/'; 189 } 208 } 190 return oss.str(); 209 return oss.str(); 191 } 210 } 192 211 193 std::vector<G4AttValue>* G4RichTrajectoryPoint 212 std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const 194 { 213 { 195 // Create base class att values... 214 // Create base class att values... 196 215 197 auto values = new std::vector<G4AttValue>; << 216 std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues(); 198 values->push_back(G4AttValue("Pos", G4BestUn << 199 << 200 #ifdef G4ATTDEBUG << 201 G4cout << G4AttCheck(values, GetAttDefs()); << 202 #endif << 203 217 204 if (fpAuxiliaryPointVector != nullptr) { << 218 if (fpAuxiliaryPointVector != nullptr) 205 for (const auto& iAux : *fpAuxiliaryPointV << 219 { 206 values->push_back(G4AttValue("Aux", G4Be << 220 for (auto iAux = fpAuxiliaryPointVector->cbegin(); >> 221 iAux != fpAuxiliaryPointVector->cend(); ++iAux) >> 222 { >> 223 values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),"")); 207 } 224 } 208 } 225 } 209 226 210 values->push_back(G4AttValue("TED", G4BestUn << 227 values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),"")); 211 values->push_back(G4AttValue("RE", G4BestUni << 228 values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),"")); 212 229 213 if (fpProcess != nullptr) { << 230 if (fpProcess != nullptr) 214 values->push_back(G4AttValue("PDS", fpProc << 231 { 215 values->push_back( << 232 values->push_back 216 G4AttValue("PTDS", G4VProcess::GetProces << 233 (G4AttValue("PDS",fpProcess->GetProcessName(),"")); >> 234 values->push_back >> 235 (G4AttValue >> 236 ("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),"")); 217 } 237 } 218 else { << 238 else 219 values->push_back(G4AttValue("PDS", "None" << 239 { 220 values->push_back(G4AttValue("PTDS", "None << 240 values->push_back(G4AttValue("PDS","None","")); >> 241 values->push_back(G4AttValue("PTDS","None","")); 221 } 242 } 222 243 223 values->push_back(G4AttValue("PreStatus", St << 244 values->push_back >> 245 (G4AttValue("PreStatus",Status(fPreStepPointStatus),"")); 224 246 225 values->push_back(G4AttValue("PostStatus", S << 247 values->push_back >> 248 (G4AttValue("PostStatus",Status(fPostStepPointStatus),"")); 226 249 227 values->push_back(G4AttValue("PreT", G4BestU << 250 values->push_back >> 251 (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),"")); 228 252 229 values->push_back(G4AttValue("PostT", G4Best << 253 values->push_back >> 254 (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),"")); 230 255 231 if (fpPreStepPointVolume && (fpPreStepPointV << 256 if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume()) 232 values->push_back(G4AttValue("PreVPath", P << 257 { >> 258 values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),"")); 233 } 259 } 234 else { << 260 else 235 values->push_back(G4AttValue("PreVPath", " << 261 { >> 262 values->push_back(G4AttValue("PreVPath","None","")); 236 } 263 } 237 264 238 if (fpPostStepPointVolume && (fpPostStepPoin << 265 if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume()) 239 values->push_back(G4AttValue("PostVPath", << 266 { >> 267 values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),"")); 240 } 268 } 241 else { << 269 else 242 values->push_back(G4AttValue("PostVPath", << 270 { >> 271 values->push_back(G4AttValue("PostVPath","None","")); 243 } 272 } 244 273 245 std::ostringstream oss1; 274 std::ostringstream oss1; 246 oss1 << fPreStepPointWeight; 275 oss1 << fPreStepPointWeight; 247 values->push_back(G4AttValue("PreW", oss1.st << 276 values->push_back(G4AttValue("PreW",oss1.str(),"")); 248 277 249 std::ostringstream oss2; 278 std::ostringstream oss2; 250 oss2 << fPostStepPointWeight; 279 oss2 << fPostStepPointWeight; 251 values->push_back(G4AttValue("PostW", oss2.s << 280 values->push_back(G4AttValue("PostW",oss2.str(),"")); 252 281 253 #ifdef G4ATTDEBUG 282 #ifdef G4ATTDEBUG 254 G4cout << G4AttCheck(values, GetAttDefs()); << 283 G4cout << G4AttCheck(values,GetAttDefs()); 255 #endif 284 #endif 256 285 257 return values; 286 return values; 258 } 287 } 259 288