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"
15#include "SimCore/G4User/TrackMap.h"
17#include "SimCore/SDs/SensitiveDetector.h"
18
19namespace simcore {
20
24class HcalSD : public SensitiveDetector {
25 public:
27 static const std::string COLLECTION_NAME;
28
36 HcalSD(const std::string& name, simcore::ConditionsInterface& ci,
37 const framework::config::Parameters& params);
38
40 virtual ~HcalSD() = default;
41
50 bool isSensDet(G4LogicalVolume* volume) const override {
51 auto region = volume->GetRegion();
52 if (region and region->GetName().contains("CalorimeterRegion")) {
53 const auto name{volume->GetName()};
54 return std::find_if(std::begin(gdml_identifiers_),
55 std::end(gdml_identifiers_),
56 [&name](const auto& identifier) {
57 return name.contains(identifier);
58 }) != std::end(gdml_identifiers_);
59 }
60 return false;
61 }
62
70 ldmx::HcalID decodeCopyNumber(const std::uint32_t copyNumber,
71 const G4ThreeVector& localPosition,
72 const G4Box* scint);
73
81 virtual G4bool ProcessHits(G4Step* aStep,
82 G4TouchableHistory* ROhist) override;
83
87 virtual void saveHits(framework::Event& event) override;
88
89 virtual void onFinishedEvent() override { hits_.clear(); }
90
91 private:
92 // A list of identifiers used to find out whether or not a given logical
93 // volume is one of the Hcal sensitive detector volumes. Any volume that is
94 // part of the CalorimeterRegion region and has a name which contains at least
95 // one of the identifiers in here will be considered a sensitive detector in
96 // the Hcal.
97 std::vector<std::string> gdml_identifiers_;
98 // TODO: document!
99 double birksc1_;
100
101 // TODO: document!
102 double birksc2_;
103
105 std::map<ldmx::HcalID, ldmx::SimCalorimeterHit> hits_;
112
113}; // HcalSD
114
115} // namespace simcore
116
117#endif // SIMCORE_HCALSD_H
Class that defines an HCal sensitive detector.
Class which represents a maximally-packed index of up to four fields.
Class which stores simulated calorimeter hit information.
Class which implements the user tracking action.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
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:24
virtual void onFinishedEvent() override
Cleanup SD and prepare a new-event state.
Definition HcalSD.h:89
ldmx::HcalID decodeCopyNumber(const std::uint32_t copyNumber, const G4ThreeVector &localPosition, const G4Box *scint)
Decode copy number of scintillator bar.
Definition HcalSD.cxx:31
virtual void saveHits(framework::Event &event) override
Add our hits to the event bus and then reset the container.
Definition HcalSD.cxx:245
bool isSensDet(G4LogicalVolume *volume) const override
Check if the input logical volume is a part of the hcal sensitive volumes.
Definition HcalSD.h:50
bool compress_hit_contribs_
compress hit contribs
Definition HcalSD.h:109
static const std::string COLLECTION_NAME
name of collection to be added to event bus
Definition HcalSD.h:27
std::map< ldmx::HcalID, ldmx::SimCalorimeterHit > hits_
map of hits to add to the event (will be squashed)
Definition HcalSD.h:105
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
Create a hit out of the energy deposition deposited during a step.
Definition HcalSD.cxx:59
HcalSD(const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &params)
Constructor.
Definition HcalSD.cxx:22
virtual ~HcalSD()=default
Destructor.
bool enable_hit_contribs_
enable hit contribs
Definition HcalSD.h:107
int max_origin_track_id_
maximum track ID to be considered an "origin"
Definition HcalSD.h:111
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 ...