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/trackFindingCDC/eventdata/hits/CDCFacet.h>
13#include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHitTriple.h>
14#include <tracking/trackFindingCDC/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;
22
24
26 : Super(allowReverse)
27{
28}
29
31{
32 const int maxInTrackHitIdDifference = 3;
33 bool isCorrectFacet = operator()(facet, maxInTrackHitIdDifference);
34
35 bool isCorrectReverseFacet =
36 this->getAllowReverse() and operator()(facet.reversed(), maxInTrackHitIdDifference);
37
38 if (isCorrectFacet) {
39 if (facet.getFitLine()->isInvalid()) {
40 facet.adjustFitLine();
41 }
42 return 3.0;
43 } else if (isCorrectReverseFacet) {
44 if (facet.getFitLine()->isInvalid()) {
45 facet.adjustFitLine();
46 }
47 return -3.0;
48 } else {
49 return NAN;
50 }
51}
52
54 int maxInTrackHitIdDifference)
55{
56 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
57
58 const CDCWireHit& startWireHit = rlWireHitTriple.getStartWireHit();
59 const CDCWireHit& middleWireHit = rlWireHitTriple.getMiddleWireHit();
60 const CDCWireHit& endWireHit = rlWireHitTriple.getEndWireHit();
61
62 // First check if the track ids are in agreement
63 ITrackType startMCTrackId = mcHitLookUp.getMCTrackId(startWireHit.getHit());
64 ITrackType middleMCTrackId = mcHitLookUp.getMCTrackId(middleWireHit.getHit());
65 ITrackType endMCTrackId = mcHitLookUp.getMCTrackId(endWireHit.getHit());
66
67 if (startMCTrackId == INVALID_ITRACK or
68 middleMCTrackId == INVALID_ITRACK or
69 endMCTrackId == INVALID_ITRACK) {
70 return false;
71 }
72
73 if (not(startMCTrackId == middleMCTrackId and middleMCTrackId == endMCTrackId)) {
74 return false;
75 }
76
77 int startInTrackId = mcHitLookUp.getInTrackId(startWireHit.getHit());
78 int middleInTrackId = mcHitLookUp.getInTrackId(middleWireHit.getHit());
79 int endInTrackId = mcHitLookUp.getInTrackId(endWireHit.getHit());
80
81 int startToMiddleInTrackDistance = middleInTrackId - startInTrackId;
82 int middleToEndInTrackDistance = endInTrackId - middleInTrackId;
83
84 // Now check the alignment in track
85 bool distanceInTrackIsSufficientlyLow =
86 0 < startToMiddleInTrackDistance and startToMiddleInTrackDistance <= maxInTrackHitIdDifference and
87 0 < middleToEndInTrackDistance and middleToEndInTrackDistance <= maxInTrackHitIdDifference;
88
89
90 if (not distanceInTrackIsSufficientlyLow) return false;
91
92 // Now check the right left information in track
93 ERightLeft startRLInfo = rlWireHitTriple.getStartRLInfo();
94 ERightLeft middleRLInfo = rlWireHitTriple.getMiddleRLInfo();
95 ERightLeft endRLInfo = rlWireHitTriple.getEndRLInfo();
96
97 ERightLeft mcStartRLInfo = mcHitLookUp.getRLInfo(startWireHit.getHit());
98 ERightLeft mcMiddleRLInfo = mcHitLookUp.getRLInfo(middleWireHit.getHit());
99 ERightLeft mcEndRLInfo = mcHitLookUp.getRLInfo(endWireHit.getHit());
100
101 if (startRLInfo == mcStartRLInfo and middleRLInfo == mcMiddleRLInfo and endRLInfo == mcEndRLInfo) {
102 return true;
103 } else {
104 return false;
105 }
106}
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:61
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:53
Interface class to the Monte Carlo information for individual hits.
ITrackType getMCTrackId(const CDCHit *ptrHit) const
Returns the track id for the hit.
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.
ERightLeft getRLInfo(const CDCHit *ptrHit) const
Returns the true right left passage information.
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:55
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:159
Weight operator()(const CDCFacet &facet) final
Main filter method returning the weight of the facet.
MCFacetFilter(bool allowReverse=true)
Constructor also setting the switch, if the reversed version of a facet (in comparison to MC truth) s...
Mixin for filters that use Monte Carlo information.
bool getAllowReverse() const
Getter for the allow reverse parameter.
bool isInvalid() const
Check it the line is in an invalid state.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.