Ignore:
Timestamp:
Nov 5, 2010, 4:08:39 PM (14 years ago)
Author:
garnier
Message:

update ti head

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/extended/electromagnetic/TestEm7/src/RunAction.cc

    r1337 r1342  
    2424// ********************************************************************
    2525//
    26 // $Id: RunAction.cc,v 1.24 2008/08/22 18:30:27 vnivanch Exp $
    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 $
    2828//
    2929//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
     
    3434#include "PhysicsList.hh"
    3535#include "StepMax.hh"
     36#include "HistoManager.hh"
    3637#include "PrimaryGeneratorAction.hh"
    3738
     
    4243
    4344#include "Randomize.hh"
    44 #include "Histo.hh"
    4545
    4646//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    4747
    4848RunAction::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)
    5151{
    5252  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);
    5953}
    6054
     
    6458{
    6559  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);
    7460}
    7561
     
    9480
    9581  // 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();
    9785  G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep();
    98   const G4int nbmin = 100;
     86  G4int nbmin = 100;
    9987  G4int nbBins = (G4int)(0.5 + length/stepMax);
    10088  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");
    10790 
    108   histo->book();
     91  histoManager->book();
    10992}
    11093
     
    147130  G4cout << " Mean number of primary steps = "<< nstep << G4endl;
    148131
    149   //compute energy deposition and NIEL
     132  //compute energy deposition and niel
    150133  //
    151134  edeptot /= NbofEvents;
     
    153136         << G4endl;
    154137  eniel /= NbofEvents;
    155   G4cout << " NIEL energy deposit = "<< G4BestUnit(eniel,"Energy")
     138  G4cout << " niel energy deposit = "<< G4BestUnit(eniel,"Energy")
    156139         << G4endl;
    157140     
     
    176159  }
    177160
    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);
    181168 
    182169  // save and clean histo
    183   histo->save();
     170  histoManager->save();
    184171 
    185172  // show Rndm status
Note: See TracChangeset for help on using the changeset viewer.