-
Notifications
You must be signed in to change notification settings - Fork 54
MC PMT Software Trigger + Trigger Subdirectory Reorganization #875
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 18 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7c39515
first commit of offline pmtmetricsproducer (same as daq module), with…
lynnt20 c09be65
update to recent daq config
lynnt20 d6bffea
flash peak pe bug fix
lynnt20 dddb506
first commit of working MC software trigger producer
lynnt20 6c8f7e8
missing trig_ts in trig_metrics
lynnt20 d678d2e
create new subdirectory for software trigger thats in use
lynnt20 a3810cd
clean up cmakelists
lynnt20 ba13126
additions to keep offline same as online
lynnt20 98c76d5
remove ttree and update padding
lynnt20 a887bbb
simple readme
lynnt20 28647f5
clean up fcls, update metric labels to reflect current daq config
lynnt20 295670f
add config fcl for mc producer module
lynnt20 9c30759
add software trigger to detsim
lynnt20 736e8e2
add software trigger labels to cafmaker
lynnt20 62a399d
add software metric labels to cafmaker
lynnt20 1454ed4
update stream type to match daq config
lynnt20 7b4d608
undo changes AKA move fcls back to PMT subdirectory
lynnt20 7dfe7ce
restore deleted CMakeList
lynnt20 6d53206
rename producers to be consistent with daq config, add instance name …
lynnt20 30b810b
add fcl configurable ADC to PE conversion
lynnt20 634ad1c
add fcl configurable ADC to PE conversion
lynnt20 16bf1c4
update to the Run1 producer labels for pmtmetric in the DAQ
lynnt20 48c16c2
Merge branch 'develop' into feature/lynnt_Fall25_pmtmetrics
lynnt20 b938fe1
remove semicolon throwing fhicl error
lynnt20 12270a9
add pmtmetricmc config line and the `sbnd` tag to the config fcl
lynnt20 c498083
whoops
lynnt20 f9aac5d
add both run1/run2 daq labels
lynnt20 bc1008e
Merge branch 'develop' into feature/lynnt_Fall25_pmtmetrics
nathanielerowe 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
1 change: 1 addition & 0 deletions
1
sbndcode/JobConfigurations/standard/caf/cafmakerjob_sbnd_data_bnblight.fcl
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,3 +1,4 @@ | ||
| #include "cafmakerjob_sbnd_data_base.fcl" | ||
|
|
||
| physics.producers.cafmaker.BNBPOTDataLabel: "bnbinfo" | ||
| physics.producers.cafmaker.SBNDSoftwareTriggerLabel: "pmtmetricbnb" |
1 change: 1 addition & 0 deletions
1
sbndcode/JobConfigurations/standard/caf/cafmakerjob_sbnd_data_bnbzerobias.fcl
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,3 +1,4 @@ | ||
| #include "cafmakerjob_sbnd_data_base.fcl" | ||
|
|
||
| physics.producers.cafmaker.BNBPOTDataLabel: "sbndbnbzerobiasinfo" | ||
| physics.producers.cafmaker.SBNDSoftwareTriggerLabel: "pmtmetricbnb" |
1 change: 1 addition & 0 deletions
1
sbndcode/JobConfigurations/standard/caf/cafmakerjob_sbnd_data_offbeamlight.fcl
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,3 +1,4 @@ | ||
| #include "cafmakerjob_sbnd_data_base.fcl" | ||
|
|
||
| physics.producers.cafmaker.OffbeamBNBCountDataLabel: "bnbextinfo" | ||
| physics.producers.cafmaker.SBNDSoftwareTriggerLabel: "pmtmetricoffbeam" |
1 change: 1 addition & 0 deletions
1
sbndcode/JobConfigurations/standard/caf/cafmakerjob_sbnd_data_sce_bnblight.fcl
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,3 +1,4 @@ | ||
| #include "cafmakerjob_sbnd_data_sce.fcl" | ||
|
|
||
| physics.producers.cafmaker.BNBPOTDataLabel: "bnbinfo" | ||
| physics.producers.cafmaker.SBNDSoftwareTriggerLabel: "pmtmetricbnb" |
1 change: 1 addition & 0 deletions
1
sbndcode/JobConfigurations/standard/caf/cafmakerjob_sbnd_data_sce_bnbzerobias.fcl
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,3 +1,4 @@ | ||
| #include "cafmakerjob_sbnd_data_sce.fcl" | ||
|
|
||
| physics.producers.cafmaker.BNBPOTDataLabel: "sbndbnbzerobiasinfo" | ||
| physics.producers.cafmaker.SBNDSoftwareTriggerLabel: "pmtmetricbnb" |
1 change: 1 addition & 0 deletions
1
sbndcode/JobConfigurations/standard/caf/cafmakerjob_sbnd_data_sce_offbeamlight.fcl
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,3 +1,4 @@ | ||
| #include "cafmakerjob_sbnd_data_sce.fcl" | ||
|
|
||
| physics.producers.cafmaker.OffbeamBNBCountDataLabel: "bnbextinfo" | ||
| physics.producers.cafmaker.SBNDSoftwareTriggerLabel: "pmtmetricoffbeam" |
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
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,35 @@ | ||
| set( | ||
| MODULE_LIBRARIES | ||
| sbndcode_OpDetSim | ||
| lardataobj::RawData | ||
| art::Framework_Core | ||
| art::Framework_Principal | ||
| art::Framework_Services_Registry | ||
| art_root_io::tfile_support | ||
| art_root_io::TFileService_service | ||
| artdaq_core::artdaq-core_Data | ||
| artdaq_core::artdaq-core_Utilities | ||
| sbnobj::SBND_Timing | ||
| sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays | ||
| sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_Common | ||
| sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_SBND | ||
| sbndaq_artdaq_core::sbndaq-artdaq-core_Obj_SBND | ||
| canvas::canvas | ||
| messagefacility::MF_MessageLogger | ||
| fhiclcpp::fhiclcpp | ||
| cetlib::cetlib | ||
| CLHEP::CLHEP | ||
| ROOT::Core | ||
| ROOT::Tree | ||
| ) | ||
|
|
||
| cet_build_plugin(MetricAnalyzer art::module SOURCE MetricAnalyzer_module.cc LIBRARIES ${MODULE_LIBRARIES}) | ||
| cet_build_plugin(MetricFilter art::module SOURCE MetricFilter_module.cc LIBRARIES ${MODULE_LIBRARIES}) | ||
| cet_build_plugin(PMTMetricProducer art::module SOURCE PMTMetricProducer_module.cc LIBRARIES ${MODULE_LIBRARIES}) | ||
| cet_build_plugin(PMTMCMetricProducer art::module SOURCE PMTMCMetricProducer_module.cc LIBRARIES ${MODULE_LIBRARIES}) | ||
|
|
||
| add_subdirectory(fcls) | ||
|
|
||
| install_headers() | ||
| install_fhicl() | ||
| install_source() |
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
169 changes: 169 additions & 0 deletions
169
sbndcode/Trigger/PMTSoftware/PMTMCMetricProducer_module.cc
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,169 @@ | ||
| //////////////////////////////////////////////////////////////////////// | ||
| // Class: PMTMCMetricProducer | ||
| // Plugin Type: producer (Unknown Unknown) | ||
| // File: PMTMCMetricProducer_module.cc | ||
| // | ||
| // Generated at Mon Nov 10 11:37:29 2025 by Lynn Tung using cetskelgen | ||
| // from cetlib version 3.18.02. | ||
| // An MC version of the PMTMetricProducer (PMT Software Trigger). | ||
| // Creates a 10 us "flash" by summing waveforms around the beam spill. | ||
| // Input: raw::OpDetWaveforms from optical simualtion | ||
| // Output:: std::vector<sbnd::trigger::pmtSoftwareTrigger>> | ||
| //////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #include "art/Framework/Core/EDProducer.h" | ||
| #include "art/Framework/Core/ModuleMacros.h" | ||
| #include "art/Framework/Principal/Event.h" | ||
| #include "art/Framework/Principal/Handle.h" | ||
| #include "art/Framework/Principal/Run.h" | ||
| #include "art/Framework/Principal/SubRun.h" | ||
| #include "canvas/Utilities/InputTag.h" | ||
| #include "fhiclcpp/ParameterSet.h" | ||
| #include "messagefacility/MessageLogger/MessageLogger.h" | ||
|
|
||
| #include "sbndcode/OpDetSim/sbndPDMapAlg.hh" | ||
|
|
||
| #include "lardataobj/RawData/OpDetWaveform.h" | ||
| #include "sbndaq-artdaq-core/Obj/SBND/pmtSoftwareTrigger.hh" | ||
|
|
||
| #include <algorithm> | ||
| #include <memory> | ||
|
|
||
| #include <TTree.h> | ||
| #include <string.h> | ||
| #include "TH1D.h" | ||
| #include "TFile.h" | ||
|
|
||
| namespace sbnd { | ||
| namespace trigger { | ||
| class PMTMCMetricProducer; | ||
| } | ||
| } | ||
|
|
||
| class sbnd::trigger::PMTMCMetricProducer : public art::EDProducer { | ||
| public: | ||
| explicit PMTMCMetricProducer(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. | ||
| PMTMCMetricProducer(PMTMCMetricProducer const&) = delete; | ||
| PMTMCMetricProducer(PMTMCMetricProducer&&) = delete; | ||
| PMTMCMetricProducer& operator=(PMTMCMetricProducer const&) = delete; | ||
| PMTMCMetricProducer& operator=(PMTMCMetricProducer&&) = delete; | ||
|
|
||
| // Required functions. | ||
| void produce(art::Event& e) override; | ||
|
|
||
| private: | ||
|
|
||
| art::ServiceHandle<art::TFileService> tfs; | ||
| std::vector <std::string> fPDTypes; | ||
| std::string OpDetWaveformsLabel; | ||
| opdet::sbndPDMapAlg fPDSMap; | ||
| float fStartTime; | ||
|
|
||
| float us_to_ticks = 500.; | ||
| float ticks_to_us = 1./us_to_ticks; | ||
|
|
||
| std::vector <int> fChannelsToIgnore; | ||
| std::vector<uint32_t> sumWvfms(const std::vector<uint32_t>& v1, const std::vector<int16_t>& v2); | ||
| float estimateBaseline(std::vector<uint32_t> wvfm); | ||
| }; | ||
|
|
||
|
|
||
| sbnd::trigger::PMTMCMetricProducer::PMTMCMetricProducer(fhicl::ParameterSet const& p) | ||
| : EDProducer{p} // , | ||
| // More initializers here. | ||
| { | ||
| fPDTypes = p.get<std::vector<std::string>>("PDTypes"); | ||
| OpDetWaveformsLabel = p.get< std::string >("OpDetWaveformsLabel"); | ||
| fStartTime = p.get<float>("StartTime"); | ||
| fChannelsToIgnore = p.get<std::vector<int>>("ChannelsToIgnore",{}); | ||
|
|
||
| // Call appropriate produces<>() functions here. | ||
| produces< std::vector<sbnd::trigger::pmtSoftwareTrigger>>(); | ||
| // Call appropriate consumes<>() for any products to be retrieved by this module. | ||
| } | ||
|
|
||
| void sbnd::trigger::PMTMCMetricProducer::produce(art::Event& e) | ||
| { | ||
|
|
||
| std::unique_ptr<std::vector<sbnd::trigger::pmtSoftwareTrigger>> trig_metrics_v = std::make_unique<std::vector<sbnd::trigger::pmtSoftwareTrigger>>(); | ||
| sbnd::trigger::pmtSoftwareTrigger trig_metrics; | ||
|
|
||
| art::Handle< std::vector< raw::OpDetWaveform > > wvfHandle; | ||
| e.getByLabel(OpDetWaveformsLabel, wvfHandle); | ||
| if(!wvfHandle.isValid() || wvfHandle->size() == 0){ | ||
| std::cout << "RawWaveform with label " << OpDetWaveformsLabel << " not found..." << std::endl; | ||
| e.put(std::move(trig_metrics_v)); | ||
| return; | ||
| } | ||
|
|
||
| // hardcoded to match match data! | ||
| size_t flash_len=5000; | ||
| std::vector<uint32_t> flash(flash_len, 0); | ||
|
|
||
| float readout_start = fStartTime; | ||
| float readout_end = readout_start + flash_len*ticks_to_us; | ||
|
|
||
| int counter=0; | ||
| for(auto const& wvf : (*wvfHandle)) { | ||
| int wvf_ch = wvf.ChannelNumber(); | ||
| auto wvf_ts = wvf.TimeStamp(); | ||
| auto wvf_end = wvf_ts+wvf.Waveform().size()*ticks_to_us; | ||
|
|
||
| if (wvf_end < readout_start || wvf_ts > readout_end ) continue; | ||
| if (std::find(fChannelsToIgnore.begin(), fChannelsToIgnore.end(), wvf_ch) != fChannelsToIgnore.end() ) continue; | ||
| if (std::find(fPDTypes.begin(), fPDTypes.end(), fPDSMap.pdType(wvf_ch) ) == fPDTypes.end() ) continue; | ||
|
|
||
| // find where readout_start is | ||
| if (wvf_ts <= readout_start && wvf_end >= readout_end){ | ||
| int offset = int((readout_start - wvf_ts)*us_to_ticks); | ||
| std::vector<short> wvfm_snippet(wvf.Waveform().begin() + offset, wvf.Waveform().begin() + offset + flash_len); | ||
| flash = sumWvfms(flash, wvfm_snippet); | ||
| counter++; | ||
| } | ||
| } | ||
|
|
||
| auto flash_baseline = estimateBaseline(flash); | ||
| auto flash_peak_it = std::min_element(flash.begin(),flash.end()); | ||
| auto flash_peakpe = (flash_baseline-(*flash_peak_it))/12.5; | ||
| auto flash_peaktime = ((flash_peak_it-flash.begin()))*ticks_to_us + readout_start; | ||
|
|
||
| trig_metrics.foundBeamTrigger = true; | ||
| trig_metrics.nAboveThreshold = counter; | ||
| trig_metrics.promptPE = 0; | ||
| trig_metrics.prelimPE = 0; | ||
| trig_metrics.peakPE = flash_peakpe; | ||
| trig_metrics.peaktime = flash_peaktime; | ||
| trig_metrics.trig_ts = 0; | ||
| trig_metrics_v->push_back(trig_metrics); | ||
|
|
||
| e.put(std::move(trig_metrics_v)); | ||
| } | ||
|
|
||
|
|
||
| std::vector<uint32_t> sbnd::trigger::PMTMCMetricProducer::sumWvfms(const std::vector<uint32_t>& v1, | ||
| const std::vector<int16_t>& v2) | ||
| { | ||
| size_t result_len = (v1.size() > v2.size()) ? v1.size() : v2.size(); | ||
| std::vector<uint32_t> result(result_len,0); | ||
| for (size_t i = 0; i < result_len; i++){ | ||
| auto value1 = (i < v1.size()) ? v1[i] : 2e4; | ||
| auto value2 = (i < v2.size()) ? v2[i] : 2e4; | ||
| result.at(i) = value1 + uint32_t(value2); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
|
|
||
| float sbnd::trigger::PMTMCMetricProducer::estimateBaseline(std::vector<uint32_t> wvfm){ | ||
| // use a copy of 'wvfm' because nth_element might do something weird! | ||
| const auto median_it = wvfm.begin() + wvfm.size() / 2; | ||
| std::nth_element(wvfm.begin(), median_it , wvfm.end()); | ||
| auto median = *median_it; | ||
| return median; | ||
| } | ||
|
|
||
| DEFINE_ART_MODULE(sbnd::trigger::PMTMCMetricProducer) | ||
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.