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