Belle II Software development
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
16namespace 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.Rho() > 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.R() < m_minMomentum) return false;
65 } else if (m_sampleType == c_dimuon or m_sampleType == c_bhabha) {
66 ROOT::Math::PxPyPzMVector lorentzLab(m_pocaMomentum.X(), m_pocaMomentum.Y(), m_pocaMomentum.Z(), m_chargedStable.getMass());
68 auto lorentzCms = T.labToCms(lorentzLab);
69 m_cmsEnergy = lorentzCms.energy();
70 double dE = m_cmsEnergy - T.getCMSEnergy() / 2;
71 if (fabs(dE) > m_deltaEcms) return false;
72 } else {
73 return false;
74 }
75
76 // cut on local z
77 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
78 const auto& module = geo->getModule(trk.getModuleID());
79 m_localPosition = module.pointToLocal(static_cast<ROOT::Math::XYZPoint>(trk.getExtHit()->getPosition()));
80 m_localMomentum = module.momentumToLocal(trk.getExtHit()->getMomentum());
81 if (m_localPosition.Z() < m_minZ or m_localPosition.Z() > m_maxZ) return false;
82
83 return true;
84 }
85
86 } // namespace TOP
88} // namespace Belle2
89
double getMass() const
Particle mass.
Definition: UnitConst.cc:356
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ChargedStable electron
electron particle
Definition: Const.h:659
ROOT::Math::XYZVector getMomentum() const
Get momentum at this extrapolation hit.
Definition: ExtHit.h:151
ROOT::Math::XYZVector getPosition() const
Get position of this extrapolation hit.
Definition: ExtHit.h:144
Class to hold Lorentz transformations from/to CMS and boost vector.
double getCMSEnergy() const
Returns CMS energy of e+e- (aka.
static ROOT::Math::PxPyPzMVector labToCms(const ROOT::Math::PxPyPzMVector &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:39
const Track * getTrack() const
Returns mdst track.
Definition: TOPTrack.h:210
bool isValid() const
Checks if track is successfully constructed.
Definition: TOPTrack.h:137
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
Definition: TOPTrack.h:216
int getModuleID() const
Returns slot ID.
Definition: TOPTrack.h:143
Const::ChargedStable m_chargedStable
track hypothesis
EType m_sampleType
data sample (skim) type
ROOT::Math::XYZVector m_pocaPosition
position of POCA
double m_minMomentum
minimal track momentum if sample is "cosmics"
double m_dz
cut on POCA in z
ROOT::Math::XYZVector m_localMomentum
momentum at TOP in local (module) frame
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:44
ROOT::Math::XYZPoint m_localPosition
position at TOP in local (module) frame
double m_deltaEcms
c.m.s energy window for "dimuon" or "bhabha"
ROOT::Math::XYZVector m_pocaMomentum
momentum at POCA
const TrackFitResult * getTrackFitResultWithClosestMass(const Const::ChargedStable &requestedType) const
Return the track fit for a fit hypothesis with the closest mass.
Definition: Track.cc:104
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.