Track based distortions update#4318
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR adds a ChangesTPC residuals and matrix handling
Micromegas track matching default
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.23.0)offline/packages/tpccalib/TpcSpaceChargeMatrixContainerv2.cc┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m [00.18][ERROR]: unable to find a config; path offline/packages/tpccalib/PHTpcResiduals.cc┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m [00.19][ERROR]: unable to find a config; path offline/packages/tpccalib/TpcSpaceChargeMatrixInversion.cc┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m [00.17][ERROR]: unable to find a config; path Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 55a636c8-1e4a-4b8d-88ec-3dcd97f2df9c
📒 Files selected for processing (7)
offline/packages/tpccalib/PHTpcResiduals.ccoffline/packages/tpccalib/PHTpcResiduals.hoffline/packages/tpccalib/TpcSpaceChargeMatrixContainer.hoffline/packages/tpccalib/TpcSpaceChargeMatrixContainerv2.ccoffline/packages/tpccalib/TpcSpaceChargeMatrixContainerv2.hoffline/packages/tpccalib/TpcSpaceChargeMatrixInversion.ccoffline/packages/trackreco/PHMicromegasTpcTrackMatching.h
| std::unique_ptr<TFile> outputfile(TFile::Open(m_outputfile.c_str(), "RECREATE")); | ||
| outputfile->cd(); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Guard against a failed TFile::Open before dereferencing.
TFile::Open returns nullptr if the output file cannot be created (bad path, permissions, disk full). The subsequent outputfile->cd() would then dereference a null pointer and crash the job at End. Note that add_from_file already guards its TFile::Open with a null check, so this path is inconsistent.
🛡️ Proposed guard
std::unique_ptr<TFile> outputfile(TFile::Open(m_outputfile.c_str(), "RECREATE"));
+ if (!outputfile)
+ {
+ std::cout << "PHTpcResiduals::End - could not create output file " << m_outputfile << std::endl;
+ return Fun4AllReturnCodes::EVENT_OK;
+ }
outputfile->cd();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| std::unique_ptr<TFile> outputfile(TFile::Open(m_outputfile.c_str(), "RECREATE")); | |
| outputfile->cd(); | |
| std::unique_ptr<TFile> outputfile(TFile::Open(m_outputfile.c_str(), "RECREATE")); | |
| if (!outputfile) | |
| { | |
| std::cout << "PHTpcResiduals::End - could not create output file " << m_outputfile << std::endl; | |
| return Fun4AllReturnCodes::EVENT_OK; | |
| } | |
| outputfile->cd(); |
Build & test reportReport for commit 4d747f2e15e21f59a40bfe960c5ba05ae9b14265:
Automatically generated by sPHENIX Jenkins continuous integration |
Build & test reportReport for commit 81cccb72de6ca28c7b943bb8c909381778112a1c:
Automatically generated by sPHENIX Jenkins continuous integration |



This PR adds a number of functionalities to further test the Matrix inversion method for track-based distortion corrections.
Namely:
In addition the default minimum PT cut for the Micromegas-TPC matching module is moved back to 0.2 GeV.
It can be set manually in the steering macro (@pedroanietom used to have it at 0.5)
This increases by about x2 the number of TPC tracks correctly matched to TPOT. (TPOT clusters being later ignored in the track fit anyway).
Types of changes
What kind of change does this PR introduce? (Bug fix, feature, ...)
TODOs (if applicable)
Links to other PRs in macros and calibration repositories (if applicable)
This PR extends the TPC distortion-correction workflow to further test the matrix inversion approach on TPOT-related studies, improving track/cluster handling and enabling charge-dependent matrix storage. It also restores the Micromegas–TPC matching module’s default minimum pT cut to 0.2 GeV to increase the number of matched TPC tracks (while still ignoring TPOT clusters later in the track fit).
Key changes:
ignoreEdgeClustersoption (setIgnoreEdgeClusters(bool)) to optionally skip edge TPC clusters.m_matrix_container_posm_matrix_container_negm_ignoreEdgeClusters.virtual int get_entries() consttoTpcSpaceChargeMatrixContainer(default 0).get_entries()inTpcSpaceChargeMatrixContainerv2to return the total entries acrossm_entries(viastd::accumulate).TpcSpaceChargeMatrixInversionverbose logging to print loaded filenames/object names and entry counts (including viam_matrix_container->get_entries()after load/guard)._pt_cutto 0.2 GeV (still overrideable via the existing steering setter).Potential risk areas:
_posand_negmatrix containers may affect downstream code expecting only the original inclusive container names.get_entries()virtual method if they use custom container subclasses.Possible future improvements:
AI can make mistakes—please use best judgment when reviewing the implementation details and assumptions.