Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
6a8989b
Trian using XGBoost
GernotMaier Dec 2, 2025
91d2298
naming
GernotMaier Dec 2, 2025
081c878
Apply XGBoost
GernotMaier Dec 2, 2025
d6ab5fb
naming
GernotMaier Dec 2, 2025
912310a
consistent tree naming
GernotMaier Dec 2, 2025
5ab28f1
Add variables
GernotMaier Dec 3, 2025
adea7df
fix branches
GernotMaier Dec 3, 2025
c1c5966
use dispx
GernotMaier Dec 3, 2025
593b534
floats
GernotMaier Dec 4, 2025
364ebdd
Train Dir BDTs
GernotMaier Nov 23, 2025
88b33d6
improve training/testing events
GernotMaier Nov 23, 2025
3fdb3a5
fix file issue
GernotMaier Nov 23, 2025
e04750a
fix file issue
GernotMaier Nov 23, 2025
4cc486f
error search
GernotMaier Nov 23, 2025
fc5f20c
help message
GernotMaier Nov 23, 2025
9b2fef8
efficiency
GernotMaier Nov 24, 2025
da943ba
application to evaluate direction
GernotMaier Nov 27, 2025
f9e11f8
naming
GernotMaier Nov 27, 2025
f7988dc
loop correction
GernotMaier Nov 27, 2025
2eca3fc
variables
GernotMaier Nov 27, 2025
6805f28
fix naming
GernotMaier Nov 27, 2025
d382df9
add a friend
GernotMaier Nov 27, 2025
e96a6c9
improved reco
GernotMaier Nov 28, 2025
ea49e67
MLP multi-target regression
GernotMaier Nov 28, 2025
79a8b4a
typo in Makefile
GernotMaier Nov 28, 2025
8b33fa1
add 2D MLP
GernotMaier Nov 29, 2025
733a764
bug fix in indexing
GernotMaier Nov 29, 2025
b0acd1f
nvar
GernotMaier Nov 29, 2025
60aa7bc
r/psi training
GernotMaier Dec 1, 2025
bd7656e
correct target
GernotMaier Dec 2, 2025
b977725
flexible usage of XY trees
GernotMaier Dec 4, 2025
88075f7
typo
GernotMaier Dec 4, 2025
9247874
ablation study
GernotMaier Dec 4, 2025
b699527
efficiency
GernotMaier Dec 4, 2025
67a9424
vectorized version
GernotMaier Dec 4, 2025
064e627
robustness
GernotMaier Dec 5, 2025
c0eed24
train for R
GernotMaier Dec 6, 2025
eec69b9
train in R
GernotMaier Dec 6, 2025
af0142c
apply for R
GernotMaier Dec 6, 2025
4f9dbdf
stupid
GernotMaier Dec 6, 2025
5b8eec3
weighting
GernotMaier Dec 6, 2025
c517d5b
SHAP
GernotMaier Dec 6, 2025
7e1f509
comments
GernotMaier Dec 7, 2025
9015a9c
childs
GernotMaier Dec 7, 2025
2e11159
feature match
GernotMaier Dec 7, 2025
807f507
no weight
GernotMaier Dec 7, 2025
4377be4
children
GernotMaier Dec 8, 2025
dc9a392
pointing corrections
GernotMaier Dec 11, 2025
07ed539
fix in filling
GernotMaier Dec 11, 2025
58dc563
print
GernotMaier Dec 11, 2025
636a8c1
dcen_x [skip ci]
GernotMaier Dec 11, 2025
db6a687
feature exclude [skip ci]
GernotMaier Dec 11, 2025
55d8290
0 events
GernotMaier Dec 11, 2025
7fd2433
print feature columns
GernotMaier Dec 11, 2025
ee7ab69
Merge branch 'main' into v492-dev8-XGBoost
GernotMaier Dec 11, 2025
72c126d
cleanup
GernotMaier Dec 11, 2025
8cc7b26
astyle
GernotMaier Dec 11, 2025
1c12020
add pre-commit
GernotMaier Dec 11, 2025
2e95960
no actionlint
GernotMaier Dec 11, 2025
7cac109
no actionlint
GernotMaier Dec 11, 2025
e891158
changelogs
GernotMaier Dec 11, 2025
e00f369
Merge branch 'main' into v492-dev8-XGBoost
GernotMaier Dec 11, 2025
6d834a0
Merge branch 'main' into v492-dev8-XGBoost
GernotMaier Dec 11, 2025
94adf2f
cleanup
GernotMaier Dec 11, 2025
05afbbb
add printBinaryOrbitalPhase to general target
GernotMaier Dec 12, 2025
0fc49f3
Merge branch 'main' into v492-dev8-XGBoost
GernotMaier Dec 12, 2025
8e65b9b
python directory
GernotMaier Dec 12, 2025
4424e31
training variables and weighting
GernotMaier Dec 12, 2025
d5eef20
eval
GernotMaier Dec 12, 2025
45bd8c8
weights
GernotMaier Dec 12, 2025
521d7bf
apply
GernotMaier Dec 12, 2025
15c3143
no mc weight
GernotMaier Dec 12, 2025
bc2c828
hubert
GernotMaier Dec 12, 2025
89f8db8
correct variables
GernotMaier Dec 12, 2025
ae391e7
no weight
GernotMaier Dec 13, 2025
c34734c
add RF
GernotMaier Dec 13, 2025
510f880
disable RF
GernotMaier Dec 14, 2025
17e329b
apply
GernotMaier Dec 14, 2025
cf19c19
random state
GernotMaier Dec 14, 2025
aaec43e
add XGB to effective areas
GernotMaier Dec 14, 2025
c881052
improved naming
GernotMaier Dec 15, 2025
10812b0
Xoff/Yoff and derotated coordinates
GernotMaier Dec 15, 2025
f46f4fe
astyle
GernotMaier Dec 15, 2025
f1edf60
nofile
GernotMaier Dec 15, 2025
c7d5037
Update python/applyXGBoostforDirection.py
GernotMaier Dec 15, 2025
43b3a82
review comments
GernotMaier Dec 15, 2025
01b8be0
changelog
GernotMaier Dec 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 45 additions & 42 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
---
repos:
# https://pycqa.github.io/isort/docs/configuration/black_compatibility.html#integration-with-pre-commit
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
args: ["--line-length=100"]
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html?highlight=other%20tools#flake8
- repo: https://github.com/PyCQA/flake8
rev: 7.3.0
hooks:
- id: flake8
args: ["--max-line-length=100", "--extend-ignore=E203,E712"]
# https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# gitup action
# - repo: https://github.com/rhysd/actionlint
# rev: v1.6.27
# hooks:
# - id: actionlint
# codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
args: [
"--write-changes",
"--skip=*.json,*.bib,*.txt,*.cls,scripts/environment_vtscat_save.yml",
"--ignore-words-list=livetime,fom,rsource,gaus,precess,forbit,nd,precessed,crate,parms,safty,sideral,ist,highe,functon,tre,ned,sourc,parm,fo,coo,miror",
]
additional_dependencies:
- tomli
# Ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.8
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
# https://pycqa.github.io/isort/docs/configuration/black_compatibility.html#integration-with-pre-commit
- repo: https://github.com/pycqa/isort
rev: 7.0.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
# https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-json
- id: check-toml
- id: no-commit-to-branch
args: [--branch=main]
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# Gitup action
#- repo: https://github.com/rhysd/actionlint
# rev: v1.7.9
# hooks:
# - id: actionlint
# codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
args: [
"--write-changes",
"--skip=*.json,*.bib,*.txt,*.cls,scripts/environment_vtscat_save.yml",
"--ignore-words-list=livetime,fom,rsource,gaus,precess,forbit,nd,precessed,crate,parms,safty,sideral,ist,highe,functon,tre,ned,sourc,parm,fo,coo,miror",
]
additional_dependencies:
- tomli
# - repo: https://github.com/Freed-Wu/mirrors-astyle
# rev: v3.4.13
# hooks:
Expand Down
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ all VTS: evndisp \
combineEffectiveAreas \
makeRadialAcceptance \
calculateBinaryPhases \
printBinaryOrbitalPhase \
compareDatawithMC \
VTS.analyzeMuonRings \
VTS.getRunListFromDB \
Expand Down Expand Up @@ -528,6 +529,10 @@ printCrabSensitivity = ./obj/printCrabSensitivity.o \
./obj/VHistogramUtilities.o ./obj/VHistogramUtilities_Dict.o \
./obj/VUtilities.o \
./obj/CEffArea.o ./obj/CEffArea_Dict.o \
./obj/CData.o \
./obj/VTMVADispAnalyzer.o ./obj/VMeanScaledVariables.o \
./obj/VDispAnalyzer.o ./obj/VDispTableReader.o ./obj/VDispTableReader_Dict.o ./obj/VDispTableAnalyzer.o \
./obj/VEmissionHeightCalculator.o ./obj/VSimpleStereoReconstructor.o ./obj/VGrIsuAnalyzer.o \
./obj/VGammaHadronCuts.o ./obj/VGammaHadronCuts_Dict.o \
./obj/VGammaHadronCutsStatistics.o ./obj/VGammaHadronCutsStatistics_Dict.o \
./obj/VEnergySpectrumfromLiterature.o ./obj/VEnergySpectrumfromLiterature_Dict.o \
Expand Down Expand Up @@ -769,7 +774,10 @@ PRINTANAOBJ= ./obj/VEvndispRunParameter.o ./obj/VEvndispRunParameter_Dict.o \
./obj/VTMVAEvaluator.o ./obj/VTMVAEvaluator_Dict.o \
./obj/VSpectralWeight.o ./obj/VSpectralWeight_Dict.o \
./obj/VPlotUtilities.o ./obj/VPlotUtilities_Dict.o \
./obj/VUtilities.o \
./obj/VUtilities.o ./obj/CData.o \
./obj/VTMVADispAnalyzer.o ./obj/VMeanScaledVariables.o \
./obj/VDispAnalyzer.o ./obj/VDispTableReader.o ./obj/VDispTableReader_Dict.o ./obj/VDispTableAnalyzer.o \
./obj/VEmissionHeightCalculator.o ./obj/VSimpleStereoReconstructor.o ./obj/VGrIsuAnalyzer.o \
./obj/VAstronometry.o ./obj/VAstronometry_Dict.o \
./obj/VSkyCoordinatesUtilities.o \
./obj/VTimeMask.o ./obj/VTimeMask_Dict.o \
Expand Down Expand Up @@ -1072,7 +1080,10 @@ WRITEPARTPHYSOBJ= ./obj/writeParticleRateFilesForTMVA.o \
./obj/VTMVARunDataEnergyCut.o ./obj/VTMVARunDataEnergyCut_Dict.o \
./obj/VTMVARunDataZenithCut.o ./obj/VTMVARunDataZenithCut_Dict.o \
./obj/VInstrumentResponseFunctionRunParameter.o ./obj/VInstrumentResponseFunctionRunParameter_Dict.o \
./obj/Ctelconfig.o \
./obj/Ctelconfig.o ./obj/CData.o \
./obj/VTMVADispAnalyzer.o ./obj/VMeanScaledVariables.o \
./obj/VDispAnalyzer.o ./obj/VDispTableReader.o ./obj/VDispTableReader_Dict.o ./obj/VDispTableAnalyzer.o \
./obj/VEmissionHeightCalculator.o ./obj/VSimpleStereoReconstructor.o ./obj/VGrIsuAnalyzer.o \
./obj/VSpectralFitter.o ./obj/VSpectralFitter_Dict.o \
./obj/VEnergyThreshold.o ./obj/VEnergyThreshold_Dict.o \
./obj/VRunList.o ./obj/VRunList_Dict.o \
Expand Down Expand Up @@ -1188,7 +1199,11 @@ COMBINEEFFAREAOBJ= ./obj/combineEffectiveAreas.o \
./obj/VInstrumentResponseFunctionRunParameter.o ./obj/VInstrumentResponseFunctionRunParameter_Dict.o \
./obj/VTMVAEvaluator.o ./obj/VTMVAEvaluator_Dict.o \
./obj/VTMVARunDataEnergyCut.o ./obj/VTMVARunDataEnergyCut_Dict.o \
./obj/VTMVARunDataZenithCut.o ./obj/VTMVARunDataZenithCut_Dict.o \
./obj/VTMVARunDataZenithCut.o ./obj/VTMVARunDataZenithCut_Dict.o \
./obj/CData.o \
./obj/VTMVADispAnalyzer.o ./obj/VMeanScaledVariables.o \
./obj/VDispAnalyzer.o ./obj/VDispTableReader.o ./obj/VDispTableReader_Dict.o ./obj/VDispTableAnalyzer.o \
./obj/VEmissionHeightCalculator.o ./obj/VSimpleStereoReconstructor.o ./obj/VGrIsuAnalyzer.o \
./obj/VGlobalRunParameter.o ./obj/VGlobalRunParameter_Dict.o \
./obj/VSkyCoordinatesUtilities.o ./obj/VUtilities.o \
./obj/VMathsandFunctions.o ./obj/VMathsandFunctions_Dict.o \
Expand Down
9 changes: 9 additions & 0 deletions docs/changes/322.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Machine learning interface for direction reconstruction

- Adds an interface to run machine learning models (e.g., scikit-learn).
- Provides an example using XGBoost regression trees to estimate directions in camera coordinates.
- Introduces a Python environment and a scripts directory to support training and inference.

The new XGBoost-based training and reconstruction methods estimate the gamma‑ray arrival direction in camera coordinates. They support `DispBDT` and intersection methods, combining image parameters to compute `Xoff`/`Yoff`.

Compared to previous approaches that averaged over all `DispBDT` directions, this implementation better handles edge cases (e.g., truncated images).
25 changes: 25 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: eventdisplay_v4
channels:
- conda-forge
dependencies:
- python=3.13
- awkward
- awkward-pandas
- joblib
- matplotlib
- numpy
- pandas
- pre-commit
- scikit-learn
- scipy
- tabulate
- towncrier
- uproot
- xgboost

# cheatsheet
# create: conda env create -f environment.yml
# activate: conda activate eventdisplay_v4
# update (conda/mamba): conda env update -f environment.yml --prune
# update (micromamba): micromamba update -f environment.yml
11 changes: 10 additions & 1 deletion inc/CData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#include "VMeanScaledVariables.h"
#include "VDispAnalyzer.h"
#include "VSimpleStereoReconstructor.h"
#include "VSkyCoordinatesUtilities.h"

#include <bitset>
#include <cstdlib>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
Expand Down Expand Up @@ -258,9 +260,16 @@ class CData
TBranch* b_Xoff_intersect;
TBranch* b_Yoff_intersect;

CData( TTree* tree = 0, bool bMC = false, bool bShort = false );
TTree* fFriendTree; //!
float Dir_Xoff; //!
float Dir_Yoff; //!

CData( TTree* tree = 0, bool bMC = false, bool bShort = false, TTree* friendTree = 0 );
virtual ~CData();
virtual Int_t GetEntry( Long64_t entry );
float get_Xoff( unsigned int method = 0 );
float get_Yoff( unsigned int method = 0 );
pair<float, float> get_XYoff_derot( unsigned int method = 0 );
virtual Long64_t LoadTree( Long64_t entry );
virtual void Init( TTree* tree );
virtual Bool_t Notify();
Expand Down
5 changes: 4 additions & 1 deletion inc/VAnaSumRunParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class VAnaSumRunParameter : public TNamed, public VGlobalRunParameter
// dead time calculation method
int fDeadTimeCalculationMethod;

// XGB reconstruction
string fXGB_file_suffix;

int f2DAcceptanceMode ; // USE2DACCEPTANCE

// add all events to DL3 tree, no gh cuts but add BDT score and IsGamma
Expand Down Expand Up @@ -272,6 +275,6 @@ class VAnaSumRunParameter : public TNamed, public VGlobalRunParameter
bool writeListOfExcludedSkyRegions();
bool getListOfExcludedSkyRegions( TFile* f );

ClassDef( VAnaSumRunParameter, 18 ) ;
ClassDef( VAnaSumRunParameter, 19 ) ;
};
#endif
1 change: 1 addition & 0 deletions inc/VDataMCComparision.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;
Expand Down
3 changes: 2 additions & 1 deletion inc/VInstrumentResponseFunctionRunParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class VInstrumentResponseFunctionRunParameter : public TNamed
string fMCdatafile_tree;
string fMCdatafile_histo;
string fGammaHadronProbabilityFile;
string fXGB_file_suffix;

double fze;
int fnoise;
Expand Down Expand Up @@ -117,7 +118,7 @@ class VInstrumentResponseFunctionRunParameter : public TNamed
bool readRunParameterFromTextFile( string iFile );
bool testRunparameters();

ClassDef( VInstrumentResponseFunctionRunParameter, 18 );
ClassDef( VInstrumentResponseFunctionRunParameter, 19 );
};

#endif
1 change: 1 addition & 0 deletions inc/VRadialAcceptance.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <cmath>
#include <iostream>
#include <string>
#include <utility>

#include "TDirectory.h"
#include "TF1.h"
Expand Down
1 change: 1 addition & 0 deletions inc/VSkyCoordinatesUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace VSkyCoordinatesUtilities
void convert_derotatedCoordinates_to_J2000( double iMJD, double i_RA_J2000_deg, double i_DEC_J2000_deg, double& x, double& y );
void getDifferenceInCameraCoordinates( double tel_ze, double tel_az, double shower_ze, double shower_az, float& x, float& y, float& z );
void getEquatorialCoordinates( int MJD, double time, double az, double ze, double& dec, double& ra );
double getDerotationAngleFromGroundCoordinates( double MJD, double time, double iTelAz, double iTelElevation );
double getDerotationAngle( double MJD, double time, double iTelRA, double iTelDec, double iObservatoryLongitude, double iObservatoryLatitude );
double getDerotationAngle( double i_UTC, double iTelRA, double iTelDec, double iObservatoryLongitude, double iObservatoryLatitude );
double getHourAngle( double i_UTC, double iTelRA, double iObservatoryLongitude );
Expand Down
2 changes: 2 additions & 0 deletions inc/VStereoAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ class VStereoAnalysis
CData* fDataRun;
TTree* fDataRunTree;
TFile* fDataFile;
TDirectory* fXGBFile;
TTree* fXGB_tree;
string fInstrumentEpochMinor;
vector< unsigned int > fTelToAnalyze;

Expand Down
1 change: 0 additions & 1 deletion inc/VTableLookupDataHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class VTableLookupDataHandler
void initializeTelTypeVector();
int fillNextEvent( bool bShort );
pair<float, float > getArrayPointing();
float getArrayPointingDeRotationAngle();
void printCutStatistics();
bool randomSelected();
void resetImageParameters();
Expand Down
Loading
Loading