Counting number of hits

Geant4 Version: 11.2.1
_Operating System: Windows 10
_Compiler/Version: g++
_CMake Version: 3.29

In my simple adaptation of the B1 example, I would like to know how to count and then output the number of times a detector is hit by a particle. I assumed you had to turn a logical volume into a sensitive detector and then set up SensitiveDetector.hh and files. Is this the wrong approach to something as simple as counting the number of times a detector is hit? I’ve attached my code below if that helps for anyone.

DetectorConstruction.hh (2.5 KB) (5.2 KB)

SensitiveDetector.hh (529 Bytes) (330 Bytes)