Belle II Software  release-08-01-10
TrackCreatorSingleSegments.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/findlets/minimal/TrackCreatorSingleSegments.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
11 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
12 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
13 
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 
16 #include <framework/core/ModuleParamList.templateDetails.h>
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
22 {
23  m_param_minimalHitsBySuperLayerId = std::map<ISuperLayer, size_t> ({{0, 15}});
24 }
25 
27 {
28  return "Creates a track for each segments that is yet unused by any of the given tracks.";
29 }
30 
31 void TrackCreatorSingleSegments::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
32 {
33  moduleParamList->addParameter(prefixed(prefix, "MinimalHitsBySuperLayerId"),
35  "Map of super layer ids to minimum hit number, "
36  "for which left over segments shall be forwarded as tracks, "
37  "if the exceed the minimal hit requirement. Default empty.",
39 }
40 
41 void TrackCreatorSingleSegments::apply(const std::vector<CDCSegment2D>& segments,
42  std::vector<CDCTrack>& tracks)
43 {
44  // Create tracks from left over segments
45  // First figure out which segments do not share any hits with any of the given tracks
46  // (if the tracks vector is empty this is the case for all segments)
47  const bool toHits = true;
48  for (const CDCSegment2D& segment : segments) {
49  segment.unsetAndForwardMaskedFlag(toHits);
50  }
51 
52  for (const CDCTrack& track : tracks) {
53  track.setAndForwardMaskedFlag();
54  }
55 
56  for (const CDCSegment2D& segment : segments) {
57  segment.receiveMaskedFlag(toHits);
58  }
59 
60  if (not m_param_minimalHitsBySuperLayerId.empty()) {
61  for (const CDCSegment2D& segment : segments) {
62  if (segment->hasMaskedFlag()) {
63  int nMasked = 0;
64  for (const CDCRecoHit2D& recoHit2D : segment) {
65  if (recoHit2D.getWireHit()->hasMaskedFlag()) ++nMasked;
66  }
67  // code above could be replaced by the following line, but needs to be tested
68  //nMasked = std::count_if( segment.begin(), segment.end(), [](const CDCRecoHit2D& recoHit2D)->bool{ return recoHit2D.getWireHit()->hasMaskedFlag(); });
69 
70  // Relaxed requirement of only 20% of hits masked by other tracks
71  if (nMasked > segment.size() * 0.2) continue;
72  }
73  ISuperLayer iSuperLayer = segment.getISuperLayer();
74  if (m_param_minimalHitsBySuperLayerId.count(iSuperLayer) and
75  segment.size() >= m_param_minimalHitsBySuperLayerId[iSuperLayer]) {
76 
77  if (segment.getTrajectory2D().isFitted()) {
78  tracks.push_back(CDCTrack(segment));
79  segment.setAndForwardMaskedFlag(toHits);
80  for (const CDCSegment2D& otherSegment : segments) {
81  otherSegment.receiveMaskedFlag(toHits);
82  }
83  }
84  }
85  }
86  }
87 }
The Module parameter list class.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
TrackCreatorSingleSegments()
Constructor setting up default parameters.
void apply(const std::vector< CDCSegment2D > &segments, std::vector< CDCTrack > &tracks) final
Main algorithm.
std::string getDescription() final
Short description of the findlet.
std::map< ISuperLayer, size_t > m_param_minimalHitsBySuperLayerId
Parameter: Map of super layer ids to minimum hit number for which left over segments shall be forward...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.