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