-
Notifications
You must be signed in to change notification settings - Fork 35
Adding SimEnergyDeposit filter module for systematics studies (mostly geared towards ICARUS but also general to both detectors) #486
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
12133ea
Initial commit of SimEnergyDeposit filter around defined rectangular …
1b10bbd
Update filter module for ICARUS systematic studies
b4221fd
Addressing review comments
38d1634
Addressing final comments
8f66947
Merge branch 'develop' into feature/jzettle_sedfilter
ibsafa 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
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 |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| /** | ||
| * @file sbncode/DetSim/FilterSimEnergyDeposits_module.cc | ||
| * @date October 17, 2024 | ||
| * @author Jacob Zettlemoyer | ||
| */ | ||
|
|
||
| #include "art/Framework/Core/EDProducer.h" | ||
| #include "art/Framework/Core/ModuleMacros.h" | ||
| #include "art/Framework/Principal/Event.h" | ||
| #include "canvas/Utilities/InputTag.h" | ||
| #include "fhiclcpp/ParameterSet.h" | ||
| #include "messagefacility/MessageLogger/MessageLogger.h" | ||
| #include "larcore/Geometry/Geometry.h" | ||
| #include "larcorealg/Geometry/GeometryCore.h" | ||
| #include "larcore/CoreUtils/ServiceUtil.h" | ||
| #include "larcorealg/Geometry/BoxBoundedGeo.h" | ||
|
|
||
| #include "lardataobj/Simulation/SimEnergyDeposit.h" | ||
|
|
||
| #include <memory> | ||
|
|
||
| class FilterSimEnergyDeposits; | ||
|
|
||
|
|
||
| class FilterSimEnergyDeposits : public art::EDProducer { | ||
| public: | ||
| explicit FilterSimEnergyDeposits(fhicl::ParameterSet const& p); | ||
| // The compiler-generated destructor is fine for non-base | ||
| // classes without bare pointers or other resource use. | ||
|
|
||
| // Plugins should not be copied or assigned. | ||
| FilterSimEnergyDeposits(FilterSimEnergyDeposits const&) = delete; | ||
| FilterSimEnergyDeposits(FilterSimEnergyDeposits&&) = delete; | ||
| FilterSimEnergyDeposits& operator=(FilterSimEnergyDeposits const&) = delete; | ||
| FilterSimEnergyDeposits& operator=(FilterSimEnergyDeposits&&) = delete; | ||
| // Required functions. | ||
| void produce(art::Event& e) override; | ||
|
|
||
| private: | ||
|
|
||
| // Declare member data here. | ||
|
|
||
| art::InputTag fInitSimEnergyDepositLabel; | ||
| geo::BoxBoundedGeo fBox; | ||
| static constexpr auto kModuleName = "FilterSimEnergyDeposit"; | ||
| double ShiftX(double z) const; | ||
| double fA; | ||
| double fB; | ||
| double fC; | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| FilterSimEnergyDeposits::FilterSimEnergyDeposits(fhicl::ParameterSet const& p) | ||
| : EDProducer{p} | ||
| , fInitSimEnergyDepositLabel{p.get<art::InputTag>("InitSimEnergyDepositLabel", "undefined")} | ||
| , fBox{p.get<double>("P1_X"), p.get<double>("P2_X"), | ||
| p.get<double>("P1_Y"), p.get<double>("P2_Y"), | ||
| p.get<double>("P1_Z"), p.get<double>("P2_Z")} | ||
| , fA{p.get<double>("A")} | ||
| , fB{p.get<double>("B")} | ||
| , fC{p.get<double>("C")} | ||
| { | ||
| // Call appropriate produces<>() functions here. | ||
| // Call appropriate consumes<>() for any products to be retrieved by this module. | ||
| produces<std::vector<sim::SimEnergyDeposit>>(); | ||
| } | ||
|
|
||
|
|
||
| double FilterSimEnergyDeposits::ShiftX(double z) const | ||
| { | ||
| //known as a "Hill equation" from fitting distribution of angle corrected tracks looking at the deflection as it gets closer to z = 0 | ||
| double a = fA; | ||
| double b = fB; | ||
| double c = fC; | ||
| double num = a*std::pow(z, b); | ||
| double denom = c + std::pow(z, b); | ||
| return num/denom; | ||
| } | ||
|
|
||
| void FilterSimEnergyDeposits::produce(art::Event& e) | ||
| { | ||
| auto const& simEDeps = | ||
| e.getProduct<std::vector<sim::SimEnergyDeposit>>(fInitSimEnergyDepositLabel); | ||
| auto pSimEDeps = std::make_unique<std::vector<sim::SimEnergyDeposit>>(); | ||
| pSimEDeps->reserve(simEDeps.size()); | ||
|
|
||
| for(auto const& sedep : simEDeps) | ||
| { | ||
| if(fBox.ContainsPosition(sedep.Start())) | ||
| continue; | ||
| art::ServiceHandle<geo::Geometry const> geom; | ||
| geo::TPCGeo const* TPC = geom->PositionToTPCptr(sedep.MidPoint()); | ||
| if(!TPC) { | ||
| mf::LogVerbatim(kModuleName) << "TPC ID not found! Not performing a shift!"; | ||
| } | ||
| const int numphotons = sedep.NumPhotons(); | ||
| const int numelectrons = sedep.NumElectrons(); | ||
| const double syratio = sedep.ScintYieldRatio(); | ||
| const double energy = sedep.Energy(); | ||
| geo::Point_t start = sedep.Start(); | ||
| if (TPC) TPC->DriftPoint(start, ShiftX(std::abs(sedep.Start().Z()))); | ||
| geo::Point_t end = sedep.End(); | ||
| if (TPC) TPC->DriftPoint(end, ShiftX(std::abs(sedep.End().Z()))); | ||
| const double startT = sedep.StartT(); | ||
| const double endT = sedep.EndT(); | ||
| const int thisID = sedep.TrackID(); | ||
| const int thisPDG = sedep.PdgCode(); | ||
| const int origID = sedep.OrigTrackID(); | ||
| pSimEDeps->push_back(sim::SimEnergyDeposit(numphotons, | ||
| numelectrons, | ||
| syratio, | ||
| energy, | ||
| start, | ||
| end, | ||
| startT, | ||
| endT, | ||
| thisID, | ||
| thisPDG, | ||
| origID)); | ||
| } | ||
| e.put(std::move(pSimEDeps)); | ||
| } | ||
|
|
||
| DEFINE_ART_MODULE(FilterSimEnergyDeposits) | ||
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 @@ | ||
| install_fhicl() |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add references to why these values are chosen, and maybe the units (cm) in some comment. |
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,19 @@ | ||
| BEGIN_PROLOG | ||
|
|
||
| simedepfilter_ind1gap: { | ||
| module_type: "FilterSimEnergyDeposits" | ||
| InitSimEnergyDepositLabel: "ionization" | ||
| P1_X: -400 #cm, create a box that spans the full x,y range. Not super-precise. | ||
| P1_Y: -200 #cm, create a box that spans the full x,y range. Not super-precise. | ||
| P1_Z: -2 #cm, one edge of the filtered gap based on the 37 mm total size of the wire gap | ||
| P2_X: 400 #cm, create a box that spans the full x,y range. Not super-precise. | ||
| P2_Y: 200 #cm, create a box that spans the full x,y range. Not super-precise. | ||
| P2_Z: 2 #cm, other edge of the filtered gap based on the 37 mm total size of the wire gap | ||
| #From SBN doc-db 38701: | ||
| A: -0.431172 | ||
| B: -2.52724 | ||
| C: 0.22043 | ||
| } | ||
|
|
||
|
|
||
| END_PROLOG |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use the three values directly below. Your choice.