print particles in detector

parent ced79486
......@@ -32,6 +32,8 @@
#include "G4UserEventAction.hh"
#include "globals.hh"
#include <map>
#include "G4ParticleDefinition.hh"
class B1RunAction;
......@@ -46,8 +48,9 @@ class B1EventAction : public G4UserEventAction
virtual void BeginOfEventAction(const G4Event* event);
virtual void EndOfEventAction(const G4Event* event);
void PrintParticles(std::map<const G4String, int>& container);
void AddEdep(G4double edep) { fEdep += edep; }
void AddEdep(G4double edep) { fEdep += edep; };
private:
B1RunAction* fRunAction;
......
......@@ -40,6 +40,9 @@
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
using namespace std;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1EventAction::B1EventAction(B1RunAction* runAction)
......@@ -83,12 +86,28 @@ void B1EventAction::EndOfEventAction(const G4Event* event)
if(HitsCol) {
int n_hit = HitsCol->entries();
G4cout << "My detector has " << n_hit << "hits" << G4endl;
for(int i1 = 0; i1 < n_hit; i1++) {
B1Hits* hit = new B1Hits;
std::map<const G4String, int> fparticles;
for(int i1 = 0; i1 < n_hit; i1++) {
B1Hits* hit = (*HitsCol)[i1];
const G4String name = hit->getParticleInTarget();
//G4cout << name << G4endl;
fparticles[name]++;
}
PrintParticles(fparticles);
}
}
void B1EventAction::PrintParticles(std::map<const G4String, int>& container) {
std::map<const G4String, int>::iterator it;
G4cout << "Número de párticulas identificadas no detetor: " << G4endl;
for(it = container.begin() ;it != container.end(); it ++)
{
G4cout << "N " << it->first << " : " << it->second << G4endl;
}
}
//....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