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

Use GBL v3 within hps-java #958

Merged
merged 32 commits into from
Apr 20, 2023
Merged

Use GBL v3 within hps-java #958

merged 32 commits into from
Apr 20, 2023

Conversation

tomeichlersmith
Copy link
Collaborator

@tomeichlersmith tomeichlersmith commented Mar 27, 2023

The main motivation for this update was to align the function signatures between the updated GBL v3 extern "C" functions and the functions in the JNA interface classes. In the course of developing this, I learned more about JNA and was able to make a few other enhancements.

  1. I merged all the JNA interface classes into one class GblInterface which directly represents the libGBL.so library it loads and calls the extern "C" functions defined within it.
  2. My developments to GBL included a "memory monitor" option which allowed me to find a few places where our alignment driver was leaking memory.
  3. I moved the GblJna example into the tracking test so functional usage of GBL is a part of the unit tests now.

Going to wait on my DESY GitLab merge request so that the GBL-JNA files can be linked with a specific version of GBL from the central public repository. For now, if you want to test this, you will need to compile the java-integration branch of my fork of GBL.

My DESY GitLab merge request was accepted and a new release has been made. Compile the updated GBL v3 with the JNA wrappers included by using v3.1 or newer.

git clone --depth 1 --branch V03-01-00 https://gitlab.desy.de/claus.kleinwort/general-broken-lines.git
cmake -B general-broken-lines/build -S general-broken-lines/cpp
cmake --build general-broken-lines/build

Running To Do

  • Get GBL developments merged
  • Move non-JNA GBL classes to a legacy sub-package avoid future confusion
    • Just a thought, willing to /not/ do this if others are against it
    • not going to do this in this PR
  • add doc comments (using mvn javadoc:javadoc to make sure they are picked up)

Validations To Do

  • Compare results of GBL Example1 between these developements and current hps-java
  • Compare calculated labels/derivatives between these developments and current hps-java - since this is a technical change, it should not change the values of these labels/derivatives outside of "normal" floating point errors
  • Make sure MPII have the same content when generated from the data

@pbutti
Copy link
Contributor

pbutti commented Mar 30, 2023

Nice work, Tom. There is a lot of clean-up, code is more easy to read and I'm happy to see that some parts are more concise. Also, great catches on the memory leaks.
I would like to see some validation of the changes:

  • Make sure Example1 gets the same results
  • Make sure that running on a single event (or few same events) we get the same labels/derivatives
  • Make sure that the MPII files have the same content on few events / tracks.

Maybe you have done this checks already, and from what I see from the code I do not see strong indication about expected changes, however this is a delicate part of the code, and best to make sure we get the same inputs to the minimizer.

@tomeichlersmith
Copy link
Collaborator Author

Good ideas on validation PF - I did do a quick comparison of the MPII files and found only floating-point differences between the my developments and what is currently on hps-java:master. I plan to rerun these validations in a more documented/formal way and post those results here so that everyone can be assured. I'll mark this PR as "Ready for Review" when I feel like I have no more To Dos and I think the branch is fully validated.

@tomeichlersmith
Copy link
Collaborator Author

tomeichlersmith commented Apr 3, 2023

Validation Update

I've written up a quick CLI for the GBL JNA example so it is easier to compare them. Since this did not exist on master, I have to compare this branch to another branch off master that only differs from master by the addition of this CLI.

Current GBL JNA Example

This is run on gbl-v3-jna-validation only cosmetically differing from master.

java -cp distribution/target/hps-distribution-5.2-SNAPSHOT-bin.jar org.hps.recon.tracking.gbl.GBLexampleJna1 -v -t 1 > master-gbl-jna-eg.log
Full Output
Running GBL Example!
  N Tries = 1 with N Layers = 10
UVDIR

 -0.0000 1.0000 0.0000
 -0.3000 -0.0000 0.9539

measPrec

 1000000.0000
 1000000.0000

measInvCov

 1000000.0000 0.0000
 0.0000 1000000.0000

scatPrec

 1000000.0000
 1000000.0000

clErr

 0.0010
 -0.1000
 0.2000
 -0.1500
 0.2500

clPar

 0.0005
 -0.0500
 0.1000
 -0.0750
 0.1250

clCov

 0.0000010 0.0000000 0.0000000 0.0000000 0.0000000
 0.0000000 0.0100000 0.0000000 0.0000000 0.0000000
 0.0000000 0.0000000 0.0400000 0.0000000 0.0000000
 0.0000000 0.0000000 0.0000000 0.0225000 0.0000000
 0.0000000 0.0000000 0.0000000 0.0000000 0.0625000

mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 0.00000 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 0.00000 0.00000 0.00000 1.00000 0.00000
 0.00000 0.00000 0.00000 0.00000 1.00000

clPar.tail

 -0.075
 0.125

measurement before smearing

 -0.075
 0.131

measurement after smearing

 -0.074
 0.132

Points::1
clPar before Scatter

 0.000
 -0.050
 0.100
 -0.154
 0.282


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.01572 0.00000
 0.00000 0.00000 0.04000 0.00000 0.06290
 -0.00000 0.01572 0.00000 0.04723 0.00000
 0.00000 0.00000 0.06290 0.00000 0.16140

clPar after Scatter

 0.000
 -0.050
 0.101
 -0.154
 0.282


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.01572 0.00000
 0.00000 0.00000 0.04000 0.00000 0.06290
 -0.00000 0.01572 0.00000 0.04723 0.00000
 0.00000 0.00000 0.06290 0.00000 0.16140

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.101
 -0.232
 0.440

--------

 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.03145 0.00000
 0.00000 0.00000 0.04000 0.00000 0.12580
 -0.00000 0.03145 0.00000 0.12141 0.00000
 0.00000 0.00000 0.12580 0.00000 0.45811

--------
3.144854510165755
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.232
 0.440

measurement before smearing

 -0.185
 0.482

measurement after smearing

 -0.184
 0.483

Points::3
clPar before Scatter

 0.000
 -0.050
 0.101
 -0.311
 0.598


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.04718 0.00000
 0.00000 0.00000 0.04000 0.00000 0.18869
 -0.00000 0.04718 0.00000 0.24505 0.00000
 0.00000 0.00000 0.18869 0.00000 0.95262

clPar after Scatter

 0.000
 -0.050
 0.101
 -0.311
 0.598


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.04718 0.00000
 0.00000 0.00000 0.04000 0.00000 0.18869
 -0.00000 0.04718 0.00000 0.24505 0.00000
 0.00000 0.00000 0.18869 0.00000 0.95262

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.101
 -0.389
 0.757

--------

 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.06291 0.00000
 0.00000 0.00000 0.04000 0.00000 0.25159
 -0.00001 0.06291 0.00000 0.41816 0.00000
 0.00000 0.00000 0.25159 0.00000 1.64494

--------
6.28970902033151
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.389
 0.757

measurement before smearing

 -0.389
 0.794

measurement after smearing

 -0.389
 0.794

Points::5
clPar before Scatter

 0.000
 -0.050
 0.101
 -0.468
 0.916


 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.07865 0.00000
 0.00000 0.00000 0.04000 0.00000 0.31449
 -0.00001 0.07865 0.00000 0.64076 0.00000
 0.00000 0.00000 0.31449 0.00000 2.53508

clPar after Scatter

 0.000
 -0.050
 0.102
 -0.468
 0.916


 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.07865 0.00000
 0.00000 0.00000 0.04000 0.00000 0.31449
 -0.00001 0.07865 0.00000 0.64076 0.00000
 0.00000 0.00000 0.31449 0.00000 2.53508

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.102
 -0.546
 1.076

--------

 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.09439 0.00000
 0.00000 0.00000 0.04000 0.00000 0.37740
 -0.00001 0.09439 0.00000 0.91286 0.00000
 0.00000 0.00000 0.37740 0.00000 3.62303

--------
9.434563530497265
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.546
 1.076

measurement before smearing

 -0.431
 1.176

measurement after smearing

 -0.430
 1.177

Points::7
clPar before Scatter

 0.000
 -0.050
 0.102
 -0.625
 1.235


 0.00000 -0.00000 0.00000 -0.00002 0.00000
 -0.00000 0.01001 0.00000 0.11014 0.00000
 0.00000 0.00000 0.04000 0.00000 0.44030
 -0.00002 0.11014 0.00000 1.23448 0.00000
 0.00000 0.00000 0.44030 0.00000 4.90879

clPar after Scatter

 0.000
 -0.050
 0.102
 -0.625
 1.235


 0.00000 -0.00000 0.00000 -0.00002 0.00000
 -0.00000 0.01001 0.00000 0.11014 0.00000
 0.00000 0.00000 0.04000 0.00000 0.44030
 -0.00002 0.11014 0.00000 1.23448 0.00000
 0.00000 0.00000 0.44030 0.00000 4.90879

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.102
 -0.703
 1.396

--------

 0.00000 -0.00000 0.00000 -0.00002 0.00000
 -0.00000 0.01002 0.00000 0.12590 0.00000
 0.00000 0.00000 0.04000 0.00000 0.50320
 -0.00002 0.12590 0.00000 1.60564 0.00000
 0.00000 0.00000 0.50320 0.00000 6.39238

--------
12.579418040663018
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.703
 1.396

measurement before smearing

 -0.703
 1.463

measurement after smearing

 -0.702
 1.463

Points::9
clPar before Scatter

 0.000
 -0.050
 0.102
 -0.781
 1.556


 0.00000 -0.00000 0.00000 -0.00003 0.00000
 -0.00000 0.01002 0.00000 0.14167 0.00000
 0.00000 0.00000 0.04000 0.00000 0.56611
 -0.00003 0.14167 0.00000 2.02636 0.00000
 0.00000 0.00000 0.56611 0.00000 8.07379

clPar after Scatter

 0.000
 -0.050
 0.103
 -0.781
 1.556


 0.00000 -0.00000 0.00000 -0.00003 0.00000
 -0.00000 0.01002 0.00000 0.14167 0.00000
 0.00000 0.00000 0.04001 0.00000 0.56611
 -0.00003 0.14167 0.00000 2.02636 0.00000
 0.00000 0.00000 0.56611 0.00000 8.07379

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.103
 -0.859
 1.717

--------

 0.00000 -0.00000 0.00000 -0.00004 0.00000
 -0.00000 0.01003 0.00000 0.15744 0.00000
 0.00000 0.00000 0.04001 0.00000 0.62901
 -0.00004 0.15744 0.00000 2.49669 0.00000
 0.00000 0.00000 0.62901 0.00000 9.95302

--------
15.724272550828772
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.859
 1.717

measurement before smearing

 -0.675
 1.877

measurement after smearing

 -0.674
 1.877

Points::11
clPar before Scatter

 0.000
 -0.050
 0.103
 -0.938
 1.878


 0.00000 -0.00000 0.00000 -0.00004 0.00000
 -0.00000 0.01003 0.00000 0.17323 0.00000
 0.00000 0.00000 0.04001 0.00000 0.69192
 -0.00004 0.17323 0.00000 3.01663 0.00000
 0.00000 0.00000 0.69192 0.00000 12.03008

clPar after Scatter

 0.000
 -0.049
 0.103
 -0.938
 1.878


 0.00000 -0.00000 0.00000 -0.00004 0.00000
 -0.00000 0.01003 0.00000 0.17323 0.00000
 0.00000 0.00000 0.04001 0.00000 0.69192
 -0.00004 0.17323 0.00000 3.01663 0.00000
 0.00000 0.00000 0.69192 0.00000 12.03008

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.103
 -1.016
 2.040

--------

 0.00000 -0.00001 0.00000 -0.00005 0.00000
 -0.00001 0.01004 0.00000 0.18902 0.00000
 0.00000 0.00000 0.04001 0.00000 0.75482
 -0.00005 0.18902 0.00000 3.58624 0.00000
 0.00000 0.00000 0.75482 0.00000 14.30497

--------
18.86912706099453
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.016
 2.040

measurement before smearing

 -1.016
 2.139

measurement after smearing

 -1.015
 2.139

Points::13
clPar before Scatter

 0.000
 -0.050
 0.103
 -1.094
 2.202


 0.00000 -0.00001 0.00000 -0.00006 0.00000
 -0.00001 0.01004 0.00000 0.20483 0.00000
 0.00000 0.00000 0.04001 0.00000 0.81773
 -0.00006 0.20483 0.00000 4.20554 0.00000
 0.00000 0.00000 0.81773 0.00000 16.77769

clPar after Scatter

 0.000
 -0.049
 0.104
 -1.094
 2.202


 0.00000 -0.00001 0.00000 -0.00006 0.00000
 -0.00001 0.01004 0.00000 0.20483 0.00000
 0.00000 0.00000 0.04001 0.00000 0.81773
 -0.00006 0.20483 0.00000 4.20554 0.00000
 0.00000 0.00000 0.81773 0.00000 16.77769

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.104
 -1.172
 2.365

--------

 0.00000 -0.00001 0.00000 -0.00007 0.00000
 -0.00001 0.01005 0.00000 0.22065 0.00000
 0.00000 0.00000 0.04001 0.00000 0.88064
 -0.00007 0.22065 0.00000 4.87458 0.00000
 0.00000 0.00000 0.88064 0.00000 19.44824

--------
22.013981571160286
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.172
 2.365

measurement before smearing

 -0.918
 2.584

measurement after smearing

 -0.918
 2.584

Points::15
clPar before Scatter

 0.000
 -0.050
 0.104
 -1.250
 2.528


 0.00000 -0.00001 0.00000 -0.00008 0.00000
 -0.00001 0.01005 0.00000 0.23649 0.00000
 0.00000 0.00000 0.04001 0.00000 0.94354
 -0.00008 0.23649 0.00000 5.59340 0.00000
 0.00000 0.00000 0.94354 0.00000 22.31663

clPar after Scatter

 0.000
 -0.049
 0.104
 -1.250
 2.528


 0.00000 -0.00001 0.00000 -0.00008 0.00000
 -0.00001 0.01005 0.00000 0.23649 0.00000
 0.00000 0.00000 0.04001 0.00000 0.94354
 -0.00008 0.23649 0.00000 5.59340 0.00000
 0.00000 0.00000 0.94354 0.00000 22.31663

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.104
 -1.328
 2.691

--------

 0.00000 -0.00001 0.00000 -0.00009 0.00000
 -0.00001 0.01006 0.00000 0.25234 0.00000
 0.00000 0.00000 0.04001 0.00000 1.00645
 -0.00009 0.25234 0.00000 6.36204 0.00000
 0.00000 0.00000 1.00645 0.00000 25.38286

--------
25.158836081326044
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.328
 2.691

measurement before smearing

 -1.328
 2.821

measurement after smearing

 -1.327
 2.822

Points::17
clPar before Scatter

 0.000
 -0.050
 0.104
 -1.406
 2.855


 0.00000 -0.00001 0.00000 -0.00010 0.00000
 -0.00001 0.01007 0.00000 0.26821 0.00000
 0.00000 0.00000 0.04001 0.00000 1.06936
 -0.00010 0.26821 0.00000 7.18056 0.00000
 0.00000 0.00000 1.06936 0.00000 28.64694

clPar after Scatter

 0.000
 -0.049
 0.105
 -1.406
 2.855


 0.00000 -0.00001 0.00000 -0.00010 0.00000
 -0.00001 0.01007 0.00000 0.26821 0.00000
 0.00000 0.00000 0.04001 0.00000 1.06936
 -0.00010 0.26821 0.00000 7.18056 0.00000
 0.00000 0.00000 1.06936 0.00000 28.64694

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.105
 -1.484
 3.019

--------

 0.00000 -0.00001 0.00000 -0.00011 0.00000
 -0.00001 0.01007 0.00000 0.28409 0.00000
 0.00000 0.00000 0.04001 0.00000 1.13227
 -0.00011 0.28409 0.00000 8.04901 0.00000
 0.00000 0.00000 1.13227 0.00000 32.10885

--------
28.3036905914918
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.484
 3.019

measurement before smearing

 -1.160
 3.297

measurement after smearing

 -1.159
 3.298

Points::19
--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.105
 -1.562
 3.183

--------

 0.00000 -0.00001 0.00000 -0.00013 0.00000
 -0.00001 0.01008 0.00000 0.29999 0.00000
 0.00000 0.00000 0.04001 0.00000 1.19519
 -0.00013 0.29999 0.00000 8.96743 0.00000
 0.00000 0.00000 1.19519 0.00000 35.76862

--------
29.87611784657468
--------
Time elapsed 104.728479 ms
Chi2/Ndf = 0.128012 
Tracks Fitted  1 

Developments GBL JNA Example

Running the branch attached to this PR. Note: without the GBL v3 library provided, you will see an error about an undefined function.

java -cp distribution/target/hps-distribution-5.2-SNAPSHOT-bin.jar org.hps.recon.tracking.gbl.GBLexampleJna1 -v -t 1 > dev-gbl-jna-eg.log
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'GblPoint_delete': /usr/local/lib/libGBL.so: undefined symbol: GblPoint_delete
        at com.sun.jna.Function.<init>(Function.java:252)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:594)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:570)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:556)
        at com.sun.jna.Library$Handler.invoke(Library.java:243)
        at com.sun.proxy.$Proxy0.GblPoint_delete(Unknown Source)
        at org.hps.recon.tracking.gbl.GblPointJna.delete(GblPointJna.java:82)
        at org.hps.recon.tracking.gbl.GBLexampleJna1.runExample(GBLexampleJna1.java:357)
        at org.hps.recon.tracking.gbl.GBLexampleJna1.main(GBLexampleJna1.java:424)

But in any case, I can provide the updated GBL v3 library.

java -cp distribution/target/hps-distribution-5.2-SNAPSHOT-bin.jar -Djna.library.path=/home/tom/hps/alignment/general-broken-lines/cpp/build/lib/ org.hps.recon.tracking.gbl.GBLexampleJna1 -v -t 1 > dev-gbl-jna-eg.log
Full Output
Running GBL Example!
UVDIR

 -0.0000 1.0000 0.0000
 -0.3000 -0.0000 0.9539

measPrec

 1000000.0000
 1000000.0000

measInvCov

 1000000.0000 0.0000
 0.0000 1000000.0000

scatPrec

 1000000.0000
 1000000.0000

clErr

 0.0010
 -0.1000
 0.2000
 -0.1500
 0.2500

clPar

 0.0005
 -0.0500
 0.1000
 -0.0750
 0.1250

clCov

 0.0000010 0.0000000 0.0000000 0.0000000 0.0000000
 0.0000000 0.0100000 0.0000000 0.0000000 0.0000000
 0.0000000 0.0000000 0.0400000 0.0000000 0.0000000
 0.0000000 0.0000000 0.0000000 0.0225000 0.0000000
 0.0000000 0.0000000 0.0000000 0.0000000 0.0625000

mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 0.00000 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 0.00000 0.00000 0.00000 1.00000 0.00000
 0.00000 0.00000 0.00000 0.00000 1.00000

clPar.tail

 -0.075
 0.125

measurement before smearing

 -0.075
 0.131

measurement after smearing

 -0.074
 0.132

Points::1
clPar before Scatter

 0.000
 -0.050
 0.100
 -0.154
 0.282


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.01572 0.00000
 0.00000 0.00000 0.04000 0.00000 0.06290
 -0.00000 0.01572 0.00000 0.04723 0.00000
 0.00000 0.00000 0.06290 0.00000 0.16140

clPar after Scatter

 0.000
 -0.050
 0.101
 -0.154
 0.282


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.01572 0.00000
 0.00000 0.00000 0.04000 0.00000 0.06290
 -0.00000 0.01572 0.00000 0.04723 0.00000
 0.00000 0.00000 0.06290 0.00000 0.16140

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.101
 -0.232
 0.440

--------

 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.03145 0.00000
 0.00000 0.00000 0.04000 0.00000 0.12580
 -0.00000 0.03145 0.00000 0.12141 0.00000
 0.00000 0.00000 0.12580 0.00000 0.45811

--------
3.144854510165755
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.232
 0.440

measurement before smearing

 -0.185
 0.482

measurement after smearing

 -0.184
 0.483

Points::3
clPar before Scatter

 0.000
 -0.050
 0.101
 -0.311
 0.598


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.04718 0.00000
 0.00000 0.00000 0.04000 0.00000 0.18869
 -0.00000 0.04718 0.00000 0.24505 0.00000
 0.00000 0.00000 0.18869 0.00000 0.95262

clPar after Scatter

 0.000
 -0.050
 0.101
 -0.311
 0.598


 0.00000 -0.00000 0.00000 -0.00000 0.00000
 -0.00000 0.01000 0.00000 0.04718 0.00000
 0.00000 0.00000 0.04000 0.00000 0.18869
 -0.00000 0.04718 0.00000 0.24505 0.00000
 0.00000 0.00000 0.18869 0.00000 0.95262

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.101
 -0.389
 0.757

--------

 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.06291 0.00000
 0.00000 0.00000 0.04000 0.00000 0.25159
 -0.00001 0.06291 0.00000 0.41816 0.00000
 0.00000 0.00000 0.25159 0.00000 1.64494

--------
6.28970902033151
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.389
 0.757

measurement before smearing

 -0.389
 0.794

measurement after smearing

 -0.389
 0.794

Points::5
clPar before Scatter

 0.000
 -0.050
 0.101
 -0.468
 0.916


 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.07865 0.00000
 0.00000 0.00000 0.04000 0.00000 0.31449
 -0.00001 0.07865 0.00000 0.64076 0.00000
 0.00000 0.00000 0.31449 0.00000 2.53508

clPar after Scatter

 0.000
 -0.050
 0.102
 -0.468
 0.916


 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.07865 0.00000
 0.00000 0.00000 0.04000 0.00000 0.31449
 -0.00001 0.07865 0.00000 0.64076 0.00000
 0.00000 0.00000 0.31449 0.00000 2.53508

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.102
 -0.546
 1.076

--------

 0.00000 -0.00000 0.00000 -0.00001 0.00000
 -0.00000 0.01001 0.00000 0.09439 0.00000
 0.00000 0.00000 0.04000 0.00000 0.37740
 -0.00001 0.09439 0.00000 0.91286 0.00000
 0.00000 0.00000 0.37740 0.00000 3.62303

--------
9.434563530497265
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.546
 1.076

measurement before smearing

 -0.431
 1.176

measurement after smearing

 -0.430
 1.177

Points::7
clPar before Scatter

 0.000
 -0.050
 0.102
 -0.625
 1.235


 0.00000 -0.00000 0.00000 -0.00002 0.00000
 -0.00000 0.01001 0.00000 0.11014 0.00000
 0.00000 0.00000 0.04000 0.00000 0.44030
 -0.00002 0.11014 0.00000 1.23448 0.00000
 0.00000 0.00000 0.44030 0.00000 4.90879

clPar after Scatter

 0.000
 -0.050
 0.102
 -0.625
 1.235


 0.00000 -0.00000 0.00000 -0.00002 0.00000
 -0.00000 0.01001 0.00000 0.11014 0.00000
 0.00000 0.00000 0.04000 0.00000 0.44030
 -0.00002 0.11014 0.00000 1.23448 0.00000
 0.00000 0.00000 0.44030 0.00000 4.90879

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.102
 -0.703
 1.396

--------

 0.00000 -0.00000 0.00000 -0.00002 0.00000
 -0.00000 0.01002 0.00000 0.12590 0.00000
 0.00000 0.00000 0.04000 0.00000 0.50320
 -0.00002 0.12590 0.00000 1.60564 0.00000
 0.00000 0.00000 0.50320 0.00000 6.39238

--------
12.579418040663018
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.703
 1.396

measurement before smearing

 -0.703
 1.463

measurement after smearing

 -0.702
 1.463

Points::9
clPar before Scatter

 0.000
 -0.050
 0.102
 -0.781
 1.556


 0.00000 -0.00000 0.00000 -0.00003 0.00000
 -0.00000 0.01002 0.00000 0.14167 0.00000
 0.00000 0.00000 0.04000 0.00000 0.56611
 -0.00003 0.14167 0.00000 2.02636 0.00000
 0.00000 0.00000 0.56611 0.00000 8.07379

clPar after Scatter

 0.000
 -0.050
 0.103
 -0.781
 1.556


 0.00000 -0.00000 0.00000 -0.00003 0.00000
 -0.00000 0.01002 0.00000 0.14167 0.00000
 0.00000 0.00000 0.04001 0.00000 0.56611
 -0.00003 0.14167 0.00000 2.02636 0.00000
 0.00000 0.00000 0.56611 0.00000 8.07379

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.103
 -0.859
 1.717

--------

 0.00000 -0.00000 0.00000 -0.00004 0.00000
 -0.00000 0.01003 0.00000 0.15744 0.00000
 0.00000 0.00000 0.04001 0.00000 0.62901
 -0.00004 0.15744 0.00000 2.49669 0.00000
 0.00000 0.00000 0.62901 0.00000 9.95302

--------
15.724272550828772
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -0.859
 1.717

measurement before smearing

 -0.675
 1.877

measurement after smearing

 -0.674
 1.877

Points::11
clPar before Scatter

 0.000
 -0.050
 0.103
 -0.938
 1.878


 0.00000 -0.00000 0.00000 -0.00004 0.00000
 -0.00000 0.01003 0.00000 0.17323 0.00000
 0.00000 0.00000 0.04001 0.00000 0.69192
 -0.00004 0.17323 0.00000 3.01663 0.00000
 0.00000 0.00000 0.69192 0.00000 12.03008

clPar after Scatter

 0.000
 -0.049
 0.103
 -0.938
 1.878


 0.00000 -0.00000 0.00000 -0.00004 0.00000
 -0.00000 0.01003 0.00000 0.17323 0.00000
 0.00000 0.00000 0.04001 0.00000 0.69192
 -0.00004 0.17323 0.00000 3.01663 0.00000
 0.00000 0.00000 0.69192 0.00000 12.03008

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.103
 -1.016
 2.040

--------

 0.00000 -0.00001 0.00000 -0.00005 0.00000
 -0.00001 0.01004 0.00000 0.18902 0.00000
 0.00000 0.00000 0.04001 0.00000 0.75482
 -0.00005 0.18902 0.00000 3.58624 0.00000
 0.00000 0.00000 0.75482 0.00000 14.30497

--------
18.86912706099453
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.016
 2.040

measurement before smearing

 -1.016
 2.139

measurement after smearing

 -1.015
 2.139

Points::13
clPar before Scatter

 0.000
 -0.050
 0.103
 -1.094
 2.202


 0.00000 -0.00001 0.00000 -0.00006 0.00000
 -0.00001 0.01004 0.00000 0.20483 0.00000
 0.00000 0.00000 0.04001 0.00000 0.81773
 -0.00006 0.20483 0.00000 4.20554 0.00000
 0.00000 0.00000 0.81773 0.00000 16.77769

clPar after Scatter

 0.000
 -0.049
 0.104
 -1.094
 2.202


 0.00000 -0.00001 0.00000 -0.00006 0.00000
 -0.00001 0.01004 0.00000 0.20483 0.00000
 0.00000 0.00000 0.04001 0.00000 0.81773
 -0.00006 0.20483 0.00000 4.20554 0.00000
 0.00000 0.00000 0.81773 0.00000 16.77769

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.104
 -1.172
 2.365

--------

 0.00000 -0.00001 0.00000 -0.00007 0.00000
 -0.00001 0.01005 0.00000 0.22065 0.00000
 0.00000 0.00000 0.04001 0.00000 0.88064
 -0.00007 0.22065 0.00000 4.87458 0.00000
 0.00000 0.00000 0.88064 0.00000 19.44824

--------
22.013981571160286
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.172
 2.365

measurement before smearing

 -0.918
 2.584

measurement after smearing

 -0.918
 2.584

Points::15
clPar before Scatter

 0.000
 -0.050
 0.104
 -1.250
 2.528


 0.00000 -0.00001 0.00000 -0.00008 0.00000
 -0.00001 0.01005 0.00000 0.23649 0.00000
 0.00000 0.00000 0.04001 0.00000 0.94354
 -0.00008 0.23649 0.00000 5.59340 0.00000
 0.00000 0.00000 0.94354 0.00000 22.31663

clPar after Scatter

 0.000
 -0.049
 0.104
 -1.250
 2.528


 0.00000 -0.00001 0.00000 -0.00008 0.00000
 -0.00001 0.01005 0.00000 0.23649 0.00000
 0.00000 0.00000 0.04001 0.00000 0.94354
 -0.00008 0.23649 0.00000 5.59340 0.00000
 0.00000 0.00000 0.94354 0.00000 22.31663

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.104
 -1.328
 2.691

--------

 0.00000 -0.00001 0.00000 -0.00009 0.00000
 -0.00001 0.01006 0.00000 0.25234 0.00000
 0.00000 0.00000 0.04001 0.00000 1.00645
 -0.00009 0.25234 0.00000 6.36204 0.00000
 0.00000 0.00000 1.00645 0.00000 25.38286

--------
25.158836081326044
--------
mDirT

 0.00000 0.00000
 1.00000 -0.00000
 0.00000 1.00000

ProM2L

 1.000 0.000
 0.000 0.954

proL2m

 1.000 0.000
 0.000 1.048

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.328
 2.691

measurement before smearing

 -1.328
 2.821

measurement after smearing

 -1.327
 2.822

Points::17
clPar before Scatter

 0.000
 -0.050
 0.104
 -1.406
 2.855


 0.00000 -0.00001 0.00000 -0.00010 0.00000
 -0.00001 0.01007 0.00000 0.26821 0.00000
 0.00000 0.00000 0.04001 0.00000 1.06936
 -0.00010 0.26821 0.00000 7.18056 0.00000
 0.00000 0.00000 1.06936 0.00000 28.64694

clPar after Scatter

 0.000
 -0.049
 0.105
 -1.406
 2.855


 0.00000 -0.00001 0.00000 -0.00010 0.00000
 -0.00001 0.01007 0.00000 0.26821 0.00000
 0.00000 0.00000 0.04001 0.00000 1.06936
 -0.00010 0.26821 0.00000 7.18056 0.00000
 0.00000 0.00000 1.06936 0.00000 28.64694

--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.105
 -1.484
 3.019

--------

 0.00000 -0.00001 0.00000 -0.00011 0.00000
 -0.00001 0.01007 0.00000 0.28409 0.00000
 0.00000 0.00000 0.04001 0.00000 1.13227
 -0.00011 0.28409 0.00000 8.04901 0.00000
 0.00000 0.00000 1.13227 0.00000 32.10885

--------
28.3036905914918
--------
mDirT

 0.00000 0.00000
 0.99499 -0.10000
 0.10000 0.99499

ProM2L

 0.995 -0.100
 0.095 0.949

proL2m

 0.995 0.105
 -0.100 1.043

JacPointToPoint

 1.00000 0.00000 0.00000 0.00000 0.00000
 -0.44970 1.00000 0.00000 0.00000 0.00000
 0.00000 0.00000 1.00000 0.00000 0.00000
 -0.35356 1.57243 0.00000 1.00000 0.00000
 0.00000 0.00000 1.57243 0.00000 1.00000

clPar.tail

 -1.484
 3.019

measurement before smearing

 -1.160
 3.297

measurement after smearing

 -1.159
 3.298

Points::19
--------
clPar/clCov/ds before next point

 0.000
 -0.050
 0.105
 -1.562
 3.183

--------

 0.00000 -0.00001 0.00000 -0.00013 0.00000
 -0.00001 0.01008 0.00000 0.29999 0.00000
 0.00000 0.00000 0.04001 0.00000 1.19519
 -0.00013 0.29999 0.00000 8.96743 0.00000
 0.00000 0.00000 1.19519 0.00000 35.76862

--------
29.87611784657468
--------
Time elapsed 108.581513 ms
Chi2/Ndf = 0.128012 
Tracks Fitted  1 

Difference (or lack thereof)

There is no difference between the two methods except the difference in timing.

917c916
< Time elapsed 104.728479 ms
---
> Time elapsed 108.581513 ms

To make sure this timing difference is not systematic, I ran without debug printouts and 100k tries.

# master-like branch
Time elapsed 22454.617711 ms
Chi2/Ndf = 0.128012 
Tracks Fitted  100000 
# these developments
Time elapsed 21110.374022 ms
Chi2/Ndf = 0.128012 
Tracks Fitted  100000 

@tomeichlersmith
Copy link
Collaborator Author

Second Validation Update

I am comparing this branch with V03-01-00 of GBL C++ to the master branch of hps-java and pbutti/GeneralBrokenLines. I will refer to the hps-java branch name in comparisons, but remember they require different GBL versions as well.

The run command looks like the following. The only change made between the two runs was the branch of hps-java compiled into the jar, the path to the GBL version, and the name of the output file. The lcsim file is copied below if you wish to inspect it.

java \
  -Xmx5000m \
  -XX:+UseSerialGC \
  -Djna.library.path=/full/path/to/gbl/build/lib \
  -jar ~/.m2/repository/org/hps/hps-distribution/5.2-SNAPSHOT/hps-distribution-5.2-SNAPSHOT-bin.jar \
  -R 10666 \
  -d L3TStereo_tu_50um_iter0 \
  -D outputFile=<hps-java-branch> \
  tracking_kf_alignment.lcsim \
  -i fee_recon_20um120nA_100.slcio

These produced identical millepede binary files (using cmp).
I looked into previous differences and they were due to a difference in the steering file configuration.
When using the same steering file, the same millepede binary files are produced.

tracking_kf_alignment.lcsim
<?xml version="1.0" encoding="UTF-8"?>
<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
    <!-- 
      Steering file for running KF tracking and mille alignment
      created:  Nov 2022
      @author Tom Eichlersmith <eichl008@umn.edu>
      @author PF <pbutti@slac.stanford.edu>
    -->
    <execute>
      
      <!-- Enable the following if re-processing lcio files -->
      <driver name="PreCleanupDriver"/>      
      
      <driver name="RfFitter"/>
      <driver name="EcalRunningPedestal"/> 
      <driver name="EcalRawConverter" />
      <driver name="EcalTimeCorrection"/> 
      <driver name="ReconClusterer" /> 
      <driver name="CopyCluster" /> 
      
      <!-- 
        SVT reconstruction drivers 
    
        SensorSetup associates hits with sensors without having to re-decode them.
        TrackerHitDriver assocites clusters with tracker modules without having to re-cluster.
      -->
      <driver name="SensorSetup"/>
      <driver name="TrackerHitDriver"/> 

      <!--
        Kalman tracking
      -->
      <driver name="KalmanPatRecDriver"/>
      <driver name="KalmanKinkFitDriver"/>
      <driver name="KalmanToGBLDriver"/> 
      
      <!--
        Use milli+GBL to prepare alignment data file for pede
      -->
      <driver name="SimpleGBLTrajAliDriverKF"/>
      
      <!-- it has to be before GBLOutputDriver -->
      <driver name="MultEvtVtx" />
      
      <!--
      Write out histograms
      <driver name="GBLOutputDriverKF"/>
      -->
      <driver name="GBLOutputDriver" />
      
      <driver name="CleanupDriver"/>
    </execute>    
    <drivers>    
        <driver name="PreCleanupDriver" type="org.hps.analysis.dataquality.ReadoutCleanupDriver">
          <!--Clean collections-->
          
          <collectionNames>EcalCalHits EcalClusters EcalClustersCorr FinalStateParticles UnconstrainedV0Candidates UnconstrainedV0Vertices TargetConstrainedV0Candidates TargetConstrainedV0Vertices BeamspotConstrainedV0Candidates BeamspotConstrainedV0Vertices GBLKinkData GBLKinkDataRelations MatchedToGBLTrackRelations HelicalTrackHits HelicalTrackHitRelations MatchedTracks GBLTracks MatchedToGBLTrackRelations RotatedHelicalTrackHits RotatedHelicalTrackHitRelations TrackData TrackDataRelations TrackResiduals TrackResidualsRelations RotatedHelicalTrackHits RotatedHelicalTrackHitRelations StripClusterer_SiTrackerHitStrip1D </collectionNames>

        </driver>
        
        <driver name="RfFitter" type="org.hps.evio.RfFitterDriver"/>       

        <!-- Ecal reconstruction drivers -->
        <driver name="EcalRunningPedestal" type="org.hps.recon.ecal.EcalRunningPedestalDriver">
            <logLevel>CONFIG</logLevel>
        </driver>
        <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverter2Driver">
            <!-- ecalCollectionName>EcalCalHits</ecalCollectionName -->
            <!-- fixShapeParameter>true</fixShapeParameter -->
            <!-- globalFixedPulseWidth>2.4</globalFixedPulseWidth -->
        </driver> 
        <driver name="EcalTimeCorrection" type="org.hps.recon.ecal.EcalTimeCorrectionDriver"/> 
        <driver name="ReconClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver">
            <logLevel>WARNING</logLevel>
            <outputClusterCollectionName>EcalClusters</outputClusterCollectionName>
        </driver> 
        <driver name="CopyCluster" type="org.hps.recon.ecal.cluster.CopyClusterCollectionDriver">
            <inputCollectionName>EcalClusters</inputCollectionName>
            <outputCollectionName>EcalClustersCorr</outputCollectionName>
        </driver>
        
        <!-- SVT reconstruction drivers -->
        <driver name="SensorSetup" type="org.hps.recon.tracking.SensorSetup" >
          <readoutCollections>SVTRawTrackerHits</readoutCollections>
          <fittedHitCollection>SVTFittedRawTrackerHits</fittedHitCollection>
        </driver>
        
        <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver">
            <neighborDeltaT>8.0</neighborDeltaT>
            <saveMonsterEvents>false</saveMonsterEvents>
            <thresholdMonsterEvents>200</thresholdMonsterEvents>
            <debug>false</debug>
        </driver>

        <driver name="GBLOutputDriver" type="org.hps.recon.tracking.gbl.GBLOutputDriver">
          <nHits>6</nHits> <!-- minimum hits -->
          <outputPlotsFilename>${outputFile}_gblplots.root</outputPlotsFilename>
          <bsZ>-7.5</bsZ>
          <trackCollectionName>GBLTracks</trackCollectionName>

          <!--the KF tracks refitted as GBL don't have kinks?? -->
          <doGBLkinks>false</doGBLkinks> 
          <dataRelationCollection>""</dataRelationCollection>

          <chi2Cut>9999</chi2Cut>
        </driver>

        <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"/>

        <driver name="MultEvtVtx" type="org.hps.recon.vertexing.MultipleEventsVertexingDriver">
          <ntrks>100</ntrks>
        </driver>

        <driver name="KalmanPatRecDriver" type="org.hps.recon.tracking.kalman.KalmanPatRecDriver">
          <!--<doDebugPlots>false</doDebugPlots>-->
          <!-- <siHitsLimit>50</siHitsLimit> -->
          <seedCompThr>0.05</seedCompThr>
          <addResiduals>true</addResiduals>
          <verbose>false</verbose>
        </driver>
        
        <!-- do front-back kink plots -->
        <driver name="KalmanKinkFitDriver" type="org.hps.recon.tracking.kalman.KalmanKinkFitDriver">
        </driver>

        <!-- Form trajectories for MPII using the GBL algorithm, starting from Kalman Tracks -->
        <driver name="KalmanToGBLDriver" type="org.hps.recon.tracking.gbl.KalmanToGBLDriver">
          <!--<debug>true</debug>-->
        </driver>
        
        <!-- Form trajectories for MPII using the GBL algorithm -->
        <driver name="SimpleGBLTrajAliDriverKF" 
                type="org.hps.recon.tracking.gbl.SimpleGBLTrajAliDriver" >

          <!-- apply the track quality cuts -->
          <enableAlignmentCuts>true</enableAlignmentCuts> 
          <!--
          <doCOMAlignment>true</doCOMAlignment>
          <minMom>0.5</minMom> 
          <maxMom>5.0</maxMom> 
          -->
          <nHitsCut>6</nHitsCut> <!-- minimum number of hits to be included -->

          <debugAlignmentDs>false</debugAlignmentDs>

          <correctTrack>true</correctTrack> <!-- refit with GBL before doing Mille -->
          <includeNoHitScatters>false</includeNoHitScatters>
          <gblRefitIterations>0</gblRefitIterations>
          <storeTrackStates>true</storeTrackStates>
          <compositeAlign>true</compositeAlign>

          <!-- <momC>4.55</momC> momentum constraint [GeV] -->
          <constrainedFit>false</constrainedFit> <!-- apply momentum constraint -->

          <constrainedBSFit>false</constrainedBSFit> <!-- apply beam spot constraint -->
          <!-- <bsZ>-7.7</bsZ> beam spot z-coordinate, used to calculate beam spot -->

          <trackSide>-1</trackSide> <!--hole-->

          <writeMilleBinary>true</writeMilleBinary>
          <milleBinaryFileName>${outputFile}_millepede.bin</milleBinaryFileName>
          <writeMilleChi2Cut>5</writeMilleChi2Cut>  <!-- max Chi2/Ndf to be included -->

          <enableStandardCuts>false</enableStandardCuts>
          <maxTrackChisq4hits>60.</maxTrackChisq4hits>
          <maxTrackChisq5hits>60.</maxTrackChisq5hits>
          <maxTrackChisq6hits>60.</maxTrackChisq6hits>

          <inputCollectionName>KalmanFullTracks</inputCollectionName>
        </driver> 
        
        <driver name="GBLOutputDriverKF" type="org.hps.recon.tracking.gbl.GBLOutputDriver">
          <nHits>0</nHits> <!-- minimum hits -->
          <outputPlotsFilename>${outputFile}_gblplots_from_kf.root</outputPlotsFilename>
          <bsZ>-7.5</bsZ>
          <trackCollectionName>KalmanFullTracks</trackCollectionName>
          <trackResidualsRelColName>TrackResidualsKFtoGBLRelations</trackResidualsRelColName>

          <!-- need to find relation collection for Kalma -->
          <doGBLkinks>false</doGBLkinks>
          <dataRelationCollection>""</dataRelationCollection>

          <chi2Cut>9999</chi2Cut>
        </driver>
        
    </drivers>
</lcsim>

@tomeichlersmith tomeichlersmith marked this pull request as ready for review April 5, 2023 14:39
@JeremyMcCormick
Copy link
Member

Would it be possible to add one or more tests for these changes that can run with the hps-java build?

@tomeichlersmith
Copy link
Collaborator Author

I added running the example to the tests - do you mean running over actual data files?

@JeremyMcCormick
Copy link
Member

I added running the example to the tests - do you mean running over actual data files?

I meant an actual junit TestCase that could run with the build automatically.

Is this tricky due to the dependency on the GBL system library?

@tomeichlersmith
Copy link
Collaborator Author

I know what you meant and I did implement more tests into the GblJna test case:

https://github.com/JeffersonLab/hps-java/pull/958/files#diff-17acd557e72e8392c874ae13e94ffa01495bbe5c279301cdea0b23ff79a30006

@tomeichlersmith
Copy link
Collaborator Author

It will be interesting to see how this test fares on systems without GBL accessible - hopefully it just reports it as a failure without anything more.

resolved conflict form tabbing different in SimpleGBLTrajAliDriver,
tabbing updated in PR #972 when PF moved where the closing bracket to
compositeAlign was
@tomeichlersmith
Copy link
Collaborator Author

I resolved the conflict created by different tabbing relative to #972 and reran the full tests (including the updated GBL tests). Looks all good!

[INFO] Reactor Summary for HPS Java 5.2-SNAPSHOT:
[INFO] 
[INFO] HPS Java ........................................... SUCCESS [  1.728 s]
[INFO] logging ............................................ SUCCESS [  1.575 s]
[INFO] util ............................................... SUCCESS [  1.752 s]
[INFO] detector-data ...................................... SUCCESS [  8.133 s]
[INFO] conditions ......................................... SUCCESS [  3.681 s]
[INFO] detector-model ..................................... SUCCESS [ 20.230 s]
[INFO] record-util ........................................ SUCCESS [  1.840 s]
[INFO] ecal-recon ......................................... SUCCESS [  1.284 s]
[INFO] ecal-readout-sim ................................... SUCCESS [  0.907 s]
[INFO] tracking ........................................... SUCCESS [  3.758 s]
[INFO] recon .............................................. SUCCESS [  1.190 s]
[INFO] analysis ........................................... SUCCESS [  2.887 s]
[INFO] digi ............................................... SUCCESS [  0.389 s]
[INFO] job ................................................ SUCCESS [  0.279 s]
[INFO] evio ............................................... SUCCESS [  0.686 s]
[INFO] steering-files ..................................... SUCCESS [  0.330 s]
[INFO] online-monitoring .................................. SUCCESS [  2.014 s]
[INFO] online-recon ....................................... SUCCESS [  1.541 s]
[INFO] distribution ....................................... SUCCESS [  6.548 s]
[INFO] plugin ............................................. SUCCESS [  0.374 s]
[INFO] integration-tests .................................. SUCCESS [15:11 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16:13 min
[INFO] Finished at: 2023-04-10T15:08:49Z
[INFO] ------------------------------------------------------------------------

@tomeichlersmith
Copy link
Collaborator Author

While cleaning up the GblPoints and helixes is not as much memory as the original GblTrajectory it still is substantial.

Anecdotally, earlier this week I was running on 2016 data that took ~2hrs to run. I could run manually at SDF but my batch jobs were crashed, being evicted since they went over the memory limit. To test this, I manually monitored the memory of a single run by watching RES in top.

Running with hps-java master, I gave the JVM 3G and saw that, by the end of the run, RES had ballooned into 8G for the process. This is approximately 5G of leaked memory over that long run. Using this branch with its memory patches kept the RES in top at 3.2G over the entire run for the same input data and steering file.

@normangraf
Copy link
Contributor

Do you have CPU times and memory usage when running the native Java version?

@tomeichlersmith
Copy link
Collaborator Author

Again anecdotally...

The native java (i.e. non-JNA) version stays within the scope of the memory allocated to the JVM (so RES stays at or below 3G), but it takes about 50% longer for the same input file (~3hrs).

Copy link
Collaborator

@cbravo135 cbravo135 left a comment

Choose a reason for hiding this comment

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

Tested in my alignment workflow. Works great and confirmed needs less memory.

@cbravo135 cbravo135 merged commit 585058f into JeffersonLab:master Apr 20, 2023
@tomeichlersmith tomeichlersmith deleted the gbl-v3-jna branch April 20, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants