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 /// \file Par01/src/Par01EMShowerModel.cc 26 /// \file Par01/src/Par01EMShowerModel.cc 27 /// \brief Implementation of the Par01EMShower 27 /// \brief Implementation of the Par01EMShowerModel class 28 // 28 // 29 // 29 // 30 // 30 // 31 #include "Par01EMShowerModel.hh" 31 #include "Par01EMShowerModel.hh" 32 << 33 #include "Par01EnergySpot.hh" 32 #include "Par01EnergySpot.hh" 34 33 >> 34 #include "Randomize.hh" >> 35 35 #include "G4Electron.hh" 36 #include "G4Electron.hh" 36 #include "G4Gamma.hh" << 37 #include "G4NistManager.hh" << 38 #include "G4PhysicalConstants.hh" << 39 #include "G4Positron.hh" 37 #include "G4Positron.hh" 40 #include "G4SystemOfUnits.hh" << 38 #include "G4Gamma.hh" 41 #include "G4TouchableHandle.hh" << 42 #include "G4TransportationManager.hh" 39 #include "G4TransportationManager.hh" 43 #include "G4VSensitiveDetector.hh" 40 #include "G4VSensitiveDetector.hh" 44 #include "Randomize.hh" << 41 #include "G4TouchableHandle.hh" >> 42 #include "G4PhysicalConstants.hh" >> 43 #include "G4SystemOfUnits.hh" >> 44 #include "G4NistManager.hh" 45 45 46 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 47 48 Par01EMShowerModel::Par01EMShowerModel(G4Strin 48 Par01EMShowerModel::Par01EMShowerModel(G4String modelName, G4Region* envelope) 49 : G4VFastSimulationModel(modelName, envelope << 49 : G4VFastSimulationModel(modelName, envelope) 50 { 50 { 51 fFakeStep = new G4Step(); << 51 fFakeStep = new G4Step(); 52 fFakePreStepPoint = fFakeStep->GetPreStepPoi << 52 fFakePreStepPoint = fFakeStep->GetPreStepPoint(); 53 fFakePostStepPoint = fFakeStep->GetPostStepP 53 fFakePostStepPoint = fFakeStep->GetPostStepPoint(); 54 fTouchableHandle = new G4TouchableHistory(); << 54 fTouchableHandle = new G4TouchableHistory(); 55 fpNavigator = new G4Navigator(); << 55 fpNavigator = new G4Navigator(); 56 fNaviSetup = false; << 56 fNaviSetup = false; 57 fCsI = nullptr; << 57 fCsI = 0; 58 } 58 } 59 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 61 62 Par01EMShowerModel::Par01EMShowerModel(G4Strin << 62 Par01EMShowerModel::Par01EMShowerModel(G4String modelName) >> 63 : G4VFastSimulationModel(modelName) 63 { 64 { 64 fFakeStep = new G4Step(); << 65 fFakeStep = new G4Step(); 65 fFakePreStepPoint = fFakeStep->GetPreStepPoi << 66 fFakePreStepPoint = fFakeStep->GetPreStepPoint(); 66 fFakePostStepPoint = fFakeStep->GetPostStepP 67 fFakePostStepPoint = fFakeStep->GetPostStepPoint(); 67 fTouchableHandle = new G4TouchableHistory(); << 68 fTouchableHandle = new G4TouchableHistory(); 68 fpNavigator = new G4Navigator(); << 69 fpNavigator = new G4Navigator(); 69 fNaviSetup = false; << 70 fNaviSetup = false; 70 fCsI = nullptr; << 71 fCsI = 0; 71 } 72 } 72 73 73 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 75 75 Par01EMShowerModel::~Par01EMShowerModel() 76 Par01EMShowerModel::~Par01EMShowerModel() 76 { 77 { 77 delete fFakeStep; 78 delete fFakeStep; 78 delete fpNavigator; 79 delete fpNavigator; 79 } 80 } 80 81 81 //....oooOO0OOooo........oooOO0OOooo........oo 82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 83 83 G4bool Par01EMShowerModel::IsApplicable(const 84 G4bool Par01EMShowerModel::IsApplicable(const G4ParticleDefinition& particleType) 84 { 85 { 85 return &particleType == G4Electron::Electron << 86 return 86 || &particleType == G4Positron::Posit << 87 &particleType == G4Electron::ElectronDefinition() || 87 || &particleType == G4Gamma::GammaDef << 88 &particleType == G4Positron::PositronDefinition() || >> 89 &particleType == G4Gamma::GammaDefinition(); 88 } 90 } 89 91 90 //....oooOO0OOooo........oooOO0OOooo........oo 92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 91 93 92 G4bool Par01EMShowerModel::ModelTrigger(const 94 G4bool Par01EMShowerModel::ModelTrigger(const G4FastTrack& fastTrack) 93 { 95 { 94 // Applies the parameterisation above 100 Me 96 // Applies the parameterisation above 100 MeV: 95 return fastTrack.GetPrimaryTrack()->GetKinet << 97 return fastTrack.GetPrimaryTrack()->GetKineticEnergy() > 100*MeV; 96 } 98 } 97 99 98 //....oooOO0OOooo........oooOO0OOooo........oo 100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 99 101 100 void Par01EMShowerModel::DoIt(const G4FastTrac << 102 void Par01EMShowerModel::DoIt(const G4FastTrack& fastTrack, >> 103 G4FastStep& fastStep) 101 { 104 { 102 // Kill the parameterised particle: 105 // Kill the parameterised particle: 103 fastStep.KillPrimaryTrack(); 106 fastStep.KillPrimaryTrack(); 104 fastStep.ProposePrimaryTrackPathLength(0.0); 107 fastStep.ProposePrimaryTrackPathLength(0.0); 105 fastStep.ProposeTotalEnergyDeposited(fastTra 108 fastStep.ProposeTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetKineticEnergy()); 106 109 107 // split into "energy spots" energy accordin 110 // split into "energy spots" energy according to the shower shape: 108 Explode(fastTrack); 111 Explode(fastTrack); 109 << 112 110 // and put those energy spots into the cryst 113 // and put those energy spots into the crystals: 111 BuildDetectorResponse(); 114 BuildDetectorResponse(); >> 115 112 } 116 } 113 117 114 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 115 119 116 void Par01EMShowerModel::Explode(const G4FastT 120 void Par01EMShowerModel::Explode(const G4FastTrack& fastTrack) 117 { 121 { 118 //------------------------------------------ 122 //----------------------------------------------------- 119 // 123 // 120 //------------------------------------------ 124 //----------------------------------------------------- 121 125 122 // Reduced quantities: 126 // Reduced quantities: 123 // -- critical energy in CsI: 127 // -- critical energy in CsI: 124 G4double Ec = 800 * MeV / (54. + 1.2); // 5 << 128 G4double Ec = 800*MeV/(54. + 1.2); // 54 = mean Z of CsI 125 G4double Energy = fastTrack.GetPrimaryTrack( 129 G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy(); 126 G4double y = Energy / Ec; << 130 G4double y = Energy/Ec; 127 131 128 // compute value of parameter "a" of longitu 132 // compute value of parameter "a" of longitudinal profile, b assumed = 0.5 129 G4double a, tmax, b(0.5), C; 133 G4double a, tmax, b(0.5), C; 130 if (fastTrack.GetPrimaryTrack()->GetDefiniti << 134 if (fastTrack.GetPrimaryTrack()->GetDefinition() == G4Gamma::GammaDefinition()) C = 0.5; 131 C = 0.5; << 135 else C = -0.5; 132 else << 133 C = -0.5; << 134 tmax = 1.0 * (std::log(y) + C); 136 tmax = 1.0 * (std::log(y) + C); 135 a = 1.0 + b * tmax; << 137 a = 1.0 + b*tmax; 136 138 137 // t : reduced quantity = z/X0: 139 // t : reduced quantity = z/X0: 138 G4double t, bt; << 140 G4double t, bt; 139 if (fCsI == nullptr) fCsI = G4NistManager::I << 141 if ( fCsI == 0 ) fCsI = G4NistManager::Instance()->FindOrBuildMaterial("G4_CESIUM_IODIDE"); 140 G4double X0 = fCsI->GetRadlen(); << 142 G4double X0 = fCsI->GetRadlen(); 141 // Moliere radius: 143 // Moliere radius: 142 G4double Es = 21 * MeV; << 144 G4double Es = 21*MeV; 143 G4double Rm = X0 * Es / Ec; << 145 G4double Rm = X0*Es/Ec; 144 146 145 // axis of the shower, in global reference f 147 // axis of the shower, in global reference frame: 146 G4ThreeVector xShower, yShower, zShower; 148 G4ThreeVector xShower, yShower, zShower; 147 zShower = fastTrack.GetPrimaryTrack()->GetMo 149 zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection(); 148 xShower = zShower.orthogonal(); 150 xShower = zShower.orthogonal(); 149 yShower = zShower.cross(xShower); 151 yShower = zShower.cross(xShower); 150 // starting point of the shower: 152 // starting point of the shower: 151 G4ThreeVector sShower = fastTrack.GetPrimary 153 G4ThreeVector sShower = fastTrack.GetPrimaryTrack()->GetPosition(); 152 154 153 // We shoot 100 spots of energy: 155 // We shoot 100 spots of energy: 154 G4int nSpots = 100; << 156 G4int nSpots = 100; 155 G4double deposit = Energy / double(nSpots); << 157 G4double deposit = Energy/double(nSpots); 156 Par01EnergySpot eSpot; 158 Par01EnergySpot eSpot; 157 eSpot.SetEnergy(deposit); 159 eSpot.SetEnergy(deposit); 158 G4ThreeVector ePoint; 160 G4ThreeVector ePoint; 159 G4double z, r, phi; 161 G4double z, r, phi; 160 162 161 feSpotList.clear(); 163 feSpotList.clear(); 162 for (int i = 0; i < nSpots; i++) { << 164 for (int i = 0; i < nSpots; i++) 163 // Longitudinal profile: << 165 { 164 // -- shoot z according to Gamma distribut << 166 // Longitudinal profile: 165 bt = G4RandGamma::shoot(a, 1.0); << 167 // -- shoot z according to Gamma distribution: 166 t = bt / b; << 168 bt = G4RandGamma::shoot(a,1.0); 167 z = t * X0; << 169 t = bt/b; 168 << 170 z = t*X0; 169 // transverse profile: << 171 170 // we set 90% of energy in one Rm, << 172 // transverse profile: 171 // the rest between 1 and 3.5 Rm: << 173 // we set 90% of energy in one Rm, 172 G4double xr = G4UniformRand(); << 174 // the rest between 1 and 3.5 Rm: 173 if (xr < 0.9) << 175 G4double xr = G4UniformRand(); 174 r = xr / 0.9 * Rm; << 176 if (xr < 0.9) r = xr/0.9*Rm; 175 else << 177 else r = ((xr - 0.9)/0.1*2.5 + 1.0)*Rm; 176 r = ((xr - 0.9) / 0.1 * 2.5 + 1.0) * Rm; << 178 phi = G4UniformRand()*twopi; 177 phi = G4UniformRand() * twopi; << 179 178 << 180 // build the position: 179 // build the position: << 181 ePoint = sShower + 180 ePoint = sShower + z * zShower + r * std:: << 182 z*zShower + 181 << 183 r*std::cos(phi)*xShower + r*std::sin(phi)*yShower; 182 // and the energy spot: << 184 183 eSpot.SetPosition(ePoint); << 185 // and the energy spot: 184 << 186 eSpot.SetPosition(ePoint); 185 // Records the eSpot: << 187 186 feSpotList.push_back(eSpot); << 188 // Records the eSpot: 187 } << 189 feSpotList.push_back(eSpot); >> 190 } 188 } 191 } 189 192 190 //....oooOO0OOooo........oooOO0OOooo........oo 193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 191 194 192 void Par01EMShowerModel::BuildDetectorResponse 195 void Par01EMShowerModel::BuildDetectorResponse() 193 { 196 { 194 // Does the assignation of the energy spots 197 // Does the assignation of the energy spots to the sensitive volumes: 195 for (size_t i = 0; i < feSpotList.size(); i+ << 198 for (size_t i = 0; i < feSpotList.size(); i++) 196 // Draw the energy spot: << 199 { 197 // feSpotList[i].Draw(); << 200 // Draw the energy spot: 198 // feSpotList[i].Print(); << 201 // feSpotList[i].Draw(); 199 << 202 // feSpotList[i].Print(); 200 // "converts" the energy spot into the fak << 203 201 // G4Step to pass to sensitive detector: << 204 // "converts" the energy spot into the fake 202 AssignSpotAndCallHit(feSpotList[i]); << 205 // G4Step to pass to sensitive detector: 203 } << 206 AssignSpotAndCallHit(feSpotList[i]); >> 207 } 204 } 208 } 205 209 206 //....oooOO0OOooo........oooOO0OOooo........oo 210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 207 211 208 void Par01EMShowerModel::AssignSpotAndCallHit( << 212 void Par01EMShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot) 209 { 213 { 210 // 214 // 211 // "converts" the energy spot into the fake 215 // "converts" the energy spot into the fake 212 // G4Step to pass to sensitive detector: 216 // G4Step to pass to sensitive detector: 213 // 217 // 214 FillFakeStep(eSpot); 218 FillFakeStep(eSpot); 215 219 216 // 220 // 217 // call sensitive part: taken/adapted from t 221 // call sensitive part: taken/adapted from the stepping: 218 // Send G4Step information to Hit/Dig if the 222 // Send G4Step information to Hit/Dig if the volume is sensitive 219 // 223 // 220 G4VPhysicalVolume* pCurrentVolume = fFakeSte << 224 G4VPhysicalVolume* pCurrentVolume = >> 225 fFakeStep->GetPreStepPoint()->GetPhysicalVolume(); 221 G4VSensitiveDetector* pSensitive; 226 G4VSensitiveDetector* pSensitive; 222 << 227 223 if (pCurrentVolume != nullptr) { << 228 if( pCurrentVolume != 0 ) 224 pSensitive = pCurrentVolume->GetLogicalVol << 229 { 225 if (pSensitive != nullptr) { << 230 pSensitive = pCurrentVolume->GetLogicalVolume()-> 226 pSensitive->Hit(fFakeStep); << 231 GetSensitiveDetector(); >> 232 if( pSensitive != 0 ) >> 233 { >> 234 pSensitive->Hit(fFakeStep); >> 235 } 227 } 236 } 228 } << 229 } 237 } 230 238 231 //....oooOO0OOooo........oooOO0OOooo........oo 239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 232 240 233 void Par01EMShowerModel::FillFakeStep(const Pa << 241 void Par01EMShowerModel::FillFakeStep(const Par01EnergySpot &eSpot) 234 { 242 { 235 //------------------------------------------ 243 //----------------------------------------------------------- 236 // find in which volume the spot is. 244 // find in which volume the spot is. 237 //------------------------------------------ 245 //----------------------------------------------------------- 238 if (!fNaviSetup) { << 246 if (!fNaviSetup) 239 fpNavigator->SetWorldVolume(G4Transportati << 247 { 240 ->GetNavigat << 248 fpNavigator-> 241 ->GetWorldVo << 249 SetWorldVolume(G4TransportationManager::GetTransportationManager()-> 242 fpNavigator->LocateGlobalPointAndUpdateTou << 250 GetNavigatorForTracking()->GetWorldVolume()); 243 eSpot.GetPosition(), G4ThreeVector(0., 0 << 251 fpNavigator-> 244 fNaviSetup = true; << 252 LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(), 245 } << 253 G4ThreeVector(0.,0.,0.), 246 else { << 254 fTouchableHandle, 247 fpNavigator->LocateGlobalPointAndUpdateTou << 255 false); 248 eSpot.GetPosition(), G4ThreeVector(0., 0 << 256 fNaviSetup = true; 249 } << 257 } >> 258 else >> 259 { >> 260 fpNavigator-> >> 261 LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(), >> 262 G4ThreeVector(0.,0.,0.), >> 263 fTouchableHandle); >> 264 } 250 //-------------------------------------- 265 //-------------------------------------- 251 // Fills attribute of the G4Step needed 266 // Fills attribute of the G4Step needed 252 // by our sensitive detector: 267 // by our sensitive detector: 253 //------------------------------------- 268 //------------------------------------- 254 // set touchable volume at PreStepPoint: 269 // set touchable volume at PreStepPoint: 255 fFakePreStepPoint->SetTouchableHandle(fTouch 270 fFakePreStepPoint->SetTouchableHandle(fTouchableHandle); 256 // set total energy deposit: 271 // set total energy deposit: 257 fFakeStep->SetTotalEnergyDeposit(eSpot.GetEn 272 fFakeStep->SetTotalEnergyDeposit(eSpot.GetEnergy()); 258 } 273 } 259 274