Belle II Software development
MCFacetFilter.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/trackFindingCDC/filters/facet/MCFacetFilter.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
11
12#include <tracking/trackingUtilities/eventdata/hits/CDCFacet.h>
13#include <tracking/trackingUtilities/eventdata/hits/CDCRLWireHitTriple.h>
14#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
15
16#include <tracking/trackFindingCDC/filters/base/MCSymmetricFilter.icc.h>
17
18#include <cmath>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22using namespace TrackingUtilities;
23
25
27 : Super(allowReverse)
28{
29}
30
32{
33 const int maxInTrackHitIdDifference = 3;
34 bool isCorrectFacet = operator()(facet, maxInTrackHitIdDifference);
35
36 bool isCorrectReverseFacet =
37 this->getAllowReverse() and operator()(facet.reversed(), maxInTrackHitIdDifference);
38
39 if (isCorrectFacet) {
40 if (facet.getFitLine()->isInvalid()) {
41 facet.adjustFitLine();
42 }
43 return 3.0;
44 } else if (isCorrectReverseFacet) {
45 if (facet.getFitLine()->isInvalid()) {
46 facet.adjustFitLine();
47 }
48 return -3.0;
49 } else {
50 return NAN;
51 }
52}
53
55 int maxInTrackHitIdDifference)
56{
57 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
58
59 const CDCWireHit& startWireHit = rlWireHitTriple.getStartWireHit();
60 const CDCWireHit& middleWireHit = rlWireHitTriple.getMiddleWireHit();
61 const CDCWireHit& endWireHit = rlWireHitTriple.getEndWireHit();
62
63 // First check if the track ids are in agreement
64 ITrackType startMCTrackId = mcHitLookUp.getMCTrackId(startWireHit.getHit());
65 ITrackType middleMCTrackId = mcHitLookUp.getMCTrackId(middleWireHit.getHit());
66 ITrackType endMCTrackId = mcHitLookUp.getMCTrackId(endWireHit.getHit());
67
68 if (startMCTrackId == INVALID_ITRACK or
69 middleMCTrackId == INVALID_ITRACK or
70 endMCTrackId == INVALID_ITRACK) {
71 return false;
72 }
73
74 if (not(startMCTrackId == middleMCTrackId and middleMCTrackId == endMCTrackId)) {
75 return false;
76 }
77
78 int startInTrackId = mcHitLookUp.getInTrackId(startWireHit.getHit());
79 int middleInTrackId = mcHitLookUp.getInTrackId(middleWireHit.getHit());
80 int endInTrackId = mcHitLookUp.getInTrackId(endWireHit.getHit());
81
82 int startToMiddleInTrackDistance = middleInTrackId - startInTrackId;
83 int middleToEndInTrackDistance = endInTrackId - middleInTrackId;
84
85 // Now check the alignment in track
86 bool distanceInTrackIsSufficientlyLow =
87 0 < startToMiddleInTrackDistance and startToMiddleInTrackDistance <= maxInTrackHitIdDifference and
88 0 < middleToEndInTrackDistance and middleToEndInTrackDistance <= maxInTrackHitIdDifference;
89
90
91 if (not distanceInTrackIsSufficientlyLow) return false;
92
93 // Now check the right left information in track
94 ERightLeft startRLInfo = rlWireHitTriple.getStartRLInfo();
95 ERightLeft middleRLInfo = rlWireHitTriple.getMiddleRLInfo();
96 ERightLeft endRLInfo = rlWireHitTriple.getEndRLInfo();
97
98 ERightLeft mcStartRLInfo = mcHitLookUp.getRLInfo(startWireHit.getHit());
99 ERightLeft mcMiddleRLInfo = mcHitLookUp.getRLInfo(middleWireHit.getHit());
100 ERightLeft mcEndRLInfo = mcHitLookUp.getRLInfo(endWireHit.getHit());
101
102 if (startRLInfo == mcStartRLInfo and middleRLInfo == mcMiddleRLInfo and endRLInfo == mcEndRLInfo) {
103 return true;
104 } else {
105 return false;
106 }
107}
Interface class to the Monte Carlo information for individual hits.
ITrackType getMCTrackId(const CDCHit *ptrHit) const
Returns the track id for the hit.
TrackingUtilities::Index getInTrackId(const CDCHit *ptrHit) const
Returns the position of the wire hit in the track along the travel direction.
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
TrackingUtilities::ERightLeft getRLInfo(const CDCHit *ptrHit) const
Returns the true right left passage information.
MCSymmetric< BaseFacetFilter > Super
Type of the super class.
MCFacetFilter(bool allowReverse=true)
Constructor also setting the switch, if the reversed version of a facet (in comparison to MC truth) s...
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCFacet &facet) final
Main filter method returning the weight of the facet.
Mixin for filters that use Monte Carlo information.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition CDCFacet.h:32
void adjustFitLine() const
Adjusts the contained fit line to touch such that it touches the first and third hit.
Definition CDCFacet.cc:62
const UncertainParameterLine2D & getFitLine() const
Getter for the contained line fit information.
Definition CDCFacet.h:61
CDCFacet reversed() const
Constructs the reverse triple from this one.
Definition CDCFacet.cc:54
Class representing a triple of neighboring wire hits.
ERightLeft getMiddleRLInfo() const
Getter for the right left passage information of the second oriented wire hit.
const CDCWireHit & getMiddleWireHit() const
Getter for the hit wire of the second oriented wire hit.
ERightLeft getStartRLInfo() const
Getter for the right left passage information of the first oriented wire hit.
const CDCWireHit & getEndWireHit() const
Getter for the hit wire of the third oriented wire hit.
ERightLeft getEndRLInfo() const
Getter for the right left passage information of the third oriented wire hit.
const CDCWireHit & getStartWireHit() const
Getter for the hit wire of the first oriented wire hit.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:58
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:162
bool isInvalid() const
Check it the line is in an invalid state.
Abstract base class for different kinds of events.