Warning, /irt/log/TAGS.txt is written in an unsupported language. File is not indexed.
0001 ================================================================================
0002 TAGS.txt -- version tags, provenance and measurement ledger for the ePIC / IRT
0003 PFRICH sandbox in /home/ayk/ePIC-2026-11-13
0004 ================================================================================
0005
0006 MAINTENANCE RULE (applies to every future session)
0007 1. Whenever a git tag is created in any repo here, APPEND an entry to section
0008 "IRT TAG HISTORY" (or a sibling section for other repos) in this file.
0009 2. Never rewrite or reorder existing entries; append only, newest at the end
0010 of the relevant section, and keep the "MEASUREMENT LEDGER" consistent with
0011 the tags it quotes.
0012 3. A tag must be annotated (git tag -a) and its message must state what
0013 changed and the measured effect.
0014 4. Any timing or physics number quoted anywhere must name the tag it was
0015 obtained with, so it can be reproduced.
0016
0017 --------------------------------------------------------------------------------
0018 STACK AS INSTALLED IN $EIC_SHELL_PREFIX (= /home/ayk/ePIC-2026-11-13/install)
0019 --------------------------------------------------------------------------------
0020 repo version (git describe) HEAD branch role
0021 edm4eic v8.11.0 2ae1454 main EDM4eic definitions
0022 irt v2.2.3a3 4878d0a irt-2.2a IRT2 reconstruction <- tagged here
0023 epic 26.11.0-13-ge671ab285 e671ab285 main geometry / calibration
0024 EICrecon v1.43.0-31-gc4708fd9 c4708fd9 main jana2 reconstruction chain
0025
0026 container: eic_xl-nightly.sif; ROOT 6.40.04, jana2 2026.03.01, podio 1.8,
0027 EDM4HEP 1.1.1, ACTS 47.7.0, DD4hep 1.38, cmake 3.31.12.
0028
0029 ABI WARNING: ReconstructionFactory gained data members in v2.2.3a2. Whenever
0030 IRT headers change, EICrecon MUST be rebuilt AND reinstalled
0031 (cmake --build EICrecon/build -j 24 && cmake --install EICrecon/build),
0032 otherwise install/lib/EICrecon/plugins/RICH-IRT.so keeps the stale layout.
0033
0034 --------------------------------------------------------------------------------
0035 IRT TAG HISTORY (repo: ./irt, remote https://github.com/eic/irt.git)
0036 --------------------------------------------------------------------------------
0037 v2.2.3 1479e60 2026-10-02 upstream base ("CherenkovEvent: use
0038 std::vector for reproducible behaviour (#65)"). Baseline for
0039 all comparisons; branch main == this commit.
0040
0041 v2.2.3a1 fd112fa 2026-11-13 branch irt-2.2a. "ReconstructionFactory:
0042 cut combinatorial overhead in ProcessHits()". Radiator history
0043 resolved once per particle; UsedInRingImaging() filter, TRef
0044 lookup and dynamic_cast hoisted out of the hit / optical-path
0045 loops; reference refractive indices retuned once per radiator;
0046 loops reordered radiator -> hit -> optical path; IRT solutions
0047 cached across hypothesis combinations (solutionsValid).
0048 Estimator unchanged, output bit-identical to v2.2.3.
0049 Measured: 5-track sample 223.09 s -> 46.79 s; marginal-cost
0050 scaling ~p^4 -> ~p^2.
0051
0052 v2.2.3a2 402409f 2026-11-14 branch irt-2.2a HEAD. "Reconstruction-
0053 Factory: add global mixture log-likelihood estimator". New JSON
0054 key "Estimator": "chi2" (default, unchanged behaviour) or "ml":
0055 per-hit mixture over all [particle,radiator,optical path]
0056 components plus flat background ("BackgroundFraction",
0057 "BackgroundWindow"), extended Poisson yield term, hit-to-track
0058 assignment marginalized and then performed a posteriori (MAP).
0059 Config for the ml mode: pfrich-reco-ml.json.
0060 Measured: pion efficiency +1.6 to +3.0 pts, kaon mis-ID down
0061 42-60% (1,2,3,5 tracks); +7% wall time at 5 tracks vs v2.2.3a1;
0062 default chi2 output identical to v2.2.3a1.
0063
0064 v2.2.3a3 4878d0a 2026-11-14 branch irt-2.2a HEAD. "Reconstruction-
0065 Factory: cache per-hit hypothesis evaluation, scan becomes
0066 lookups" (Stage A). New ScoreHits() evaluates the single-photon
0067 thp/tt/chi2/CCDF of every hit for every PID hypothesis once per
0068 particle per iteration, keeping the best [radiator,optical path]
0069 component per hypothesis; the cdim combination scan is reduced to
0070 table lookups. Scan bookkeeping moved out of per-hit std::set /
0071 std::map operations into flat per-event tables (selected hits per
0072 particle, cached [hit,particle] solution pointers); the event
0073 chi^2 accumulation walks the hits once instead of tracks times
0074 per-hit selection lists.
0075 Output identical to v2.2.3a2 with the chi2 estimator at 1, 2, 3
0076 and 5 tracks (incl. radiator angle sums).
0077 Measured: 5 tracks 46.79 -> 43.62 s; marginal cost above the
0078 single-track floor 18.2 -> 15.0 s. See the hypothesis-count
0079 diagnostic below: the scan is no longer the bottleneck.
0080
0081 Naming convention for future tags: v<upstream-base>a<N> for local development
0082 milestones on top of an upstream release (a1, a2, ...). Next expected tags:
0083 v2.2.3a4 = Stage B (separable objective, cdim scan removed),
0084 v2.2.3a5 = Stage C (EM iterations).
0085
0086 --------------------------------------------------------------------------------
0087 MEASUREMENT LEDGER (all runs: README.AYK eicrecon recipe, single-threaded,
0088 -Pjana:nevents=500, ONE run per configuration)
0089 --------------------------------------------------------------------------------
0090 Wall time, seconds (500 events):
0091 tracks v2.2.3 (main) v2.2.3a1 (chi2) v2.2.3a2 (ml) v2.2.3a3 (chi2)
0092 1 29.05 28.63 29.22 28.64
0093 2 34.34 31.28 31.71 31.17
0094 3 48.50 33.89 34.50 34.64
0095 5 223.09 46.79 50.09 43.62
0096
0097 Marginal cost above the ~29 s single-track floor:
0098 tracks v2.2.3 v2.2.3a1 v2.2.3a2 v2.2.3a3
0099 2 5.3 2.7 2.5 2.5
0100 3 19.5 5.3 5.3 6.0
0101 5 194.1 18.2 20.9 15.0
0102 log-log slope p=2..5: v2.2.3 ~p^3.5-4.5 ; v2.2.3a1/a2/a3 ~p^2
0103
0104 v2.2.3a3 physics output is IDENTICAL to v2.2.3a1 (and to the chi2 column of
0105 v2.2.3a2): same IRT particle counts, PDG content, npe, nhits and radiator
0106 angle sums at 1, 2, 3 and 5 tracks. Use the v2.2.3a1/a2 physics table below.
0107
0108 Hypothesis-count diagnostic (5-track sample, 500 events, one run, v2.2.3a3,
0109 configs pfrich-reco-1hypo/3hypo/4hypo.json which change only the value of
0110 "IdentifiedParticles"): cdim = hdim^pdim
0111 hdim=1 (cdim=1) 44.18 s PDG {211: 2267, 0: 183}
0112 hdim=2 (cdim=32) 43.62 s PDG {211: 2101, 321: 166, 0: 183}
0113 hdim=3 (cdim=243) 43.99 s PDG {211: 1823, 321: 168, 2212: 276, 0: 183}
0114 hdim=4 (cdim=1024) 45.34 s PDG {211: 1143, 321: 187, 2212: 373, 11: 564, 0: 183}
0115 -> a x1024 increase in the number of combinations costs 2.7%: after
0116 v2.2.3a1 + v2.2.3a3 the combinatorial scan is essentially free. What is
0117 left scales with particles x hits, i.e. with the IRT ray-tracing.
0118
0119 Physics, 500 events (IRT particles / pion efficiency / K mis-ID / no-ID /
0120 mean npe / mean nhits):
0121 1tr v2.2.3 493 94.73% 15 11 13.18 11.07
0122 1tr v2.2.3a1 493 94.73% 15 11 13.18 11.07
0123 1tr v2.2.3a2 493 96.55% 6 11 13.18 11.03
0124 2tr v2.2.3 982 92.36% 56 19 13.47 11.57
0125 2tr v2.2.3a1 982 92.36% 56 19 13.47 11.57
0126 2tr v2.2.3a2 982 94.70% 33 19 13.47 11.28
0127 3tr v2.2.3 1475 87.73% 64 117 13.21 11.35
0128 3tr v2.2.3a1 1475 87.73% 64 117 13.21 11.35
0129 3tr v2.2.3a2 1475 89.29% 41 117 13.21 10.63
0130 5tr v2.2.3 2450 85.76% 166 183 13.30 11.73
0131 5tr v2.2.3a1 2450 85.76% 166 183 13.30 11.73
0132 5tr v2.2.3a2 2450 88.73% 93 183 13.30 10.18
0133
0134 VOID / DO NOT QUOTE: every timing number produced before 2026-11-14 13:20
0135 local (the "411 s -> 57.9 s", "23.32/33.43/63.82 s" and the 75 s ladder) was
0136 measured with a non-README command line ("-o", "-c /concurrency=24",
0137 JANA_THREADS, jana:parameter_strictness=2). Those flags are invalid or change
0138 the threading, so those numbers are not reproducible and are superseded by the
0139 tables above.
0140
0141 --------------------------------------------------------------------------------
0142 SAMPLE INVENTORY (sandbox root; 1000 events each unless noted)
0143 --------------------------------------------------------------------------------
0144 electron-going-endcap.hepmc 1 track (pi+/- 211, p=7 GeV, eta=-2.5,
0145 phi=pi/2) -> sim.edm4hep.pfrich.root
0146 is only 300 events (cannot feed
0147 a 500-event comparison)
0148 tracks1.hepmc / tracks2.hepmc / tracks3.hepmc
0149 1/2/3 tracks (211, p=7, eta=-2.5,
0150 phi in [0, pi/2])
0151 -> sim.1tr.root / sim.2tr.root / sim.3tr.root
0152 electron-going-endcap-5tracks.hepmc 5 tracks -> sim.edm4hep.pfrich.5tr.root
0153
0154 Generators: hepmc-writer-single-track.C, hepmc-writer-multiple-tracks.C.
0155 Simulation: npsim --runType run --compactFile
0156 $EIC_SHELL_PREFIX/share/epic/epic_tracking_and_pfrich.xml
0157 --part.userParticleHandler= -N 1000
0158
0159 --------------------------------------------------------------------------------
0160 RUN RECIPE (the ONLY eicrecon keys allowed; single-threaded, never add
0161 threading flags, -o, -c /concurrency, jana:parameter_strictness)
0162 --------------------------------------------------------------------------------
0163 $EIC_SHELL_PREFIX/bin/eicrecon -Pplugins="janadot" \
0164 -Pdd4hep:xml_files=$EIC_SHELL_PREFIX/share/epic/epic.xml \
0165 -Ppodio:output_collections="PFRICHHits,MCParticles,PFRICHTracks,PFRICHIrtRadiatorInfo,PFRICHIrtParticles" \
0166 -Peicrecon:LogLevel="info" -Pjana:timeout=180 -Pjana:warmup_timeout=180 \
0167 -Pjana:nevents=500 -Pjana:debug_plugin_loading="1" \
0168 -Pacts:MaterialMap="calibrations/materials-map.cbor" \
0169 -Pplugins_to_ignore=LUMISPECCAL,LOWQ2,FOFFMTRK,RPOTS,B0TRK,ZDC,B0ECAL,FHCAL,BHCAL,EHCAL,FEMC,BEMC,EEMC,PFRICH,DIRC \
0170 -Ppodio:output_file="rec_<sample>_<tag>.root" <sim file> \
0171 -PPFRICH:config=pfrich-reco.json # chi2 estimator
0172 -PPFRICH:config=pfrich-reco-ml.json # ml estimator (v2.2.3a2+)
0173
0174 Only the VALUES of these keys may be changed (output file, input file,
0175 PFRICH:config, nevents). Comparisons are always 500 events, one run.
0176
0177 --------------------------------------------------------------------------------
0178 OPEN WORK (as of v2.2.3a2)
0179 --------------------------------------------------------------------------------
0180 Combinatorics plan:
0181 Stage A DONE (v2.2.3a3). Memoize the per [hit,particle,radiator,path,
0182 hypothesis] evaluation; scan reduced to lookups; scan bookkeeping
0183 moved to flat tables.
0184 Stage B separable objective / hypothesis-as-mixture-component, cdim -> 1
0185 (-> v2.2.3a4). Timing value is now small (the diagnostic above
0186 shows cdim=1024 costs 2.7%); its value is that it makes the
0187 objective statistically coherent and enables Stage C.
0188 Stage C EM iterations (weights, yields, optionally Coffset/Csigma)
0189 (-> v2.2.3a5).
0190 NEW finding from v2.2.3a3: the remaining p-dependence is the IRT ray-tracing
0191 in ProcessHits(), which costs ~particles x hits. Candidate next levers,
0192 orthogonal to the estimator:
0193 - pre-filter hits before solving (cheap theta-window test against the
0194 kinematic band of any hypothesis) so IRT is not asked for hits that cannot
0195 match;
0196 - reuse/share IRT solutions between hypotheses (already done) and across
0197 events with identical geometry context, if safe;
0198 - reduce the number of [radiator,optical path] components solved per hit.
0199 Validation for each stage: the MEASUREMENT LEDGER protocol above, plus new
0200 7- and 8-track samples to fit the scaling exponent (target ~p^1-2).
0201
0202 Diagnostic configs added on 2026-11-14: pfrich-reco-1hypo.json,
0203 pfrich-reco-3hypo.json, pfrich-reco-4hypo.json (hypothesis-count scan only;
0204 their physics output is NOT to be used for PID comparisons).
0205 ================================================================================
0206 ================================================================================
0207 APPENDED 2026-11-14 (v2.2.3a3) -- single-track eta scan, PFRICH geometry audit,
0208 MC-truth direction-seed test
0209 ================================================================================
0210 A. Single-track production runs. All v2.2.3a3, 300 events, README.AYK recipe,
0211 single-threaded, -Pjana:nevents="0" (all events):
0212 eta=-2.5 sim.edm4hep.pfrich.root 24.35 s 300 ev @ 43.5 Hz
0213 295 IRT particles PDG {211:289, 321:5, 0:1} pi 97.97%
0214 npe 14.27 nhits 11.98 sim hits/ev 328.5
0215 eta=-2.0 sim.edm4hep.pfrich.eta2.root 23.98 s 300 ev @ 43.4 Hz
0216 295 IRT particles PDG {211:284, 321:8, 0:3} pi 96.27%
0217 npe 13.97 nhits 8.91 sim hits/ev 351.1
0218 eta=-1.9 sim.edm4hep.pfrich.eta19.root 23.90 s 300 ev @ 43.7 Hz
0219 295 IRT particles PDG {211:278, 321:16, 0:1} pi 94.24%
0220 npe 13.04 nhits 7.17 sim hits/ev 367.2
0221 -> baseline for sections B/C; outputs preserved as
0222 rec.edm4hep.pfrich.eta19.root, pfrich_eta19_a3.root
0223 main (v2.2.3) repeat of eta=-1.9: 24.37 s, 300 ev @ 41.9 Hz; physics
0224 identical to v2.2.3a3 (PDG / npe / nhits / radiator angle / radiator npe /
0225 radiator nhits all element-wise equal); pfrich.root differs only by 96
0226 bytes, all ROOT timestamp fields. Preserved as pfrich_eta19_main.root.
0227
0228 B. PFRICH geometry audit (code reading only, no measurement):
0229 - EICrecon/src/services/geometry/richgeo/IrtGeoPFRICH.cc is DEAD CODE in
0230 this configuration: the only GetIrtGeo() call site in EICrecon passes the
0231 literal "DRICH" (src/factories/pid/IrtCherenkovParticleID_factory.h:72);
0232 the dispatch (RichGeo_service.cc:44-52) maps "RICHEndcapN" -> IrtGeoPFRICH
0233 and throws for anything else, while the DD4hep detector is named "PFRICH"
0234 (install/share/epic/compact/pid/pfrich.xml:70-73, type epic_PFRICH) and
0235 "RICHEndcapN" appears nowhere in the geometry.
0236 - The IRT geometry actually used is built by the DD4hep detector
0237 constructor epic/src/PFRICH_geo.cpp: AddNewDetector("PFRICH") (:80),
0238 SetContainerVolume "GasVolume" (:179), AddFlatRadiator "Aerogel" /
0239 "Acrylic" / "QuartzWindow" (:276 / :311 / :469). The conical mirrors ARE
0240 registered with IRT2, as OpticalBoundary of the GasVolume radiator via a
0241 ConicalSurface + cdet->StoreOpticalBoundary (:363-370, :393-401);
0242 WITH_IRT2_SUPPORT is on in the built install/lib/libepic.so.
0243 - Optical paths per HRPPD = 4 (PFRICH_geo.cpp:674 switch): direct,
0244 inner-mirror, outer-mirror, outer->inner; paths are truncated at 2
0245 reflections. HRPPD modules = 68 (9x9 flags grid, :479-489) => 272 IRT
0246 ray tracers. Each hit carries hit.m_IRTs of size 4 (Digitization.cc:78 ->
0247 CherenkovPhotonDetector::GetIRTs) and ProcessHits loops over them
0248 (ReconstructionFactory.cc:550): 4 ray-trace solves per hit per imaging
0249 radiator, i.e. ~4 x 367 ~ 1.5k solves/event at eta=-1.9.
0250 - With pfrich-reco.json only "Aerogel" has imaging:yes, so GasVolume (the
0251 radiator the cone is a boundary of) never enters the ring fit; nhits
0252 counts aerogel-attributed hits only.
0253
0254 C. MC-truth photon direction seed test. v2.2.3a3, eta=-1.9 sample, 300 events,
0255 README.AYK recipe, single-threaded. Config pfrich-reco-seedyes.json =
0256 pfrich-reco.json with "UseMcTruthPhotonDirectionSeed": "yes" (line 10;
0257 code default is true, the JSON "no" disables it via
0258 ReconstructionFactory::IgnoreMcTruthPhotonDirectionSeed, :282-284).
0259 seed "no" (baseline) seed "yes"
0260 wall 23.90 s 24.75 s
0261 IRT particles 295 295
0262 PDG {211:278, 321:16, 0:1} {211:286, 321:8, 0:1}
0263 pi correct 94.24% 96.95%
0264 mean npe 13.044 13.044 (unchanged by
0265 construction)
0266 mean nhits 7.173 10.831 (+51%)
0267 sum nhits / sum npe 2116 / 3848 = 0.5499 3195 / 3848 = 0.8303
0268 mean radiator angle 275.99 mrad 276.47 mrad
0269 Interpretation: the npe -> nhits deficit is dominated by IRT solver
0270 convergence, not by a missing mirror model. Seeding each hit with the true
0271 photon direction at the photocathode (Digitization.cc:132,
0272 photon->GetVertexMomentum().Unit()) raises the attached fraction from 55%
0273 to 83% and halves kaon mis-ID (321: 16 -> 8) at ~+0.9 s cost. Candidate
0274 explanations for the remaining 17% (NOT yet measured): photons needing >=3
0275 reflections (paths truncated at 2), hits whose best solution is attributed
0276 to the non-imaging GasVolume radiator, and the single-hit CCDF cut.
0277 CAVEAT: this mode is a diagnostic upper bound, not a reconstruction option
0278 -- it feeds truth information into the fit.
0279 Outputs: rec.edm4hep.pfrich.eta19.seedyes.root, pfrich_eta19_seedyes.root,
0280 eicrecon_eta19_seedyes.log, pfrich-reco-seedyes.json.
0281 ================================================================================
0282 D. Why nhits < npe (analysis of existing files, no new runs; eta=-1.9 sample,
0283 v2.2.3a3 baseline and seed-"yes" variant):
0284 Definitions (code): npe = photons in the particle's radiator history with
0285 WasDetected() (ReconstructionFactory.cc:1231-1233); nhits =
0286 ChargedParticle::GetRecoCherenkovPhotonCount() = attached DigitizedHits
0287 (:1226). They count different objects: photons vs hits.
0288 Measured chain of the yield, per event, 300 events:
0289 aerogel photons reaching the photosensor (sim truth, MC photon vertex z
0290 in [-1275,-1240] mm) 147.10
0291 virtual QE x collection-efficiency selection (IrtInterface.cc:299-311;
0292 geoEff = HRPPD_COLLECTION_EFFICIENCY = 0.70, QE table 160-660 nm
0293 x 0.81 rescaling) -> npe 12.83 (8.7%; naive
0294 <QE>x0.70 from the table = 13.3%)
0295 digitization cell merging (Digitization.cc:113-120, SensorActiveArea-
0296 Pixellation=32 over 10.8 cm -> 3.375 mm cells): -0.4% -> 12.64
0297 (blackout cells not configured; no out-of-area / unknown-cellID
0298 messages in the logs)
0299 attached (nhits): seed off 6.75 (plot nhitsA mean 7.20 per track)
0300 seed on 10.46 (plot nhitsA mean 10.87 per track)
0301 => digitization is NOT the loss (ceiling 99.6% of npe); the whole gap is
0302 "hit not attached". Attachment requires a converged IRT solution in at
0303 least one of the 4 modeled optical paths (ReconstructionFactory.cc:715
0304 "if (!sc.m_Solution) continue;") AND single-photon CCDF > cut
0305 (m_SingleHitCCDFcut = _SINGLE_HIT_CCDF_CUT_DEFAULT_ = 0.001, :4, not
0306 overridden in pfrich-reco.json); then AddHit() at :803.
0307 Evidence on which mechanism: ccdfphA (attached hits only) is broad, mean
0308 0.465 (seed off) / 0.474 (seed on), only 1.6% below 0.02 -> the 0.001 cut
0309 is not marginal; rejected hits have CCDF ~ 0 or no solution at all.
0310 thphA (Cherenkov angle offset of attached photons) rms 5.4 mrad, nothing
0311 beyond +-20 mrad -> rejection is hard, not a soft tail. Both point to
0312 photons whose true path is not among the 4 modeled ones (paths truncated
0313 at 2 reflections, PFRICH_geo.cpp:674).
0314 Not yet measured: the split between "no converged solution" and "CCDF
0315 below cut" -- needs one run with "WriteOutputTree": "yes".
0316 ================================================================================
0317
0318 STATE CHANGE 2026-11-14 17:54: the working tree of irt/ was checked out back
0319 to `main` (= tag v2.2.3, commit 1479e60, == origin/main). libIRT2.so and
0320 EICrecon's RICH-IRT.so were rebuilt and reinstalled from that commit, so
0321 the INSTALLED STACK IS NOW v2.2.3 (unpatched): nm -D -C install/lib/libIRT2.so
0322 contains no ScoreHits / HypoScore / MixtureLnL symbols.
0323 Nothing was deleted: branch irt-2.2a (tip 4878d0a) and the annotated tags
0324 v2.2.3a1 / v2.2.3a2 / v2.2.3a3 remain local-only (never pushed). To restore
0325 the patched stack: `git checkout irt-2.2a` (or `git checkout v2.2.3a3`) and
0326 rebuild + reinstall IRT2 and RICH-IRT.so.
0327 All measurements in sections A-D above were taken with the tags named in
0328 each entry; they are unaffected by this checkout.
0329 ================================================================================
0330
0331 STATE CHANGE 2026-11-14 18:58: irt/ checked out back to branch `irt-2.2a`
0332 (tip 4878d0a, `git describe --tags` = v2.2.3a3) and the stack rebuilt +
0333 reinstalled from it: install/lib/libIRT2.so (1 149 544 B) and
0334 install/lib/EICrecon/plugins/RICH-IRT.so (921 272 B), plugin resolving
0335 libIRT2.so to the local install. Verified patched: nm -D -C libIRT2.so
0336 exports ReconstructionFactory::ScoreHits(...) and ::MixtureLnL(...).
0337 => INSTALLED STACK IS v2.2.3a3 (Stage A per-hit hypothesis cache; the ML
0338 estimator from v2.2.3a2 is compiled in but only active with
0339 "Estimator": "ml" in the PFRICH config -- default remains "chi2").
0340 ================================================================================
0341
0342 STATE CHANGE 2026-11-14 19:11: irt/ checked out to `main` (1479e60, v2.2.3,
0343 == origin/main) and the stack rebuilt + reinstalled from it:
0344 install/lib/libIRT2.so (1 132 360 B) + install/lib/EICrecon/plugins/
0345 RICH-IRT.so (921 272 B). Verified unpatched: nm -D -C libIRT2.so has 0
0346 matches for ScoreHits / MixtureLnL.
0347 => INSTALLED STACK IS v2.2.3 (upstream, no Stage A, no ML estimator).
0348 Branch irt-2.2a (4878d0a) and tags v2.2.3a1/a2/a3 remain intact, local-only.
0349 ================================================================================
0350 ================================================================================
0351 APPENDED 2026-11-14 (branch irt-2.2a) -- Stage B implemented as three tagged
0352 sub-stages B1/B2/B3
0353 ================================================================================
0354 The plan above said "v2.2.3a4 = Stage B, v2.2.3a5 = Stage C". That split is
0355 superseded: Stage B was carried out as three separately tagged sub-stages,
0356 and the former Stage C (EM) is B3. Actual mapping (annotated tags, local
0357 only, on top of v2.2.3a3 = 4878d0a):
0358
0359 v2.2.3a4 = 074265d Stage B1 separable mixture objective
0360 v2.2.3a5 = 224795f Stage B2 PID hypothesis marginalized, scan removed
0361 v2.2.3a6 = a139245 Stage B3 expectation-maximization iterations
0362
0363 B1 (v2.2.3a4) -- "make the objective separable".
0364 ScoreMixture() evaluates, once per particle per iteration, every
0365 [hit,radiator,optical path] component of that particle with all
0366 hypothesis-independent lookups resolved (MixComponent: radiator, IRT
0367 solution, calibration bin, momentum + path length in the radiator,
0368 reference refractive index, angular resolution and offset, measured
0369 detection time) and aggregates them per [particle,hit,hypothesis]
0370 (MixAgg: log-sum-exp of the component log-densities + density-weighted
0371 mean Cherenkov angle). MixtureLnL() then only does log-sum-exp over
0372 cached aggregates, so the objective no longer depends on the
0373 [particle,hypothesis] combination. The per-component walk survives only
0374 in the a posteriori assignment pass. chi^2 path untouched; ML path
0375 mathematically unchanged (two-level log-sum-exp differs only by
0376 floating-point rounding).
0377
0378 B2 (v2.2.3a5) -- "hypothesis as a mixture-component index, cdim -> 1".
0379 MixtureLnLWeighted() evaluates the objective ONCE over
0380 [particle,hypothesis,radiator,optical path] components weighted by
0381 pi_{p,h} (pdim*hdim numbers, normalized to 1 per particle). For the
0382 mixture estimator cdim stays 1: the hdim^pdim combination loop is gone.
0383 The calibration pass, which used to force the truth combination, now
0384 starts from truth one-hot weights; everything else starts from a uniform
0385 prior. One M-step updates the weights from the responsibilities and the
0386 PID of a track is argmax_h pi_{p,h} (hypoBest[]). The a posteriori
0387 attachment picks the best [hypothesis,radiator,optical path] component
0388 of the most probable track and attaches only when that track's posterior
0389 exceeds 0.5. Single-photon plots are filled with soft,
0390 responsibility-weighted statistics over all hypotheses (normalization
0391 therefore differs from v2.2.3a2/a3 by construction). Neither the
0392 assignment nor the hypothesis is fixed a priori, so no hit is discarded
0393 and no ownership ambiguity can delete hits. chi^2 path and its scan are
0394 untouched and remain the reference implementation.
0395
0396 B3 (v2.2.3a6) -- "EM iterations".
0397 RunEM() iterates { E-step = separable objective at the current weights;
0398 M-step = closed-form pi_{p,h} update } until |dlnL| < EmTolerance
0399 (default 1e-6) or EmMaxIterations (default 20); the iteration count is
0400 kept (GetEmIterationsUsed) and printed in verbose mode.
0401 Deliberately NOT free parameters: the expected photon yield of a track.
0402 It is tied to the responsibility-weighted mean Cherenkov angle by the
0403 radiator yield model, and that tie is what makes the hypotheses
0404 identifiable once the assignment is marginalized; freeing it would make
0405 the extended Poisson term monotone in the number of assigned photons and
0406 destroy the discrimination. Global yield coefficients stay in the
0407 existing UpdateYields() calibration path.
0408 Optional (EmFitCalibration: "yes", default off): the per-[radiator,
0409 theta bin] angular offset and width are also updated by a maximization
0410 step (weighted least-squares fit of the single-photon angle residuals;
0411 moments cached in MixAgg: m_ThSolBar, m_ThSol2, m_ThSolP, m_ThP2). Since
0412 the objective uses those constants, the component caches are rebuilt
0413 after such an update, so the EM loop costs one component walk per
0414 iteration when it is enabled.
0415 New JSON keys: EmMaxIterations, EmTolerance, EmFitCalibration.
0416
0417 STATUS OF THE INSTALLED STACK: v2.2.3a6 (a139245). libIRT2.so and
0418 EICrecon's RICH-IRT.so were rebuilt and reinstalled from it (the header
0419 gained data members, so the plugin rebuild is mandatory).
0420
0421 VALIDATION STATUS -- NO RUNS WERE PERFORMED for B1/B2/B3. Per instruction,
0422 no npsim->eicrecon comparisons were made while implementing these stages.
0423 Each stage was verified to compile and link only. Outstanding validation,
0424 when runs are authorized:
0425 (1) chi^2 regression: outputs of v2.2.3a6 with "Estimator":"chi2" must be
0426 identical to the v2.2.3a3 entries in the MEASUREMENT LEDGER above
0427 (1/2/3/5-track samples, incl. PDG content, npe, nhits, radiator
0428 angle sums);
0429 (2) ML path: v2.2.3a4 vs v2.2.3a2/a3 must agree within floating-point
0430 rounding; v2.2.3a5/a6 vs v2.2.3a4 quantify the effect of hypothesis
0431 marginalization and of iterating EM;
0432 (3) timing: the ML estimator at 5 tracks (v2.2.3a2 cost 50.09 s vs chi^2
0433 46.79 s) should now be cheaper, since the scan is gone and the
0434 per-hit evaluation is cached -- measure with the README.AYK protocol
0435 (500 events, single-threaded, one run per configuration).
0436 ================================================================================
0437
0438 STATE CHANGE 2026-11-14 20:32: irt/ checked out to the annotated tag
0439 v2.2.3a4 (074265d, Stage B1; detached HEAD) and the stack rebuilt +
0440 reinstalled from it: install/lib/libIRT2.so (1 154 744 B) +
0441 install/lib/EICrecon/plugins/RICH-IRT.so (921 272 B), plugin resolving
0442 libIRT2.so to the local install.
0443 Verified by symbol check: libIRT2.so exports ScoreHits (Stage A),
0444 ScoreMixture + MixtureLnD + the combination-based MixtureLnL (Stage B1),
0445 and does NOT export MixtureLnLWeighted / RunEM (Stages B2/B3 absent).
0446 => INSTALLED STACK IS v2.2.3a4: chi^2 path with the Stage A per-hit cache;
0447 ML estimator = separable objective but still evaluated per
0448 [particle,hypothesis] combination (cdim = hdim^pdim), one E-step plus the
0449 a posteriori assignment.
0450 Branch irt-2.2a still points at a139245 (v2.2.3a6); tags a1..a6 intact.
0451 ================================================================================
0452
0453 STATE CHANGE 2026-11-14 20:36: irt/ checked out to the annotated tag
0454 v2.2.3a5 (224795f, Stage B2; detached HEAD) and the stack rebuilt +
0455 reinstalled from it: install/lib/libIRT2.so (1 158 864 B) +
0456 install/lib/EICrecon/plugins/RICH-IRT.so (921 272 B), plugin resolving
0457 libIRT2.so to the local install.
0458 Verified by symbol check: libIRT2.so exports ScoreHits (Stage A),
0459 ScoreMixture + MixtureLnD (Stage B1) and MixtureLnLWeighted (Stage B2);
0460 the combination-based MixtureLnL is gone and RunEM (Stage B3) is absent.
0461 => INSTALLED STACK IS v2.2.3a5: chi^2 path with the Stage A cache and its
0462 hdim^pdim scan (reference); ML estimator = separable objective with the
0463 PID hypothesis marginalized, cdim = 1, one M-step, PID = argmax_h pi_{p,h}.
0464 Branch irt-2.2a still points at a139245 (v2.2.3a6); tags a1..a6 intact.
0465 ================================================================================
0466
0467 STATE CHANGE 2026-11-14 20:42: irt/ checked out to branch `irt-2.2a`
0468 (tip a139245, `git describe --tags` = v2.2.3a6, Stage B3; branch used
0469 rather than the tag to avoid a detached HEAD) and the stack rebuilt +
0470 reinstalled from it: install/lib/libIRT2.so (1 164 032 B) +
0471 install/lib/EICrecon/plugins/RICH-IRT.so (921 272 B), plugin resolving
0472 libIRT2.so to the local install.
0473 Verified by symbol check: libIRT2.so exports ScoreHits (Stage A),
0474 ScoreMixture + MixtureLnD (B1), MixtureLnLWeighted (B2) and
0475 RunEM + RebuildMixtureCache + ApplyCalibrationMStep (B3).
0476 => INSTALLED STACK IS v2.2.3a6: chi^2 path with the Stage A cache and its
0477 hdim^pdim scan (reference); ML estimator = separable objective, PID
0478 hypothesis marginalized (cdim = 1), EM iterations to convergence
0479 (EmMaxIterations 20 / EmTolerance 1e-6 by default), optional
0480 EmFitCalibration M-step (off by default).
0481 ================================================================================
0482
0483 ================================================================================
0484 APPENDED 2026-11-14 (branch irt-2.2a) -- v2.2.3a7: M-steps for the mixture
0485 estimator
0486 ================================================================================
0487 v2.2.3a7 = d4ab0d8 (on top of v2.2.3a6 = a139245).
0488
0489 The EM loop now maximizes over all parameters of the per-hit mixture, which
0490 are collected in EmParameters:
0491 m_Pi pdim*hdim hypothesis weights pi_{p,h}, normalized to 1 per
0492 particle (unchanged closed-form update from the
0493 responsibilities);
0494 m_Background beta, the fraction of hits attributed to the flat background
0495 component;
0496 m_YieldScale per imaging radiator, the yield scale s_r of THIS event,
0497 multiplying m_YieldCff * m_DetectedToCalibrationPhotonRatio.
0498
0499 Mixture normalization (proper, sums to 1 per hit):
0500 beta*g + sum_{p,h} (1-beta)/pdim * pi_{p,h} * f_{p,h},
0501 g = 1/BackgroundWindow (flat in theta), f = the single-photon angular
0502 (and, when enabled, timing) Gaussian.
0503
0504 M-steps implemented:
0505 - pi_{p,h}: closed form, from the responsibilities (unchanged);
0506 - beta = (nhits - sum_p n_p)/nhits, i.e. the hits left over once every
0507 track has been paid its responsibilities; clamped to [1e-3, 0.999] to
0508 avoid the degenerate ends where the mixture either has no background
0509 slot or explains nothing;
0510 - s_r: multiplicative expectation-maximization update of a Poisson mean
0511 linear in the parameters,
0512 s_r <- s_r * sum_p n_p a_rp/lambda_p / sum_p a_rp,
0513 a_rp = s_r * YieldCff_r * ratio_r * sin^2(theta_p),
0514 which is exactly the stationary condition of the extended Poisson
0515 term sum_p [n_p log lambda_p - lambda_p];
0516 - Coffset / Csigma per [radiator,theta bin]: already present since
0517 v2.2.3a6, still OFF by default (EmFitCalibration: "yes" enables it; it
0518 mutates calibration constants the reconstruction itself uses and forces
0519 a component-cache rebuild per iteration).
0520
0521 Deliberately NOT free: the per-track expected yield. It stays tied to the
0522 responsibility-weighted mean Cherenkov angle through the radiator yield
0523 model -- that tie is what makes the hypotheses identifiable once the
0524 assignment is marginalized. Fitting only the global scale of each radiator
0525 keeps the sin^2(theta) dependence, and hence the discrimination, intact.
0526
0527 Scope safety: s_r and beta are per-event parameters held in EmParameters and
0528 are NEVER written back into the geometry or into the configuration.
0529 "BackgroundFraction" now only supplies the starting value of beta; the
0530 global yield fit remains the business of UpdateYields() on the calibration
0531 path.
0532
0533 New JSON keys: EmFitBackground, EmFitYields (both ON by default; "no"
0534 switches them off). EmFitCalibration unchanged (OFF by default). Verbose
0535 mode now also prints the fitted background fraction.
0536
0537 chi^2 path verified untouched: the diff of v2.2.3a6..v2.2.3a7 contains no
0538 change to ccdfevsave / ccdftrsave / npetrsave / sel / nsel / AddHit /
0539 chisquared_cdf_c / ScoreHits / ProcessHits / MinHitCountCutoff / hmatch.
0540
0541 INSTALLED STACK: v2.2.3a7 (libIRT2.so + RICH-IRT.so rebuilt and reinstalled;
0542 header gained data members, so the plugin rebuild is mandatory).
0543
0544 VALIDATION: still NO runs performed. Beyond the items listed above, v2.2.3a7
0545 adds: check EM monotonicity of lnL with the new M-steps, the number of
0546 iterations actually used, the fitted beta and s_r distributions, and whether
0547 fitting beta/s_r changes the pion efficiency and kaon mis-ID relative to
0548 v2.2.3a6.
0549 ================================================================================
0550
0551 STATE CHANGE 2026-11-15 13:06: irt/ checked out to `main` (1479e60, v2.2.3,
0552 == origin/main) and the stack rebuilt + reinstalled from it:
0553 install/lib/libIRT2.so (1 132 360 B) + install/lib/EICrecon/plugins/
0554 RICH-IRT.so (921 272 B), plugin resolving libIRT2.so to the local install.
0555 Verified unpatched: nm -D -C libIRT2.so has 0 matches for ScoreHits /
0556 ScoreMixture / MixtureLnD / MixtureLnLWeighted / RunEM /
0557 ApplyCalibrationMStep.
0558 => INSTALLED STACK IS v2.2.3 (upstream: no Stage A cache, no mixture
0559 estimator, no EM/M-steps).
0560 Branch irt-2.2a (d4ab0d8 = v2.2.3a7) and tags v2.2.3a1..a7 intact,
0561 local-only (never pushed). To restore the patched stack: `git checkout
0562 irt-2.2a` (or `git checkout v2.2.3a7`) + rebuild + reinstall IRT2 and
0563 RICH-IRT.so.
0564 ================================================================================
0565
0566 ================================================================================
0567 APPENDED 2026-11-15 -- v2.2.3a8 = EXPERIMENT on top of v2.2.3a7
0568 ================================================================================
0569 v2.2.3a8 = 9326e29 (branch irt-2.2a). Carried over verbatim from the
0570 uncommitted edits that were sitting in the `main` working tree at 13:39
0571 (they were never compiled there; preserved as stash@{0} "main EXPERIMENT:
0572 _EXPECTED_BG_PHOTON_COUNT_=0.1 + hard-coded m_YieldCff=160" and as the file
0573 main-exp-yield-bg.patch in the sandbox root). The switch to irt-2.2a had
0574 been refused by git until those edits were stashed on `main`.
0575
0576 1. #define _EXPECTED_BG_PHOTON_COUNT_ ( 0.1 )
0577 switches on the Poisson term for hits claimed by no track hypothesis:
0578 nbg counts hits with m_BackgroundCandidate,
0579 chi2ev += 2*(bexp - nbg + nbg*log(nbg/bexp)) and ndfev += 1, the
0580 latter only when hdim >= 2 (the PFRICH config has pi + K -> active).
0581
0582 2. Inside the per-track Poisson term of the chi^2 path:
0583 radiator->m_YieldCff = 160.0;
0584 radiator->m_DetectedToCalibrationPhotonRatio = 1.0;
0585 (debug printf left commented out, hence no such string in the binary).
0586
0587 CAVEATS when running this tag:
0588 - item 2 lives inside `if (!calibration && itr &&
0589 m_UsePoissonTermInChiSquare)`, so it is INERT while pfrich-reco.json
0590 keeps "UsePoissonTermInChiSquare": "no". Set it to "yes" for the
0591 hard-coded yields to take effect.
0592 - it mutates shared per-radiator state in place: the override persists
0593 across hypotheses, particles and events within the process, and
0594 overwrites whatever UpdateYields() or the calibration file set.
0595 - item 1 is NOT inert: with hdim >= 2 it changes the event-level chi^2,
0596 hence which [particle,hypothesis] combination wins.
0597 - the mixture/EM path (v2.2.3a4..a7) is untouched by this commit: under
0598 "Estimator":"ml" neither item applies (item 1 is chi^2-only, item 2 is
0599 inside the chi^2 branch); the ML lambda still uses m_YieldCff scaled
0600 by the per-event fitted yield scale s_r.
0601
0602 INSTALLED STACK: v2.2.3a8 -- install/lib/libIRT2.so (1 168 128 B) and
0603 install/lib/EICrecon/plugins/RICH-IRT.so (921 272 B) rebuilt and
0604 reinstalled from it at 14:06 (only the .cc changed, so no ABI break; the
0605 plugin was rebuilt anyway). Branch irt-2.2a now at 9326e29; tags
0606 v2.2.3a1..a8, all local-only. No runs performed on v2.2.3a8.
0607 ================================================================================
0608
0609 STATE CHANGE 2026-11-15 14:19: irt/ checked out back to `main` (1479e60,
0610 v2.2.3, == origin/main) and the stack rebuilt + reinstalled from it:
0611 install/lib/libIRT2.so (1 132 360 B) + install/lib/EICrecon/plugins/
0612 RICH-IRT.so (921 272 B), plugin resolving libIRT2.so to the local install.
0613 Verified pristine: 0 matches in libIRT2.so for ScoreHits / ScoreMixture /
0614 MixtureLnD / MixtureLnLWeighted / RunEM / ApplyCalibrationMStep, and 0
0615 active `#define _EXPECTED_BG_PHOTON_COUNT_` / `m_YieldCff = 160.0` in the
0616 checked-out source (the v2.2.3a8 experiment is NOT on main).
0617 => INSTALLED STACK IS v2.2.3 (upstream).
0618 Still preserved: stash@{0} "main EXPERIMENT: _EXPECTED_BG_PHOTON_COUNT_=0.1
0619 + hard-coded m_YieldCff=160" (restore with `git checkout main && git stash
0620 pop`), main-exp-yield-bg.patch, branch irt-2.2a at 9326e29 (v2.2.3a8) and
0621 tags v2.2.3a1..a8 -- all local-only, never pushed.
0622 ================================================================================
0623
0624 ================================================================================
0625 APPENDED 2026-11-15 -- BUGFIX (uncommitted, on `main`): wrong radix in the
0626 [particle -> hypothesis] combination index
0627 ================================================================================
0628 Reported in BUG.txt: swapping "IdentifiedParticles" from
0629 ["pi+","proton","K+"] to ["pi+","K+","proton"] made PID wrong in ~50% of
0630 cases, although reordering hypotheses must be a pure relabeling.
0631
0632 Root cause (present in every tag from v2.2.3 up through v2.2.3a8):
0633 the combination index is ENCODED with radix hdim
0634 for(...) cdim *= hdim; // cdim = hdim^pdim
0635 but DECODED with radix = number of particles:
0636 unsigned hypo = id%hdim; ... id /= Event()->ChargedParticles().size();
0637 correct only when hdim == pdim (or pdim == 1).
0638
0639 Effect when hdim != pdim (distinct combinations actually evaluated):
0640 pdim=2 hdim=3 : 9 iterations -> 6 distinct, missing (0,2),(1,1),(2,0)
0641 pdim=3 hdim=2 : 8 -> 4 ; pdim=5 hdim=3 : 243 -> 54 ; pdim=5 hdim=2 : 32 -> 8
0642 pdim=1 (any hdim) and pdim == hdim : unaffected
0643 Secondary effect: the calibration pass (itr=0) filter `if (pdg mismatch) goto
0644 _next_combination` can never find the truth-matching combination when that
0645 combination is one of the missing ones, so the calibration pass is silently
0646 skipped for those events.
0647
0648 Explains BUG.txt exactly: hepmc-writer-multiple-tracks.C:54
0649 `particles[itrack%2 ? 0 : 2]` with particles = {211, 321, 2212} makes every
0650 event (track0 = proton, track1 = pion):
0651 ["pi+","proton","K+"] -> truth (1,0) is scanned -> PID correct
0652 ["pi+","K+","proton"] -> truth (2,0) NEVER scanned; best possible is 1
0653 of 2 tracks right -> the observed ~50% mis-ID.
0654 Falsifiable prediction: of the 6 hypothesis orders, exactly two break --
0655 proton at index 2 with pion at 0, and pion at 2 with proton at 0.
0656
0657 FIX applied on `main` (source/ReconstructionFactory.cc, three sites, now at
0658 lines 581, 726, 876): `qid /= hdim;` and `id /= hdim;` instead of dividing
0659 by Event()->ChargedParticles().size().
0660
0661 Scope of the bug for the measurements in this ledger: with
0662 "IdentifiedParticles" = [pi+, proton, K+] (hdim=3) the 1-track and 3-track
0663 samples were unaffected (pdim == hdim or pdim == 1); the 2-track and
0664 5-track samples WERE affected -- identically in `main` and in every patched
0665 tag, so all comparisons remain internally valid, but their absolute PID
0666 numbers are degraded. Wall times are unaffected (the loop count cdim is
0667 unchanged).
0668 The ML estimator from v2.2.3a5 up does not decode the combination index at
0669 all (hypotheses are marginalized), so it is immune; v2.2.3a4's MixtureLnL
0670 inherited the same decode; the chi^2 reference path is affected everywhere.
0671
0672 STATUS: the fix is UNCOMMITTED on `main`, sitting in the same working tree
0673 as the user's experiment hunks (_EXPECTED_BG_PHOTON_COUNT_ = 0.1 and the
0674 hard-coded m_YieldCff = 160 / ratio = 1). Not tagged, not cherry-picked to
0675 irt-2.2a yet. Installed stack rebuilt from this tree at 14:44
0676 (install/lib/libIRT2.so + EICrecon/plugins/RICH-IRT.so), i.e. it now
0677 contains BOTH the fix and the experiment. No runs performed.
0678 ================================================================================