14 #ifndef GGSHITSACTION_H_
15 #define GGSHITSACTION_H_
19 #include "G4GenericMessenger.hh"
20 #include "G4HCofThisEvent.hh"
21 #include "G4LogicalVolumeStore.hh"
22 #include "G4PhysicalVolumeStore.hh"
24 #include "G4SDManager.hh"
25 #include "G4VHitsCollection.hh"
28 #include "TClonesArray.h"
30 #include "TObjString.h"
41 class GGSHitsMessenger;
44 #include <unordered_map>
171 void SetHitThreshold(
const std::string &detectorName,
const std::string &hitType,
const std::string &valueStr,
172 const std::string &unit);
175 G4GenericMessenger _messenger;
176 std::string _outFileBase;
180 TString _outTreeName;
183 struct OutputHandle {
184 std::string intHitClassName, partHitClassName, posHitClassName;
185 std::unique_ptr<GGSTClonesArrayService> partHitCAService, posHitCAService;
186 std::unique_ptr<TClonesArray> intHitArray;
187 std::unique_ptr<TObjArray> partHitArray, posHitArray;
188 float intHitThreshold, partHitThreshold, posHitThreshold;
190 : intHitClassName(
"GGSTIntHit"), partHitClassName(
"GGSTPartHit"), posHitClassName(
"GGSTPosHit"),
191 intHitThreshold(0.), partHitThreshold(0.), posHitThreshold(0.) {}
194 std::unordered_map<std::string, OutputHandle> _outputHandles;
196 struct ThresholdStruct {
197 std::string detectorName;
202 std::vector<ThresholdStruct> _thresholds;
204 void _GiveBackAllArrays();
216 void _Convert(
const GGSPosHitsCollection &posHits, TClonesArray &tPosHits, OutputHandle &handle);
242 void _Convert(
const GGSIntHitsCollection &intHits, TClonesArray &tIntHits, OutputHandle &handle,
243 const std::string &detectorName);
251 class GGSHitsActionPrivateMessenger :
public G4UImessenger {
266 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.