a

parent 62998e5a
......@@ -52,8 +52,8 @@ class B1EventAction : public G4UserEventAction
virtual void BeginOfEventAction(const G4Event* event);
virtual void EndOfEventAction(const G4Event* event);
void PrintParticles(std::map<const G4String, int>& container, std::ofstream& gamma, std::ofstream& mu_minus, std::ofstream& mu_plus,
std::ofstream& nu_e, std::ofstream& nu_mu, std::ofstream& anti_nu_e, std::ofstream& anti_nu_mu, G4double position);
void PrintParticles(std::map<const G4String, int>& container, std::ofstream& gamma, std::ofstream& mu,
std::ofstream& nu_e, std::ofstream& nu_mu, std::ofstream& e, G4double position);
void WriteHistogram(const G4String name, G4int Detec);
void AddEdep(G4double edep) { fEdep += edep; };
G4double SetPosition(G4int detec);
......
......@@ -79,9 +79,9 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//
//caracteristicas do cilíndro -> world
G4double raio_i = 0;
G4double raio_e = 40*km;
G4double h_detector = 0.1*mm;
G4double h = 40*km;
G4double raio_e = 50*km;
G4double h_detector = 0.5*mm;
G4double h = 50*km;
G4double theta_0 = 0.*deg;
G4double theta_f = 360.*deg;
//making world of vacuum
......@@ -115,7 +115,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//making air materiais
//Nitrogen
G4int num_layers = 4000;
G4int num_layers = 201;
G4double layer_delta_h = 2*h/num_layers;
std::vector<G4Material *> layers_material;
layers_material.reserve(num_layers);
......@@ -126,7 +126,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
for(G4int j = 0; j < num_layers; j++) {
for(G4int j = 0; j < (num_layers - 1); j++) {
//fazer if clause para verificar valor de delta h progressivamente.
//dependendo do h + delta_h -> parâmetros diferentes.
G4double density;
......@@ -191,6 +191,8 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
G4int num_detector = 32;
number_detectors = num_layers - 1;
//UTILIZAR NÚMEROS QUE num_layers/num_detector = inteiro.
G4double total_safe = h_detector + safe_distance;
G4double delta_h = (2*h - 2*safe_distance - 4*h_detector)/(num_detector - 1);
G4double initial_pos = -h + total_safe;
......
......@@ -88,12 +88,10 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
variation = detectorConstruction->get_delta();
std::ofstream gammafile("gamma.csv");
std::ofstream mu_plusfile("mu+.csv");
std::ofstream mu_minusfile("mu-.csv");
std::ofstream mu_file("mu.csv");
std::ofstream nu_e_file("nu_e.csv");
std::ofstream nu_mu_file("nu_mu.csv");
std::ofstream anti_nu_e_file("anti_nu_e.csv");
std::ofstream anti_nu_mu_file("anti_nu_mu.csv");
std::ofstream e_file("e.txt");
std::ofstream particles_file("particles.csv");
......@@ -127,30 +125,39 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
fparticles[name]++;
//WriteHistogram(name, 1);
}
PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, nu_e_file, nu_mu_file, anti_nu_e_file, anti_nu_mu_file, pos_detec);
PrintParticles(fparticles, gammafile, mu_file, nu_e_file, nu_mu_file, e_file, pos_detec);
fparticles.clear();
}
}
gammafile.close();
mu_plusfile.close();
mu_minusfile.close();
mu_file.close();
nu_e_file.close();
nu_mu_file.close();
anti_nu_e_file.close();
anti_nu_mu_file.close();
particles_file.close();
e_file.close();
}
void B1EventAction::PrintParticles(std::map<const G4String, int>& container, std::ofstream& gamma, std::ofstream& mu_minus, std::ofstream& mu_plus,
std::ofstream& nu_e, std::ofstream& nu_mu, std::ofstream& anti_nu_e, std::ofstream& anti_nu_mu, G4double position) {
void B1EventAction::PrintParticles(std::map<const G4String, int>& container, std::ofstream& gamma, std::ofstream& mu,
std::ofstream& nu_e, std::ofstream& nu_mu, std::ofstream& e, G4double position) {
std::map<const G4String, int>::iterator it;
// G4cout << "Número de párticulas identificadas no detetor: " << G4endl;
G4bool isGamma, ismu_minus, ismu_plus, isnu_e, isnu_mu, isanti_nu_e, isanti_nu_mu = false;
G4bool isGamma, ismu, isnu_e_anti, isnu_mu_anti, is_e = false;
G4int n_e_minus, n_e_pl, n_mu_minus, n_mu_plus, n_nu_e, n_anti_nu_e, n_nu_mu, n_anti_nu_mu = 0;
n_e_minus = 0;
n_e_pl = 0;
n_mu_minus = 0;
n_mu_plus = 0;
n_nu_e = 0;
n_anti_nu_e = 0;
n_nu_mu = 0;
n_anti_nu_mu = 0;
for(it = container.begin() ;it != container.end(); it ++)
{
G4cout << n_e_pl << G4endl;
G4cout << "N " << it->first << " : " << it->second << G4endl;
//FUTURO -> substituir por switch;
if(it->first == "gamma") {
......@@ -158,47 +165,69 @@ void B1EventAction::PrintParticles(std::map<const G4String, int>& container, std
gamma << it->second << " " << position << "\n";
isGamma = true;
} else if (it->first == "mu+") {
mu_plus << it->second << " " << position << "\n";
ismu_plus= true;
n_mu_plus = it->second;
ismu = true;
} else if (it->first == "mu-") {
mu_minus << it->second << " " << position << "\n";
ismu_minus = true;
n_mu_minus = it->second;
ismu = true;
} else if (it->first == "nu_e") {
nu_e << it->second << " " << position << "\n";
isnu_e = true;
} else if (it->first == "nu_mu") {
nu_mu << it->second << " " << position << "\n";
isnu_mu = true;
n_nu_e = it->second;
isnu_e_anti = true;
} else if (it->first == "anti_nu_e") {
anti_nu_e << it->second << " " << position << "\n";
isanti_nu_e = true;
n_anti_nu_e = it->second;
isnu_e_anti = true;
} else if (it->first == "nu_mu") {
n_nu_mu = it->second;
isnu_mu_anti = true;
} else if (it->first == "anti_nu_mu") {
anti_nu_mu << it->second << " " << position << "\n";
isanti_nu_mu = true;
n_anti_nu_mu = it->second;
isnu_mu_anti = true;
} else if (it->first == "e+") {
n_e_pl = it->second;
G4cout << "aa" << n_e_pl << G4endl;
is_e = true;
} else if (it->first == "e-") {
n_e_minus = it->second;
G4cout << "aa" << n_e_minus << G4endl;
is_e = true;
}
}
if (!isGamma) {
gamma << "0 " << position << "\n";
}
if (!ismu_plus) {
mu_plus << "0 " << position << "\n";
}
if (!ismu_minus) {
mu_minus << "0 " << position << "\n";
gamma << 0 << " " << position << "\n";
}
if (!isnu_e) {
nu_e << "0 " << position << "\n";
if (!ismu) {
mu << 0 << " " << position << "\n";
} else {
G4int n = n_mu_minus + n_mu_plus;
mu << n << " " << position << "\n";
}
if (!isnu_mu) {
nu_mu << "0 " << position << "\n";
if(!is_e) {
e << 0 << " " << position << "\n";
} else {
G4int n = n_e_pl + n_e_minus;
G4cout << n_e_pl << G4endl;
G4cout << n_e_minus << G4endl;
G4cout << n << G4endl;
e << n << " " << position << "\n";
}
if (!isanti_nu_e) {
anti_nu_e << "0 " << position << "\n";
if (!isnu_e_anti) {
nu_e << 0 << " " << position << "\n";
} else {
G4int n = n_nu_e + n_anti_nu_e;
nu_e << n << " " << position << "\n";
}
if (!isanti_nu_mu) {
anti_nu_mu << "0 " << position << "\n";
if (!isnu_mu_anti) {
nu_mu << 0 << " " << position << "\n";
} else {
G4int n = n_nu_mu + n_anti_nu_mu;
nu_mu << n << " " << position << "\n";
}
}
void B1EventAction::WriteHistogram(const G4String name, G4int Detec) {
......
......@@ -79,7 +79,7 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
fParticleGun->SetParticlePosition(G4ThreeVector(0,0,-40.*km));
fParticleGun->SetParticlePosition(G4ThreeVector(0,0,-50.*km));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
......
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