Belle II Software  release-05-01-25
TrackSelector.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <top/utilities/TrackSelector.h>
12 #include <framework/logging/Logger.h>
13 #include <top/reconstruction/TOPtrack.h>
14 #include <top/geometry/TOPGeometryPar.h>
15 #include <mdst/dataobjects/Track.h>
16 #include <analysis/utility/PCmsLabTransform.h>
17 
18 
19 namespace Belle2 {
24  namespace TOP {
25 
26  TrackSelector::TrackSelector(const std::string& sampleName): m_sampleName(sampleName)
27  {
28  if (sampleName == "dimuon") {
29  m_sampleType = c_dimuon;
30  m_chargedStable = Const::muon;
31  } else if (sampleName == "bhabha") {
32  m_sampleType = c_bhabha;
33  m_chargedStable = Const::electron;
34  } else if (sampleName == "cosmics") {
35  m_sampleType = c_cosmics;
36  m_chargedStable = Const::muon;
37  } else {
38  m_sampleType = c_undefined;
39  m_sampleName = "undefined";
40  B2ERROR("TOP::TrackSelector: unknown data sample."
41  << LogVar("name", sampleName));
42  }
43  }
44 
45  bool TrackSelector::isSelected(const TOPtrack& trk) const
46  {
47 
48  if (m_sampleType == c_undefined) {
49  B2ERROR("TOP::TrackSelector: sample type is undefined, default constructor used");
50  return false;
51  }
52 
53  if (not trk.isValid()) return false;
54 
55  const auto* fit = trk.getTrack()->getTrackFitResultWithClosestMass(m_chargedStable);
56  if (not fit) return false;
57 
58  // cut on POCA
59  m_pocaPosition = fit->getPosition();
60  if (m_pocaPosition.Perp() > m_dr) return false;
61  if (fabs(m_pocaPosition.Z()) > m_dz) return false;
62 
63  // momentum/energy cut
64  m_pocaMomentum = fit->getMomentum();
65  if (m_sampleType == c_cosmics) {
66  if (m_pocaMomentum.Mag() < m_minMomentum) return false;
67  } else if (m_sampleType == c_dimuon or m_sampleType == c_bhabha) {
68  TLorentzVector lorentzLab;
69  lorentzLab.SetXYZM(m_pocaMomentum.X(), m_pocaMomentum.Y(), m_pocaMomentum.Z(),
72  auto lorentzCms = T.labToCms(lorentzLab);
73  m_cmsEnergy = lorentzCms.Energy();
74  double dE = m_cmsEnergy - T.getCMSEnergy() / 2;
75  if (fabs(dE) > m_deltaEcms) return false;
76  } else {
77  return false;
78  }
79 
80  // cut on local z
81  const auto* geo = TOPGeometryPar::Instance()->getGeometry();
82  const auto& module = geo->getModule(trk.getModuleID());
83  m_localPosition = module.pointToLocal(trk.getPosition());
84  m_localMomentum = module.momentumToLocal(trk.getMomentum());
85  if (m_localPosition.Z() < m_minZ or m_localPosition.Z() > m_maxZ) return false;
86 
87  return true;
88  }
89 
90  } // namespace TOP
92 } // namespace Belle2
93 
Belle2::TOP::TrackSelector::m_maxZ
double m_maxZ
maximal local z of extrapolated hit
Definition: TrackSelector.h:190
Belle2::TOP::TrackSelector::TrackSelector
TrackSelector()
Default constructor.
Definition: TrackSelector.h:54
Belle2::PCmsLabTransform::labToCms
static TLorentzVector labToCms(const TLorentzVector &vec)
Transforms Lorentz vector into CM System.
Definition: PCmsLabTransform.cc:15
Belle2::Const::electron
static const ChargedStable electron
electron particle
Definition: Const.h:533
Belle2::TOP::TrackSelector::m_localMomentum
TVector3 m_localMomentum
momentum at TOP in local (module) frame
Definition: TrackSelector.h:198
Belle2::TOP::TrackSelector::m_sampleType
EType m_sampleType
data sample (skim) type
Definition: TrackSelector.h:183
Belle2::PCmsLabTransform::getCMSEnergy
double getCMSEnergy() const
Returns CMS energy of e+e- (aka.
Definition: PCmsLabTransform.h:57
Belle2::TOP::TrackSelector::m_dr
double m_dr
cut on POCA in r
Definition: TrackSelector.h:187
Belle2::TOP::TrackSelector::m_chargedStable
Const::ChargedStable m_chargedStable
track hypothesis
Definition: TrackSelector.h:191
Belle2::TOP::TrackSelector::m_minZ
double m_minZ
minimal local z of extrapolated hit
Definition: TrackSelector.h:189
Belle2::TOP::TOPGeometryPar::Instance
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
Definition: TOPGeometryPar.cc:45
Belle2::TOP::TrackSelector::m_pocaPosition
TVector3 m_pocaPosition
position of POCA
Definition: TrackSelector.h:194
Belle2::TOP::TrackSelector::m_dz
double m_dz
cut on POCA in z
Definition: TrackSelector.h:188
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOP::TrackSelector::m_minMomentum
double m_minMomentum
minimal track momentum if sample is "cosmics"
Definition: TrackSelector.h:185
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::TOP::TrackSelector::m_localPosition
TVector3 m_localPosition
position at TOP in local (module) frame
Definition: TrackSelector.h:197
Belle2::TOP::TrackSelector::m_pocaMomentum
TVector3 m_pocaMomentum
momentum at POCA
Definition: TrackSelector.h:195
Belle2::TOP::TrackSelector::isSelected
bool isSelected(const TOPtrack &track) const
Returns selection status.
Definition: TrackSelector.cc:53
Belle2::PCmsLabTransform
Class to hold Lorentz transformations from/to CMS and boost vector.
Definition: PCmsLabTransform.h:37
Belle2::TOP::TrackSelector::m_deltaEcms
double m_deltaEcms
c.m.s energy window for "dimuon" or "bhabha"
Definition: TrackSelector.h:186
Belle2::Const::muon
static const ChargedStable muon
muon particle
Definition: Const.h:534
Belle2::TOP::TOPGeometryPar::getGeometry
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using Basf2 units.
Definition: TOPGeometryPar.cc:167
Belle2::TOP::TrackSelector::m_cmsEnergy
double m_cmsEnergy
c.m.s.
Definition: TrackSelector.h:196
Belle2::Const::ParticleType::getMass
double getMass() const
Particle mass.
Definition: UnitConst.cc:310