LDMX Software
HcalSD.h
1#ifndef SIMCORE_HCALSD_H
2#define SIMCORE_HCALSD_H
3
4/*~~~~~~~~~~~~~~*/
5/* DetDescr */
6/*~~~~~~~~~~~~~~*/
7#include <algorithm>
8#include <string>
9#include <vector>
10
11#include "DetDescr/HcalID.h"
15#include "SimCore/SensitiveDetector.h"
16#include "SimCore/TrackMap.h"
17
18namespace simcore {
19
23class HcalSD : public SensitiveDetector {
24 public:
26 static const std::string COLLECTION_NAME;
27
35 HcalSD(const std::string& name, simcore::ConditionsInterface& ci,
36 const framework::config::Parameters& params);
37
39 virtual ~HcalSD() = default;
40
49 bool isSensDet(G4LogicalVolume* volume) const override {
50 auto region = volume->GetRegion();
51 if (region and region->GetName().contains("CalorimeterRegion")) {
52 const auto name{volume->GetName()};
53 return std::find_if(std::begin(gdmlIdentifiers_),
54 std::end(gdmlIdentifiers_),
55 [&name](const auto& identifier) {
56 return name.contains(identifier);
57 }) != std::end(gdmlIdentifiers_);
58 }
59 return false;
60 }
61
69 ldmx::HcalID decodeCopyNumber(const std::uint32_t copyNumber,
70 const G4ThreeVector& localPosition,
71 const G4Box* scint);
72
80 virtual G4bool ProcessHits(G4Step* aStep,
81 G4TouchableHistory* ROhist) override;
82
86 virtual void saveHits(framework::Event& event) override {
87 event.add(COLLECTION_NAME, hits_);
88 }
89
90 virtual void OnFinishedEvent() override { hits_.clear(); }
91
92 private:
93 // A list of identifiers used to find out whether or not a given logical
94 // volume is one of the Hcal sensitive detector volumes. Any volume that is
95 // part of the CalorimeterRegion region and has a name which contains at least
96 // one of the identifiers in here will be considered a sensitive detector in
97 // the Hcal.
98 std::vector<std::string> gdmlIdentifiers_;
99 // TODO: document!
100 double birksc1_;
101
102 // TODO: document!
103 double birksc2_;
104
105 // collection of hits to write to event bus
106 std::vector<ldmx::SimCalorimeterHit> hits_;
107
108}; // HcalSD
109
110} // namespace simcore
111
112#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:41
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
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:23
virtual void OnFinishedEvent() override
Cleanup SD and prepare a new-event state.
Definition HcalSD.h:90
ldmx::HcalID decodeCopyNumber(const std::uint32_t copyNumber, const G4ThreeVector &localPosition, const G4Box *scint)
Decode copy number of scintillator bar.
Definition HcalSD.cxx:29
bool isSensDet(G4LogicalVolume *volume) const override
Check if the input logical volume is a part of the hcal sensitive volumes.
Definition HcalSD.h:49
static const std::string COLLECTION_NAME
name of collection to be added to event bus
Definition HcalSD.h:26
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
Create a hit out of the energy deposition deposited during a step.
Definition HcalSD.cxx:57
virtual ~HcalSD()=default
Destructor.
virtual void saveHits(framework::Event &event) override
Add our hits to the event bus and then reset the container.
Definition HcalSD.h:86
Dynamically loaded Geant4 SensitiveDetector for saving hits in specific volumes within the simulation...