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