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