// // ******************************************************************** // * 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 (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......