Belle II Software release-09-00-00
InterceptDistancePXDPairFilter.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#include <tracking/ckf/pxd/filters/relations/InterceptDistancePXDPairFilter.h>
9#include <tracking/trackFindingCDC/filters/base/Filter.icc.h>
10
11#include <tracking/dataobjects/RecoTrack.h>
12#include <tracking/dataobjects/PXDIntercept.h>
13
14#include <pxd/geometry/SensorInfo.h>
15#include <vxd/geometry/SensorInfoBase.h>
16#include <vxd/geometry/GeoCache.h>
17
18#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19#include <framework/core/ModuleParamList.templateDetails.h>
20
21using namespace Belle2;
22using namespace TrackFindingCDC;
23
24TrackFindingCDC::Weight
25InterceptDistancePXDPairFilter::operator()(const std::pair<const CKFToPXDState*, const CKFToPXDState*>& relation)
26{
27 const CKFToPXDState& fromState = *(relation.first);
28 const CKFToPXDState& toState = *(relation.second);
29
30 const CKFToPXDState::stateCache& fromStateCache = fromState.getStateCache();
31 const CKFToPXDState::stateCache& toStateCache = toState.getStateCache();
32
33 B2ASSERT("You have filled the wrong states into this!", toStateCache.isHitState);
34
35 const unsigned int layerDiff = abs(fromStateCache.geoLayer - toStateCache.geoLayer);
36
37 float phiDiff = deltaPhi(fromStateCache.phi, toStateCache.phi);
38 float etaDiff = deltaEtaFromTheta(fromStateCache.theta, toStateCache.theta);
39
40 // fromState and toState on the same layer, i.e. hits in ladder overlap region
41 if (layerDiff == 0) {
42 if (abs(phiDiff) < static_cast<float>(m_param_PhiOverlapHitHitCut) and
43 abs(etaDiff) < static_cast<float>(m_param_EtaOverlapHitHitCut)) {
44 return 1.0;
45 }
46 return NAN;
47 }
48
49 // if fromState is not HitState, then it is the last hit on SVD or SVD/CDC track
50 if (not fromStateCache.isHitState) {
51 const RecoTrack* seedRecoTrack = fromState.getSeed();
52 const auto& relatedIntercepts = seedRecoTrack->getRelationsTo<PXDIntercept>(m_param_PXDInterceptsName);
53 // pT dependent factor, pre-set cut value should correspond to pT>=1GeV
54 const float scaleInvPt =
55 (fromStateCache.ptSeed < m_param_PtThresholdTrackToHitCut ? (m_param_PtThresholdTrackToHitCut / fromStateCache.ptSeed) : 1.);
56 if (relatedIntercepts.size() > 0) {
57 // We have PXDIntercepts for this Seed (RecoTrack), so use the intercept position for filtering
58 for (const auto& intercept : relatedIntercepts) {
59 const VxdID& fromStateSensorID(intercept.getSensorID());
60 if (fromStateSensorID.getLayerNumber() != toStateCache.geoLayer) {
61 continue;
62 }
63 const PXD::SensorInfo& sensorInfo = dynamic_cast<const PXD::SensorInfo&>(VXD::GeoCache::get(fromStateSensorID));
64 const auto& interceptGlobalPoint = sensorInfo.pointToGlobal({intercept.getCoorU(), intercept.getCoorV(), 0});
65 phiDiff = deltaPhi(interceptGlobalPoint.Phi(), toStateCache.phi);
66 etaDiff = deltaEtaFromTheta(interceptGlobalPoint.Theta(), toStateCache.theta);
67 if (abs(phiDiff) < static_cast<float>(m_param_PhiInterceptToHitCut)*float(layerDiff)*scaleInvPt and
68 abs(etaDiff) < static_cast<float>(m_param_EtaInterceptToHitCut)*float(layerDiff)*scaleInvPt) {
69 return 1.0;
70 }
71 }
72 // We have PXD for this Seed (RecoTrack), but the toState isn't close to any of them -> discard combination
73 return NAN;
74 } else {
75 // We don't have PXDIntercepts for this Seed (RecoTrack), so use simple angular filters.
76 // Get eta/theta separation from track angle
77 const float dR = fromStateCache.perp - toStateCache.perp;
78 const float dZ = fromStateCache.perp / tan(fromStateCache.theta) - toStateCache.perp / tan(toStateCache.theta);
79 const float cosThetaSeedhit = dZ / sqrt(dR * dR + dZ * dZ);
80 etaDiff = convertThetaToEta(cosThetaSeedhit) - convertThetaToEta(cos(fromStateCache.thetaSeed));
81 if (abs(phiDiff) < static_cast<float>(m_param_PhiRecoTrackToHitCut)*float(layerDiff)*scaleInvPt and
82 abs(etaDiff) < static_cast<float>(m_param_EtaRecoTrackToHitCut)*float(layerDiff)*scaleInvPt) {
83 return 1.0;
84 }
85 return NAN;
86 }
87 }
88
89 // hit-hit relation from Layer-2 to Layer-1
90 if (abs(phiDiff) < static_cast<float>(m_param_PhiHitHitCut) and
91 abs(etaDiff) < static_cast<float>(m_param_EtaHitHitCut)) {
92 return 1.0;
93 }
94
95 return NAN;
96
97}
98
99void InterceptDistancePXDPairFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
100{
101 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "ptThresholdTrackToHitCut"), m_param_PtThresholdTrackToHitCut,
102 "Treshold on pT to apply inverse pT scale on cut value.",
104 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiInterceptToHitCut"), m_param_PhiInterceptToHitCut,
105 "Cut in phi for the difference between PXDIntercept from RecoTrack on the same layer and current hit-based state.",
107 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaInterceptToHitCut"), m_param_EtaInterceptToHitCut,
108 "Cut in eta for the difference between PXDIntercept from RecoTrack on the same layer and current hit-based state.",
110 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiRecoTrackToHitCut"), m_param_PhiRecoTrackToHitCut,
111 "Cut in phi for the difference between RecoTrack information and current hit-based state.",
113 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaRecoTrackToHitCut"), m_param_EtaRecoTrackToHitCut,
114 "Cut in eta for the difference between RecoTrack information and current hit-based state.",
116 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiHitHitCut"), m_param_PhiHitHitCut,
117 "Cut in phi between two hit-based states.", m_param_PhiHitHitCut);
118 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaHitHitCut"), m_param_EtaHitHitCut,
119 "Cut in eta between two hit-based states.", m_param_EtaHitHitCut);
120 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiOverlapHitHitCut"), m_param_PhiOverlapHitHitCut,
121 "Cut in phi between two hit-based states in ladder overlap.", m_param_PhiOverlapHitHitCut);
122 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaOverlapHitHitCut"), m_param_EtaOverlapHitHitCut,
123 "Cut in eta between two hit-based states in ladder overlap.", m_param_EtaOverlapHitHitCut);
124 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "PXDInterceptsName"), m_param_PXDInterceptsName,
125 "Name of the PXDIntercepts StoreArray.", m_param_PXDInterceptsName);
126}
127
128float InterceptDistancePXDPairFilter::deltaPhi(float phi1, float phi2)
129{
130 float dphi = phi1 - phi2;
131 while (dphi > M_PI) dphi -= 2. * M_PI;
132 while (dphi < -M_PI) dphi += 2. * M_PI;
133 return dphi;
134}
135
137{
138 return (convertThetaToEta(cos(theta1)) - convertThetaToEta(cos(theta2)));
139}
140
142{
143 if (abs(cosTheta) < 1) return -0.5 * log((1.0 - cosTheta) / (1.0 + cosTheta));
144 else {
145 B2INFO("AngularDistancePXDPairFilter::cosTheta >=1 : " << cosTheta);
146 return 0;
147 }
148}
const Seed * getSeed() const
Return the track this state is related to.
Definition: CKFState.h:60
Specialized CKF State for extrapolating into the PXD.
Definition: CKFToPXDState.h:27
const struct stateCache & getStateCache() const
Get the cached data of this state.
Definition: CKFToPXDState.h:48
float deltaPhi(float phi1, float phi2)
Calculate delta phi.
double m_param_EtaHitHitCut
Filter potential relations in eta between hit states.
float deltaEtaFromTheta(float theta1, float theta2)
Calculate delta eta from theta.
double m_param_EtaRecoTrackToHitCut
Filter potential relations in eta between seed states (based on RecoTracks) and hit states.
double m_param_PhiHitHitCut
Filter potential relations in phi between hit states.
double m_param_PhiOverlapHitHitCut
Filter potential relations in phi between hit states in ladder overlap.
double m_param_EtaOverlapHitHitCut
Filter potential relations in eta between hit states in ladder overlap.
double m_param_PhiInterceptToHitCut
Filter potential relations in phi between seed states (based on PXDIntercepts) and hit states.
double m_param_EtaInterceptToHitCut
Filter potential relations in eta between seed states (based on PXDIntercepts) and hit states.
double m_param_PtThresholdTrackToHitCut
Threshold to apply inverse pT dependent cut [GeV].
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters.
double m_param_PhiRecoTrackToHitCut
Filter potential relations in phi between seed states (based on RecoTracks) and hit states.
float convertThetaToEta(float cosTheta)
Convert theta to eta (pseudorapidity)
std::string m_param_PXDInterceptsName
Name of the PXDIntercepts StoreArray.
TrackFindingCDC::Weight operator()(const std::pair< const CKFToPXDState *, const CKFToPXDState * > &relation) override
Return the weight based on azimuthal-angle separation.
The Module parameter list class.
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:22
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.