Skip to content

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.

@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.


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 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

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.

I remain concerned about the GetPrimaryEventVertex method. Specifically in a full simulation, we should be fitting to the reconstructed rather than the simulated event vertex. That said, we should not hold up getting this ready for data production.

mTreeData.fcsY.push_back( y0 );
mTreeData.fcsZ.push_back( zepd );
mTreeData.fcsDet.push_back( det );
TVector3 StFwdTrackMaker::GetEventPrimaryVertex(){
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't traced this through, but... if GetEventPrimaryVertex is used in the track fit, then I have some concerns with this implementation.

Here is my reading of what this does...

If the MC vertex is available, return it. If not, use the MuDst. If not... check to see if StEvent is available and return what we have. If not, return some default values.

Here are my concerns...

  1. StEvent is our event data model. We do not need to create the MuDst to run our code, but StEvent must be available. It is the preferred source for the primary vertex.

  2. Simulated vertices are returned if they are found, taking precedence if the vertex is available in StEvent / MuDst. This means that you will be treating simulated data and real data differently... you'll take the exact primary vertex for simulation (which is always the correct one) and the reconstructed primary vertex from data (which might not point to the real primary vertex).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@klendathu2k Thanks for pointing this out - I agree with your concerns. I will address this in new PR - The primary vertex handling can still be improved in a couple of ways in addition to your comment here. I will follow this up promptly with a (draft) PR so that this is addressed.

FillTrackDeltas();

LOG_INFO << "Forward tracking on this event took " << (FwdTrackerUtils::nowNanoSecond() - itStart) * 1e-6 << " ms" << endm;
/**********************************************************************/
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a show stopper ... but I would split visualization into a separate maker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@klendathu2k - thanks for the suggestion. While I was able to separate almost all of the other non-essential parts of the tracking (matching, QA+ttree generation, etc.) I have not yet been able to move this out of the core FwdTrackMaker because it needs the in-memory GenFit track object. I will continue to look into ways to separate it out.

The visualization is OFF by default (only turned on if the user turns it on)

@jdbrice
Copy link
Contributor Author

jdbrice commented Feb 25, 2025

@plexoos @genevb @iraklic @fisyak @R-Witt Can you please review the code / comments and resolutions. If things are good please approve - we'd like to get this merged

@jdbrice jdbrice requested a review from akioogawa February 26, 2025 15:57
@jdbrice jdbrice merged commit 0ad5eb6 into star-bnl:main Mar 5, 2025
148 checks passed
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.

6 participants