added comments to the code

parent 3a0a0ad6
......@@ -18,11 +18,12 @@ public:
B1SD(G4String SDname);
//destrutor
~B1SD();
//função chamda a cada hit
G4bool ProcessHits(G4Step* step, G4TouchableHistory* ROhist);
void Initialize(G4HCofThisEvent* HCE);
//função chamada ao final do evento
void EndOfEvent(G4HCofThisEvent* HCE);
private:
......
......@@ -75,9 +75,9 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//
//caracteristicas do cilíndro -> world
G4double raio_i = 0;
G4double raio_e = 25*m;
G4double raio_e = 50*m;
G4double h_detector = 1*cm;
G4double h = 50*m;
G4double h = 100*m;
G4double theta_0 = 0.*deg;
G4double theta_f = 360.*deg;
G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
......@@ -104,8 +104,8 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//
fScoringVolume = logicWorld;
//Criando detetor para ver partículas que chegam à superfície
//Criando os Logical volume
G4Tubs* detector = new G4Tubs("detector", raio_i, raio_e, h_detector, theta_0, theta_f);
......@@ -126,7 +126,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
world_mat,
"detector4");
G4LogicalVolume* logicDetector5 = new G4LogicalVolume(detector,
G4LogicalVolume* logicDetector5 = new G4LogicalVolume(detector,
world_mat,
"detector5");
......@@ -242,7 +242,11 @@ G4LogicalVolume* logicDetector32 = new G4LogicalVolume(detector,
"detector32");
G4double safe_distance = 0.003*km;
//Continhas para deixar os detetores igualmente espaçados:
//Coloque a distancia que quer do inicio do cilindro
G4double safe_distance = 0.02*m;
//Coloque aqui o número de detetores
G4int num_detector = 32;
G4double total_safe = h_detector + safe_distance;
G4double delta_h = (2*h - 2*safe_distance - 4*h_detector)/(num_detector - 1);
......@@ -251,6 +255,8 @@ G4double final_pos = h - total_safe;
size = h;
delta = delta_h;
//colocando mais detetores
//Coloca os deteroes dentro do cilindro e coloca a sua posição em um vetor com push_back()
G4double pos1 = initial_pos;
positions.push_back(pos1);
......@@ -649,7 +655,8 @@ new G4PVPlacement(0,
//fScoringDetector = logicDetector;
//associando à um sensitive G4VSensitiveDetecto
//Associando os detetores à classe sensitive detector
auto sdman = G4SDManager::GetSDMpointer();
G4String SDname1;
......@@ -816,7 +823,8 @@ G4String SDname17;
//colocando cor vermelha para detector
//colocando cor vermelha para detectores
G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
worldVisAtt1->SetVisibility(true);
......
......@@ -77,6 +77,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
// accumulate statistics in run action
fRunAction->AddEdep(fEdep);
// pega as collections ID's
G4SDManager * SDman = G4SDManager::GetSDMpointer();
G4String detName;
......@@ -148,6 +149,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
B1HitsCollection* HitsCol31 = 0;
B1HitsCollection* HitsCol32 = 0;
//Pega os valores das colunas de cada Hit collection
if(HCE) {
HitsCol1 = (B1HitsCollection*)(HCE->GetHC(Col1));
......@@ -185,6 +187,8 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
}
//G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
//Abre um arquivo de saída para colocar os valores tirados da Hit collection
std::ofstream gammafile("gamma.txt");
std::ofstream mu_plusfile("mu+.txt");
std::ofstream mu_minusfile("mu-.txt");
......@@ -194,6 +198,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
std::ofstream anti_nu_mu_file("anti_nu_mu.txt");
//Cria um ponteiro para pegar informações da classe B1DetectorConstruction
detectorConstruction = (B1DetectorConstruction*) G4RunManager::GetRunManager()->GetUserDetectorConstruction();
G4cout << "tttttt" << G4endl;
......@@ -201,6 +206,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
half_height = detectorConstruction->get_size();
variation = detectorConstruction->get_delta();
//Retira os valores das Hit Collections
if(HitsCol1) {
G4cout << "test" << G4endl;
......@@ -741,7 +747,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
fparticles.clear();
}
//fecha os arquivos
gammafile.close();
mu_plusfile.close();
mu_minusfile.close();
......@@ -762,6 +768,7 @@ void B1EventAction::PrintParticles(std::map<const G4String, int>& container, std
G4cout << "N " << it->first << " : " << it->second << G4endl;
//FUTURO -> substituir por switch;
if(it->first == "gamma") {
//Escreve o valor no arquivo
gamma << it->second << " " << position << "\n";
isGamma = true;
} else if (it->first == "mu+") {
......@@ -823,6 +830,7 @@ void B1EventAction::WriteHistogram(const G4String name, G4int Detec) {
}
G4double B1EventAction::SetPosition(G4int detec) {
//coloca a origem no topo da atmosfera
G4int detec_index = detec - 1;
G4double first_value = dec_pos[0]/1000000;
G4cout << first_value << G4endl;
......
......@@ -79,7 +79,7 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
fParticleGun->SetParticlePosition(G4ThreeVector(0,0,-50.*m));
fParticleGun->SetParticlePosition(G4ThreeVector(0,0,-100.*m));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
......
......@@ -9,6 +9,7 @@
B1SD::B1SD(G4String SDname): G4VSensitiveDetector(SDname),
hitCollection(nullptr), HCID(-1) {
//cria a hit collection
G4cout << "Criando Hit Collection com nome: " << SDname <<G4endl;
collectionName.insert(SDname);
track_id = 0;
......@@ -21,19 +22,16 @@ B1SD::~B1SD() {
G4bool B1SD::ProcessHits(G4Step* step, G4TouchableHistory* ROhist) {
G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
//pega o nome da partícula
const G4String particle_name = step->GetTrack()->GetDynamicParticle()->GetParticleDefinition()->GetParticleName();
//G4cout << particle_def->GetParticleName() << G4endl;
//pega o Track relacionado à ela
G4int track = step->GetTrack()->GetTrackID();
/*
G4cout << sdname << G4endl;
G4cout << track << G4endl;
G4cout << track_id << G4endl;
*/
//Checa se a partícula é repetida
if (track == track_id) {
if (track == 0) {
B1Hits* hit = new B1Hits();
hit->set_partdef(particle_name);
//coloca o valor na hitCollecion
hitCollection->insert(hit);
track_id = track;
return true;
......
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