Belle II Software  release-06-01-15
TrackSelector.cc
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 #include <top/utilities/TrackSelector.h>
10 #include <framework/logging/Logger.h>
11 #include <top/geometry/TOPGeometryPar.h>
12 #include <mdst/dataobjects/Track.h>
13 #include <tracking/dataobjects/ExtHit.h>
14 #include <analysis/utility/PCmsLabTransform.h>
15 
16 namespace Belle2 {
21  namespace TOP {
22 
23  TrackSelector::TrackSelector(const std::string& sampleName): m_sampleName(sampleName)
24  {
25  if (sampleName == "dimuon") {
26  m_sampleType = c_dimuon;
28  } else if (sampleName == "bhabha") {
29  m_sampleType = c_bhabha;
31  } else if (sampleName == "cosmics") {
32  m_sampleType = c_cosmics;
34  } else {
35  m_sampleType = c_undefined;
36  m_sampleName = "undefined";
37  B2ERROR("TOP::TrackSelector: unknown data sample."
38  << LogVar("name", sampleName));
39  }
40  }
41 
42 
43  bool TrackSelector::isSelected(const TOPTrack& trk) const
44  {
45 
46  if (m_sampleType == c_undefined) {
47  B2ERROR("TOP::TrackSelector:isSelected sample type is undefined, returning false");
48  return false;
49  }
50 
51  if (not trk.isValid()) return false;
52 
54  if (not fit) return false;
55 
56  // cut on POCA
57  m_pocaPosition = fit->getPosition();
58  if (m_pocaPosition.Perp() > m_dr) return false;
59  if (fabs(m_pocaPosition.Z()) > m_dz) return false;
60 
61  // momentum/energy cut
62  m_pocaMomentum = fit->getMomentum();
63  if (m_sampleType == c_cosmics) {
64  if (m_pocaMomentum.Mag() < m_minMomentum) return false;
65  } else if (m_sampleType == c_dimuon or m_sampleType == c_bhabha) {
66  TLorentzVector lorentzLab;
67  lorentzLab.SetXYZM(m_pocaMomentum.X(), m_pocaMomentum.Y(), m_pocaMomentum.Z(),
70  auto lorentzCms = T.labToCms(lorentzLab);
71  m_cmsEnergy = lorentzCms.Energy();
72  double dE = m_cmsEnergy - T.getCMSEnergy() / 2;
73  if (fabs(dE) > m_deltaEcms) return false;
74  } else {
75  return false;
76  }
77 
78  // cut on local z
79  const auto* geo = TOPGeometryPar::Instance()->getGeometry();
80  const auto& module = geo->getModule(trk.getModuleID());
81  m_localPosition = module.pointToLocal(trk.getExtHit()->getPosition());
82  m_localMomentum = module.momentumToLocal(trk.getExtHit()->getMomentum());
83  if (m_localPosition.Z() < m_minZ or m_localPosition.Z() > m_maxZ) return false;
84 
85  return true;
86  }
87 
88  } // namespace TOP
90 } // namespace Belle2
91 
double getMass() const
Particle mass.
Definition: UnitConst.cc:323
static const ChargedStable muon
muon particle
Definition: Const.h:541
static const ChargedStable electron
electron particle
Definition: Const.h:540
TVector3 getMomentum() const
Get momentum at this extrapolation hit.
Definition: ExtHit.h:147
TVector3 getPosition() const
Get position of this extrapolation hit.
Definition: ExtHit.h:143
Class to hold Lorentz transformations from/to CMS and boost vector.
double getCMSEnergy() const
Returns CMS energy of e+e- (aka.
static TLorentzVector labToCms(const TLorentzVector &vec)
Transforms Lorentz vector into CM System.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
Reconstructed track at TOP.
Definition: TOPTrack.h:40
bool isValid() const
Checks if track is successfully constructed.
Definition: TOPTrack.h:139
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
Definition: TOPTrack.h:218
const Track * getTrack() const
Returns mdst track.
Definition: TOPTrack.h:212
int getModuleID() const
Returns slot ID.
Definition: TOPTrack.h:145
Const::ChargedStable m_chargedStable
track hypothesis
EType m_sampleType
data sample (skim) type
TVector3 m_pocaMomentum
momentum at POCA
double m_minMomentum
minimal track momentum if sample is "cosmics"
double m_dz
cut on POCA in z
TVector3 m_pocaPosition
position of POCA
std::string m_sampleName
data sample (skim) name
double m_maxZ
maximal local z of extrapolated hit
bool isSelected(const TOPTrack &track) const
Returns selection status.
double m_minZ
minimal local z of extrapolated hit
double m_dr
cut on POCA in r
TrackSelector()
Default constructor.
Definition: TrackSelector.h:43
double m_deltaEcms
c.m.s energy window for "dimuon" or "bhabha"
TVector3 m_localMomentum
momentum at TOP in local (module) frame
TVector3 m_localPosition
position at TOP in local (module) frame
const TrackFitResult * getTrackFitResultWithClosestMass(const Const::ChargedStable &requestedType) const
Return the track fit for a fit hypothesis with the closest mass.
Definition: Track.cc:68
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.