Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file radiobiology/src/SD.cc 28 /// \brief Implementation of the RadioBio::SD 29 30 #include "SD.hh" 31 32 #include "G4AccumulableManager.hh" 33 #include "G4HCofThisEvent.hh" 34 #include "G4SDManager.hh" 35 #include "G4Step.hh" 36 #include "G4ThreeVector.hh" 37 38 #include "Hit.hh" 39 #include "Manager.hh" 40 #include "VRadiobiologicalAccumulable.hh" 41 42 namespace RadioBio 43 { 44 45 //....oooOO0OOooo........oooOO0OOooo........oo 46 47 SD::SD(const G4String& name, const G4String& h 48 { 49 collectionName.insert(hitsCollectionName); 50 } 51 52 //....oooOO0OOooo........oooOO0OOooo........oo 53 54 void SD::Initialize(G4HCofThisEvent* hce) 55 { 56 // Create hits collection 57 fHitsCollection = new RadioBioHitsCollection 58 59 // Add this collection in hce 60 G4int hcID = G4SDManager::GetSDMpointer()->G 61 hce->AddHitsCollection(hcID, fHitsCollection 62 } 63 64 //....oooOO0OOooo........oooOO0OOooo........oo 65 66 G4bool SD::ProcessHits(G4Step* aStep, G4Toucha 67 { 68 // FIXME why the namespace specification? Sh 69 RadioBio::Hit* newHit = new RadioBio::Hit(); 70 71 // Get the pre-step kinetic energy 72 G4double eKinPre = aStep->GetPreStepPoint()- 73 // Get the post-step kinetic energy 74 G4double eKinPost = aStep->GetPostStepPoint( 75 // Get the step average kinetic energy 76 G4double eKinMean = (eKinPre + eKinPost) * 0 77 78 const std::vector<const G4Track*>* secondary 79 80 size_t SecondarySize = (*secondary).size(); 81 G4double EnergySecondary = 0.; 82 83 // Get secondary electrons energy deposited 84 if (SecondarySize) // Calculate only second 85 { 86 for (size_t numsec = 0; numsec < Secondary 87 // Get the PDG code of every secondaty p 88 G4int PDGSecondary = (*secondary)[numsec 89 90 if (PDGSecondary == 11) // Calculate on 91 { 92 // Calculate the energy deposit of sec 93 EnergySecondary += (*secondary)[numsec 94 } 95 } 96 } 97 98 // Update the hit with the necessary quantit 99 newHit->SetTrackID(aStep->GetTrack()->GetTra 100 newHit->SetPartType(aStep->GetTrack()->GetPa 101 newHit->SetEkinMean(eKinMean); 102 newHit->SetDeltaE(aStep->GetTotalEnergyDepos 103 newHit->SetEinit(aStep->GetPreStepPoint()->G 104 newHit->SetTrackLength(aStep->GetStepLength( 105 newHit->SetElectronEnergy(EnergySecondary); 106 newHit->SetPhysicalVolume(aStep->GetPreStepP 107 newHit->SetVoxelIndexes(aStep->GetPreStepPoi 108 109 // Insert the hit in the hitcollection 110 fHitsCollection->insert(newHit); 111 112 // Accumulables are accumulated only if calc 113 for (G4int i = 0; i < G4AccumulableManager:: 114 // Get the accumulable from the proper man 115 G4VAccumulable* GenAcc = G4AccumulableMana 116 117 // Get the quantity from the proper manage 118 auto q = Manager::GetInstance()->GetQuanti 119 120 VRadiobiologicalAccumulable* radioAcc = dy 121 122 // If the dynamic_cast did not work, this 123 // was not a VRadiobiologicalAccumulable 124 if (radioAcc == nullptr) continue; 125 126 // If calculation is enabled, accumulate 127 if (q->IsCalculationEnabled()) radioAcc->A 128 } 129 130 return true; 131 } 132 133 //....oooOO0OOooo........oooOO0OOooo........oo 134 135 void SD::EndOfEvent(G4HCofThisEvent*) 136 { 137 if (verboseLevel > 1) { 138 G4int nofHits = fHitsCollection->entries() 139 G4cout << G4endl << "-------->Hits Collect 140 << " hits in the detector slices: " 141 for (G4int i = 0; i < nofHits; i++) 142 (*fHitsCollection)[i]->Print(); 143 } 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oo 147 148 } // namespace RadioBio