Belle II Software development
KLMMuonIDDNNExpertModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12#include <framework/database/DBObjPtr.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/datastore/StoreArray.h>
15
16#include <klm/dataobjects/bklm/BKLMElementNumbers.h>
17#include <klm/dataobjects/eklm/EKLMElementNumbers.h>
18
19
20#include <string>
21
22namespace Belle2 {
28 class KLMHit2d;
31 class Track;
32
33 namespace MVA {
34 class Weightfile;
35 class Expert;
36 class SingleDataset;
37 }
42
43 public:
44
49
54
58 void initialize() override;
59
63 void beginRun() override;
64
68 void event() override;
69
73 void endRun() override;
74
78 void terminate() override;
79
80 private:
81
87 void initializeMVA(MVA::Weightfile& weightfile);
88
95 float getNNmuProbability(const Track* track, const KLMMuidLikelihood* klmll);
96
102 float getHitWidth(const KLMHit2d* klmhit);
103
106
109
111 const std::string m_identifier = "KLMMuonIDDNNWeightFile";
112
115
117 std::unique_ptr<MVA::Expert> m_expert;
118
120 std::unique_ptr<MVA::SingleDataset> m_dataset;
121
124
127
129 std::array < float, m_maxBKLMLayers > m_BarrelPhiStripWidth;
130
132 std::array < float, m_maxBKLMLayers > m_BarrelZStripWidth;
133
136
138 std::array < float, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_width;
139
141 std::array < float, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_steplength;
142
144 std::array < float, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_chi2;
145
147 std::array < bool, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_hasext;
148
149 };
150
151}
static constexpr int getMaximalLayerNumber()
Get maximal layer number (1-based).
Class for accessing objects in the database.
Definition DBObjPtr.h:21
Database representation of a Weightfile object.
static constexpr int getMaximalLayerNumber()
Get maximal layer number.
KLM 2d hit.
Definition KLMHit2d.h:33
Class to store the likelihoods from KLM with additional information related to the extrapolation.
std::array< float, m_maxBKLMLayers+m_maxEKLMLayers > m_hitpattern_width
Container of hit widths of one track.
std::unique_ptr< MVA::SingleDataset > m_dataset
Pointer to the current dataset.
float getHitWidth(const KLMHit2d *klmhit)
Get Hit width (cluster size) of a KLMHit2d.
void event() override
This method is called for each event.
float m_EndcapScintWidth
EKLM scintillator strip width (cm).
void endRun() override
This method is called if the current run ends.
static constexpr int m_maxBKLMLayers
Total BKLM layers.
std::array< float, m_maxBKLMLayers+m_maxEKLMLayers > m_hitpattern_chi2
Container of hit chi2 of one track.
void terminate() override
This method is called at the end of the event processing.
std::unique_ptr< MVA::Expert > m_expert
Pointer to the current MVA expert.
void beginRun() override
Called when entering a new run.
StoreArray< Track > m_tracks
Required array for Tracks.
std::array< float, m_maxBKLMLayers+m_maxEKLMLayers > m_hitpattern_steplength
Container of hit steplength of one track.
float getNNmuProbability(const Track *track, const KLMMuidLikelihood *klmll)
Get the NN-based muon probability.
std::array< float, m_maxBKLMLayers > m_BarrelPhiStripWidth
BKLM phi-measuring strip width (cm) by layer.
DBObjPtr< DatabaseRepresentationOfWeightfile > m_weightfile_representation
Database pointer to the database representation of the weightfile.
void initializeMVA(MVA::Weightfile &weightfile)
Initialize mva expert, dataset and features.
std::array< float, m_maxBKLMLayers > m_BarrelZStripWidth
BKLM Z-measuring strip width (cm) by layer.
std::array< bool, m_maxBKLMLayers+m_maxEKLMLayers > m_hitpattern_hasext
Container of extrapolation situation at each KLM layer of one track.
const std::string m_identifier
Database identifier or file used to load the weights.
StoreArray< KLMMuonIDDNNInputVariable > m_inputVariable
Input variables of DNN.
static constexpr int m_maxEKLMLayers
Total EKLM layers.
KLM MuonID DNN input variables datastore object to store the input variables for retraining KLMMuonID...
Abstract base class of all Expert Each MVA library has its own implementation of this class,...
Definition Expert.h:31
Wraps the data of a single event into a Dataset.
Definition Dataset.h:135
The Weightfile class serializes all information about a training into an xml tree.
Definition Weightfile.h:38
Module()
Constructor.
Definition Module.cc:30
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Class that bundles various TrackFitResults.
Definition Track.h:25
Abstract base class for different kinds of events.