| [807] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | // $Id: SteppingAction.cc,v 1.6 2007/03/15 15:52:39 maire Exp $
|
|---|
| 27 | // GEANT4 tag $Name: $
|
|---|
| 28 | //
|
|---|
| 29 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 31 |
|
|---|
| 32 | #include "SteppingAction.hh"
|
|---|
| 33 | #include "DetectorConstruction.hh"
|
|---|
| 34 | #include "PrimaryGeneratorAction.hh"
|
|---|
| 35 | #include "RunAction.hh"
|
|---|
| 36 | #include "HistoManager.hh"
|
|---|
| 37 |
|
|---|
| 38 | #include "G4RunManager.hh"
|
|---|
| 39 |
|
|---|
| 40 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 41 |
|
|---|
| 42 | SteppingAction::SteppingAction(DetectorConstruction* det,
|
|---|
| 43 | PrimaryGeneratorAction* prim, RunAction* RuAct,
|
|---|
| 44 | HistoManager* Hist)
|
|---|
| 45 | :detector(det), primary(prim), runAction(RuAct), histoManager(Hist)
|
|---|
| 46 | { }
|
|---|
| 47 |
|
|---|
| 48 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 49 |
|
|---|
| 50 | SteppingAction::~SteppingAction()
|
|---|
| 51 | { }
|
|---|
| 52 |
|
|---|
| 53 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 54 |
|
|---|
| 55 | void SteppingAction::UserSteppingAction(const G4Step* aStep)
|
|---|
| 56 | {
|
|---|
| 57 | G4StepPoint* prePoint = aStep->GetPreStepPoint();
|
|---|
| 58 |
|
|---|
| 59 | // if World --> return
|
|---|
| 60 | if (prePoint->GetTouchableHandle()->GetVolume()==detector->GetWorld()) return;
|
|---|
| 61 |
|
|---|
| 62 | // here we enter in the absorber Box
|
|---|
| 63 | // tag the event to be killed anyway after this step
|
|---|
| 64 | //
|
|---|
| 65 | G4RunManager::GetRunManager()->AbortEvent();
|
|---|
| 66 |
|
|---|
| 67 | //count processes and keep only Multiple Scattering
|
|---|
| 68 | //
|
|---|
| 69 | G4StepPoint* endPoint = aStep->GetPostStepPoint();
|
|---|
| 70 | G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
|
|---|
| 71 | runAction->CountProcesses(procName);
|
|---|
| 72 |
|
|---|
| 73 | if (procName != "msc" && procName != "stepMax") return;
|
|---|
| 74 |
|
|---|
| 75 | //below, only multiple Scattering happens
|
|---|
| 76 | //
|
|---|
| 77 | G4ThreeVector position = endPoint->GetPosition();
|
|---|
| 78 | G4ThreeVector direction = endPoint->GetMomentumDirection();
|
|---|
| 79 |
|
|---|
| 80 | G4double truePathLength = aStep->GetStepLength();
|
|---|
| 81 | G4double geomPathLength = position.x() + 0.5*detector->GetBoxSize();
|
|---|
| 82 | G4double ratio = geomPathLength/truePathLength;
|
|---|
| 83 | runAction->SumPathLength(truePathLength,geomPathLength);
|
|---|
| 84 | histoManager->FillHisto(1,truePathLength);
|
|---|
| 85 | histoManager->FillHisto(2,geomPathLength);
|
|---|
| 86 | histoManager->FillHisto(3,ratio);
|
|---|
| 87 |
|
|---|
| 88 | G4double yend = position.y(), zend = position.z();
|
|---|
| 89 | G4double lateralDisplacement = std::sqrt(yend*yend + zend*zend);
|
|---|
| 90 | runAction->SumLateralDisplacement(lateralDisplacement);
|
|---|
| 91 | histoManager->FillHisto(4,lateralDisplacement);
|
|---|
| 92 |
|
|---|
| 93 | G4double psi = std::atan(lateralDisplacement/geomPathLength);
|
|---|
| 94 | runAction->SumPsi(psi);
|
|---|
| 95 | histoManager->FillHisto(5,psi);
|
|---|
| 96 |
|
|---|
| 97 | G4double xdir = direction.x(), ydir = direction.y(), zdir = direction.z();
|
|---|
| 98 | G4double tetaPlane = std::atan2(ydir, xdir);
|
|---|
| 99 | runAction->SumTetaPlane(tetaPlane);
|
|---|
| 100 | histoManager->FillHisto(6,tetaPlane);
|
|---|
| 101 | tetaPlane = std::atan2(zdir, xdir);
|
|---|
| 102 | runAction->SumTetaPlane(tetaPlane);
|
|---|
| 103 | histoManager->FillHisto(6,tetaPlane);
|
|---|
| 104 |
|
|---|
| 105 | G4double phiPos = std::atan2(zend, yend);
|
|---|
| 106 | histoManager->FillHisto(7,phiPos);
|
|---|
| 107 | G4double phiDir = std::atan2(zdir, ydir);
|
|---|
| 108 | histoManager->FillHisto(8,phiDir);
|
|---|
| 109 |
|
|---|
| 110 | G4double phiCorrel = 0.;
|
|---|
| 111 | if (lateralDisplacement > 0.)
|
|---|
| 112 | phiCorrel = (yend*ydir + zend*zdir)/lateralDisplacement;
|
|---|
| 113 | runAction->SumPhiCorrel(phiCorrel);
|
|---|
| 114 | histoManager->FillHisto(9,phiCorrel);
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|