Changeset 1342 for trunk/examples/extended/electromagnetic/TestEm7/src
- Timestamp:
- Nov 5, 2010, 4:08:39 PM (14 years ago)
- Location:
- trunk/examples/extended/electromagnetic/TestEm7/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandardNR.cc
r1337 r1342 24 24 // ******************************************************************** 25 25 // 26 // $Id: PhysListEmStandardNR.cc,v 1. 4 2009/11/21 22:02:51 maireExp $27 // GEANT4 tag $Name: geant4-09-04-beta-01$26 // $Id: PhysListEmStandardNR.cc,v 1.5 2010/10/13 12:21:56 vnivanch Exp $ 27 // GEANT4 tag $Name: examples-V09-03-09 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 122 122 123 123 G4ionIonisation* ion = new G4ionIonisation(); 124 ion->ActivateNuclearStopping(false);125 124 pmanager->AddProcess(ion, -1, 2, 2); 126 125 … … 136 135 137 136 G4ionIonisation* ion = new G4ionIonisation(); 138 ion->ActivateNuclearStopping(false);139 137 ion->SetStepFunction(0.1, um); 140 138 pmanager->AddProcess(ion, -1, 2, 2); -
trunk/examples/extended/electromagnetic/TestEm7/src/RunAction.cc
r1337 r1342 24 24 // ******************************************************************** 25 25 // 26 // $Id: RunAction.cc,v 1.2 4 2008/08/22 18:30:27 vnivanchExp $27 // GEANT4 tag $Name: geant4-09-04-beta-01$26 // $Id: RunAction.cc,v 1.25 2010/09/17 18:45:43 maire Exp $ 27 // GEANT4 tag $Name: examples-V09-03-09 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 34 34 #include "PhysicsList.hh" 35 35 #include "StepMax.hh" 36 #include "HistoManager.hh" 36 37 #include "PrimaryGeneratorAction.hh" 37 38 … … 42 43 43 44 #include "Randomize.hh" 44 #include "Histo.hh"45 45 46 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 47 48 48 RunAction::RunAction(DetectorConstruction* det, PhysicsList* phys, 49 PrimaryGeneratorAction* kin)50 :detector(det), physics(phys), kinematic(kin)49 HistoManager* histo, PrimaryGeneratorAction* kin) 50 :detector(det), physics(phys),histoManager(histo), kinematic(kin) 51 51 { 52 52 tallyEdep = new G4double[MaxTally]; 53 binLength = offsetX = 0.;54 histo = new Histo();55 histo->setFileName("testem7");56 histo->add1D("1","Edep (MeV/mm) along absorber (mm)", 100, 0, 100);57 histo->add1D("2","Edep (MeV/mm) along absorber zoomed (mm)", 100, 0, 100);58 histo->add1D("3","Projectile range (mm)", 100, 0, 100);59 53 } 60 54 … … 64 58 { 65 59 delete [] tallyEdep; 66 delete histo;67 }68 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......70 71 void RunAction::FillHisto(G4int ih, G4double x, G4double weight)72 {73 histo->fill(ih, x, weight);74 60 } 75 61 … … 94 80 95 81 // define "1" histogram binning 96 length = detector->GetAbsorSizeX(); 82 // histogram "1" is defined by the length of the target 83 // zoomed histograms are defined by UI command 84 G4double length = detector->GetAbsorSizeX(); 97 85 G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep(); 98 constG4int nbmin = 100;86 G4int nbmin = 100; 99 87 G4int nbBins = (G4int)(0.5 + length/stepMax); 100 88 if (nbBins < nbmin) nbBins = nbmin; 101 binLength = length/nbBins; 102 offsetX = 0.5*length; 103 104 // histogram "1" is defined by the length of the target 105 // zoomed histograms are defined by UI command 106 histo->setHisto1D(0, nbBins, 0, length, mm); 89 histoManager->SetHisto(1, nbBins, 0., length, "mm"); 107 90 108 histo ->book();91 histoManager->book(); 109 92 } 110 93 … … 147 130 G4cout << " Mean number of primary steps = "<< nstep << G4endl; 148 131 149 //compute energy deposition and NIEL132 //compute energy deposition and niel 150 133 // 151 134 edeptot /= NbofEvents; … … 153 136 << G4endl; 154 137 eniel /= NbofEvents; 155 G4cout << " NIELenergy deposit = "<< G4BestUnit(eniel,"Energy")138 G4cout << " niel energy deposit = "<< G4BestUnit(eniel,"Energy") 156 139 << G4endl; 157 140 … … 176 159 } 177 160 178 // normalize histogram 179 G4double fac = (mm/MeV)/(NbofEvents * binLength); 180 for (G4int j=0; j<3; j++) {histo->scale(j, fac);} 161 // normalize histograms 162 for (G4int j=1; j<3; j++) { 163 G4double binWidth = histoManager->GetBinWidth(j); 164 G4double fac = (mm/MeV)/(NbofEvents * binWidth); 165 histoManager->Scale(j, fac); 166 } 167 histoManager->Scale(3, 1./NbofEvents); 181 168 182 169 // save and clean histo 183 histo ->save();170 histoManager->save(); 184 171 185 172 // show Rndm status -
trunk/examples/extended/electromagnetic/TestEm7/src/SteppingAction.cc
r1337 r1342 24 24 // ******************************************************************** 25 25 // 26 // $Id: SteppingAction.cc,v 1.1 4 2008/08/22 18:30:27 vnivanchExp $27 // GEANT4 tag $Name: geant4-09-04-beta-01$26 // $Id: SteppingAction.cc,v 1.15 2010/09/17 18:45:43 maire Exp $ 27 // GEANT4 tag $Name: examples-V09-03-09 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 32 32 #include "SteppingAction.hh" 33 33 #include "DetectorConstruction.hh" 34 #include "HistoManager.hh" 34 35 #include "RunAction.hh" 35 36 #include "G4SteppingManager.hh" … … 38 39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 39 40 40 SteppingAction::SteppingAction(DetectorConstruction* det,RunAction* RuAct) 41 :detector(det),runAction(RuAct) 41 SteppingAction::SteppingAction(DetectorConstruction* det, HistoManager* histo, 42 RunAction* RuAct) 43 :detector(det), histoManager(histo), runAction(RuAct) 42 44 { } 43 45 … … 49 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 52 51 void SteppingAction::UserSteppingAction(const G4Step* aStep)53 void SteppingAction::UserSteppingAction(const G4Step* step) 52 54 { 53 G4double edep = aStep->GetTotalEnergyDeposit();55 G4double edep = step->GetTotalEnergyDeposit(); 54 56 if (edep <= 0.) return; 57 58 G4double niel = step->GetNonIonizingEnergyDeposit(); 55 59 56 // G4cout << "edep= " << edep << "NIEL= " << aStep->GetNonIonizingEnergyDeposit()<<G4endl;60 runAction->FillEdep(edep, niel); 57 61 58 runAction->FillEdep(edep,aStep->GetNonIonizingEnergyDeposit()); 59 60 if(aStep->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep(); 62 if (step->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep(); 61 63 62 64 //Bragg curve 63 65 // 64 G4StepPoint* prePoint = aStep->GetPreStepPoint();65 G4StepPoint* postPoint = aStep->GetPostStepPoint();66 G4StepPoint* prePoint = step->GetPreStepPoint(); 67 G4StepPoint* postPoint = step->GetPostStepPoint(); 66 68 67 G4double x1 = prePoint->GetPosition().x(), x2 = postPoint->GetPosition().x(); 68 G4double x = runAction->GetOffsetX() + x1 + G4UniformRand()*(x2-x1); 69 runAction->FillHisto(0, x/mm , edep); 70 runAction->FillHisto(1, x/mm , edep); 69 G4double x1 = prePoint->GetPosition().x(); 70 G4double x2 = postPoint->GetPosition().x(); 71 G4double x = x1 + G4UniformRand()*(x2-x1) + 0.5*(detector->GetAbsorSizeX()); 72 histoManager->FillHisto(1, x, edep); 73 histoManager->FillHisto(2, x, edep); 71 74 72 75 //fill tallies -
trunk/examples/extended/electromagnetic/TestEm7/src/TrackingAction.cc
r1337 r1342 24 24 // ******************************************************************** 25 25 // 26 // $Id: TrackingAction.cc,v 1. 5 2008/08/22 18:30:27 vnivanchExp $27 // GEANT4 tag $Name: geant4-09-04-beta-01$26 // $Id: TrackingAction.cc,v 1.6 2010/09/17 18:45:43 maire Exp $ 27 // GEANT4 tag $Name: examples-V09-03-09 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 32 32 #include "TrackingAction.hh" 33 33 34 #include "DetectorConstruction.hh" 35 #include "HistoManager.hh" 34 36 #include "RunAction.hh" 35 37 … … 38 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 39 41 40 TrackingAction::TrackingAction(RunAction* run) 41 :runAction(run) 42 TrackingAction::TrackingAction(DetectorConstruction* det, HistoManager* histo, 43 RunAction* run) 44 :detector(det), histoManager(histo), runAction(run) 42 45 { } 43 46 44 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 45 48 46 void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)49 void TrackingAction::PostUserTrackingAction(const G4Track* track) 47 50 { 48 51 // extract Projected Range of primary particle 49 if (aTrack->GetTrackID() == 1) { 50 G4double x = aTrack->GetPosition().x() + runAction->GetOffsetX(); 51 if(x > runAction->GetLength()) x = runAction->GetLength(); 52 //G4cout << " range= " << x << " x= " << aTrack->GetPosition().x() 53 // << " ofset= " << runAction->GetOffsetX() << G4endl; 52 if (track->GetTrackID() == 1) { 53 G4double x = track->GetPosition().x() + 0.5*detector->GetAbsorSizeX(); 54 54 if(x > 0.0) runAction->AddProjRange(x); 55 runAction->FillHisto(2, x/mm, 1.0);55 histoManager->FillHisto(3, x); 56 56 } 57 57 }
Note: See TracChangeset
for help on using the changeset viewer.