print hitCollections

parent 781cda35
......@@ -114,7 +114,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//Coloque aqui o número de detetores ao longo do cilindro
G4int num_detector_longitudinal = 30;
G4int num_detector_longitudinal = 10;
number_detectors_longitudinal = num_detector_longitudinal;
......@@ -132,7 +132,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
detector = new G4Tubs("detector", raio_i, raio_e, h_detector, theta_0, theta_f);
G4int num_radial_detectors = 5;
G4int num_radial_detectors = 5 ;
number_detectors_radial = num_radial_detectors;
G4int delta_r = raio_e/num_radial_detectors;
......
......@@ -77,14 +77,17 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
// accumulate statistics in run action
fRunAction->AddEdep(fEdep);
/*
// pega as collections ID's
G4SDManager * SDman = G4SDManager::GetSDMpointer();
G4HCofThisEvent* HCE = event->GetHCofThisEvent();
G4int num_event = event->GetEventID();
detectorConstruction = (B1DetectorConstruction*) G4RunManager::GetRunManager()->GetUserDetectorConstruction();
G4int num = detectorConstruction->return_num_detec();
dec_pos = detectorConstruction->GetPositions();
G4int num_longitudinal = detectorConstruction->return_num_detec_longitudinal();
G4int num_radial = detectorConstruction->return_num_detec_radial();
dec_pos = detectorConstruction->GetPositions();
half_height = detectorConstruction->get_size();
variation = detectorConstruction->get_delta();
......@@ -96,27 +99,26 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
std::ofstream anti_nu_e_file("anti_nu_e" + std::to_string(num_event) + ".txt");
std::ofstream anti_nu_mu_file("anti_nu_mu" + std::to_string(num_event) + ".txt");
std::vector<G4int> col;
std::vector<B1HitsCollection*> HitsCol;
std::vector<std::vector <G4int> > col(num_radial, std::vector <G4int>(num_longitudinal));
std::vector<std::vector <B1HitsCollection*> > HitsCol(num_radial, std::vector<B1HitsCollection*>(num_longitudinal));
col.reserve(num);
HitsCol.reserve(num);
for(G4int i=0; i < num_radial; i++) {
for(G4int j = 0; j < num_longitudinal; j++ ) {
for(G4int i=0; i < num; i++) {
col[i] = SDman->GetCollectionID("SD" + std::to_string(i + 1));
col[i][j] = SDman->GetCollectionID("SD" + std::to_string(i) + std::to_string(j));
if(HCE) {
HitsCol[i] = (B1HitsCollection*)(HCE->GetHC(col[i]));
HitsCol[i][j] = (B1HitsCollection*)(HCE->GetHC(col[i][j]));
}
if(HitsCol[i]) {
if(HitsCol[i][j]) {
G4double pos_detec = SetPosition(i + 1);
int n_hit = HitsCol[i]->entries();
G4cout << "My detector " + std::to_string(i+1) +" has " << n_hit << "hits" << G4endl;
int n_hit = HitsCol[i][j]->entries();
G4cout << "My detector " + std::to_string(i) + std::to_string(j) + " has " << n_hit << "hits" << G4endl;
B1Hits* hit = new B1Hits;
std::map<const G4String, int> fparticles;
for(int i1 = 0; i1 < n_hit; i1++) {
B1Hits* hit = (*HitsCol[i])[i1];
B1Hits* hit = (*HitsCol[i][j])[i1];
const G4String name = hit->getParticleInTarget();
//G4cout << name << G4endl;
fparticles[name]++;
......@@ -126,6 +128,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
fparticles.clear();
}
}
}
gammafile.close();
mu_plusfile.close();
......@@ -134,7 +137,7 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
nu_mu_file.close();
anti_nu_e_file.close();
anti_nu_mu_file.close();
*/
}
......
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