Belle II Software development
ValidationAndOptimisationTask Class Reference
Inheritance diagram for ValidationAndOptimisationTask:

Public Member Functions

def output (self)
 
def requires (self)
 
def create_optimisation_and_validation_path (self)
 
def create_path (self)
 

Static Public Attributes

b2luigi experiment_number = b2luigi.IntParameter()
 Experiment number of the conditions database, e.g.
 
b2luigi n_events_training = b2luigi.IntParameter()
 Number of events to generate for the training data set.
 
b2luigi fast_bdt_option_state_filter
 FastBDT option to use to train the StateFilters.
 
b2luigi fast_bdt_option_result_filter
 FastBDT option to use to train the Result Filter.
 
b2luigi n_events_testing = b2luigi.IntParameter()
 Number of events to generate for the testing, validation, and optimisation data set.
 
b2luigi state_filter_cut = b2luigi.FloatParameter()
 Value of the cut on the MVA classifier output for accepting a state during CKF tracking.
 
b2luigi use_n_best_states = b2luigi.IntParameter()
 How many states should be kept at maximum in the combinatorial part of the CKF tree search.
 
b2luigi result_filter_cut = b2luigi.FloatParameter()
 Value of the cut on the MVA classifier output for a result candidate.
 
b2luigi use_n_best_results = b2luigi.IntParameter()
 How many results should be kept at maximum to search for overlaps.
 

Detailed Description

Validate the performance of the trained filters by trying various combinations of FastBDT options, as well as cut values for
the states, the number of best candidates kept after each filter, and similar for the result filter.

Definition at line 829 of file combined_to_pxd_ckf_mva_training.py.

Member Function Documentation

◆ create_optimisation_and_validation_path()

def create_optimisation_and_validation_path (   self)
Create a path to validate the trained filters.

Definition at line 905 of file combined_to_pxd_ckf_mva_training.py.

905 def create_optimisation_and_validation_path(self):
906 """
907 Create a path to validate the trained filters.
908 """
909 path = basf2.create_path()
910
911 # get all the file names from the list of input files that are meant for optimisation / validation
912 file_list = [fname for sublist in self.get_input_file_names().values()
913 for fname in sublist if "generated_mc_N" in fname and "optimisation" in fname and fname.endswith(".root")]
914 path.add_module("RootInput", inputFileNames=file_list)
915
916 path.add_module("Gearbox")
917 path.add_module("Geometry")
918 path.add_module("SetupGenfitExtrapolation")
919
920 add_hit_preparation_modules(path, components=["SVD", "PXD"])
921
922 add_track_finding(path, reco_tracks="CDCSVDRecoTracks", components=["CDC", "SVD"], prune_temporary_tracks=False)
923
924 path.add_module("DAFRecoFitter", recoTracksStoreArrayName="CDCSVDRecoTracks")
925
926 fbdt_state_filter_string = create_fbdt_option_string(self.fast_bdt_option_state_filter)
927 fbdt_result_filter_string = create_fbdt_option_string(self.fast_bdt_option_result_filter)
928
929 # write the tracking MVA filter parameters and the cut on MVA classifier to be applied on a local db
930 iov = [0, 0, 0, -1]
932 f"trk_ToPXDStateFilter_1_Parameter{fbdt_state_filter_string}",
933 iov,
934 f"trk_ToPXDStateFilter_1{fbdt_state_filter_string}",
935 self.state_filter_cut)
936
938 f"trk_ToPXDStateFilter_2_Parameter{fbdt_state_filter_string}",
939 iov,
940 f"trk_ToPXDStateFilter_2{fbdt_state_filter_string}",
941 self.state_filter_cut)
942
944 f"trk_ToPXDStateFilter_3_Parameter{fbdt_state_filter_string}",
945 iov,
946 f"trk_ToPXDStateFilter_3{fbdt_state_filter_string}",
947 self.state_filter_cut)
948
950 f"trk_ToPXDResultFilter_Parameter{fbdt_result_filter_string}",
951 iov,
952 f"trk_ToPXDResultFilter{fbdt_result_filter_string}",
953 self.result_filter_cut)
954
955 basf2.conditions.prepend_testing_payloads("localdb/database.txt")
956 first_high_filter_parameters = {"DBPayloadName": f"trk_ToPXDStateFilter_1_Parameter{fbdt_state_filter_string}",
957 "direction": "backward"}
958 second_high_filter_parameters = {"DBPayloadName": f"trk_ToPXDStateFilter_2_Parameter{fbdt_state_filter_string}"}
959 third_high_filter_parameters = {"DBPayloadName": f"trk_ToPXDStateFilter_3_Parameter{fbdt_state_filter_string}"}
960 filter_parameters = {"DBPayloadName": f"trk_ToPXDResultFilter_Parameter{fbdt_result_filter_string}"}
961
962 path.add_module("ToPXDCKF",
963 inputRecoTrackStoreArrayName="CDCSVDRecoTracks",
964 outputRecoTrackStoreArrayName="PXDRecoTracks",
965 outputRelationRecoTrackStoreArrayName="CDCSVDRecoTracks",
966
967 relationCheckForDirection="backward",
968 reverseSeed=False,
969 writeOutDirection="backward",
970
971 firstHighFilter="mva_with_direction_check",
972 firstHighFilterParameters=first_high_filter_parameters,
973 firstHighUseNStates=self.use_n_best_states,
974
975 advanceHighFilter="advance",
976 advanceHighFilterParameters={"direction": "backward"},
977
978 secondHighFilter="mva",
979 secondHighFilterParameters=second_high_filter_parameters,
980 secondHighUseNStates=self.use_n_best_states,
981
982 updateHighFilter="fit",
983
984 thirdHighFilter="mva",
985 thirdHighFilterParameters=third_high_filter_parameters,
986 thirdHighUseNStates=self.use_n_best_states,
987
988 filter="mva",
989 filterParameters=filter_parameters,
990 useBestNInSeed=self.use_n_best_results,
991
992 exportTracks=True,
993 enableOverlapResolving=True)
994
995 path.add_module('RelatedTracksCombiner',
996 VXDRecoTracksStoreArrayName="PXDRecoTracks",
997 CDCRecoTracksStoreArrayName="CDCSVDRecoTracks",
998 recoTracksStoreArrayName="RecoTracks")
999
1000 path.add_module('TrackFinderMCTruthRecoTracks',
1001 RecoTracksStoreArrayName="MCRecoTracks",
1002 WhichParticles=[],
1003 UsePXDHits=True,
1004 UseSVDHits=True,
1005 UseCDCHits=True)
1006
1007 path.add_module("MCRecoTracksMatcher", UsePXDHits=True, UseSVDHits=True, UseCDCHits=True,
1008 mcRecoTracksStoreArrayName="MCRecoTracks",
1009 prRecoTracksStoreArrayName="RecoTracks")
1010
1011 path.add_module(
1012 CombinedTrackingValidationModule(
1013 output_file_name=self.get_output_file_name(
1014 f"to_pxd_ckf_validation{fbdt_state_filter_string}_{fbdt_result_filter_string}.root"),
1015 reco_tracks_name="RecoTracks",
1016 mc_reco_tracks_name="MCRecoTracks",
1017 name="",
1018 contact="",
1019 expert_level=200))
1020
1021 return path
1022

◆ create_path()

def create_path (   self)
Create basf2 path to process with event generation and simulation.

Definition at line 1023 of file combined_to_pxd_ckf_mva_training.py.

1023 def create_path(self):
1024 """
1025 Create basf2 path to process with event generation and simulation.
1026 """
1027 return self.create_optimisation_and_validation_path()
1028
1029

◆ output()

def output (   self)
Generate list of output files that the task should produce.
The task is considered finished if and only if the outputs all exist.

Definition at line 864 of file combined_to_pxd_ckf_mva_training.py.

864 def output(self):
865 """
866 Generate list of output files that the task should produce.
867 The task is considered finished if and only if the outputs all exist.
868 """
869 fbdt_state_filter_string = create_fbdt_option_string(self.fast_bdt_option_state_filter)
870 fbdt_result_filter_string = create_fbdt_option_string(self.fast_bdt_option_result_filter)
871 yield self.add_to_output(
872 f"to_pxd_ckf_validation{fbdt_state_filter_string}_{fbdt_result_filter_string}.root")
873

◆ requires()

def requires (   self)
This task requires trained result filters, trained state filters, and that an independent data set for validation was
created using the SplitMergeSimTask with the random seed optimisation.

Definition at line 874 of file combined_to_pxd_ckf_mva_training.py.

874 def requires(self):
875 """
876 This task requires trained result filters, trained state filters, and that an independent data set for validation was
877 created using the SplitMergeSimTask with the random seed optimisation.
878 """
879 fbdt_state_filter_string = create_fbdt_option_string(self.fast_bdt_option_state_filter)
880 yield CKFResultFilterTeacherTask(
881 result_filter_records_name=f"filter_records{fbdt_state_filter_string}.root",
882 experiment_number=self.experiment_number,
883 n_events=self.n_events_training,
884 fast_bdt_option_state_filter=self.fast_bdt_option_state_filter,
885 fast_bdt_option_result_filter=self.fast_bdt_option_result_filter,
886 random_seed='training'
887 )
888 yield SplitNMergeSimTask(
889 bkgfiles_dir=MainTask.bkgfiles_by_exp[self.experiment_number],
890 experiment_number=self.experiment_number,
891 n_events=self.n_events_testing,
892 random_seed="optimisation",
893 )
894 filter_numbers = [1, 2, 3]
895 for filter_number in filter_numbers:
896 yield self.clone(
897 CKFStateFilterTeacherTask,
898 experiment_number=self.experiment_number,
899 n_events=self.n_events_training,
900 random_seed="training",
901 filter_number=filter_number,
902 fast_bdt_option_state_filter=self.fast_bdt_option_state_filter
903 )
904

Member Data Documentation

◆ experiment_number

b2luigi experiment_number = b2luigi.IntParameter()
static

Experiment number of the conditions database, e.g.

defines simulation geometry.

Definition at line 835 of file combined_to_pxd_ckf_mva_training.py.

◆ fast_bdt_option_result_filter

b2luigi fast_bdt_option_result_filter
static
Initial value:
= b2luigi.ListParameter(
# ##
)

FastBDT option to use to train the Result Filter.

Definition at line 845 of file combined_to_pxd_ckf_mva_training.py.

◆ fast_bdt_option_state_filter

b2luigi fast_bdt_option_state_filter
static
Initial value:
= b2luigi.ListParameter(
# ##
)

FastBDT option to use to train the StateFilters.

Definition at line 839 of file combined_to_pxd_ckf_mva_training.py.

◆ n_events_testing

b2luigi n_events_testing = b2luigi.IntParameter()
static

Number of events to generate for the testing, validation, and optimisation data set.

Definition at line 851 of file combined_to_pxd_ckf_mva_training.py.

◆ n_events_training

b2luigi n_events_training = b2luigi.IntParameter()
static

Number of events to generate for the training data set.

Definition at line 837 of file combined_to_pxd_ckf_mva_training.py.

◆ result_filter_cut

b2luigi result_filter_cut = b2luigi.FloatParameter()
static

Value of the cut on the MVA classifier output for a result candidate.

Definition at line 857 of file combined_to_pxd_ckf_mva_training.py.

◆ state_filter_cut

b2luigi state_filter_cut = b2luigi.FloatParameter()
static

Value of the cut on the MVA classifier output for accepting a state during CKF tracking.

Definition at line 853 of file combined_to_pxd_ckf_mva_training.py.

◆ use_n_best_results

b2luigi use_n_best_results = b2luigi.IntParameter()
static

How many results should be kept at maximum to search for overlaps.

Definition at line 859 of file combined_to_pxd_ckf_mva_training.py.

◆ use_n_best_states

b2luigi use_n_best_states = b2luigi.IntParameter()
static

How many states should be kept at maximum in the combinatorial part of the CKF tree search.

Definition at line 855 of file combined_to_pxd_ckf_mva_training.py.


The documentation for this class was generated from the following file: