geant4-B1-example  1.0
 All Classes Files Functions Variables Pages
B1SteppingAction.cc
Go to the documentation of this file.
1 /// \file B1SteppingAction.cc
2 /// \brief Implementation of the B1SteppingAction class
3 
4 #include "B1SteppingAction.hh"
5 #include "B1EventAction.hh"
7 
8 #include "G4Step.hh"
9 #include "G4Event.hh"
10 #include "G4RunManager.hh"
11 #include "G4LogicalVolume.hh"
12 
13 
14 
16  : G4UserSteppingAction(),
17  fEventAction(eventAction),
18  fScoringVolume(0)
19 {}
20 
21 
22 
24 {}
25 
26 
27 
28 // note: UserSteppingAction() is a virtual method.
29 
30 void B1SteppingAction::UserSteppingAction(const G4Step* step)
31 {
32  // G4Step stores the transient information of a step.
33  // This includes the two endpoints of the step:
34  // PreStepPoint and PostStepPoint. G4Step also stores the change in track
35  // properties between the two points. These properties, such as energy and
36  // momentum, are updated as the various active processes are invoked.
37  // since fScoringVolume is set to 0 initially, !0 = true.
38  if (!fScoringVolume)
39  {
40  // to retrieve our detector setting.
41  const B1DetectorConstruction* detectorConstruction
42  = static_cast<const B1DetectorConstruction*>
43  ( G4RunManager::GetRunManager()->GetUserDetectorConstruction() );
44 
45  fScoringVolume = detectorConstruction->GetScoringVolume();
46  // GetScoringVolume() is get the G4LogicalVolume* logicShape2
47  // scoring volume is the one of 80% of the total volume.
48  }
49 
50 
51 
52  // get volume of the current step;
53  // note: step is the input argument.
54  G4LogicalVolume* volume
55  = step-> GetPreStepPoint()
56  -> GetTouchableHandle()
57  -> GetVolume()
58  -> GetLogicalVolume();
59 
60  // check if we are in scoring volume
61  if (volume != fScoringVolume) return;
62 
63  // collect energy deposited in this step
64  G4double edepStep = step->GetTotalEnergyDeposit();
65 
66  fEventAction->AddEdep(edepStep);
67  // link to the B1EventAction obj.
68  // will add the edepStep to the fEep defined in EventAction
69 }
70 
71 
72 
Definition of the B1DetectorConstruction class.
Detector construction class to define materials and geometry.
Definition of the B1SteppingAction class.
G4LogicalVolume * GetScoringVolume() const
B1SteppingAction(B1EventAction *eventAction)
virtual void UserSteppingAction(const G4Step *)
Definition of the B1EventAction class.
void AddEdep(G4double edep)
for user stepping action object to update the B1EventAction::fEdep.
user event class
virtual ~B1SteppingAction()