Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New FWD tracking mode based on FST-track finding #571

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

jdbrice
Copy link
Contributor

@jdbrice jdbrice commented Jul 25, 2023

These updates provide a new FWD tracking mode in which the track finding is one with FST information.
Tracks are then fit to valid Seeds and then (optionally) any FTT hits are added to the track if found along the trajectory.

This mode is needed for any analysis of real data at this point. That would include fast offline for ongoing data taking.

@jdbrice jdbrice requested a review from klendathu2k as a code owner July 25, 2023 19:21
@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 25, 2023

Note, this PR includes the changes from PR #569 but the only changes relevant here are those in StRoot/StFwdTrackMaker and StRoot/StFwdUtils/

@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 25, 2023

Also the CI jobs seem to be failing on code unrelated to my changes (things in StEvent)

@plexoos
Copy link
Member

plexoos commented Jul 25, 2023

These errors should be fixed first:

2023-07-25T19:47:18.5349686Z #10 1453.7 g++ -m64 -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -Werror -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc485 -D__ROOT__ -DNEW_DAQ_READER -I. -IStRoot -I.sl79_gcc485/include -I/opt/software/linux-scientific7-x86_64/gcc-4.8.5/root-5.34.38-l3v6vso6qgojm4l2ctwjojs6trbt4hpn/include -c .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx -o .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.o
2023-07-25T19:47:19.4377677Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx: In member function 'void StFwdAnalysisMaker::ProcessFwdTracks()':
2023-07-25T19:47:19.4378676Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:191:54: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4379329Z #10 1454.6          for( int i = 0; i < fcs->clusters(iDet).size(); i++){
2023-07-25T19:47:19.4379659Z #10 1454.6                                                       ^
2023-07-25T19:47:19.4380367Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:245:68: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4381434Z #10 1454.6          for ( int iEcal = 0; iEcal < fwdTrack->ecalClusters().size(); iEcal++ ){
2023-07-25T19:47:19.4381970Z #10 1454.6                                                                     ^
2023-07-25T19:47:19.4382676Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:263:62: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4383319Z #10 1454.6                  for( int i = 0; i < fcs->clusters(iDet).size(); i++){
2023-07-25T19:47:19.4383665Z #10 1454.6                                                               ^
2023-07-25T19:47:19.4384345Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:301:62: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4384994Z #10 1454.6                  for( int i = 0; i < fcs->clusters(iDet).size(); i++){
2023-07-25T19:47:19.4385329Z #10 1454.6                                                               ^
2023-07-25T19:47:19.4385933Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:235:15: error: unused variable 'c' [-Werror=unused-variable]
2023-07-25T19:47:19.4386330Z #10 1454.6          float c[9];
2023-07-25T19:47:19.4386574Z #10 1454.6                ^
2023-07-25T19:47:19.4387294Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx: In member function 'void StFwdAnalysisMaker::ProcessFwdMuTracks()':
2023-07-25T19:47:19.4388295Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:413:55: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4388939Z #10 1454.6              for( int i = 0; i < fcs->numberOfClusters(); i++){
2023-07-25T19:47:19.4389281Z #10 1454.6                                                        ^
2023-07-25T19:47:19.4389984Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:437:70: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4390652Z #10 1454.6          for ( size_t i = 0; i < muFwdTrack->mEcalClusters.GetEntries(); i++ ){
2023-07-25T19:47:19.4391042Z #10 1454.6                                                                       ^
2023-07-25T19:47:19.4391851Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:455:70: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
2023-07-25T19:47:19.4392547Z #10 1454.6          for ( size_t i = 0; i < muFwdTrack->mHcalClusters.GetEntries(); i++ ){
2023-07-25T19:47:19.4392918Z #10 1454.6                                                                       ^
2023-07-25T19:47:19.4393526Z #10 1454.6 .sl79_gcc485/OBJ/StRoot/StFwdUtils/StFwdAnalysisMaker.cxx:402:15: error: unused variable 'c' [-Werror=unused-variable]
2023-07-25T19:47:19.4394034Z #10 1454.6          float c[9];
2023-07-25T19:47:19.4394264Z #10 1454.6                ^

Copy link
Contributor

@klendathu2k klendathu2k left a comment

Choose a reason for hiding this comment

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

Few initial comments made. Will review in more detail tomorrow.

StRoot/StEvent/StFttCluster.h Outdated Show resolved Hide resolved
StRoot/StEvent/StFttPoint.h Outdated Show resolved Hide resolved
StRoot/StEvent/StFwdTrack.h Outdated Show resolved Hide resolved
StRoot/StFttClusterMaker/StFttClusterMaker.cxx Outdated Show resolved Hide resolved
StRoot/StFttClusterMaker/StFttClusterMaker.h Outdated Show resolved Hide resolved
StRoot/StFttClusterMaker/StFttClusterMaker.h Outdated Show resolved Hide resolved
@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 26, 2023

@klendathu2k I will remove everything StFtt related from this PR. Everything you suggest is valid - but it I've addressed it in PR #569 instead of here

@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 26, 2023

Well, I thought that PR #538 (Add Fwd Tracks to MuDst) was already merged. It was submitted in May but has not received any review. So I removed MuDST from the PR also (done in ae1dae2)

@plexoos
Copy link
Member

plexoos commented Jul 26, 2023

Well, I thought that PR #538 (Add Fwd Tracks to MuDst) was already merged. It was submitted in May but has not received any review. So I removed MuDST from the PR also (done in ae1dae2)

I reviewed #538 just now. It looks good to me. I suggest we merge it before this one

@jdbrice
Copy link
Contributor Author

jdbrice commented Dec 18, 2023

I finally updated this PR to include only the needed changes for this feature (FST based tracking)
Review can go ahead now

@jdbrice
Copy link
Contributor Author

jdbrice commented Dec 19, 2023

commit e65362f made changes to verify everything works for the ideal simulation cases:

  • FTT seed finding + FST refit
  • FST seed finding + FTT refit

I added:
StRoot/StFwdTrackMaker/macro/sim/ideal_sim.C
StRoot/StFwdTrackMaker/macro/sim/gen

to make running the code in this way easy. It can be tested with:

cons
ln -s StRoot/StFwdTrackMaker/macro/sim/ .
./sim/gen 100
./sim/ideal_sim.C 100

@jdbrice
Copy link
Contributor Author

jdbrice commented Apr 18, 2024

OK with 99752c4
I think I have brought in all of the most important updates:

  • Many changes throughout the StFwdTrackMaker package to improve memory management and remove old code / ensure debug and code meant for simulation only runs when requested.
  • StEvent and StMuDst have minor updates to the St(Mu)FwdTrack classes to allow MC association information
  • Updates to macros for standard use of the fwd tracking on simulation files, mudst etc.

Copy link
Contributor

@genevb genevb left a comment

Choose a reason for hiding this comment

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

Just a few minor observations. I didn't dig through all the sim and Tracker changes, so I can't comment on those.

@@ -19,6 +19,9 @@ void StMuFwdTrack::set( StFwdTrack * evTrack) {
mCharge = evTrack->charge();
mPrimaryMomentum = TVector3( evTrack->momentum().x(), evTrack->momentum().y(), evTrack->momentum().z() );

mIdTruth = evTrack->idTruth();
mQATruth = evTrack->qaTruth();

Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can tell, you rely on the default behavior of C++ to initialize the value of StEvent/StFwdTrack.cxx::mIdTruth to zero (for all real tracks), as it isn't explicitly initialized to have a default value neither there nor here. Is this the desired approach?

// needed since I use the StMuTrack
gSystem->Load("StarClassLibrary");
gSystem->Load("StStrangeMuDstMaker");
gSystem->Load("StMuDSTMaker");
Copy link
Contributor

Choose a reason for hiding this comment

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

loadSharedLibraries() already loads StarClassLibrary, StStrangeMuDstMaker, StMuDSTMaker, so not needed here. Not sure if I missed others, but this isn't critical.

cout << "LL1" << endl;
gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
loadSharedLibraries();
cout << "LL2" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

These three LL0/1/2 cout lines can probably be dropped off now?

@plexoos
Copy link
Member

plexoos commented Jun 26, 2024

Thank you, Daniel, for addressing the comments! Everything looks good as far as I can tell.

As a last request we discussed, could you point me to a recent data file with raw FST data from this run? I would like to extend our CI tests at https://github.com/star-bnl/star-sw/blob/main/tests/joblist.json#L1126, which already include data from 2023.

- Improve memory management of FwdHits
- Add FST and FTT detection methods to FwdHit class and update FwdGeomUtils
- cleanup track fitter logic
- Add additional track seed modes
- use enums where possible for clearer intentions
- remove histogram and ttree output from FwdTrackMaker and TrackFitter
- Tests against data and simulation
@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 5, 2024

@plexoos @iraklic Please let me know if anything more is needed before we can merge this PR. There are others that depend on this. From what I can tell the 2 tests that failed were due to network issues - @plexoos maybe knows better.

@iraklic
Copy link
Member

iraklic commented Jul 9, 2024

@plexoos @iraklic Please let me know if anything more is needed before we can merge this PR. There are others that depend on this. From what I can tell the 2 tests that failed were due to network issues - @plexoos maybe knows better.

Sorry for not answering so long. I am not ignoring your PR. I just have been super busy and this seems to be a substantial one, with the discussion that I have not really followed. I this it is better if I defer this to others, but I will go over this once I am back to the office if it is not done till then.

@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 18, 2024

@fgeurts @plexoos Please let me know if I need to do anything more. The recent commits were mostly clean-up (albeit a lot because I removed almost all debug histograms/ttree output). I am not sure why test 125 fails, I wonder if it is a separate issue? Either way I am looking into it.

@plexoos
Copy link
Member

plexoos commented Jul 19, 2024

The last time all checks passed was with this commit: @jdbrice
Use FST z locations from geom to identify hit plane index
0e9b674

However, the next commit failed: @jdbrice
Cleanup of the StFwdTrackMaker code
0241f63

Let's try to revert it to see if it really introduced a bug.

@plexoos
Copy link
Member

plexoos commented Jul 19, 2024

The test job 125 completed successfully after reverting the changes in @jdbrice's commit.

Use FST z locations from geom to identify hit plane index
0e9b674

This is the only test that uses the FwdTrack option:

bfc.C(200, "pp2022,StiCA,BEmcChkStat,epdhit,FwdTrack", "/star/rcf/test/daq/2023/072/23072022//st_physics_23072022_raw_4000001.daq")

From this, I conclude that something in that commit causes the test to fail.

@jdbrice
Copy link
Contributor Author

jdbrice commented Jul 21, 2024

Thank you @plexoos - I will investigate and try to resolve.

@jdbrice jdbrice added the FWD Forward Upgrade label Aug 22, 2024
@jdbrice
Copy link
Contributor Author

jdbrice commented Feb 3, 2025

@plexoos, @klendathu2k - I have finally identified the seg fault, it occurs when I try to find from various possible sources an event primary vertex. This is the code that fails:

    if(mMuDstMaker && mMuDstMaker->muDst() && mMuDstMaker->muDst()->primaryVertex() ) {
        mEventVertex.SetX(mMuDstMaker->muDst()->primaryVertex()->position().x());
        mEventVertex.SetY(mMuDstMaker->muDst()->primaryVertex()->position().y());
        mEventVertex.SetZ(mMuDstMaker->muDst()->primaryVertex()->position().z());
        mFwdVertexSource = kFwdVertexSourceTpc;
        return mEventVertex;
    } 

as you can see I am testing for nullptrs, and in the most recent code I print out each pointer:

StFwdTrackMaker:INFO  - Searching for Event Vertex from MuDstMaker: 0xc279e60
StFwdTrackMaker:INFO  - Searching for Event Vertex from MuDst: 0xc2825a0
StFwdTrackMaker:INFO  - Searching for Event Vertex from MuDst Primary Vertex: 0x700000000000093
StFwdTrackMaker:FATAL - TUnixSystem::DispatchSignals : segmentation violation
 Generating stack trace...

The mMuDstMaker->muDst()->primaryVertex() is NOT null but also not valid, so when it gets dereferenced it causes a set fault. However, in every other environment I can run (docker any container, RCF etc.) for the exact same chain (test 125) I get a nullptr for the mMuDstMaker->muDst()->primaryVertex() and the code runs fine.

So I will temporarily remove this code to fix this PR so we can move forward with the next library, but this is likely indicative of some deeper issues with the MuDst Primary Vertex. Let me know if you have any thoughts

@plexoos
Copy link
Member

plexoos commented Feb 3, 2025

Good catch, @jdbrice! Yeah, dereferencing an invalid pointer is a classic case of undefined behavior in C++, where it might work on one machine but crash on another.

@jdbrice
Copy link
Contributor Author

jdbrice commented Feb 4, 2025

@plexoos - thanks for the suggestions that helped me find it.

OK I 'd like to close this PR without adding anything else to it (except anything identified necessary by further review). I prefer to make any final changes needed for a new library in smaller more scoped PRs. So if you and @klendathu2k or @genevb etc can take a look, I will leave this alone for now. But it is ready from my side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FWD Forward Upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants