- Timestamp:
- Nov 5, 2010, 4:08:39 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.