Skip to content

Fcl tools to go with https://github.com/Mu2e/Offline/pull/1960 - #576

Open
YongyiBWu wants to merge 27 commits into
Mu2e:mainfrom
YongyiBWu:main
Open

Fcl tools to go with https://github.com/Mu2e/Offline/pull/1960#576
YongyiBWu wants to merge 27 commits into
Mu2e:mainfrom
YongyiBWu:main

Conversation

@YongyiBWu

Copy link
Copy Markdown
Contributor

Fcl tools to go with Mu2e/Offline#1960. More details there.

YongyiBWu and others added 27 commits May 12, 2026 19:47
This change clarifies and standardizes the STM VD resampler training configuration. It documents the expected data source tags and TFileService output naming, keeps the run number aligned with Offline/STMMC/fcl/VDResamplerTrainingPlan.fcl, and leaves VDResamplerDir and fclDir unset so the defaults can resolve to the current working directory and config path.
Refresh the STM pileup resampler FCL defaults for both the model-based and mix generators. This adds SBDM stage-1 configuration, resampler source file/tree inputs, catalog-based model lists, and newer validation and diffusion settings. It also enables default validation plots and clarifies the expected model and source-file metadata used by the generators.
Centralize the VDResamplerGenerator configuration in JobConfig/pileup/STM/prolog.fcl and make VDResamplerGenerateMix.fcl reference it instead of defining its own block. Add a new VDResamplerToCrystals.fcl job that reuses the shared generator, runs G4 to propagate VD116 samples to the STM crystals, and produces separate paths/outputs for crystals and VD crossings (VD101, VD89, VD90). The prolog now supplies defaults (hitSummaryFiles, potsPerFile, ModelFileList, resamplerSourceRootFiles, and related flags), consolidating settings and enabling reuse between generation and propagation jobs.
Corrected the STM pileup POT comment labels and the neutrals dataset name in the STM prolog configuration. This keeps the metadata aligned with the actual MDC sample names and catalog entries used by the resampler, without changing the underlying pileup logic.
Adds the STM resampler training plan file to the pileup prolog and documents the optional peak-tag model parameters in the generate-from-model configuration. This makes the model-based virtual detector generation use the intended training plan and keeps the relevant SBDM settings visible for future runs.
Factor per-VD STM extraction/compression into templates in prolog.fcl and reuse them from VDResamplerToCrystals.fcl to remove duplicated producer blocks. Apply per-VD overrides (VirtualDetectorID, stepPointMCTags) at top-level as FHiCL requires. Replace root://fndcadoor... data/model paths with CVMFS paths, and re-enable the MT include. Add explanatory comments about the FHiCL limitation and template usage.
This change clarifies the staged STM VD resampling flow: stage 1 now writes only the generated GenParticles to an art file, while ROOT dump and validation plots remain opt-in and are moved out of the production path. It also documents the source-selection flags and sets explicit output filenames and seed values for reproducible generation.
This change converts the STM VD-to-crystal tracking job to consume pre-generated GenParticles from the stage-1 art files instead of producing them locally. It removes the TFileService-based generator dump and tree creation, keeps only the compressed output products on each trigger path, and preserves the input GenParticles so downstream analyses can trace each event back to its source sample.
@FNALbuild

Copy link
Copy Markdown
Collaborator

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

  • JobConfig

which require these tests: build.

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

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

About FNALbuild. Code review on Mu2e/Offline.

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at ff2bfc1.

Test Result Details
test with Command did not list any other PRs to include
merge Merged ff2bfc1 at 817bff4
build (prof) Log file. Build time: 15 min 33 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.
FIXME, TODO TODO (0) FIXME (0) in 0 files
clang-tidy 0 errors 0 warnings

N.B. These results were obtained from a build of this Pull Request at ff2bfc1 after being merged into the base branch at 817bff4.

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.

@FNALbuild

Copy link
Copy Markdown
Collaborator

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

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PR Review Summary — #576

Reviewed at head ff2bfc1. First pass; no prior reviews on the PR.

Decision

  • 🟡 comment only

Scope understood

  • The FHiCL half of the STM VD-resampler work in Mu2e/Offline#1960: VDResamplerConfigureTrainer.fcl, VDResamplerGenerateFromModel.fcl and VDResamplerGenerateMix.fcl are rewired onto new module parameters, a two-stage VDResamplerToCrystals.fcl is added, and JobConfig/pileup/STM/prolog.fcl gains 102 lines of shared configuration.
  • The prolog is the part with reach beyond the new tool: BeamToVD.fcl, BeamToVD1809.fcl and STMResampler.fcl all include it today.
  • The physics of the diffusion model itself is Offline#1960's review, not this one. That PR is open and so far unreviewed, and this PR cannot run without it.

Findings

  1. 🟠 [S1] Nothing in CI parses any of these five files, and the changed prolog reaches three existing production configs

    • Evidence: FNALbuild's table at ff2bfc1 lists build (prof), ceSimReco, g4test_03MT, transportOnly, POT, g4study, cosmicSimReco, cosmicOffSpill, ceSteps, ceDigi, muDauSteps, ceMix, rootOverlaps and g4surfaceCheck. None of them reads anything under JobConfig/pileup/STM/. FNALbuild has since posted that main moved to fed9a04 and the result is out of date, so even the build is now stale.
    • Impact: a composition error in the 102 new prolog lines would break BeamToVD.fcl, BeamToVD1809.fcl and STMResampler.fcl, and no automated check anywhere would catch it. The green tick on this PR is not evidence about these files.
    • Suggested fix: paste the output of fhicl-dump -a (or a one-event mu2e -c) for the four job fcl and for the three existing STM configs that include the prolog. I traced the composition by hand and found nothing wrong — see the verified list below — but hand-tracing is not a parse, and this is the one thing only you can supply.
    • I have left this as a comment rather than a change request because I found no actual error, only the absence of evidence.
  2. 🟡 [S2] The TargetStops1809 entry in potsPerFile cannot be checked against the recipe the block claims to follow

    • The header comment gives the formula as <number of simulated events> / <number of output from last stage> * <POT of the last stage>, three terms. The other three entries follow it; the 1809 entry is 4e9 / 1442670/1e3 * 4e9 / 213816 * 1e8, five terms, with an unexplained /1e3 and the MuBeam denominator 213816 reappearing inside it. All four values reproduce their comments exactly, so the arithmetic is fine and this is purely a documentation gap — but these are the mixing weights, and a reader cannot presently confirm one of them.
  3. ⚪ [S3] Smaller things, collected

    • # ModelFileDir is now overridden by ModelFileList records an edit rather than describing the parameter; git already holds that. Saying what ModelFileList expects would be more use to the next reader.
    • services.SeedService.baseSeed : 8 in VDResamplerToCrystals.fcl repeats Common.BaseSeed : 8, which that file already has in scope through Production/JobConfig/common/prolog.fcl. The production configs spell it @local::Common.BaseSeed (JobConfig/primary/epilog.fcl, JobConfig/digitize/epilog.fcl, JobConfig/cosmic/NoField.fcl).
    • All four data files sit under .../STMVDResampler/MDC2025ai/ but two are named MDC2025au and MDC2025av, and the two sample dumps are nts.yongyiwu.* where the summaries are etc.mu2e.*. Every path exists, so nothing is broken; the directory name just no longer says what is in it.
    • JobConfig/pileup/STM/prolog.fcl and VDResamplerToCrystals.fcl both end without a trailing newline.

Verified

  • 🟢 All four potsPerFile values reproduce their inline derivations to the last digit: 98360017778.32725, 467691847195.7197, 5186958594225.648 and 3743491962.61981.
  • 🟢 Every referenced data file exists on cvmfs — the four hitSummaryFiles, the ModelFileList catalog and the resamplerSourceRootFiles dumps.
  • 🟢 The new VDResamplerGenerator producer added to STMPileup.producers does not leak into the three existing jobs. BeamToVD.fcl, BeamToVD1809.fcl and STMResampler.fcl reference only @sequence::STMPileup.BeamToVDKeptProducts and @sequence::STMPileup.stmResamplerSequence; none of them takes @table::STMPileup.producers.
  • 🟢 The two new #includes in the prolog do not introduce a new double-inclusion hazard. BeamToVD.fcl already includes both Production/JobConfig/pileup/prolog.fcl and Production/JobConfig/pileup/STM/prolog.fcl, and those two already share Offline/TrackerMC/fcl/prolog.fcl plus four siblings, so re-including a prolog is already exercised by these jobs in production.
  • 🟢 Every @local:: reference into Offline resolves to the value its comment claims, checked against Offline/STMMC/fcl/prolog.fcl on main: ResamplingProducer.StepPointMCsTag is "g4run:virtualdetector" (:42), ResamplingProducer.VirtualDetectorID is 101 (:43), ResamplingFilter.StepPointMCsTag is "compressDetStepMCsSTM" (:46) and VirtualDetectorCounter.StepPointMCsTag is "g4run:virtualdetector" (:49).
  • 🟢 physics.producers.g4run.Mu2eG4CommonCut : {} matches the files VDResamplerToCrystals.fcl says it follows — BeamToVD.fcl:116 and STMResampler.fcl:132 both clear it the same way.
  • 🟢 Replacing the old @nil placeholders with "" does not turn a validation failure into a silent one. The module constructors throw a cet::exception naming the parameter for an empty stage2ModelFile, an empty resamplerSourceRootFile under a non-DIFFUSION stage-1 method, an unopenable ModelFileList or hit summary, and a non-positive potsPerFile; hitSummaryFiles, potsPerFile, useSummaryFile and resamplerSourceRootFiles are all length-checked against each other.

Validation check

  • Build/tests run: no. The build at ff2bfc1 was green but FNALbuild has marked it out of date, and it covers none of these files either way. I did not trigger a rerun, since a rerun would not test them.
  • Config contract check: partial. Every @local:: and @sequence:: reference was resolved by hand against the Offline and Production prologs on main, and every data-file path was checked to exist. No fhicl-dump was produced.
  • Cross-repo consistency: needs follow-up on merge order. trainingPlanFile : "Offline/STMMC/fcl/VDResamplerTrainingPlan.fcl" names a file Offline#1960 adds, and the new parameter names come from modules that PR rewrites, so #1960 has to merge first. That is ordering, not a blocker.

Not checked

  • Nothing was run — no fhicl-dump, no art job, no G4 stage.
  • The diffusion-model physics, the sampling method and the validation plots. Those belong to Offline#1960, which has no review yet.
  • Whether the absolute /cvmfs/... paths should stay absolute. They have to be as the code stands — the module reads them with a bare std::ifstream, so the search-path form used by, say, Offline/CaloMC/fcl/prolog.fcl ("OfflineData/ConditionsService/...") would not resolve. Worth settling on #1960 whether these parameters ought to go through a lookup policy, since as written the job cannot run anywhere cvmfs is not mounted and the configuration is pinned to one MDC2025ai directory.

Author follow-ups

  1. Post fhicl-dump -a output for the four job fcl and for BeamToVD.fcl, BeamToVD1809.fcl and STMResampler.fcl, since CI covers none of them.
  2. Rewrite the TargetStops1809 derivation so it reads against the formula in the block header, or extend the header to cover the five-term case.
  3. Say in the PR body that Offline#1960 must merge first.

@YongyiBWu

Copy link
Copy Markdown
Contributor Author

To clarify [S2]: The TargetStops1809 entry in potsPerFile have additional factors, because the sample comes from TargetStops, which is a staged propagated from MuBeam. The extra factors count for efficiency of MuBeam->TargetStops. This stage also has a random selection filter to downsample by 1000x. For matching the POTs, this calls for the additional 1000x

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