LDMX Software
HcalSD.h
1#ifndef SIMCORE_HCALSD_H
2#define SIMCORE_HCALSD_H
3
4/*~~~~~~~~~~~~~~*/
5/* DetDescr */
6/*~~~~~~~~~~~~~~*/
7#include <algorithm>
8#include <map>
9#include <string>
10#include <vector>
11
12#include "DetDescr/HcalID.h"
14#include "SimCore/SDs/SensitiveDetector.h"
15
16namespace simcore {
17
21class HcalSD : public SensitiveDetector {
22 public:
24 static const std::string COLLECTION_NAME;
25
33 HcalSD(const std::string& name, simcore::ConditionsInterface& ci,
34 const framework::config::Parameters& params);
35
37 virtual ~HcalSD() = default;
38
47 bool isSensDet(G4LogicalVolume* volume) const override {
48 auto region = volume->GetRegion();
49 if (region and region->GetName().contains("CalorimeterRegion")) {
50 const auto name{volume->GetName()};
51 return std::find_if(std::begin(gdml_identifiers_),
52 std::end(gdml_identifiers_),
53 [&name](const auto& identifier) {
54 return name.contains(identifier);
55 }) != std::end(gdml_identifiers_);
56 }
57 return false;
58 }
59
67 ldmx::HcalID decodeCopyNumber(const std::uint32_t copyNumber,
68 const G4ThreeVector& localPosition,
69 const G4Box* scint);
70
78 virtual G4bool ProcessHits(G4Step* aStep,
79 G4TouchableHistory* ROhist) override;
80
84 virtual void saveHits(framework::Event& event) override;
85
86 virtual void onFinishedEvent() override { hits_.clear(); }
87
88 private:
89 // A list of identifiers used to find out whether or not a given logical
90 // volume is one of the Hcal sensitive detector volumes. Any volume that is
91 // part of the CalorimeterRegion region and has a name which contains at least
92 // one of the identifiers in here will be considered a sensitive detector in
93 // the Hcal.
94 std::vector<std::string> gdml_identifiers_;
95 // TODO: document!
96 double birksc1_;
97
98 // TODO: document!
99 double birksc2_;
100
102 std::map<ldmx::HcalID, ldmx::SimCalorimeterHit> hits_;
109
110}; // HcalSD
111
112} // namespace simcore
113
114#endif // SIMCORE_HCALSD_H
Class that defines an HCal sensitive detector.
Class which stores simulated calorimeter hit information.
Implements an event buffer system for storing event data.
Definition Event.h:40
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
Handle to the conditions system, provided at construction to classes which require it.
Class defining a sensitive detector of type HCal.
Definition HcalSD.h:21
virtual void onFinishedEvent() override
Cleanup SD and prepare a new-event state.
Definition HcalSD.h:86
ldmx::HcalID decodeCopyNumber(const std::uint32_t copyNumber, const G4ThreeVector &localPosition, const G4Box *scint)
Decode copy number of scintillator bar.
Definition HcalSD.cxx:33
virtual void saveHits(framework::Event &event) override
Add our hits to the event bus and then reset the container.
Definition HcalSD.cxx:247
bool isSensDet(G4LogicalVolume *volume) const override
Check if the input logical volume is a part of the hcal sensitive volumes.
Definition HcalSD.h:47
bool compress_hit_contribs_
compress hit contribs
Definition HcalSD.h:106
static const std::string COLLECTION_NAME
name of collection to be added to event bus
Definition HcalSD.h:24
std::map< ldmx::HcalID, ldmx::SimCalorimeterHit > hits_
map of hits to add to the event (will be squashed)
Definition HcalSD.h:102
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
Create a hit out of the energy deposition deposited during a step.
Definition HcalSD.cxx:61
HcalSD(const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &params)
Constructor.
Definition HcalSD.cxx:24
virtual ~HcalSD()=default
Destructor.
bool enable_hit_contribs_
enable hit contribs
Definition HcalSD.h:104
int max_origin_track_id_
maximum track ID to be considered an "origin"
Definition HcalSD.h:108
Dynamically loaded Geant4 SensitiveDetector for saving hits in specific volumes within the simulation...
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...