Belle II Software  release-05-01-25
SpacePointTagger.icc.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/ckf/general/findlets/SpacePointTagger.dcl.h>
13 
14 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
15 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
16 
17 #include <tracking/spacePointCreation/SpacePoint.h>
18 
19 #include <framework/core/ModuleParamList.templateDetails.h>
20 
21 namespace Belle2 {
26  template <class AResult, class ACluster>
29  {
30  Super::beginEvent();
31 
32  m_usedClusters.clear();
33  m_usedSpacePoints.clear();
34  }
35 
37  template <class AResult, class ACluster>
38  void SpacePointTagger<AResult, ACluster>::exposeParameters(ModuleParamList* moduleParamList,
39  const std::string& prefix)
40  {
41  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "singleClusterLevel"),
42  m_param_singleClusterLevel,
43  "Mark SP as used, if the share a single cluster with the results, or if they "
44  "share a whole SP.",
45  m_param_singleClusterLevel);
46  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "markUsedSpacePoints"),
47  m_param_markUsedSpacePoints,
48  "Mark used space points as assigned.",
49  m_param_markUsedSpacePoints);
50  }
51 
53  template <class AResult, class ACluster>
54  void SpacePointTagger<AResult, ACluster>::apply(const std::vector<AResult>& results,
55  const std::vector<const SpacePoint*>& spacePoints)
56  {
57  if (not m_param_markUsedSpacePoints) {
58  return;
59  }
60 
61  for (const AResult& result : results) {
62  const std::vector<const SpacePoint*>& hits = result.getHits();
63  for (const SpacePoint* spacePoint : hits) {
64  m_usedSpacePoints.insert(spacePoint);
65 
66  if (not m_param_singleClusterLevel) {
67  continue;
68  }
69 
70  const auto& relatedClusters = spacePoint->getRelationsTo<ACluster>();
71  for (const ACluster& relatedCluster : relatedClusters) {
72  m_usedClusters.insert(&relatedCluster);
73  }
74  }
75  }
76 
77  for (const SpacePoint* spacePoint : spacePoints) {
78  if (TrackFindingCDC::is_in(spacePoint, m_usedSpacePoints)) {
79  spacePoint->setAssignmentState(true);
80  continue;
81  }
82 
83  if (not m_param_singleClusterLevel) {
84  continue;
85  }
86 
87  const auto& relatedClusters = spacePoint->getRelationsTo<ACluster>();
88  for (const ACluster& relatedCluster : relatedClusters) {
89  if (TrackFindingCDC::is_in(&relatedCluster, m_usedClusters)) {
90  spacePoint->setAssignmentState(true);
91  break;
92  }
93  }
94  }
95  }
97 }
Belle2::SpacePointTagger::apply
void apply(const std::vector< AResult > &results, const std::vector< const SpacePoint * > &spacePoints) override
Mark all space points as used, that they share clusters if the given kind with the results.
Definition: SpacePointTagger.icc.h:62
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SpacePointTagger::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the findlet.
Definition: SpacePointTagger.icc.h:46
Belle2::SpacePointTagger::beginEvent
void beginEvent() override
Clear the used clusters.
Definition: SpacePointTagger.icc.h:36