Belle II Software  release-08-01-10
MVATeacherAndAnalyser Class Reference

Public Member Functions

def __init__ (self, run_class, use_jupyter=True)
 
def train (self)
 
def evaluate_tracking (self)
 
def evaluate_classification (self)
 

Public Attributes

 run_class
 cached copy of the run class
 
 use_jupyter
 cached flag to use jupyter notebook
 
 recording_file_name
 cached name of the output file
 
 training_file_name
 cached path without extension of the output file More...
 
 test_file_name
 cached path with extension of the testing-output file
 
 identifier_name
 cached identifier
 
 evaluation_file_name
 cached name of the output PDF file
 
 expert_file_name
 cached path with extension of the testing-export file
 
 weight_data_location
 cached path of the weight input data
 

Private Member Functions

def _call_training_routine (self)
 
def _write_train_and_test_files (self)
 
def _create_records_file (self)
 
def _call_expert_routine (self)
 
def _call_evaluation_routine (self)
 

Detailed Description

Class for training and analysing a tracking module, which has a MVA filter in it.

Works best, if you are on a jupyter ntoebook.

You need to supply a run_class, which includes all needed settings, on how to
train and execute the module. This class will be mixed in with the normal trackfindingcdc
run classes, so you can add the setting (e.g. tracking_coverage etc.) as normal.

One examples is:

class TestClass:
    # This module will be trained
    recording_module = "FilterBasedVXDCDCTrackMerger"
    # This is the name of the parameter of this module, which will be set to "mva" etc.
    recording_parameter = "filter"

    # These mva cuts will be tested during evaluation.
    evaluation_cuts = [0.1, 0.2, ...]

    tracking_coverage = {
        'UsePXDHits': True,
        'UseSVDHits': True,
        'UseCDCHits': True,
    }

    # Some options, which will control the run classes
    fit_tracks = False
    generator_module = "EvtGenInput"

    # This will be added to the "normal" path, to record the training data (you do not have to set the module to
    # recording, as this is done automatically).
    def add_recording_modules(self, path):
        mctrackfinder = path.add_module('TrackFinderMCTruthRecoTracks',
                                RecoTracksStoreArrayName='MCRecoTracks',
                                WhichParticles=[])

        path.add_module('MCRecoTracksMatcher', mcRecoTracksStoreArrayName="MCRecoTracks",
                        prRecoTracksStoreArrayName="CDCRecoTracks", UseCDCHits=True, UsePXDHits=False, UseSVDHits=False)
        path.add_module('MCRecoTracksMatcher', mcRecoTracksStoreArrayName="MCRecoTracks",
                        prRecoTracksStoreArrayName="VXDRecoTracks", UseCDCHits=False, UsePXDHits=True, UseSVDHits=True)

        # Merge CDC and CXD tracks
        path.add_module('FilterBasedVXDCDCTrackMerger',
                        extrapolate=False,
                        CDCRecoTrackStoreArrayName="CDCRecoTracks",
                        VXDRecoTrackStoreArrayName="VXDRecoTracks",
                        MergedRecoTrackStoreArrayName="RecoTracks")

        return path

    # This will be added to the "normal" path, to evaluate the mva cuts. In most cases, this is the same as the
    # add_recording_modules (as the module parameters will be set automatically), but maybe you need
    # more here...
    def add_validation_modules(self, path):
        mctrackfinder = path.add_module('TrackFinderMCTruthRecoTracks',
                                RecoTracksStoreArrayName='MCRecoTracks',
                                WhichParticles=[])

        # Merge CDC and CXD tracks
        path.add_module('FilterBasedVXDCDCTrackMerger',
                        extrapolate=True,
                        CDCRecoTrackStoreArrayName="CDCRecoTracks",
                        VXDRecoTrackStoreArrayName="VXDRecoTracks",
                        MergedRecoTrackStoreArrayName="PrefitRecoTracks")

        path.add_module("SetupGenfitExtrapolation")

        path.add_module("DAFRecoFitter", recoTracksStoreArrayName="PrefitRecoTracks")

        path.add_module("TrackCreator", recoTrackColName="PrefitRecoTracks")

        path.add_module("FittedTracksStorer", inputRecoTracksStoreArrayName="PrefitRecoTracks",
                        outputRecoTracksStoreArrayName="RecoTracks")

        # We need to include the matching ourselves, as we have already a matching algorithm in place
        path.add_module('MCRecoTracksMatcher', mcRecoTracksStoreArrayName="MCRecoTracks",
                        prRecoTracksStoreArrayName="RecoTracks", UseCDCHits=True, UsePXDHits=True, UseSVDHits=True)

        return path

Definition at line 49 of file analyse.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  run_class,
  use_jupyter = True 
)
Constructor

Definition at line 132 of file analyse.py.

Member Function Documentation

◆ _call_evaluation_routine()

def _call_evaluation_routine (   self)
private
Call the mva evaluation routine

Definition at line 301 of file analyse.py.

◆ _call_expert_routine()

def _call_expert_routine (   self)
private
Call the mva expert

Definition at line 290 of file analyse.py.

◆ _call_training_routine()

def _call_training_routine (   self)
private
Call the mva training routine in the train file

Definition at line 238 of file analyse.py.

◆ _create_records_file()

def _create_records_file (   self)
private
Create a path using the settings of the run_class and process it.
This will create a ROOT file with the recorded data.

Definition at line 258 of file analyse.py.

◆ _write_train_and_test_files()

def _write_train_and_test_files (   self)
private
Split the recorded file into two halves: training and test file and write it back

Definition at line 245 of file analyse.py.

◆ evaluate_classification()

def evaluate_classification (   self)
Evaluate the classification power on the test data set and produce a PDF.

Definition at line 215 of file analyse.py.

◆ evaluate_tracking()

def evaluate_tracking (   self)
Use the trained weight file and call the path again using different mva cuts. Validation using the
normal tracking validation modules.

Definition at line 173 of file analyse.py.

◆ train()

def train (   self)
Record a training file, split it in two parts and call the training method of the mva package

Definition at line 163 of file analyse.py.

Member Data Documentation

◆ training_file_name

training_file_name

cached path without extension of the output file

cached path with extension of the training-output file

Definition at line 147 of file analyse.py.


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