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 // G4RichTrajectory class implementation << 26 // >> 27 // $Id: G4RichTrajectory.cc,v 1.6 2006/10/16 13:43:43 allison Exp $ >> 28 // GEANT4 tag $Name: geant4-09-00 $ >> 29 // >> 30 // --------------------------------------------------------------- >> 31 // >> 32 // G4RichTrajectory.cc 27 // 33 // 28 // Contact: 34 // Contact: 29 // Questions and comments on G4Trajectory, o 35 // Questions and comments on G4Trajectory, 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 "G4RichTrajectory.hh" 46 #include "G4RichTrajectory.hh" 40 #include "G4ClonedRichTrajectory.hh" << 47 #include "G4RichTrajectoryPoint.hh" 41 << 42 #include "G4ParticleTable.hh" << 43 #include "G4AttDef.hh" << 44 #include "G4AttDefStore.hh" 48 #include "G4AttDefStore.hh" >> 49 #include "G4AttDef.hh" 45 #include "G4AttValue.hh" 50 #include "G4AttValue.hh" 46 #include "G4PhysicsModelCatalog.hh" << 47 #include "G4RichTrajectoryPoint.hh" << 48 #include "G4UIcommand.hh" << 49 #include "G4UnitsTable.hh" << 50 #include "G4VProcess.hh" 51 #include "G4VProcess.hh" 51 52 52 namespace { << 53 //#define G4ATTDEBUG 53 G4Mutex CloneRichTrajectoryMutex = G4MUTEX_IN << 54 } << 55 << 56 // #define G4ATTDEBUG << 57 #ifdef G4ATTDEBUG 54 #ifdef G4ATTDEBUG 58 # include "G4AttCheck.hh" << 55 #include "G4AttCheck.hh" 59 #endif 56 #endif 60 57 61 #include <sstream> << 58 G4Allocator<G4RichTrajectory> aRichTrajectoryAllocator; 62 59 63 G4Allocator<G4RichTrajectory>*& aRichTrajector << 60 G4RichTrajectory::G4RichTrajectory(): >> 61 fpRichPointsContainer(0), >> 62 fpInitialVolume(0), >> 63 fpInitialNextVolume(0), >> 64 fpCreatorProcess(0) >> 65 {} >> 66 >> 67 G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack): >> 68 G4Trajectory(aTrack) // Note: this initialises the base class data >> 69 // members and, unfortunately but never mind, >> 70 // creates a G4TrajectoryPoint in >> 71 // TrajectoryPointContainer that we cannot >> 72 // access because it's private. We store the >> 73 // same information (plus more) in a >> 74 // G4RichTrajectoryPoint in the >> 75 // RichTrajectoryPointsContainer 64 { 76 { 65 G4ThreadLocalStatic G4Allocator<G4RichTrajec << 77 fpInitialVolume = aTrack->GetVolume(); 66 return _instance; << 78 fpInitialNextVolume = aTrack->GetNextVolume(); 67 } << 68 << 69 G4RichTrajectory::G4RichTrajectory(const G4Tra << 70 { << 71 G4ParticleDefinition* fpParticleDefinition = << 72 ParticleName = fpParticleDefinition->GetPart << 73 PDGCharge = fpParticleDefinition->GetPDGChar << 74 PDGEncoding = fpParticleDefinition->GetPDGEn << 75 fTrackID = aTrack->GetTrackID(); << 76 fParentID = aTrack->GetParentID(); << 77 initialKineticEnergy = aTrack->GetKineticEne << 78 initialMomentum = aTrack->GetMomentum(); << 79 positionRecord = new G4TrajectoryPointContai << 80 << 81 // Following is for the first trajectory poi << 82 positionRecord->push_back(new G4RichTrajecto << 83 << 84 fpInitialVolume = aTrack->GetTouchableHandle << 85 fpInitialNextVolume = aTrack->GetNextTouchab << 86 fpCreatorProcess = aTrack->GetCreatorProcess 79 fpCreatorProcess = aTrack->GetCreatorProcess(); 87 fCreatorModelID = aTrack->GetCreatorModelID( << 80 fpRichPointsContainer = new RichTrajectoryPointsContainer; 88 << 89 // On construction, set final values to init << 90 // Final values are updated at the addition << 91 // << 92 fpFinalVolume = aTrack->GetTouchableHandle() << 93 fpFinalNextVolume = aTrack->GetNextTouchable << 94 fpEndingProcess = aTrack->GetCreatorProcess( << 95 fFinalKineticEnergy = aTrack->GetKineticEner << 96 << 97 // Insert the first rich trajectory point (s 81 // Insert the first rich trajectory point (see note above)... 98 // << 82 fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack)); 99 fpRichPointContainer = new G4TrajectoryPoint << 100 fpRichPointContainer->push_back(new G4RichTr << 101 } 83 } 102 84 103 G4RichTrajectory::G4RichTrajectory(G4RichTraje << 85 G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right): >> 86 G4Trajectory(right) 104 { 87 { 105 ParticleName = right.ParticleName; << 106 PDGCharge = right.PDGCharge; << 107 PDGEncoding = right.PDGEncoding; << 108 fTrackID = right.fTrackID; << 109 fParentID = right.fParentID; << 110 initialKineticEnergy = right.initialKineticE << 111 initialMomentum = right.initialMomentum; << 112 positionRecord = new G4TrajectoryPointContai << 113 << 114 for (auto& i : *right.positionRecord) { << 115 auto rightPoint = (G4RichTrajectoryPoint*) << 116 positionRecord->push_back(new G4RichTrajec << 117 } << 118 << 119 fpInitialVolume = right.fpInitialVolume; 88 fpInitialVolume = right.fpInitialVolume; 120 fpInitialNextVolume = right.fpInitialNextVol 89 fpInitialNextVolume = right.fpInitialNextVolume; 121 fpCreatorProcess = right.fpCreatorProcess; 90 fpCreatorProcess = right.fpCreatorProcess; 122 fCreatorModelID = right.fCreatorModelID; << 91 fpRichPointsContainer = new RichTrajectoryPointsContainer; 123 fpFinalVolume = right.fpFinalVolume; << 92 for(size_t i=0;i<right.fpRichPointsContainer->size();i++) 124 fpFinalNextVolume = right.fpFinalNextVolume; << 93 { 125 fpEndingProcess = right.fpEndingProcess; << 94 G4RichTrajectoryPoint* rightPoint = 126 fFinalKineticEnergy = right.fFinalKineticEne << 95 (G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]); 127 fpRichPointContainer = new G4TrajectoryPoint << 96 fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint)); 128 for (auto& i : *right.fpRichPointContainer) << 129 auto rightPoint = (G4RichTrajectoryPoint*) << 130 fpRichPointContainer->push_back(new G4Rich << 131 } 97 } 132 } 98 } 133 99 134 G4RichTrajectory::~G4RichTrajectory() 100 G4RichTrajectory::~G4RichTrajectory() 135 { 101 { 136 if (fpRichPointContainer != nullptr) { << 102 if (fpRichPointsContainer) { 137 for (auto& i : *fpRichPointContainer) { << 103 // fpRichPointsContainer->clearAndDestroy(); 138 delete i; << 104 size_t i; >> 105 for(i=0;i<fpRichPointsContainer->size();i++){ >> 106 delete (*fpRichPointsContainer)[i]; 139 } 107 } 140 fpRichPointContainer->clear(); << 108 fpRichPointsContainer->clear(); 141 delete fpRichPointContainer; << 109 delete fpRichPointsContainer; 142 } 110 } 143 } 111 } 144 112 145 void G4RichTrajectory::AppendStep(const G4Step 113 void G4RichTrajectory::AppendStep(const G4Step* aStep) 146 { 114 { 147 fpRichPointContainer->push_back(new G4RichTr << 115 fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep)); 148 << 149 // Except for first step, which is a sort of << 150 // the track, compute the final values... << 151 // << 152 const G4Track* track = aStep->GetTrack(); << 153 const G4StepPoint* postStepPoint = aStep->Ge << 154 if (track->GetCurrentStepNumber() > 0) { << 155 fpFinalVolume = track->GetTouchableHandle( << 156 fpFinalNextVolume = track->GetNextTouchabl << 157 fpEndingProcess = postStepPoint->GetProces << 158 fFinalKineticEnergy = << 159 aStep->GetPreStepPoint()->GetKineticEner << 160 } << 161 } 116 } 162 << 117 163 void G4RichTrajectory::MergeTrajectory(G4VTraj 118 void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) 164 { 119 { 165 if (secondTrajectory == nullptr) return; << 120 if(!secondTrajectory) return; >> 121 >> 122 G4Trajectory::MergeTrajectory(secondTrajectory); 166 123 167 auto seco = (G4RichTrajectory*)secondTraject << 124 G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory; 168 G4int ent = seco->GetPointEntries(); 125 G4int ent = seco->GetPointEntries(); 169 for (G4int i = 1; i < ent; ++i) { << 126 for(G4int i=1;i<ent;i++) { 170 // initial point of the second trajectory 127 // initial point of the second trajectory should not be merged 171 // << 128 fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]); 172 fpRichPointContainer->push_back((*(seco->f << 129 // fpRichPointsContainer->push_back(seco->fpRichPointsContainer->removeAt(1)); 173 } 130 } 174 delete (*seco->fpRichPointContainer)[0]; << 131 delete (*seco->fpRichPointsContainer)[0]; 175 seco->fpRichPointContainer->clear(); << 132 seco->fpRichPointsContainer->clear(); 176 } << 177 << 178 void G4RichTrajectory::ShowTrajectory(std::ost << 179 { << 180 // Invoke the default implementation in G4VT << 181 // << 182 G4VTrajectory::ShowTrajectory(os); << 183 << 184 // ... or override with your own code here. << 185 } 133 } 186 134 187 void G4RichTrajectory::DrawTrajectory() const << 135 const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const 188 { << 189 // Invoke the default implementation in G4VT << 190 // << 191 G4VTrajectory::DrawTrajectory(); << 192 << 193 // ... or override with your own code here. << 194 } << 195 << 196 const std::map<G4String, G4AttDef>* G4RichTraj << 197 { 136 { 198 G4bool isNew; 137 G4bool isNew; 199 std::map<G4String, G4AttDef>* store = G4AttD << 138 std::map<G4String,G4AttDef>* store >> 139 = G4AttDefStore::GetInstance("G4RichTrajectory",isNew); 200 if (isNew) { 140 if (isNew) { 201 G4String ID; << 202 << 203 ID = "ID"; << 204 (*store)[ID] = G4AttDef(ID, "Track ID", "P << 205 << 206 ID = "PID"; << 207 (*store)[ID] = G4AttDef(ID, "Parent ID", " << 208 << 209 ID = "PN"; << 210 (*store)[ID] = G4AttDef(ID, "Particle Name << 211 << 212 ID = "Ch"; << 213 (*store)[ID] = G4AttDef(ID, "Charge", "Phy << 214 141 215 ID = "PDG"; << 142 // Get att defs from base class... 216 (*store)[ID] = G4AttDef(ID, "PDG Encoding" << 143 *store = *(G4Trajectory::GetAttDefs()); 217 144 218 ID = "IKE"; << 145 G4String ID; 219 (*store)[ID] = G4AttDef(ID, "Initial kinet << 220 << 221 ID = "IMom"; << 222 (*store)[ID] = G4AttDef(ID, "Initial momen << 223 << 224 ID = "IMag"; << 225 (*store)[ID] = G4AttDef(ID, "Initial momen << 226 << 227 ID = "NTP"; << 228 (*store)[ID] = G4AttDef(ID, "No. of points << 229 << 230 ID = "IVPath"; << 231 (*store)[ID] = G4AttDef(ID, "Initial Volum << 232 146 233 ID = "INVPath"; << 147 ID = "IVN"; 234 (*store)[ID] = G4AttDef(ID, "Initial Next << 148 (*store)[ID] = G4AttDef(ID,"Initial Volume Name", >> 149 "Physics","","G4String"); >> 150 >> 151 ID = "INVN"; >> 152 (*store)[ID] = G4AttDef(ID,"Initial Next Volume Name", >> 153 "Physics","","G4String"); 235 154 236 ID = "CPN"; 155 ID = "CPN"; 237 (*store)[ID] = G4AttDef(ID, "Creator Proce << 156 (*store)[ID] = G4AttDef(ID,"Creator Process Name", >> 157 "Physics","","G4String"); 238 158 239 ID = "CPTN"; 159 ID = "CPTN"; 240 (*store)[ID] = G4AttDef(ID, "Creator Proce << 160 (*store)[ID] = G4AttDef(ID,"Creator Process Type Name", 241 << 161 "Physics","","G4String"); 242 ID = "CMID"; << 243 (*store)[ID] = G4AttDef(ID, "Creator Model << 244 << 245 ID = "CMN"; << 246 (*store)[ID] = G4AttDef(ID, "Creator Model << 247 << 248 ID = "FVPath"; << 249 (*store)[ID] = G4AttDef(ID, "Final Volume << 250 << 251 ID = "FNVPath"; << 252 (*store)[ID] = G4AttDef(ID, "Final Next Vo << 253 << 254 ID = "EPN"; << 255 (*store)[ID] = G4AttDef(ID, "Ending Proces << 256 162 257 ID = "EPTN"; << 258 (*store)[ID] = G4AttDef(ID, "Ending Proces << 259 << 260 ID = "FKE"; << 261 (*store)[ID] = G4AttDef(ID, "Final kinetic << 262 } 163 } 263 164 264 return store; 165 return store; 265 } 166 } 266 167 267 static G4String Path(const G4TouchableHandle& << 268 { << 269 std::ostringstream oss; << 270 G4int depth = th->GetHistoryDepth(); << 271 for (G4int i = depth; i >= 0; --i) { << 272 oss << th->GetVolume(i)->GetName() << ':' << 273 if (i != 0) oss << '/'; << 274 } << 275 return oss.str(); << 276 } << 277 << 278 std::vector<G4AttValue>* G4RichTrajectory::Cre 168 std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const 279 { 169 { 280 // Create base class att values... 170 // Create base class att values... 281 //std::vector<G4AttValue>* values = G4VTraje << 171 std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues(); 282 auto values = new std::vector<G4AttValue>; << 283 values->push_back(G4AttValue("ID", G4UIcomma << 284 values->push_back(G4AttValue("PID", G4UIcomm << 285 values->push_back(G4AttValue("PN", ParticleN << 286 values->push_back(G4AttValue("Ch", G4UIcomma << 287 values->push_back(G4AttValue("PDG", G4UIcomm << 288 values->push_back(G4AttValue("IKE", G4BestUn << 289 values->push_back(G4AttValue("IMom", G4BestU << 290 values->push_back(G4AttValue("IMag", G4BestU << 291 values->push_back(G4AttValue("NTP", G4UIcomm << 292 172 293 if (fpInitialVolume && (fpInitialVolume->Get << 173 values->push_back(G4AttValue("IVN",fpInitialVolume->GetName(),"")); 294 values->push_back(G4AttValue("IVPath", Pat << 295 } << 296 else { << 297 values->push_back(G4AttValue("IVPath", "No << 298 } << 299 174 300 if (fpInitialNextVolume && (fpInitialNextVol << 175 values->push_back(G4AttValue("INVN",fpInitialNextVolume->GetName(),"")); 301 values->push_back(G4AttValue("INVPath", Pa << 302 } << 303 else { << 304 values->push_back(G4AttValue("INVPath", "N << 305 } << 306 176 307 if (fpCreatorProcess != nullptr) { << 177 if (fpCreatorProcess) { 308 values->push_back(G4AttValue("CPN", fpCrea << 178 values->push_back(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),"")); 309 G4ProcessType type = fpCreatorProcess->Get 179 G4ProcessType type = fpCreatorProcess->GetProcessType(); 310 values->push_back(G4AttValue("CPTN", G4VPr << 180 values->push_back(G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),"")); 311 values->push_back(G4AttValue("CMID", G4UIc << 181 } else { 312 const G4String& creatorModelName = G4Physi << 182 values->push_back(G4AttValue("CPN","User Defined","")); 313 values->push_back(G4AttValue("CMN", creato << 183 values->push_back(G4AttValue("CPTN","User","")); 314 } 184 } 315 else { << 316 values->push_back(G4AttValue("CPN", "None" << 317 values->push_back(G4AttValue("CPTN", "None << 318 values->push_back(G4AttValue("CMID", "None << 319 values->push_back(G4AttValue("CMN", "None" << 320 } << 321 << 322 if (fpFinalVolume && (fpFinalVolume->GetVolu << 323 values->push_back(G4AttValue("FVPath", Pat << 324 } << 325 else { << 326 values->push_back(G4AttValue("FVPath", "No << 327 } << 328 << 329 if (fpFinalNextVolume && (fpFinalNextVolume- << 330 values->push_back(G4AttValue("FNVPath", Pa << 331 } << 332 else { << 333 values->push_back(G4AttValue("FNVPath", "N << 334 } << 335 << 336 if (fpEndingProcess != nullptr) { << 337 values->push_back(G4AttValue("EPN", fpEndi << 338 G4ProcessType type = fpEndingProcess->GetP << 339 values->push_back(G4AttValue("EPTN", G4VPr << 340 } << 341 else { << 342 values->push_back(G4AttValue("EPN", "None" << 343 values->push_back(G4AttValue("EPTN", "None << 344 } << 345 << 346 values->push_back(G4AttValue("FKE", G4BestUn << 347 185 348 #ifdef G4ATTDEBUG 186 #ifdef G4ATTDEBUG 349 G4cout << G4AttCheck(values, GetAttDefs()); << 187 G4cout << G4AttCheck(values,GetAttDefs()); 350 #endif 188 #endif 351 189 352 return values; 190 return values; 353 } 191 } 354 << 355 G4ParticleDefinition* G4RichTrajectory::GetPar << 356 { << 357 return (G4ParticleTable::GetParticleTable()- << 358 } << 359 << 360 G4VTrajectory* G4RichTrajectory::CloneForMaste << 361 { << 362 G4AutoLock lock(&CloneRichTrajectoryMutex); << 363 auto* cloned = new G4ClonedRichTrajectory(*t << 364 return cloned; << 365 } << 366 << 367 192