Belle II Software development
TrackIsoCalculatorModule.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/datastore/StoreObjPtr.h>
13#include <framework/dataobjects/EventMetaData.h>
14#include <framework/logging/LogConfig.h>
15#include <framework/datastore/StoreArray.h>
16#include <framework/gearbox/Const.h>
17#include <framework/database/DBObjPtr.h>
18
19#include <analysis/dataobjects/Particle.h>
20#include <analysis/dataobjects/ParticleList.h>
21#include <analysis/VariableManager/Manager.h>
22#include <analysis/VariableManager/Utility.h>
23#include <analysis/DecayDescriptor/DecayDescriptor.h>
24#include <analysis/dbobjects/PIDDetectorWeights.h>
25
26
27namespace Belle2 {
37
38 public:
39
44
49
56 void initialize() override;
57
63 void event() override;
64
65
66 private:
67
72
76 std::string m_decayString;
77
81 unsigned short m_nSelectedDaughters;
82
87
91 std::vector<std::string> m_detNames;
92
99 std::unordered_map<std::string, std::string> m_detLayerToDistVariable;
100
106 std::unordered_map<std::string, std::string> m_detLayerToRefPartIdxVariable;
107
113
119
124 std::map<std::pair<std::string, int>, double> m_distThreshPerDetLayer = {
125 { {Const::parseDetectors(Const::CDC), 0}, 5.0 },
126 { {Const::parseDetectors(Const::CDC), 1}, 5.0 },
127 { {Const::parseDetectors(Const::CDC), 2}, 5.0 },
128 { {Const::parseDetectors(Const::CDC), 3}, 5.0 },
129 { {Const::parseDetectors(Const::CDC), 4}, 5.0 },
130 { {Const::parseDetectors(Const::CDC), 5}, 5.0 },
131 { {Const::parseDetectors(Const::CDC), 6}, 5.0 },
132 { {Const::parseDetectors(Const::CDC), 7}, 5.0 },
133 { {Const::parseDetectors(Const::CDC), 8}, 5.0 },
134 { {Const::parseDetectors(Const::TOP), 0}, 22.0 },
135 { {Const::parseDetectors(Const::ARICH), 0}, 10.0 },
136 { {Const::parseDetectors(Const::ECL), 0}, 36.0 },
137 { {Const::parseDetectors(Const::ECL), 1}, 36.0 },
138 { {Const::parseDetectors(Const::KLM), 0}, 20.0 }
139 };
140
145
150
155
160
166
171
175 std::string m_payloadName;
176
180 std::unique_ptr<DBObjPtr<PIDDetectorWeights>> m_DBWeights;
181
186 double getDistAtDetSurface(const Particle* iParticle, const Particle* jParticle, const std::string& detLayerName) const;
187
192 double getDetectorWeight(const Particle* iParticle, const std::string& detName) const;
193
209 double getWeightedSumNonIsoLayers(const Particle* iParticle, const std::string& detName, const float detWeight) const;
210
224 double getWeightedSumInvDists(const Particle* iParticle, const std::string& detName, const float detWeight) const;
225
232 double getDistThreshold(Const::EDetector det, int layer) const
233 {
234 auto detAndLayer = std::make_pair(Const::parseDetectors(det), layer);
235 return m_distThreshPerDetLayer.at(detAndLayer);
236 };
237
242
246 Const::EDetector getDetEnum(const std::string& detName) const
247 {
248
249 if (detName == "CDC") return Const::CDC;
250 else if (detName == "TOP") return Const::TOP;
251 else if (detName == "ARICH") return Const::ARICH;
252 else if (detName == "ECL") return Const::ECL;
253 else if (detName == "KLM") return Const::KLM;
254 else B2FATAL("Unknown detector component: " << detName);
255
256 };
257
258 };
260}
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
static std::string parseDetectors(EDetector det)
Converts Const::EDetector object to string.
Definition: UnitConst.cc:162
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:75
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Calculate track isolation variables on the input ParticleList.
StoreObjPtr< EventMetaData > m_event_metadata
The event information.
std::unique_ptr< DBObjPtr< PIDDetectorWeights > > m_DBWeights
Interface to get the database payload with the PID detector weights.
~TrackIsoCalculatorModule() override
Destructor, use this to clean up anything you created in the constructor.
void initialize() override
Use this to initialize resources or memory your module needs.
double getDistAtDetSurface(const Particle *iParticle, const Particle *jParticle, const std::string &detLayerName) const
Calculate the distance between the points where the two input extrapolated track helices cross the gi...
void event() override
Called once for each event.
std::unordered_map< std::string, std::string > m_detLayerToDistVariable
Map that associates to each detector layer (e.g., 'CDC6') the name of the variable representing the d...
std::string m_decayString
The name of the input charged stable particle list, or composite particle w/ charged stable daughters...
StoreObjPtr< ParticleList > m_pListTarget
The input ParticleList object for which distances are to be calculated.
std::string m_isoScoreVariable
The name of the variable representing the track isolation score.
double getWeightedSumInvDists(const Particle *iParticle, const std::string &detName, const float detWeight) const
Get the sum of the inverse (scaled) minimum distances over the given detector layers,...
StoreArray< Particle > m_particles
StoreArray of Particles.
std::string m_payloadName
The name of the database payload object with the MVA weights.
std::vector< std::string > m_detNames
The list of names of the detectors at whose inner (cylindrical) surface we extrapolate each track's p...
Const::EDetector getDetEnum(const std::string &detName) const
Get the enum type for this detector name.
std::string m_pListReferenceName
The name of the input ParticleList of reference tracks.
std::unordered_map< std::string, std::string > m_detLayerToRefPartIdxVariable
Map that associates to each detector layer (e.g, 'CDC6') the name of the variable representing the md...
double getDistThreshold(Const::EDetector det, int layer) const
Get the threshold value per detector layer for the distance to closest ext.
bool onlySelectedStdChargedInDecay()
Check whether input particle list and reference list are of a valid charged stable particle.
std::map< std::pair< std::string, int >, double > m_distThreshPerDetLayer
Threshold values for the distance (in [cm]) to closest ext.
double getDetectorWeight(const Particle *iParticle, const std::string &detName) const
Get the PID weight, , for this particle and detector reading it from the payload, if selected.
bool m_excludePIDDetWeights
Exclude the PID detector weights for the isolation score definition.
DecayDescriptor m_decaydescriptor
< Decay descriptor of decays to look for.
TrackIsoCalculatorModule()
Constructor: Sets the description, the properties and the parameters of the module.
double getWeightedSumNonIsoLayers(const Particle *iParticle, const std::string &detName, const float detWeight) const
Get the sum of layers with a close-by track, divided by the total number of layers,...
unsigned short m_nSelectedDaughters
The number of selected daughters in the decay string.
StoreObjPtr< ParticleList > m_pListReference
The input ParticleList object of reference tracks.
std::string m_isoScoreVariableAsWeightedAvg
The name of the variable representing the track isolation score.
bool m_useHighestProbMassForExt
If this option is set, the helix extrapolation for the target and reference particles will use the tr...
Abstract base class for different kinds of events.