[827] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[1293] | 27 | // $Id: G4RichTrajectoryPoint.cc,v 1.6 2010/02/22 21:26:56 allison Exp $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[827] | 29 | // |
---|
| 30 | // |
---|
| 31 | // --------------------------------------------------------------- |
---|
| 32 | // |
---|
| 33 | // G4RichTrajectoryPoint.cc |
---|
| 34 | // |
---|
| 35 | // Contact: |
---|
| 36 | // Questions and comments on G4TrajectoryPoint, on which this is based, |
---|
| 37 | // should be sent to |
---|
| 38 | // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) |
---|
| 39 | // Makoto Asai (e-mail: asai@kekvax.kek.jp) |
---|
| 40 | // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) |
---|
| 41 | // and on the extended code to: |
---|
| 42 | // John Allison (e-mail: John.Allison@manchester.ac.uk) |
---|
| 43 | // Joseph Perl (e-mail: perl@slac.stanford.edu) |
---|
| 44 | // |
---|
| 45 | // --------------------------------------------------------------- |
---|
| 46 | |
---|
| 47 | #include "G4RichTrajectoryPoint.hh" |
---|
| 48 | |
---|
| 49 | #include "G4Track.hh" |
---|
| 50 | #include "G4Step.hh" |
---|
| 51 | #include "G4VProcess.hh" |
---|
| 52 | |
---|
| 53 | #include "G4AttDefStore.hh" |
---|
| 54 | #include "G4AttDef.hh" |
---|
| 55 | #include "G4AttValue.hh" |
---|
| 56 | #include "G4UnitsTable.hh" |
---|
| 57 | |
---|
| 58 | //#define G4ATTDEBUG |
---|
| 59 | #ifdef G4ATTDEBUG |
---|
| 60 | #include "G4AttCheck.hh" |
---|
| 61 | #endif |
---|
| 62 | |
---|
[1228] | 63 | #include <sstream> |
---|
| 64 | |
---|
[827] | 65 | G4Allocator<G4RichTrajectoryPoint> aRichTrajectoryPointAllocator; |
---|
| 66 | |
---|
| 67 | G4RichTrajectoryPoint::G4RichTrajectoryPoint(): |
---|
| 68 | fpAuxiliaryPointVector(0), |
---|
| 69 | fTotEDep(0.), |
---|
[1196] | 70 | fRemainingEnergy(0.), |
---|
[827] | 71 | fpProcess(0), |
---|
| 72 | fPreStepPointGlobalTime(0), |
---|
| 73 | fPostStepPointGlobalTime(0) |
---|
| 74 | {} |
---|
| 75 | |
---|
| 76 | G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack): |
---|
| 77 | G4TrajectoryPoint(aTrack->GetPosition()), |
---|
| 78 | fpAuxiliaryPointVector(0), |
---|
| 79 | fTotEDep(0.), |
---|
[1196] | 80 | fRemainingEnergy(aTrack->GetKineticEnergy()), |
---|
[827] | 81 | fpProcess(0), |
---|
| 82 | fPreStepPointGlobalTime(aTrack->GetGlobalTime()), |
---|
[1228] | 83 | fPostStepPointGlobalTime(aTrack->GetGlobalTime()), |
---|
| 84 | fpPreStepPointVolume(aTrack->GetTouchableHandle()), |
---|
| 85 | fpPostStepPointVolume(aTrack->GetNextTouchableHandle()) |
---|
[827] | 86 | {} |
---|
| 87 | |
---|
| 88 | G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep): |
---|
| 89 | G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()), |
---|
| 90 | fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()), |
---|
| 91 | fTotEDep(aStep->GetTotalEnergyDeposit()) |
---|
| 92 | { |
---|
| 93 | G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); |
---|
| 94 | G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); |
---|
[1196] | 95 | if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) { // First step |
---|
| 96 | fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy(); |
---|
| 97 | } else { |
---|
| 98 | fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep; |
---|
| 99 | } |
---|
[827] | 100 | fpProcess = postStepPoint->GetProcessDefinedStep(); |
---|
| 101 | fPreStepPointGlobalTime = preStepPoint->GetGlobalTime(); |
---|
| 102 | fPostStepPointGlobalTime = postStepPoint->GetGlobalTime(); |
---|
[1228] | 103 | fpPreStepPointVolume = preStepPoint->GetTouchableHandle(); |
---|
| 104 | fpPostStepPointVolume = postStepPoint->GetTouchableHandle(); |
---|
[827] | 105 | |
---|
| 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 | */ |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | G4RichTrajectoryPoint::G4RichTrajectoryPoint |
---|
| 135 | (const G4RichTrajectoryPoint &right): |
---|
| 136 | G4TrajectoryPoint(right), |
---|
| 137 | fpAuxiliaryPointVector(right.fpAuxiliaryPointVector), |
---|
| 138 | fTotEDep(right.fTotEDep), |
---|
[1196] | 139 | fRemainingEnergy(right.fRemainingEnergy), |
---|
[827] | 140 | fpProcess(right.fpProcess), |
---|
| 141 | fPreStepPointGlobalTime(right.fPreStepPointGlobalTime), |
---|
| 142 | fPostStepPointGlobalTime(right.fPostStepPointGlobalTime) |
---|
| 143 | {} |
---|
| 144 | |
---|
| 145 | G4RichTrajectoryPoint::~G4RichTrajectoryPoint() |
---|
| 146 | { |
---|
| 147 | if(fpAuxiliaryPointVector) { |
---|
| 148 | /* |
---|
| 149 | G4cout << "Deleting fpAuxiliaryPointVector at " |
---|
| 150 | << (void*) fpAuxiliaryPointVector |
---|
| 151 | << G4endl; |
---|
| 152 | */ |
---|
| 153 | delete fpAuxiliaryPointVector; |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | const std::map<G4String,G4AttDef>* |
---|
| 158 | G4RichTrajectoryPoint::GetAttDefs() const |
---|
| 159 | { |
---|
| 160 | G4bool isNew; |
---|
| 161 | std::map<G4String,G4AttDef>* store |
---|
| 162 | = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew); |
---|
| 163 | if (isNew) { |
---|
| 164 | |
---|
| 165 | // Copy base class att defs... |
---|
| 166 | *store = *(G4TrajectoryPoint::GetAttDefs()); |
---|
| 167 | |
---|
| 168 | G4String ID; |
---|
| 169 | |
---|
| 170 | ID = "Aux"; |
---|
| 171 | (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position", |
---|
| 172 | "Physics","G4BestUnit","G4ThreeVector"); |
---|
| 173 | ID = "TED"; |
---|
| 174 | (*store)[ID] = G4AttDef(ID,"Total Energy Deposit", |
---|
| 175 | "Physics","G4BestUnit","G4double"); |
---|
[1196] | 176 | ID = "RE"; |
---|
| 177 | (*store)[ID] = G4AttDef(ID,"Remaining Energy", |
---|
| 178 | "Physics","G4BestUnit","G4double"); |
---|
[827] | 179 | ID = "PDS"; |
---|
| 180 | (*store)[ID] = G4AttDef(ID,"Process Defined Step", |
---|
| 181 | "Physics","","G4String"); |
---|
| 182 | ID = "PTDS"; |
---|
| 183 | (*store)[ID] = G4AttDef(ID,"Process Type Defined Step", |
---|
| 184 | "Physics","","G4String"); |
---|
| 185 | ID = "PreT"; |
---|
| 186 | (*store)[ID] = G4AttDef(ID,"Pre-step-point global time", |
---|
| 187 | "Physics","G4BestUnit","G4double"); |
---|
| 188 | ID = "PostT"; |
---|
| 189 | (*store)[ID] = G4AttDef(ID,"Post-step-point global time", |
---|
| 190 | "Physics","G4BestUnit","G4double"); |
---|
[1228] | 191 | ID = "PreVPath"; |
---|
| 192 | (*store)[ID] = G4AttDef(ID,"Pre-step Volume Path", |
---|
| 193 | "Physics","","G4String"); |
---|
| 194 | ID = "PostVPath"; |
---|
| 195 | (*store)[ID] = G4AttDef(ID,"Post-step Volume Path", |
---|
| 196 | "Physics","","G4String"); |
---|
[827] | 197 | } |
---|
| 198 | return store; |
---|
| 199 | } |
---|
| 200 | |
---|
[1228] | 201 | static G4String Path(const G4TouchableHandle& th) |
---|
| 202 | { |
---|
| 203 | std::ostringstream oss; |
---|
| 204 | G4int depth = th->GetHistoryDepth(); |
---|
| 205 | for (G4int i = depth; i >= 0; --i) { |
---|
| 206 | oss << th->GetVolume(i)->GetName() |
---|
| 207 | << ':' << th->GetCopyNumber(i); |
---|
| 208 | if (i != 0) oss << '/'; |
---|
| 209 | } |
---|
| 210 | return oss.str(); |
---|
| 211 | } |
---|
| 212 | |
---|
[827] | 213 | std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const |
---|
| 214 | { |
---|
| 215 | // Create base class att values... |
---|
| 216 | std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues(); |
---|
| 217 | |
---|
| 218 | if (fpAuxiliaryPointVector) { |
---|
| 219 | std::vector<G4ThreeVector>::iterator iAux; |
---|
| 220 | for (iAux = fpAuxiliaryPointVector->begin(); |
---|
| 221 | iAux != fpAuxiliaryPointVector->end(); ++iAux) { |
---|
| 222 | values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),"")); |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),"")); |
---|
| 227 | |
---|
[1196] | 228 | values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),"")); |
---|
| 229 | |
---|
[827] | 230 | if (fpProcess) { |
---|
| 231 | values->push_back |
---|
| 232 | (G4AttValue("PDS",fpProcess->GetProcessName(),"")); |
---|
| 233 | values->push_back |
---|
| 234 | (G4AttValue |
---|
| 235 | ("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()), |
---|
| 236 | "")); |
---|
| 237 | } else { |
---|
[1293] | 238 | values->push_back(G4AttValue("PDS","None","")); |
---|
| 239 | values->push_back(G4AttValue("PTDS","None","")); |
---|
[827] | 240 | } |
---|
| 241 | |
---|
| 242 | values->push_back |
---|
| 243 | (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),"")); |
---|
| 244 | |
---|
| 245 | values->push_back |
---|
| 246 | (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),"")); |
---|
| 247 | |
---|
[1228] | 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","")); |
---|
| 258 | } |
---|
| 259 | |
---|
[827] | 260 | #ifdef G4ATTDEBUG |
---|
| 261 | G4cout << G4AttCheck(values,GetAttDefs()); |
---|
| 262 | #endif |
---|
| 263 | |
---|
| 264 | return values; |
---|
| 265 | } |
---|