-
Notifications
You must be signed in to change notification settings - Fork 13
add Calorimeter detector and output scheme #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gipert
wants to merge
4
commits into
main
Choose a base branch
from
calo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright (C) 2022 Luigi Pertoldi <https://orcid.org/0000-0002-0467-2571> | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify it under | ||
| // the terms of the GNU Lesser General Public License as published by the Free | ||
| // Software Foundation, either version 3 of the License, or (at your option) any | ||
| // later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, but WITHOUT | ||
| // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
| // details. | ||
| // | ||
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| #ifndef _RMG_CALORIMETER_DETECTOR_HH_ | ||
| #define _RMG_CALORIMETER_DETECTOR_HH_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "G4VSensitiveDetector.hh" | ||
|
|
||
| #include "RMGDetectorHit.hh" | ||
|
|
||
| class G4Step; | ||
| class G4HCofThisEvent; | ||
| class G4TouchableHistory; | ||
| /** @brief Class to describe the germanium detector, mainly handles processing of the detected hits. | ||
| * Extends @c G4VSensitiveDetector */ | ||
| class RMGCalorimeterDetector : public G4VSensitiveDetector { | ||
|
|
||
| public: | ||
|
|
||
| RMGCalorimeterDetector(); | ||
| ~RMGCalorimeterDetector() = default; | ||
|
|
||
| RMGCalorimeterDetector(RMGCalorimeterDetector const&) = delete; | ||
| RMGCalorimeterDetector& operator=(RMGCalorimeterDetector const&) = delete; | ||
| RMGCalorimeterDetector(RMGCalorimeterDetector&&) = delete; | ||
| RMGCalorimeterDetector& operator=(RMGCalorimeterDetector&&) = delete; | ||
|
|
||
| void Initialize(G4HCofThisEvent* hit_coll) override; | ||
|
|
||
| /** @brief Process the detected hits computing the various parameters of a @c | ||
| * RMGDetectorHit and then adding this to the hit collection.*/ | ||
| bool ProcessHits(G4Step* step, G4TouchableHistory* history) override; | ||
| void EndOfEvent(G4HCofThisEvent* hit_coll) override; | ||
|
|
||
| private: | ||
|
|
||
| RMGDetectorHitsCollection* fHitsCollection = nullptr; | ||
| }; | ||
|
|
||
|
|
||
| #endif | ||
|
|
||
| // vim: tabstop=2 shiftwidth=2 expandtab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (C) 2022 Luigi Pertoldi <https://orcid.org/0000-0002-0467-2571> | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify it under | ||
| // the terms of the GNU Lesser General Public License as published by the Free | ||
| // Software Foundation, either version 3 of the License, or (at your option) any | ||
| // later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, but WITHOUT | ||
| // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
| // details. | ||
| // | ||
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| #ifndef _RMG_CALORIMETER_OUTPUT_SCHEME_HH_ | ||
| #define _RMG_CALORIMETER_OUTPUT_SCHEME_HH_ | ||
|
|
||
| #include <memory> | ||
| #include <optional> | ||
| #include <set> | ||
|
|
||
| #include "G4AnalysisManager.hh" | ||
| #include "G4GenericMessenger.hh" | ||
|
|
||
| #include "RMGCalorimeterDetector.hh" | ||
| #include "RMGDetectorHit.hh" | ||
| #include "RMGOutputTools.hh" | ||
| #include "RMGVOutputScheme.hh" | ||
|
|
||
| class G4Event; | ||
| /** @brief Output scheme for Calorimeters. | ||
| * | ||
| * @details This output scheme records the hits in the Calorimeters. | ||
| * The properties of each @c RMGDetectorHit are recorded: | ||
| * - event index, | ||
| * - time, | ||
| * - energy deposition, | ||
| */ | ||
| class RMGCalorimeterOutputScheme : public RMGVOutputScheme { | ||
|
|
||
| public: | ||
|
|
||
| RMGCalorimeterOutputScheme() {}; | ||
|
|
||
| /** @brief Sets the names of the output columns, invoked in @c RMGRunAction::SetupAnalysisManager */ | ||
| void AssignOutputNames(G4AnalysisManager* ana_man) override; | ||
|
|
||
| /** @brief Store the information from the event, invoked in @c RMGEventAction::EndOfEventAction | ||
| * @details Only steps with non-zero energy are stored, unless @c fDiscardZeroEnergyHits is false. | ||
| */ | ||
| void StoreEvent(const G4Event* event) override; | ||
|
|
||
| protected: | ||
|
|
||
| [[nodiscard]] std::string GetNtupleNameFlat() const override { return "calorimeter"; } | ||
|
|
||
| private: | ||
|
|
||
| RMGDetectorHitsCollection* GetHitColl(const G4Event*); | ||
| }; | ||
|
|
||
| #endif | ||
|
|
||
| // vim: tabstop=2 shiftwidth=2 expandtab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,17 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from collections import defaultdict | ||
|
|
||
|
|
||
| def _to_list(thing): | ||
| if not isinstance(thing, tuple | list): | ||
| return [thing] | ||
| return thing | ||
|
|
||
|
|
||
| def _icp_to_dict(thing): | ||
| d = defaultdict(list) | ||
| for k, v in thing: | ||
| d[k].append(v) | ||
|
|
||
| return dict(d) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.