Belle II Software development
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::getInstance().getSensorInfo(
64 fromStateSensorID));
65 const auto& interceptGlobalPoint = sensorInfo.pointToGlobal({intercept.getCoorU(), intercept.getCoorV(), 0});
66 phiDiff = deltaPhi(interceptGlobalPoint.Phi(), toStateCache.phi);
67 etaDiff = deltaEtaFromTheta(interceptGlobalPoint.Theta(), toStateCache.theta);
68 if (abs(phiDiff) < static_cast<float>(m_param_PhiInterceptToHitCut)*float(layerDiff)*scaleInvPt and
69 abs(etaDiff) < static_cast<float>(m_param_EtaInterceptToHitCut)*float(layerDiff)*scaleInvPt) {
70 return 1.0;
71 }
72 }
73 // We have PXD for this Seed (RecoTrack), but the toState isn't close to any of them -> discard combination
74 return NAN;
75 } else {
76 // We don't have PXDIntercepts for this Seed (RecoTrack), so use simple angular filters.
77 // Get eta/theta separation from track angle
78 const float dR = fromStateCache.perp - toStateCache.perp;
79 const float dZ = fromStateCache.perp / tan(fromStateCache.theta) - toStateCache.perp / tan(toStateCache.theta);
80 const float cosThetaSeedhit = dZ / sqrt(dR * dR + dZ * dZ);
81 etaDiff = convertThetaToEta(cosThetaSeedhit) - convertThetaToEta(cos(fromStateCache.thetaSeed));
82 if (abs(phiDiff) < static_cast<float>(m_param_PhiRecoTrackToHitCut)*float(layerDiff)*scaleInvPt and
83 abs(etaDiff) < static_cast<float>(m_param_EtaRecoTrackToHitCut)*float(layerDiff)*scaleInvPt) {
84 return 1.0;
85 }
86 return NAN;
87 }
88 }
89
90 // hit-hit relation from Layer-2 to Layer-1
91 if (abs(phiDiff) < static_cast<float>(m_param_PhiHitHitCut) and
92 abs(etaDiff) < static_cast<float>(m_param_EtaHitHitCut)) {
93 return 1.0;
94 }
95
96 return NAN;
97
98}
99
100void InterceptDistancePXDPairFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
101{
102 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "ptThresholdTrackToHitCut"), m_param_PtThresholdTrackToHitCut,
103 "Threshold on pT to apply inverse pT scale on cut value.",
105 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiInterceptToHitCut"), m_param_PhiInterceptToHitCut,
106 "Cut in phi for the difference between PXDIntercept from RecoTrack on the same layer and current hit-based state.",
108 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaInterceptToHitCut"), m_param_EtaInterceptToHitCut,
109 "Cut in eta for the difference between PXDIntercept from RecoTrack on the same layer and current hit-based state.",
111 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiRecoTrackToHitCut"), m_param_PhiRecoTrackToHitCut,
112 "Cut in phi for the difference between RecoTrack information and current hit-based state.",
114 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaRecoTrackToHitCut"), m_param_EtaRecoTrackToHitCut,
115 "Cut in eta for the difference between RecoTrack information and current hit-based state.",
117 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiHitHitCut"), m_param_PhiHitHitCut,
118 "Cut in phi between two hit-based states.", m_param_PhiHitHitCut);
119 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaHitHitCut"), m_param_EtaHitHitCut,
120 "Cut in eta between two hit-based states.", m_param_EtaHitHitCut);
121 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiOverlapHitHitCut"), m_param_PhiOverlapHitHitCut,
122 "Cut in phi between two hit-based states in ladder overlap.", m_param_PhiOverlapHitHitCut);
123 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "etaOverlapHitHitCut"), m_param_EtaOverlapHitHitCut,
124 "Cut in eta between two hit-based states in ladder overlap.", m_param_EtaOverlapHitHitCut);
125 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "PXDInterceptsName"), m_param_PXDInterceptsName,
126 "Name of the PXDIntercepts StoreArray.", m_param_PXDInterceptsName);
127}
128
129float InterceptDistancePXDPairFilter::deltaPhi(float phi1, float phi2)
130{
131 float dphi = phi1 - phi2;
132 while (dphi > M_PI) dphi -= 2. * M_PI;
133 while (dphi < -M_PI) dphi += 2. * M_PI;
134 return dphi;
135}
136
138{
139 return (convertThetaToEta(cos(theta1)) - convertThetaToEta(cos(theta2)));
140}
141
143{
144 if (abs(cosTheta) < 1) return -0.5 * log((1.0 - cosTheta) / (1.0 + cosTheta));
145 else {
146 B2INFO("AngularDistancePXDPairFilter::cosTheta >=1 : " << cosTheta);
147 return 0;
148 }
149}
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.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
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.