#include "FCALStackingAction.hh" #include "FCALDetectorConstruction.hh" #include "FCALEventAction.hh" #include "G4ParticleTypes.hh" #include "G4ParticleDefinition.hh" #include "G4Track.hh" #include "G4ios.hh" #include "G4ThreeVector.hh" FCALStackingAction::FCALStackingAction(FCALEventAction* event_Act) : event_Action(event_Act) {} FCALStackingAction::~FCALStackingAction() {} G4ClassificationOfNewTrack FCALStackingAction::ClassifyNewTrack(const G4Track * aTrack) { // Condition: If the parent particle is Optical Photon and Secondary, then execute if (aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) { if ( aTrack->GetParentID() > 0 ) { // extract the x component of aTrack object. It will give you only the // number itself without any units, but I made sure that its unit is mm. G4double x_Position = (aTrack->GetPosition()).x(); // extract the y component of aTrack object. Also, you have to note that // this method gives the position in the global coordinate. G4double y_Position = (aTrack->GetPosition()).y(); // count optical photons event_Action->countPhotons(x_Position, y_Position); } } return fUrgent; }