Skip to content

Optical sim/reco and overlay updates - #892

Open
mvicenzi wants to merge 166 commits into
release/SBN2025Afrom
feature/pmtsim_gain
Open

Optical sim/reco and overlay updates#892
mvicenzi wants to merge 166 commits into
release/SBN2025Afrom
feature/pmtsim_gain

Conversation

@mvicenzi

@mvicenzimvicenzi commented Apr 1, 2026

Copy link
Copy Markdown
Member

This PR contains the required updates and fhicls to enable the reprocessing of light products for the SBN2025 spring productions (both MC and data). In particular, it includes fixes to the trigger/overlays procedure, as well as model improvements such as the use of time-dependent gain and pmt status databases.

Some highlights:

  • added new MC2 tune (SPR + sim gain tune)
  • added new MC3/4 tune (SPR + sim gain tune)
  • noise in MC waveforms for overlays turned off
  • introduced new PMT overlays module
  • updated trigger shifting module to emit shifted trigger reference
  • added DetectorClocksService configuration overrides for simulation
  • introduced new simulation of timing delays from database in detsim overlays
  • introduced new PMT channel status/voltage database for both detsim and stage0
  • introduced new interface to the PMT gain database in detsim and stage0 for MC-overlays/data
  • introduced new OpHit recalibrator module for data
  • formally enforced same reconstruction algorithms for data and MC (including pedestal's)
  • switched optical reconstruction entry point to local module
  • re-tuned flash PE thresholds based on new PE scale
  • added optional debug tree in optical detsim module
  • updated FHiCLs for database use in MC-overlays/data (fixed/constant values still used for legacy MC)
  • added run number overrides for calibration services
  • added vertical track selection module
  • added DetSim + Overlay stage reprocessing fhicl(s)
  • added “MCStage0” reprocessing fhicl(s)
  • added data “stage0” reprocessing fhicl(s)
  • enfocing use of shared GENIE configuration from sbncode
  • fixes on CRT hit time reconstruction for simulation and overlays

This PR requires three icarus_data updates:

  • new SPR response files
  • pmt_speareas_data.db to v1r2
  • pmt_voltage_data.db to v1r3

These requirements are satisfied by icarus_data v10_20_04.

This PR depends on:

(this PR includes developements previously discussed in #876 and #785 )

mvicenziand others added 30 commits May 23, 2025 00:17
…plate
It used to end when the template SPR goes under 1e-4 ADC#.
Now it needs to stay within +/- 1w-4 ADC# for 20 nanoseconds.
This should make it possible to include undershootings.
All these parameters are currently hard-coded.
Good catches on names and strings.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Trigger simulation modules now support input tags with process name [private]
…ples
It allows the creation of a raw::trigger data product with the shifted time reference,
which AdjustSimForTrigger module used not to produce (newer one does).
By default changes are applied to all gate types (used to be to unknown only).
In addition, maintenance changes:
- added debug messages;
- moved some of the code of general use to `icarusalg` (sbn::BeamTime enumerator and selector);
would be more impressive if the selector mechanism supported `fhicl::Sequence`,
which it does not because support of `fhicl::Atom` was enough of a hack already.
This module allows to print explicitly which data product is picked
when an input tag is specified at a certain step of the execution chain.
For example, it would expand a `std::vector<sim::SimPhotons>` tag
"shifted" to `shifted::DetSim`, or claim no data product matches.
@PetrilloAtWork
PetrilloAtWork changed the base branch from release/SBN2025A to migrate/SBN2025AJune 12, 2026 22:50
@PetrilloAtWork
PetrilloAtWork changed the base branch from migrate/SBN2025A to release/SBN2025AJune 12, 2026 22:51

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ICARUS optical simulation/reconstruction and overlay workflows to support SBN2025 spring reprocessing (MC + data), including new/updated database-backed calibrations (PMT gain, PMT channel status, PMT timing), trigger/beam-gate handling changes, and a set of new/updated FHiCL “partial” configs for targeted reprocessing.

Changes:

  • Introduces DB-backed PMT channel status and SPE-area (gain) calibration services, and wires them into stage0/detsim/simulation service stacks.
  • Refactors trigger/beam-gate configuration and multiple trigger modules to use art::InputTag consistently, plus adds shifting/overlay workflow updates.
  • Adds/updates many reprocessing/partial FHiCLs for detsim, overlay, and stage0/stage1, and adjusts build system dependencies accordingly.

Reviewed changes

Copilot reviewed 138 out of 138 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
scripts/manageDataRunDefinitions.pyExtends SAM-definition tooling (raw/compressedraw, extra dims, suffix).
icaruscode/Utilities/CMakeLists.txtAdds new DataProductReader plugin build target.
icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/CMakeLists.txtUpdates DetectorClocksService linkage.
icaruscode/Timing/timing_icarus.fclAdds run-number override option for PMT timing service.
icaruscode/Timing/PMTTimingCorrectionsProvider.hAdds run override + DB tag accessors.
icaruscode/Timing/PMTTimingCorrectionsProvider.cxxImplements override run-number DB queries.
icaruscode/Timing/PMTTimingCorrections.hExtends interface with DB tag getters.
icaruscode/PMT/Trigger/triggerwindowdefs_icarus.fclMoves trigger-window definitions include usage.
icaruscode/PMT/Trigger/triggeremu_settings_icarus.fclAdds timing delay parameters + includes window defs.
icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.hSwitches TriggerGatesTag to art::InputTag + helper.
icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.cxxBuilds per-threshold tags via helper with validation.
icaruscode/PMT/Trigger/TriggerEfficiencyPlots_module.ccSame tag handling updates as base class.
icaruscode/PMT/Trigger/trigger_icarus.fclUpdates thresholds, gates, and patterns for Run2+ tuning.
icaruscode/PMT/Trigger/trigger_emulation_icarus.fclUpdates trigger emulation workflow + baseline handling.
icaruscode/PMT/Trigger/SlidingWindowTriggerSimulation_module.ccUses art::InputTag and validated tag building.
icaruscode/PMT/Trigger/SlidingWindowTrigger_module.ccUses art::InputTag and validated tag building.
icaruscode/PMT/Trigger/MajorityTriggerSimulation_module.ccUses art::InputTag and validated tag building.
icaruscode/PMT/Trigger/LVDSgates_module.ccSwitches optional default gate tag to art::InputTag.
icaruscode/PMT/Trigger/FixBeamGateInfo_module.ccRefactors beam-type selection + adds trace logging.
icaruscode/PMT/Trigger/DiscriminatePMTwaveforms_module.ccConsumes baseline “parallel data product” when configured.
icaruscode/PMT/Trigger/DiscriminatedAdderSignal_module.ccSimplifies optional interval parsing + improves error text.
icaruscode/PMT/Trigger/CMakeLists.txtUpdates link deps and target naming to newer conventions.
icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.cxxFixes trace message formatting.
icaruscode/PMT/Status/PMTChannelStatusService_service.ccNew art service for PMT channel status DB.
icaruscode/PMT/Status/PMTChannelStatusProvider.hNew provider interface + configuration docs.
icaruscode/PMT/Status/PMTChannelStatusProvider.cxxImplements DB reads, caching, override run number.
icaruscode/PMT/Status/PMTChannelStatus.hNew status/voltage provider interface.
icaruscode/PMT/Status/pmt_channel_status_icarus.fclStandard FHiCL config for PMT status service.
icaruscode/PMT/Status/IPMTChannelStatusService.hWrapper service interface for provider access.
icaruscode/PMT/Status/CMakeLists.txtBuilds PMT status library + service plugin.
icaruscode/PMT/SampledWaveformFunctionTool_tool.ccAdds BiasRatio option plumbed into pulse function.
icaruscode/PMT/OpReco/ICARUSOpHitFinder_module.ccAdds channel-status filtering + optional rise-time tool.
icaruscode/PMT/OpReco/ICARUSFlashAssAna_module.ccAdds per-PMT integral branch in analysis tree.
icaruscode/PMT/OpReco/FlashFinder/ICARUSFlashFinder_module.ccModernizes module, uses PE() directly, SharedProducer.
icaruscode/PMT/OpReco/FlashFinder/FlashFinderFMWKInterface.hCleans includes, adds standard types.
icaruscode/PMT/OpReco/FlashFinder/FlashFinderFMWKInterface.cxxCleans includes, adds ServiceHandle include.
icaruscode/PMT/OpReco/FlashFinder/CMakeLists.txtSimplifies library deps + plugin link list.
icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_config.fclUnifies TriggerDelay setting.
icaruscode/PMT/OpReco/fcl/icarus_spe.fclAdds Run2/3/4 SPE defaults + documentation.
icaruscode/PMT/OpReco/fcl/icarus_ophitfinder.fclSwitches to ICARUSOpHitFinder + enables DB services.
icaruscode/PMT/OpReco/fcl/icarus_opana_modules.fclRetunes MC OpHit config to new SPE defaults.
icaruscode/PMT/OpReco/fcl/icarus_flashfinder.fclRemoves PECalib configuration (uses OpHit PE).
icaruscode/PMT/OpReco/fcl/icarus_flashcalib.fclRemoves obsolete flash calibration tables.
icaruscode/PMT/OpReco/fcl/icarus_flashalgo.fclRetunes PE thresholds to new PE scale.
icaruscode/PMT/OpReco/Algorithms/OpRecoFactoryStuff.hAllows injecting optional rise-time calculator into algos.
icaruscode/PMT/OpReco/Algorithms/CMakeLists.txtUpdates dependencies for OpReco algorithm library.
icaruscode/PMT/opdetsim_pmt_icarus.fclAdds Run-dependent SimPMT configurations + no-noise variants.
icaruscode/PMT/CopyBeamTimePMTwaveforms_module.ccSimplifies optional interval parsing.
icaruscode/PMT/CMakeLists.txtAdds Status subdir + updates module/tool link deps.
icaruscode/PMT/Calibration/PhotonCalibratorFromDB.hNew DB-backed IPhotonCalibrator implementation.
icaruscode/PMT/Calibration/PhotonCalibratorFromDB.cxxImplements DB reads + PE conversion for SPE-area table.
icaruscode/PMT/Calibration/ICARUSPhotonCalibratorServiceFromDB.hNew art service wrapper for DB calibrator provider.
icaruscode/PMT/Calibration/ICARUSPhotonCalibratorServiceFromDB_service.ccImplements preBeginRun cache refresh.
icaruscode/PMT/Calibration/fcl/pmt-calibration.fclRemoves legacy calibration job config.
icaruscode/PMT/Calibration/fcl/pmt_calibration_icarus.fclNew consolidated calibration config incl. IPhotonCalibrator.
icaruscode/PMT/Calibration/fcl/ophit_recalibrator_icarus.fclNew OpHitRecalibrator defaults + timing tag config.
icaruscode/PMT/Calibration/fcl/decodePMT_icarus_laser.fclUpdates include to new calibration config file.
icaruscode/PMT/Calibration/fcl/debug_speAreas_db.fclAdds a debugging stage0 job for SPE DB configs.
icaruscode/PMT/Calibration/fcl/bkgphotons-calibration.fclUpdates include to new calibration config file.
icaruscode/PMT/Calibration/CMakeLists.txtBuilds new DB calibrator library + service plugin + new modules.
icaruscode/PMT/Algorithms/SampledWaveformFunction.hAdds integral + bias constant to sampled pulse function.
icaruscode/PMT/Algorithms/PhotoelectronPulseFunction.hExtends base interface with integral + bias constant.
icaruscode/PMT/Algorithms/FastGaussianNoiseGeneratorAlg.hUpdates documentation + increases gauss adaptor resolution.
icaruscode/PMT/Algorithms/DiscretePhotoelectronPulse.hImproves pulse-termination logic API.
icaruscode/PMT/Algorithms/DiscretePhotoelectronPulse.cxxImplements “close-to-baseline” termination with persistence.
icaruscode/PMT/Algorithms/CMakeLists.txtLinks PMT algorithms with new calibration library.
icaruscode/Overlays/CMakeLists.txtAdds RebuildShiftedTrigger plugin target.
icaruscode/Generators/CMakeLists.txtAdds new generator-side selection module build target.
icaruscode/Generators/beamspilltimings.fclDelegates default spill timing config to SBN shared config.
icaruscode/Decode/OverlayProducts_module.ccTemporarily truncates tail filling after data waveform end.
icaruscode/Decode/CMakeLists.txtAdds OverlayPMTwaveforms plugin target; updates deps.
icaruscode/CRT/CRTUtils/CRTHitRecoAlg.hExposes isData() accessor.
icaruscode/CRT/CRTUtils/CRTHitRecoAlg.ccAvoids trigger-offset subtraction for simulation.
icaruscode/CRT/CRTUtils/CMakeLists.txtUpdates DetectorClocksService linkage.
icaruscode/CRT/CRTSimHitProducer_module.ccCleans trigger handling; validates/ignores trigger tag by mode.
icaruscode/CRT/CRTDetSim_module.ccComment typo fixes in module header docs.
icaruscode/CRT/CMakeLists.txtUpdates DetectorClocksService linkage.
icaruscode/Analysis/trigger/CMakeLists.txtUpdates DetectorClocksService linkage.
fcl/utilities/dump_opflashes_icarus.fclNew utility job to dump standard OpFlash products.
fcl/utilities/dump_opdetwaveforms_icarus.fclUses simulation DetectorClocksService config in utility.
fcl/SkipTesting.txtAdds override_services_for_simulation.fcl to skip list.
fcl/services/services_icarus_simulation.fclWires timing/status/gain services + simulation clocks override.
fcl/services/override_services_for_simulation.fclNew reusable services override for simulation workflows.
fcl/reco/Stage1/mc/stage1_run2_icarus_MC.fclIncludes simulation services override.
fcl/reco/Stage0/partial/stage0_run4_opdetonly_icarus_data_reprocessing.fclNew Run4 optical-only data reprocessing config.
fcl/reco/Stage0/partial/stage0_run2_opdetonly_icarus_overlay_reprocessing.fclNew optical-only overlay stage0 reprocessing config.
fcl/reco/Stage0/partial/stage0_run2_opdetonly_icarus_data_reprocessing.fclNew Run2 optical-only data reprocessing config.
fcl/reco/Stage0/partial/CMakeLists.txtInstalls new partial stage0 configs.
fcl/reco/Stage0/mc/stage0_run2_wc_icarus_mc.fclIncludes override + tunes optical reconstruction to Run2.
fcl/reco/Stage0/mc/stage0_run2_wc_icarus_mc_notriggersim.fclRestores non-shifted inputs for no-trigger-sim workflows.
fcl/reco/Stage0/mc/stage0_run2_icarus_mc.fclIncludes override + enables fast cloning (no SelectEvents).
fcl/reco/Stage0/mc/stage0_run2_icarus_mc_notriggersim.fclRestores non-shifted inputs for no-trigger-sim workflows.
fcl/reco/Stage0/data/partial/decodePMT_icarus.fclAdds channel status service to PMT decode services.
fcl/reco/Stage0/CMakeLists.txtAdds new partial stage0 configs subdirectory.
fcl/reco/Definitions/stage0_icarus_mc_defs.fclSplits corrected/uncorrected ophit path; overlay PMT sequence.
fcl/reco/Definitions/stage0_icarus_driver_common.fclAdds photon calibrator + channel status services.
fcl/reco/Definitions/stage0_icarus_defs.fclIncludes new calibration + recalibrator configs.
fcl/reco/Definitions/enable_overlay_sp.fclSwitches to overlay PMT path + timing correction override.
fcl/overlays/partial/overlay_opdetonly_waveforms_reprocessing.fclNew overlay-only waveform reprocessing job.
fcl/overlays/partial/CMakeLists.txtInstalls new partial overlay configs.
fcl/overlays/overlay_waveforms.fclReplaces OverlayProducts PMT overlay with OverlayPMTwaveforms module.
fcl/overlays/CMakeLists.txtAdds partial overlay configs subdirectory.
fcl/gen/numi/genie_icarus_numioffaxis.fclSwitches to SBN shared NuMI GENIE base + volume/log updates.
fcl/gen/genie/genie_icarus_bnb.fclSwitches to SBN shared BNB GENIE base + volume/log updates.
fcl/g4/PDFastSim_icarus.fclUpdates SimulationLabel and minor formatting.
fcl/detsim/partial/detsim_opdetonly_icarus.fclNew optical-only detsim job config.
fcl/detsim/partial/detsim_opdetonly_icarus_overlay_reprocessing_run4.fclNew Run3/4 overlay optical detsim reprocessing config.
fcl/detsim/partial/CMakeLists.txtInstalls new partial detsim configs.
fcl/detsim/detsim_2d_icarus.fclExplicitly disables DB effects for non-overlay MC opdaq.
fcl/detsim/detsim_2d_icarus_refactored.fclExplicitly disables DB effects for non-overlay MC opdaq.
fcl/detsim/detsim_2d_icarus_refactored_yzsim.fclExplicitly disables DB effects for non-overlay MC opdaq.
fcl/detsim/detsim_2d_icarus_refactored_yzsim_Run4.fclSelects Run3/4 optical tune; keeps DB effects off for non-overlay.
fcl/detsim/detsim_2d_icarus_refactored_yzsim_overlay.fclEnables DB effects and no-noise for overlay opdaq.
fcl/detsim/detsim_2d_icarus_refactored_yzsim_overlay_Run4.fclRun3/4 overlay tune with DB effects + no-noise.
fcl/detsim/detsim_2d_icarus_refactored_yzsim_notrigger.fclExplicitly disables DB effects for non-overlay MC opdaq.
fcl/detsim/detsim_2d_icarus_refactored_yzsim_notrigger_overlay.fclEnables DB effects + no-noise for overlay notrigger.
fcl/detsim/detsim_2d_icarus_refactored_Run4.fclNew Run3/4 optical tune config (non-overlay).
fcl/detsim/detsim_2d_icarus_refactored_overlay.fclEnables DB effects + no-noise for overlay opdaq.
fcl/detsim/detsim_2d_icarus_refactored_overlay_Run4.fclNew Run3/4 overlay tune config (DB + no-noise).
fcl/detsim/detsim_1d_icarus.fclExplicitly disables DB effects for non-overlay MC opdaq.
fcl/detsim/commissioning/run4759like_detsim_icarus.fclSwitches includes to pmtsimulation_icarus tuning table.
fcl/detsim/commissioning/run4642like_detsim_icarus.fclSwitches includes to pmtsimulation_icarus tuning table.
fcl/detsim/CMakeLists.txtAdds partial detsim configs subdirectory.
fcl/decoder/decoder_run2_icarus.fclUpdates inline comments; clarifies PMT discrimination purpose.
fcl/caf/cafmakerjob_icarus.fclIncludes simulation services override.
CMakeLists.txtAdds sbnalg dependency to build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadscripts/manageDataRunDefinitions.py
Comment threadscripts/manageDataRunDefinitions.py
Comment threadfcl/overlays/partial/overlay_opdetonly_waveforms_reprocessing.fcl Outdated
Comment threadfcl/reco/Stage0/partial/stage0_run4_opdetonly_icarus_data_reprocessing.fcl Outdated
Comment threadicaruscode/PMT/Status/PMTChannelStatusProvider.h
Comment threadicaruscode/Overlays/RebuildShiftedTrigger_module.cc
Comment threadicaruscode/Generators/SelectCathodeCrossingGenParticles_module.cc Outdated
Comment threadicaruscode/Generators/SelectCathodeCrossingGenParticles_module.cc Outdated
Comment threadicaruscode/Generators/SelectCathodeCrossingGenParticles_module.cc Outdated
Comment threadicaruscode/Generators/SelectCathodeCrossingGenParticles_module.cc Outdated
Comment threadicaruscode/Overlays/RebuildShiftedTrigger_module.cc Outdated
PetrilloAtWorkand others added 4 commits June 12, 2026 21:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mvicenzi <64699641+mvicenzi@users.noreply.github.com>
Co-authored-by: Gianluca Petrillo <petrillo.at.work@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@PetrilloAtWorkPetrilloAtWork left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears all the comments are marked as "resolved" so we are good to go.

@PetrilloAtWork

Copy link
Copy Markdown
Member

@jas1005: it appears there are merge conflicts. Please contact us when you are ready to merge so that we can solve them on the spot.

@francescopoppifrancescopoppi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracking everything is a titanic work. Kudos to Gianluca and Matteo for this incredibly huge work. I reviewed output stage1 of several CRT related variables and to my understanding it works. I have to admit, I asked Claude to provide me a summary of this PR. I do not see showstoppers. If it compiles, and this itself iwould be a great success, the result should be the intended one.

@mvicenzimvicenzi mentioned this pull request Jul 28, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the PMT dead/noisy channel list PMT timing corrections should not be applied on simulation

4 participants

@mvicenzi@PetrilloAtWork@francescopoppi