14 #ifndef GGSHITSACTION_H_
15 #define GGSHITSACTION_H_
20 #include "G4LogicalVolumeStore.hh"
21 #include "G4PhysicalVolumeStore.hh"
22 #include "G4HCofThisEvent.hh"
23 #include "G4VHitsCollection.hh"
24 #include "G4SDManager.hh"
25 #include "G4GenericMessenger.hh"
29 #include "TObjString.h"
32 #include "TClonesArray.h"
41 class GGSHitsMessenger;
44 #include <unordered_map>
118 _outFileBase = outFileBase;
129 _outTreeName = outTreeName;
175 void SetHitThreshold(
const std::string &detectorName,
const std::string &hitType,
const std::string &valueStr,
176 const std::string &unit);
180 G4GenericMessenger _messenger;
181 std::string _outFileBase;
185 TString _outTreeName;
188 struct OutputHandle {
189 std::string intHitClassName, partHitClassName, posHitClassName;
190 std::unique_ptr<GGSTClonesArrayService> partHitCAService, posHitCAService;
191 std::unique_ptr<TClonesArray> intHitArray;
192 std::unique_ptr<TObjArray> partHitArray, posHitArray;
193 float intHitThreshold, partHitThreshold, posHitThreshold;
195 intHitClassName(
"GGSTIntHit"), partHitClassName(
"GGSTPartHit"), posHitClassName(
"GGSTPosHit"), intHitThreshold(
196 std::numeric_limits<float>::lowest()), partHitThreshold(std::numeric_limits<float>::lowest()), posHitThreshold(
197 std::numeric_limits<float>::lowest()) {
201 std::unordered_map<std::string, OutputHandle> _outputHandles;
203 struct ThresholdStruct {
204 std::string detectorName;
209 std::vector<ThresholdStruct> _thresholds;
211 void _GiveBackAllArrays();
221 void _Convert(
const GGSPosHitsCollection &posHits, TClonesArray &tPosHits, OutputHandle &handle);
243 void _Convert(
const GGSIntHitsCollection &intHits, TClonesArray &tIntHits, OutputHandle &handle,
244 const std::string &detectorName);
252 class GGSHitsActionPrivateMessenger:
public G4UImessenger {
267 void SetNewValue(G4UIcommand *command, G4String newValue);
269 std::unique_ptr<G4UIcommand> _setThreshCmd;
273 friend class GGSHitsActionPrivateMessenger;
274 GGSHitsActionPrivateMessenger _privateMessenger;
G4THitsCollection< GGSPosHit > GGSPosHitsCollection
Alias for G4 template hits collection for GGSPosHit.
void EndOfRunAction(const G4Run *run)
Actions executed at end of run.
void SetOutputTreeName(const std::string &outTreeName)
Sets the output tree name.
void SetHitThreshold(const std::string &detectorName, const std::string &hitType, const std::string &valueStr, const std::string &unit)
Sets a lower energy deposit threshold for hits.
GGSHitsAction()
Constructor.
~GGSHitsAction()
Destructor.
void EndOfEventAction(const G4Event *event)
Actions executed at end of event.
void BeginOfEventAction(const G4Event *event)
Actions executed at beginning of event.
void BeginOfRunAction(const G4Run *run)
Actions executed at beginning of run.
G4THitsCollection< GGSIntHit > GGSIntHitsCollection
Alias for G4 template hits collection for GGSIntHit.
void SetOutputPartHitClass(std::string detectorName, const std::string &className)
Sets the name of the particle hit class to be used for output.
An action which saves hits in sensitive volumes on ROOT file.
G4THitsCollection< GGSPartHit > GGSPartHitsCollection
Alias for G4 template hits collection for GGSPartHit.
Mother class for user actions in GGS.
void SetOutputPosHitClass(std::string detectorName, const std::string &className)
Sets the name of the position hit class to be used for output.
void SetOutputFileBase(const std::string &outFileBase)
Sets the output file base name.
void SetOutputIntHitClass(std::string detectorName, const std::string &className)
Sets the name of the integrated hit class to be used for output of a given detector.