Skip to content

Feature/ivysaurus - #3

Open
imawby wants to merge 2 commits into
PandoraPFAOrg:mainfrom
imawby:feature/Ivysaurus
Open

Feature/ivysaurus#3
imawby wants to merge 2 commits into
PandoraPFAOrg:mainfrom
imawby:feature/Ivysaurus

Conversation

@imawby

@imawby imawby commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Hello!

This PR add the Ivysaurus training scripts to the LArPython repository, creating the ml/networks/training/ structure as requested.

The workflow is as follows:

  1. The user creates several .root files from the associated larpandora analyser
  2. The user runs 'CreateTrainingFile.py' to create .npz files which form the input to the training script. An example of this command is python3 CreateTrainArrays.py --file_name ivy_0.root --input_dir ~/LArPython/files/ --output_dir ~/LArPython/files/
  3. The user runs 'train.py' to train the network. An example of the command is python3 train.py --n_epochs=10 --input_dir ~/LArPython/primary_files/ --output_dir ~/LArPython/model/primary/ --learning_rate 0.00005 --batch_size 64
  4. DONE.

The network architecture is found in ivysaurus_model.py and Normalisation.py contains the normalisation constants used to normalise each parameter for training.

Although the .npz training files are split on the basis containment, the training can proceed on all particles.

@AndyChappell AndyChappell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor changes requested

Comment on lines +88 to +89
pfpVars_train = pfpVars[:,0][train_idx]
pfpVars_test = pfpVars[:,0][test_idx]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only x vars?

# Split training sample into contained and exiting
this_detector_boundaries = detector_boundaries.get(args.detector)

(startGridU, startGridU_valid,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be useful to have a comment that briefly notes the structures of the variables here.

train_idx = indices[:ntrain]
test_idx = indices[ntrain:ntrain + ntest]

startGridU_train = startGridU[train_idx]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It does seem as though having some of these variables as dictionaries keyed on U/V/W could make thiscode much more concise/

########################################################################################################

def readTree(args, detector) :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove

Comment on lines +246 to +250
displacement_valid = displacement > -0.5
dca_valid = dca > -0.5
trackStubLength_valid = trackStubLength > -0.5
nuVertexAvSeparation_valid = nuVertexAvSeparation > -0.5
nuVertexChargeAsymmetry_valid = nuVertexChargeAsymmetry > -0.5

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why compare to -0.5 here? Would > -1 not be more direct? Is it also worth adding an "invalid" value and using that in the comparison?

particlePDG[abs(particlePDG) == 13] = 0
particlePDG[abs(particlePDG) == 2212] = 1
particlePDG[abs(particlePDG) == 211] = 2
# particlePDG[abs(particlePDG) == 321] = 3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove

Comment on lines +92 to +97
startGridU = startGridU[target_mask]
startGridV = startGridV[target_mask]
startGridW = startGridW[target_mask]
endGridU = endGridU[target_mask]
endGridV = endGridV[target_mask]
endGridW = endGridW[target_mask]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not as big an effect as previously, but again, map based definitions here could compress some of the code

@@ -0,0 +1,41 @@
# Grid

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Brief comment about where these numbers come from

from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove one empty line

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.

2 participants