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/datastore/StoreArray.h>
15#include <framework/gearbox/Const.h>
16#include <framework/database/DBObjPtr.h>
17
18#include <analysis/dataobjects/Particle.h>
19#include <analysis/dataobjects/ParticleList.h>
20#include <analysis/DecayDescriptor/DecayDescriptor.h>
21#include <analysis/dbobjects/PIDDetectorWeights.h>
22
23
24namespace Belle2 {
34
35 public:
36
41
46
53 void initialize() override;
54
60 void event() override;
61
62
63 private:
64
69
73 std::string m_decayString;
74
78 unsigned short m_nSelectedDaughters;
79
84
88 std::vector<std::string> m_detNames;
89
96 std::unordered_map<std::string, std::string> m_detLayerToDistVariable;
97
103 std::unordered_map<std::string, std::string> m_detLayerToRefPartIdxVariable;
104
110
116
121 std::map<std::pair<std::string, int>, double> m_distThreshPerDetLayer = {
122 { {Const::parseDetectors(Const::CDC), 0}, 5.0 },
123 { {Const::parseDetectors(Const::CDC), 1}, 5.0 },
124 { {Const::parseDetectors(Const::CDC), 2}, 5.0 },
125 { {Const::parseDetectors(Const::CDC), 3}, 5.0 },
126 { {Const::parseDetectors(Const::CDC), 4}, 5.0 },
127 { {Const::parseDetectors(Const::CDC), 5}, 5.0 },
128 { {Const::parseDetectors(Const::CDC), 6}, 5.0 },
129 { {Const::parseDetectors(Const::CDC), 7}, 5.0 },
130 { {Const::parseDetectors(Const::CDC), 8}, 5.0 },
131 { {Const::parseDetectors(Const::TOP), 0}, 22.0 },
132 { {Const::parseDetectors(Const::ARICH), 0}, 10.0 },
133 { {Const::parseDetectors(Const::ECL), 0}, 36.0 },
134 { {Const::parseDetectors(Const::ECL), 1}, 36.0 },
135 { {Const::parseDetectors(Const::KLM), 0}, 20.0 }
136 };
137
142
147
152
157
163
168
172 std::string m_payloadName;
173
177 std::unique_ptr<DBObjPtr<PIDDetectorWeights>> m_DBWeights;
178
183 double getDistAtDetSurface(const Particle* iParticle, const Particle* jParticle, const std::string& detLayerName) const;
184
189 double getDetectorWeight(const Particle* iParticle, const std::string& detName) const;
190
206 double getWeightedSumNonIsoLayers(const Particle* iParticle, const std::string& detName, const float detWeight) const;
207
221 double getWeightedSumInvDists(const Particle* iParticle, const std::string& detName, const float detWeight) const;
222
229 double getDistThreshold(Const::EDetector det, int layer) const
230 {
231 auto detAndLayer = std::make_pair(Const::parseDetectors(det), layer);
232 return m_distThreshPerDetLayer.at(detAndLayer);
233 };
234
239
243 Const::EDetector getDetEnum(const std::string& detName) const
244 {
245
246 if (detName == "CDC") return Const::CDC;
247 else if (detName == "TOP") return Const::TOP;
248 else if (detName == "ARICH") return Const::ARICH;
249 else if (detName == "ECL") return Const::ECL;
250 else if (detName == "KLM") return Const::KLM;
251 else B2FATAL("Unknown detector component: " << detName);
252
253 };
254
255 };
257}
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:161
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:76
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:95
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.