B1SteppingAction.cc 5.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
//
/// \file B1SteppingAction.cc
/// \brief Implementation of the B1SteppingAction class

#include "B1SteppingAction.hh"
#include "B1EventAction.hh"
#include "B1DetectorConstruction.hh"
#include "B1Analysis.hh"

#include "G4Step.hh"
#include "G4SystemOfUnits.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4LogicalVolume.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B1SteppingAction::B1SteppingAction(B1EventAction* eventAction)
: G4UserSteppingAction(),
  fEventAction(eventAction),
  fScoringVolume(0)
{}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B1SteppingAction::~B1SteppingAction()
{}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void B1SteppingAction::UserSteppingAction(const G4Step* step)
{
  G4double e_minus, p, pi_p, pi_m, mu_p, mu_m, e_p, neutron, gamma = 0;
  if (!fScoringVolume) {
    const B1DetectorConstruction* detectorConstruction
      = static_cast<const B1DetectorConstruction*>
        (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
    fScoringVolume = detectorConstruction->GetScoringVolume();
  }


  // get volume of the current step
  G4LogicalVolume* volume
    = step->GetPreStepPoint()->GetTouchableHandle()
      ->GetVolume()->GetLogicalVolume();



  // check if we are in scoring volume
  if (volume != fScoringVolume) {
  return;
  }

  //ATENÇÃO - Comments dentro dos else-if -> para histograma de particlas x z (BUG no Z=0 e resultado duvidoso -- MELHORAR)

  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
  //collect particle for each step
  G4String particle = step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName();
  G4double z =step->GetPreStepPoint()->GetPosition().z()/meter;
  //G4double x =step->GetPreStepPoint()->GetPosition().x()/meter;// se quiser plotar com x e y
  //G4double y =step->GetPreStepPoint()->GetPosition().y()/meter;
  if (particle == "e-") {
    e_minus = 1;
    //analysisManager->FillNtupleDColumn(2, z);
  } else if (particle == "e+") {
    e_p = 1;
    //analysisManager->FillNtupleDColumn(1, z);
  }else if (particle == "proton") {
    p = 1;
    //analysisManager->FillNtupleDColumn(0, z);
  }else if (particle == "pi-") {
    pi_m = 1;
    //analysisManager->FillNtupleDColumn(6, z);
  }else if (particle == "pi+") {
    pi_p = 1;
    //analysisManager->FillNtupleDColumn(5, z);
  }else if (particle == "mu-") {
    mu_m = 1;
    //analysisManager->FillNtupleDColumn(3, z);
  }else if (particle == "mu+") {
    mu_p = 1;
    //analysisManager->FillNtupleDColumn(4, z);
  }else if (particle == "gamma") {
    gamma = 1;
    //analysisManager->FillNtupleDColumn(7, z);
  }
  //Retire esse comment para histograma que leva em conta o numero de vezes que a particula foi identificado no evento. ->  Por enquanto o mais confiável.
  /*
  analysisManager->FillNtupleDColumn(0, p);
  analysisManager->FillNtupleDColumn(1, e_p);
  analysisManager->FillNtupleDColumn(2, e_minus);
  analysisManager->FillNtupleDColumn(3, mu_m);
  analysisManager->FillNtupleDColumn(4, mu_p);
  analysisManager->FillNtupleDColumn(5, pi_p);
  analysisManager->FillNtupleDColumn(6, pi_m);
  analysisManager->FillNtupleDColumn(7, gamma);
  analysisManager->FillNtupleDColumn(8, z);

  /**/
  analysisManager->AddNtupleRow();
  // collect energy deposited in this step
  G4double edepStep = step->GetTotalEnergyDeposit();
  fEventAction->AddEdep(edepStep);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......