Belle II Software  light-2212-foldex
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 
27 namespace Belle2 {
38 
39  public:
47  DetSurfCylBoundaries(float rho, float zfwd, float zbwd, float th_fwd, float th_fwd_brl, float th_bwd_brl, float th_bwd)
48  {
49  m_rho = rho;
50  m_zfwd = zfwd;
51  m_zbwd = zbwd;
52  m_th_fwd = th_fwd;
53  m_th_fwd_brl = th_fwd_brl;
54  m_th_bwd_brl = th_bwd_brl;
55  m_th_bwd = th_bwd;
56  };
57  float m_rho;
58  float m_zfwd;
59  float m_zbwd;
60  float m_th_fwd;
61  float m_th_fwd_brl;
62  float m_th_bwd_brl;
63  float m_th_bwd;
64  };
65 
73 
74  public:
75 
80 
84  ~TrackIsoCalculatorModule() override;
85 
92  void initialize() override;
93 
99  void event() override;
100 
101 
102  private:
103 
108 
112  std::string m_decayString;
113 
117  unsigned short m_nSelectedDaughters;
118 
122  std::string m_pListReferenceName;
123 
127  std::string m_detName;
128 
132  unsigned int m_nLayers;
133 
140  std::unordered_map<std::string, std::string> m_detLayerToDistVariable;
141 
147  std::unordered_map<std::string, std::string> m_detLayerToRefPartIdxVariable;
148 
154  std::string m_isoScoreVariable;
155 
159  std::unordered_map<std::string, std::vector<int>> m_detToLayers = {
160  {"CDC", {0, 1, 2, 3, 4, 5, 6, 7, 8}},
161  {"TOP", {0}},
162  {"ARICH", {0}},
163  {"ECL", {0, 1}},
164  {"KLM", {0}}
165  };
166 
171  std::unordered_map<std::string, DetSurfCylBoundaries> m_detLayerToSurfBoundaries = {
172  {"CDC0", DetSurfCylBoundaries(16.8, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
173  {"CDC1", DetSurfCylBoundaries(25.7, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
174  {"CDC2", DetSurfCylBoundaries(36.52, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
175  {"CDC3", DetSurfCylBoundaries(47.69, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
176  {"CDC4", DetSurfCylBoundaries(58.41, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
177  {"CDC5", DetSurfCylBoundaries(69.53, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
178  {"CDC6", DetSurfCylBoundaries(80.25, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
179  {"CDC7", DetSurfCylBoundaries(91.37, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
180  {"CDC8", DetSurfCylBoundaries(102.09, 150.0, -75.0, 0.0, 0.29, 2.61, 3.14)},
181  {"TOP0", DetSurfCylBoundaries(117.8, 193.0, -94.0, 0.24, 0.52, 2.23, 3.14)},
182  {"ARICH0", DetSurfCylBoundaries(117.8, 193.0, -94.0, 0.24, 0.52, 2.23, 3.14)},
183  {"ECL0", DetSurfCylBoundaries(125.0, 196.0, -102.0, 0.21, 0.56, 2.24, 2.70)},
184  {"ECL1", DetSurfCylBoundaries(140.0, 211.0, -117.0, 0.21, 0.56, 2.24, 2.70)},
185  {"KLM0", DetSurfCylBoundaries(202.0, 283.9, -189.9, 0.40, 0.82, 2.13, 2.60)},
186  };
187 
192  std::map<std::pair<std::string, int>, double> m_distThreshPerDetLayer = {
193  { {Const::parseDetectors(Const::CDC), 0}, 5.0 },
194  { {Const::parseDetectors(Const::CDC), 1}, 5.0 },
195  { {Const::parseDetectors(Const::CDC), 2}, 5.0 },
196  { {Const::parseDetectors(Const::CDC), 3}, 5.0 },
197  { {Const::parseDetectors(Const::CDC), 4}, 5.0 },
198  { {Const::parseDetectors(Const::CDC), 5}, 5.0 },
199  { {Const::parseDetectors(Const::CDC), 6}, 5.0 },
200  { {Const::parseDetectors(Const::CDC), 7}, 5.0 },
201  { {Const::parseDetectors(Const::CDC), 8}, 5.0 },
202  { {Const::parseDetectors(Const::TOP), 0}, 22.0 },
203  { {Const::parseDetectors(Const::ARICH), 0}, 10.0 },
204  { {Const::parseDetectors(Const::ECL), 0}, 36.0 },
205  { {Const::parseDetectors(Const::ECL), 1}, 36.0 },
206  { {Const::parseDetectors(Const::KLM), 0}, 20.0 }
207  };
208 
213 
218 
223 
228 
234 
239 
243  std::string m_payloadName;
244 
248  std::unique_ptr<DBObjPtr<PIDDetectorWeights>> m_DBWeights;
249 
254  double getDistAtDetSurface(const Particle* iParticle, const Particle* jParticle, const std::string& detLayerName) const;
255 
272  double getIsoScore(const Particle* iParticle) const;
273 
280  double getDistThreshold(Const::EDetector det, int layer) const
281  {
282  auto detAndLayer = std::make_pair(Const::parseDetectors(det), layer);
283  return m_distThreshPerDetLayer.at(detAndLayer);
284  };
285 
290 
294  Const::EDetector getDetEnum(const std::string& detName) const
295  {
296 
297  if (detName == "CDC") return Const::CDC;
298  else if (detName == "TOP") return Const::TOP;
299  else if (detName == "ARICH") return Const::ARICH;
300  else if (detName == "ECL") return Const::ECL;
301  else if (detName == "KLM") return Const::KLM;
302  else B2FATAL("Unknown detector component: " << detName);
303 
304  };
305 
306  };
308 }
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.
Simple class to encapsulate a detector surface's boundaries in cylindrical coordinates.
DetSurfCylBoundaries()
Default constructor.
DetSurfCylBoundaries(float rho, float zfwd, float zbwd, float th_fwd, float th_fwd_brl, float th_bwd_brl, float th_bwd)
Constructor with parameters.
float m_zfwd
Inner surface z fwd [cm].
float m_th_fwd_brl
fwd/barrel separation theta [rad]
float m_th_fwd
Lower theta edge of fwd region [rad].
float m_th_bwd_brl
bwd/barrel separation theta [rad]
float m_zbwd
Inner surface z bwd [cm].
float m_rho
Inner surface radius [cm].
float m_th_bwd
Upper theta edge of bwd region [rad].
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:74
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.
std::unordered_map< std::string, std::vector< int > > m_detToLayers
Map that associates to each detector its list of valid layers.
~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 the name of the variable representing the distance to the ...
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 in this detector.
StoreArray< Particle > m_particles
StoreArray of Particles.
std::string m_payloadName
The name of the database payload object with the MVA weights.
Const::EDetector getDetEnum(const std::string &detName) const
Get the enum type for this detector name.
std::string m_detName
The name of the detector at whose inner (cylindrical) surface we extrapolate each track's polar and a...
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 the name of the variable representing the mdst array index...
double getDistThreshold(Const::EDetector det, int layer) const
Get the threshold value per detctor 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.
bool m_excludePIDDetWeights
Exclude the PID detector weights for the isolation score definition.
double getIsoScore(const Particle *iParticle) const
Define a semi-continuous variable to quantify the isolation of a standard charged particle in the giv...
DecayDescriptor m_decaydescriptor
< Decay descriptor of decays to look for.
std::unordered_map< std::string, DetSurfCylBoundaries > m_detLayerToSurfBoundaries
Map that associates to each detector layer its valid cylindrical surface's boundaries.
TrackIsoCalculatorModule()
Constructor: Sets the description, the properties and the parameters of the module.
unsigned int m_nLayers
The number of layers for the input detector.
unsigned short m_nSelectedDaughters
The number of selected daughters in the decay string.
StoreObjPtr< ParticleList > m_pListReference
The input ParticleList object of reference tracks.
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.
Definition: ClusterUtils.h:23