Belle II Software development
EventInfoExtractor.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#include <framework/dataobjects/EventMetaData.h>
11#include <framework/datastore/StoreObjPtr.h>
12
13#include <tracking/trackFindingVXD/variableExtractors/VariableExtractor.h>
14#include <tracking/dataobjects/RecoTrack.h>
15
16#include <limits>
17
18namespace Belle2 {
25 public:
26
28 explicit EventInfoExtractor(std::vector<Named<float*>>& variableSet):
30 {
31 addVariable("__experiment__", variableSet);
32 addVariable("__run__", variableSet);
33 addVariable("__event__", variableSet);
34 addVariable("N_RecoTracks", variableSet);
35 addVariable("N_PXDRecoTracks", variableSet);
36 addVariable("N_SVDRecoTracks", variableSet);
37 addVariable("N_CDCRecoTracks", variableSet);
38 addVariable("N_diff_PXD_SVD_RecoTracks", variableSet);
39 addVariable("N_diff_SVD_CDC_RecoTracks", variableSet);
40 addVariable("RTs_Min_Mom_diff_Mag", variableSet);
41 addVariable("RTs_Min_Mom_diff_Pt", variableSet);
42 addVariable("RTs_Min_Pos_diff_Theta", variableSet);
43 addVariable("RTs_Min_Pos_diff_Phi", variableSet);
44 }
45
47 void extractVariables(const StoreArray<RecoTrack>& recoTracks, const RecoTrack& thisRecoTrack)
48 {
49 m_variables.at("N_RecoTracks") = recoTracks.getEntries();
50
51 int n_pxdRecoTracks = 0;
52 int n_svdRecoTracks = 0;
53 int n_cdcRecoTracks = 0;
54 float min_mom_diff_mag = std::numeric_limits<float>::max();
55 float min_mom_diff_Pt = std::numeric_limits<float>::max();
56 float min_pos_diff_Theta = std::numeric_limits<float>::max();
57 float min_pos_diff_Phi = std::numeric_limits<float>::max();
58
59 for (const RecoTrack& recoTrack : recoTracks) {
60 if (recoTrack.hasPXDHits())
61 n_pxdRecoTracks++;
62 if (recoTrack.hasSVDHits())
63 n_svdRecoTracks++;
64 if (recoTrack.hasCDCHits())
65 n_cdcRecoTracks++;
66
67 if (recoTrack.getArrayIndex() == thisRecoTrack.getArrayIndex())
68 continue;
69
70 float mom_diff_mag = fabs(recoTrack.getMomentumSeed().R() - thisRecoTrack.getMomentumSeed().R());
71 if (mom_diff_mag < min_mom_diff_mag) {
72 min_mom_diff_mag = mom_diff_mag;
73 }
74 float mom_diff_Pt = fabs(recoTrack.getMomentumSeed().Rho() - thisRecoTrack.getMomentumSeed().Rho());
75 if (mom_diff_Pt < min_mom_diff_Pt) {
76 min_mom_diff_Pt = mom_diff_Pt;
77 }
78 float pos_diff_Theta = fabs(recoTrack.getPositionSeed().Theta() - thisRecoTrack.getPositionSeed().Theta());
79 if (pos_diff_Theta < min_pos_diff_Theta) {
80 min_pos_diff_Theta = pos_diff_Theta;
81 }
82 float pos_diff_Phi = fabs(recoTrack.getPositionSeed().Phi() - thisRecoTrack.getPositionSeed().Phi());
83 if (pos_diff_Phi < min_pos_diff_Phi) {
84 min_pos_diff_Phi = pos_diff_Phi;
85 }
86 }
87
88 StoreObjPtr<EventMetaData> m_eventMetaData;
89
90 m_variables.at("__experiment__") = m_eventMetaData->getExperiment();
91 m_variables.at("__run__") = m_eventMetaData->getRun();
92 m_variables.at("__event__") = m_eventMetaData->getEvent();
93 m_variables.at("N_PXDRecoTracks") = n_pxdRecoTracks;
94 m_variables.at("N_SVDRecoTracks") = n_svdRecoTracks;
95 m_variables.at("N_CDCRecoTracks") = n_cdcRecoTracks;
96 m_variables.at("N_diff_PXD_SVD_RecoTracks") = n_svdRecoTracks - n_pxdRecoTracks;
97 m_variables.at("N_diff_SVD_CDC_RecoTracks") = n_cdcRecoTracks - n_svdRecoTracks;
98 m_variables.at("RTs_Min_Mom_diff_Mag") = min_mom_diff_mag;
99 m_variables.at("RTs_Min_Mom_diff_Pt") = min_mom_diff_Pt;
100 m_variables.at("RTs_Min_Pos_diff_Theta") = min_pos_diff_Theta;
101 m_variables.at("RTs_Min_Pos_diff_Phi") = min_pos_diff_Phi;
102 }
103
104 private:
105
106 };
108}
class to extract results from qualityEstimation
EventInfoExtractor(std::vector< Named< float * > > &variableSet)
Define names of variables that get extracted.
void extractVariables(const StoreArray< RecoTrack > &recoTracks, const RecoTrack &thisRecoTrack)
extract the actual variables and write into a variable set
A mixin class to attach a name to an object. Based on class with same name in CDC package.
Definition: Named.h:21
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:480
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:487
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
class to extract individual variables
void addVariable(const std::string &identifier, std::vector< Named< float * > > &variables)
add a variable to the variable set
std::unordered_map< std::string, float > m_variables
unordered_map to associate float value with a string name
Abstract base class for different kinds of events.