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/StoreArray.h>
14
15#include <klm/dataobjects/KLMHit2d.h>
16#include <klm/dataobjects/KLMMuidLikelihood.h>
17#include <klm/dataobjects/bklm/BKLMElementNumbers.h>
18#include <klm/dataobjects/eklm/EKLMElementNumbers.h>
19
20#include <mdst/dataobjects/Track.h>
21
22#include <reconstruction/dataobjects/KLMMuonIDDNNInputVariable.h>
23
24#include <mva/dataobjects/DatabaseRepresentationOfWeightfile.h>
25#include <mva/interface/Expert.h>
26#include <mva/interface/Weightfile.h>
27
28#include <string>
29
30namespace Belle2 {
39
40 public:
41
46
51
55 void initialize() override;
56
60 void beginRun() override;
61
65 void event() override;
66
70 void endRun() override;
71
75 void terminate() override;
76
77 private:
78
84 void initializeMVA(MVA::Weightfile& weightfile);
85
92 float getNNmuProbability(const Track* track, const KLMMuidLikelihood* klmll);
93
99 float getHitWidth(const KLMHit2d* klmhit);
100
103
106
108 const std::string m_identifier = "KLMMuonIDDNNWeightFile";
109
112
114 std::unique_ptr<MVA::Expert> m_expert;
115
117 std::unique_ptr<MVA::SingleDataset> m_dataset;
118
121
124
126 std::array < float, m_maxBKLMLayers > m_BarrelPhiStripWidth;
127
129 std::array < float, m_maxBKLMLayers > m_BarrelZStripWidth;
130
133
135 std::array < float, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_width;
136
138 std::array < float, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_steplength;
139
141 std::array < float, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_chi2;
142
144 std::array < bool, m_maxBKLMLayers + m_maxEKLMLayers > m_hitpattern_hasext;
145
146 };
148}
static constexpr int getMaximalLayerNumber()
Get maximal layer number (1-based).
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
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.
KLMMuonIDDNNExpert for calculating Neural Network based muonID.
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.
void initialize() override
Initializer.
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.
The Weightfile class serializes all information about a training into an xml tree.
Definition: Weightfile.h:38
Base class for Modules.
Definition: Module.h:72
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.