Skip to content

Pawel plesniak/absorber shift#1875

Open
PawelPlesniak wants to merge 15 commits into
Mu2e:mainfrom
PawelPlesniak:PawelPlesniak/AbsorberShift
Open

Pawel plesniak/absorber shift#1875
PawelPlesniak wants to merge 15 commits into
Mu2e:mainfrom
PawelPlesniak:PawelPlesniak/AbsorberShift

Conversation

@PawelPlesniak

@PawelPlesniak PawelPlesniak commented Jul 7, 2026

Copy link
Copy Markdown

This PR addresses several issues found when completing the corrections to my normalization studies.

Changes are summarized in the bullet point list for each file affected by core code changes. Critically note - there are several other files that are also affected, but the pre-commit config highlighted many changes that needed to happen before my changes could go in (after rebasing with branch main). These changes have been addressed.

  • CountVirtualDetectorHits_module.cc - this makes the vector of virtual detectors being summarized in the model unique, my mapping to and back from an unordered set
  • PhotonGun_module.cc - this now allows for a set of photons to travel in a straight line from the origin to target position, defined by a direction vector as delta_x, delta_y, and delta_z. This vector is mapped to the unit vector, and the momentum is scaled accordingly.
  • AbsorberFromSTHPGe.fcl - driver code that will allow future unfolding studies to be performed, especially important for the HPGe where additional absorber is present, and the results have not yet been fully quantified.
  • AbsorberFromSTLaBr.fcl - as above but for LaBr.
  • EventFilter.fcl - debugging tool to help with ongoing simulation studies. Allows for looking at individual events in a data file. For my studies, it was used to demonstrate the behaviour of the ZS and MWD algorithms on a macro-spill worth of beam-on time.
  • FirePhotonToDetector.fcl - driver code that fires singular photons to a detector of choice, aimed for use with studying the STM detector waveform generators and analysis tools.
  • STMMC/fcl/prolog.fcl - rewritten to define the simulation parameters more clearly
  • ROOTAnalysisDump.fcl - driver code to convert the art files into ROOT format for easy plotting. I will not be rewriting this for the current analysis framework as I do not have the time for this.
  • HPGeWaveformsFromStepPointMCs_module.cc - addresses issues with the waveform generator, namely
    • MWD was failing with this implementation as the waveform amplitudes were set to zero during microspills that did not have photons interacting with the detector crystal, throwing off MWD
    • Concatenated events were discontinuous
    • Added preamplifier charge collection response function
  • SimParticleAndVDBacktrace_module.cc - new module generating ROOT files with data that backtraces of STM signal photons back through the SimParticle provenance. The code to plot these will be merged in the STMAnalysis repository
  • SimParticleDump_module.cc - dumps the full SimParticle provenance to ROOT files for plotting, with a more compact format than the previous module.
  • STMResamplingProducer_module.cc - Initial simulations had different data product names for SimParticles propagated with the BeamToVD and BeamToVD1809 drivers, this change standardizes them.
  • VirtualDetectorTree_module.cc - add more data to ROOT files generated for plotting.
  • STMMovingWindowDeconvolution_module.cc - some more data for visualizing the behaviour of analyzed waveforms

I would like to ask some questions

  • Why was the STMMWDDigi renamed to STMPHDigi, and what is the difference in analysis chains?

@FNALbuild

Copy link
Copy Markdown
Collaborator

Hi @PawelPlesniak,
You have proposed changes to files in these packages:

  • STMMC
  • STMReco
  • Analyses
  • EventGenerator
  • RecoDataProducts

which require these tests: build.

@Mu2e/write, @Mu2e/fnalbuild-users have access to CI actions on main.

⌛ The following tests have been triggered for 3bb3d47: build (Build queue - API unavailable)

About FNALbuild. Code review on Mu2e/Offline.

@FNALbuild

Copy link
Copy Markdown
Collaborator

‼️ It was not possible to prepare the workspace for this test. This is often caused by merge conflicts - please check and try again.

> git diff --check | grep -i conflict
EventGenerator/src/PhotonGun_module.cc:69: leftover conflict marker
EventGenerator/src/PhotonGun_module.cc:71: leftover conflict marker
EventGenerator/src/PhotonGun_module.cc:74: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:21: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:29: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:40: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:48: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:53: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:56: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:64: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:66: leftover conflict marker
RecoDataProducts/inc/STMWaveformDigi.hh:68: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:66: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:70: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:76: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:84: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:86: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:88: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:101: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:104: leftover conflict marker
STMMC/fcl/HPGeWaveformGenerationAndAnalysis.fcl:109: leftover conflict marker
STMMC/fcl/prolog.fcl:158: leftover conflict marker
STMMC/fcl/prolog.fcl:160: leftover conflict marker
STMMC/fcl/prolog.fcl:162: leftover conflict marker
STMMC/fcl/prolog.fcl:174: leftover conflict marker
STMMC/fcl/prolog.fcl:178: leftover conflict marker
STMMC/fcl/prolog.fcl:188: leftover conflict marker
STMReco/src/STMMovingWindowDeconvolution_module.cc:118: leftover conflict marker
STMReco/src/STMMovingWindowDeconvolution_module.cc:120: leftover conflict marker
STMReco/src/STMMovingWindowDeconvolution_module.cc:130: leftover conflict marker
STMReco/src/STMMovingWindowDeconvolution_module.cc:317: leftover conflict marker
STMReco/src/STMMovingWindowDeconvolution_module.cc:326: leftover conflict marker
STMReco/src/STMMovingWindowDeconvolution_module.cc:330: leftover conflict marker
Test Result Details
test with Command did not list any other PRs to include
merge 3bb3d47 into 704459c merge failed

PawelPlesniak added 3 commits July 7, 2026 06:50
@PawelPlesniak

Copy link
Copy Markdown
Author

I leave this for review by @YongyiBWu and @AndrewEdmonds11

@PawelPlesniak PawelPlesniak marked this pull request as ready for review July 7, 2026 12:36
@PawelPlesniak

Copy link
Copy Markdown
Author

Note - I will review any failures that the CI workflow raises

@PawelPlesniak

Copy link
Copy Markdown
Author

@FNALbuild run build test

@FNALbuild

Copy link
Copy Markdown
Collaborator

⌛ The following tests have been triggered for b19652b: build (Build queue - API unavailable)

@FNALbuild

Copy link
Copy Markdown
Collaborator

☔ The build is failing at b19652b.

scons: *** [build/al9-prof-e29-p101/Offline/tmp/STMReco/src/STMMovingWindowDeconvolution_module.os] Error 1
Test Result Details
test with Command did not list any other PRs to include
merge Merged b19652b at 8a343bd
build (prof) Log file.
ceSimReco 〰️ Log file.
g4test_03MT 〰️ Log file.
transportOnly 〰️ Log file.
POT 〰️ Log file.
g4study 〰️ Log file.
cosmicSimReco 〰️ Log file.
cosmicOffSpill 〰️ Log file.
ceSteps 〰️ Log file.
ceDigi 〰️ Log file.
muDauSteps 〰️ Log file.
ceMix 〰️ Log file.
rootOverlaps 〰️ Log file.
g4surfaceCheck 〰️ Log file.
trigger Log file.
check_cmake 〰️ Log file.
FIXME, TODO ➡️ TODO (8) FIXME (1) in 19 files
clang-tidy ➡️ 30 errors 265 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at b19652b after being merged into the base branch at 8a343bd.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@PawelPlesniak

Copy link
Copy Markdown
Author

@FNALbuild run build test

@FNALbuild

Copy link
Copy Markdown
Collaborator

⌛ The following tests have been triggered for 7463724: build (Build queue - API unavailable)

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at 7463724.

Test Result Details
test with Command did not list any other PRs to include
merge Merged 7463724 at 8a343bd
build (prof) Log file. Build time: 04 min 17 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
trigger Log file.
check_cmake Log file.
FIXME, TODO ➡️ TODO (8) FIXME (1) in 19 files
clang-tidy ➡️ 28 errors 267 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at 7463724 after being merged into the base branch at 8a343bd.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@PawelPlesniak

Copy link
Copy Markdown
Author

@YongyiBWu and @AndrewEdmonds11 The CI workflow issues have been addressed, this is now ready for review

@oksuzian

oksuzian commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

🔴 Bugs (likely functional problems)

1. SimParticleDump_module.cc — empty-file counter never resets, and threshold check is wrong

if (!stepHandle || stepHandle->empty()) { consecutiveEmptyFileCounter++; return; }   // returns BEFORE threshold check
...
if (consecutiveEmptyFileCounter > consecutiveEmptyFileThreshold)
    throw cet::exception("LogicError", "Too many consecutive empty files, stopping the job");

Because the empty branches return immediately, the threshold throw is only ever reached on a non-empty event — the exact opposite of intended. The counter is also never reset to 0 on success in the early-return paths. Compare with SimParticleAndVDBacktrace / VirtualDetectorTree, which check the threshold before returning. The author also flags this file as unvalidated: // TODO before upload - validate that the code works.

2. HPGeWaveformsFromStepPointMCs_module.ccdigitize() clipping logic is inverted

ADC = _chargeDecayed[i] * chargeToADC;
_adcs[i] = (ADC > ADCMax) ? static_cast<int16_t>(std::round(ADC)) : ADCMax;

ADCMax is the most-negative value (-2^15 + 1), and the waveform is negative-going. This keeps the rounded value only when ADC > ADCMax and otherwise floors it to ADCMax — that clamps from below but nothing prevents positive overflow, and the ternary condition reads backwards relative to its intent. Worth double-checking the direction against the validation if (j > 1000) throw ... "ADC values too high!" on line 355.

3. HPGeWaveformsFromStepPointMCs_module.cc — validation constant defaultMicrospillBufferLengthCount < 1 is unreachable

if (defaultMicrospillBufferLengthCount < 1)
    throw cet::exception("RANGE", "defaultMicrospillBufferLengthCount has to be at least 1!\n");

defaultMicrospillBufferLengthCount is a hard-coded const int = 2, so this guard can never fire. The check should validate the user-supplied microspillBufferLengthCount instead.

4. PhotonGun_module.cc — new energy check rejects valid low-energy photons

if (E < std::numeric_limits<double>::epsilon())
    throw cet::exception("RANGE") << "Energy must be greater than zero, exiting.";

epsilon() (~2.2e-16) is a floating-point precision tolerance, not "zero". Any legitimately small energy below it is rejected. Use E <= 0.0. (The good news: this diff fixes a real copy-paste bug on the same lines — px = conf().py()py = conf().py().)

5. HPGeWaveformGenerationAndAnalysis.fcl — dangling data-product tag after module rename
The producer PHHPGe was renamed to MWDHPGe, but the output still references the old name:

"keep mu2e::STMPHDigis_PHHPGe_*_HPGeReco"

With no PHHPGe module in any path, this keep will drop the intended digis. Should be MWDHPGe.

🟠 Correctness / robustness concerns

6. Uninitialized counters read in summaries — In both STMMovingWindowDeconvolution_module.cc (processedADCs) and HPGeWaveformsFromStepPointMCs, some counters are declared without an initializer (uint ... processedADCs;) and later printed / accumulated (processedADCs += nADCs). Undefined initial value. Initialize to 0.

7. SimParticleDump uses SimParticles.at(step.trackId()).at() on the SimParticleCollection throws if the track id isn't present; other modules in this PR guard more defensively. Given the file is explicitly unvalidated, worth confirming the key type/lookup.

8. Hard-coded 320 MHz couplingproduce() now throws unless fADC == 320, and decayCharge() hard-codes the 320 MHz assumption for the preamplifier rise time. The author acknowledges this (// TODO - this only keeps accurate time if the sampling is 320MHz), but it silently makes the fADC fhicl parameter a lie for any other value.

🟡 Minor / cleanup

  • Typo: unqiueEnabledVDsVec in CountVirtualDetectorHits_module.cc, and duplicate ;; on the same line.
  • Debug leftovers: HPGeWaveformsFromStepPointMCs carries waveform_time with a self-described // TODO - REMOVE ME!, plus kept_events/dropped_events labelled "for debugging".
  • Copy-pasted banner: STMMovingWindowDeconvolution::beginJob() prints "STM HPGe digitization parameters" — wrong header for the MWD module.
  • Copy-paste in .fcl: AbsorberFromSTLaBr.fcl uses process_name: HPGeAbsorberSpectrumShift (LaBr file, HPGe process name).
  • Author-acknowledged unfinished work: several @nil "Populate me!" placeholders (HPGeWaveformGenerationAndAnalysis.fcl, ROOTAnalysisDump.fcl), a makeADCPlot path that always throws "not yet implemented", and TODO blocks left in prolog.fcl ("TODOs before Pawel uploads").
  • Comment typo: "5. Ou1tputs" and "[BRAKCETS]" in HPGeWaveformGenerationAndAnalysis.fcl / ROOTAnalysisDump.fcl.

@FNALbuild

Copy link
Copy Markdown
Collaborator

📝 The HEAD of main has changed to 90a91d2. Tests are now out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants