Belle II Software  release-08-01-10
BasicAxialSegmentPairVarSet.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/axialSegmentPair/BasicAxialSegmentPairVarSet.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
11 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
12 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
13 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14 
15 #include <tracking/trackFindingCDC/utilities/Functional.h>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 namespace {
21  std::array<int, 8> getNHitsByILayer(const CDCSegment2D& segment)
22  {
23  std::array<int, 8> result{};
24  for (const CDCRecoHit2D& recoHit2D : segment) {
25  ++result[recoHit2D.getWireHit().getILayer()];
26  }
27  return result;
28  }
29 }
30 
32 {
33  if (not ptrAxialSegmentPair) return false;
34 
35  const CDCAxialSegmentPair& axialSegmentPair = *ptrAxialSegmentPair;
36 
37  const CDCSegment2D* ptrFromSegment = axialSegmentPair.getStartSegment();
38  const CDCSegment2D* ptrToSegment = axialSegmentPair.getEndSegment();
39 
40  const CDCSegment2D& fromSegment = *ptrFromSegment;
41  const CDCSegment2D& toSegment = *ptrToSegment;
42 
43  var<named("stereo_kind")>() = static_cast<float>(fromSegment.getStereoKind());
44  var<named("sl_id")>() = fromSegment.getISuperLayer();
45 
46  var<named("from_size")>() = fromSegment.size();
47  var<named("to_size")>() = toSegment.size();
48 
49  std::array<int, 8> fromNHitsByILayer = getNHitsByILayer(fromSegment);
50  std::array<int, 8> toNHitsByILayer = getNHitsByILayer(toSegment);
51 
52  var<named("from_n_layers")>() = std::count_if(fromNHitsByILayer.begin(), fromNHitsByILayer.end(), Id() > 0);;
53  var<named("to_n_layers")>() = std::count_if(toNHitsByILayer.begin(), toNHitsByILayer.end(), Id() > 0);
54 
55  return true;
56 }
bool extract(const CDCAxialSegmentPair *ptrAxialSegmentPair) override
Generate and assign the contained variables.
Class representing a pair of reconstructed axial segements in adjacent superlayer.
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
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
ISuperLayer getISuperLayer() const
Returns the common super layer id of all stored tracking hits.
Definition: CDCSegment.h:57
EStereoKind getStereoKind() const
Returns the common stereo type of all hits.
Definition: CDCSegment.h:39
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:93
Abstract base class for different kinds of events.
Generic identity functor.
Definition: Functional.h:25