Message: Recording the first hit inside a multi-chamber calorimeter Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Recording the first hit inside a multi-chamber calorimeter 

Forum: Hits, Digitization and Pileup
Date: 28 Sep, 2015
From: Daniele Paradiso <Daniele Paradiso>


I have been trying to modify Example B2a so that I can record the first hit of a neutron inside the calorimeter implemented in the example itself. My purpose is to know whether a neutron has passed through a target (which is the material of interest) or not, and I figured I should try to record the first hit in the calorimeter (i.e. the sensitive detector). First hit detection should already be implemented in the file I have modified, but the number of hits is always 0 even when I can see neutrons passed through target into the SD from the graphic visualization. I then tried to implement code using the GetStepStatus() method from the G4StepPoint class in order to retrieve the information on the 1st hit. Below I attach the code which is from Example B2a with my addition:

#include "B2EventAction.hh"

#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4ios.hh"

#include "G4StepPoint.hh"


B2EventAction::B2EventAction() : G4UserEventAction() {}


B2EventAction::~B2EventAction() {}


void B2EventAction::BeginOfEventAction(const G4Event*) {}



G4int no_hits = 0;
G4int total_no_hits = 0;
G4int B2EventAction::ProcessHits(G4StepPoint* firstStep)
    //First hit in calorimeter
    if (firstStep->GetStepStatus() == fGeomBoundary) no_hits=no_hits+1;                     
  total_no_hits = no_hits;

  return total_no_hits;



void B2EventAction::EndOfEventAction(const G4Event* event)
  // get number of stored trajectories

  G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer();
  G4int n_trajectories = 0;
  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();

  // periodic printing

  G4int eventID = event->GetEventID();
  //G4int no_hits = 0;
  //G4int no_passed = 0;
  if ( eventID < 100 || eventID % 100 == 0) {
    G4cout << ">>> Event: " << eventID  << G4endl;
    if ( trajectoryContainer ) {
      G4cout << "    " << n_trajectories
             << " trajectories stored in this event." << G4endl;
    G4VHitsCollection* hc = event->GetHCofThisEvent()->GetHC(0);
    G4cout << "    "  
           << hc->GetSize() << " hits stored in this event" << G4endl;
    G4cout << " " << total_no_hits << "neutrons have passed through the target." << G4endl;

Shouldn't "hc->GetSize()" give the information on the first hit?

"total_no_hits" is my G4int variable that should give the info on the 1st hit.

I would appreciate your help about how to detect the first hit. I might be looking at the wrong file to modify, and/or the wrong class/method. I definitely need to be directed to the appropriate tool to use.

Thank you very much in advance,

Daniele Paradiso

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Recording the first hit inside a multi-chamber calorimeter   (Tsukasa Aso - 28 Sep, 2015)
(_ None: Re: Recording the first hit inside a multi-chamber calorimeter   (Daniele Paradiso - 29 Sep, 2015)
 Add Message Add Message
to: "Recording the first hit inside a multi-chamber calorimeter"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]