fill ntuples(BUGS)

parent 85bd776f
......@@ -30,8 +30,10 @@
#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"
......@@ -53,26 +55,79 @@ B1SteppingAction::~B1SteppingAction()
void B1SteppingAction::UserSteppingAction(const G4Step* step)
{
if (!fScoringVolume) {
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();
fScoringVolume = detectorConstruction->GetScoringVolume();
}
// get volume of the current step
G4LogicalVolume* volume
G4LogicalVolume* volume
= step->GetPreStepPoint()->GetTouchableHandle()
->GetVolume()->GetLogicalVolume();
// check if we are in scoring volume
if (volume != fScoringVolume) return;
if (volume != fScoringVolume) {
G4cout << "AAAAAA" << G4endl;
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.
/*
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
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);
fEventAction->AddEdep(edepStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment