Belle II Software  release-05-02-19
BasicSegmentRelationVarSet.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/segmentRelation/BasicSegmentRelationVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13 
14 #include <tracking/trackFindingCDC/topology/CDCWire.h>
15 
16 #include <tracking/trackFindingCDC/utilities/Functional.h>
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
21 namespace {
22  std::array<int, 8> getNHitsByILayer(const CDCSegment2D& segment)
23  {
24  std::array<int, 8> result{};
25  for (const CDCRecoHit2D& recoHit2D : segment) {
26  ++result[recoHit2D.getWire().getILayer()];
27  }
28  return result;
29  }
30 }
31 
33 {
34  if (not ptrSegmentRelation) return false;
35 
36  const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
37 
38  const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
39  const CDCSegment2D* ptrToSegment = segmentPair.getTo();
40 
41  const CDCSegment2D& fromSegment = *ptrFromSegment;
42  const CDCSegment2D& toSegment = *ptrToSegment;
43 
44  var<named("stereo_kind")>() = static_cast<float>(fromSegment.getStereoKind());
45  var<named("sl_id")>() = fromSegment.getISuperLayer();
46 
47  var<named("from_size")>() = fromSegment.size();
48  var<named("to_size")>() = toSegment.size();
49 
50  std::array<int, 8> fromNHitsByILayer = getNHitsByILayer(fromSegment);
51  std::array<int, 8> toNHitsByILayer = getNHitsByILayer(toSegment);
52 
53  var<named("from_n_layers")>() = std::count_if(fromNHitsByILayer.begin(), fromNHitsByILayer.end(), Id() > 0);;
54  var<named("to_n_layers")>() = std::count_if(toNHitsByILayer.begin(), toNHitsByILayer.end(), Id() > 0);
55 
56  return true;
57 }
Belle2::TrackFindingCDC::Relation::getFrom
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:69
Belle2::TrackFindingCDC::Relation
Type for two related objects.
Definition: CDCSegment2D.h:37
Belle2::TrackFindingCDC::Id
Generic identity functor.
Definition: Functional.h:35
Belle2::TrackFindingCDC::CDCSegment::getStereoKind
EStereoKind getStereoKind() const
Returns the common stereo type of all hits.
Definition: CDCSegment.h:49
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< BasicSegmentRelationVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Relation::getTo
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:75
Belle2::TrackFindingCDC::VarSet< BasicSegmentRelationVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::BasicSegmentRelationVarSet::extract
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) override
Generate and assign the contained variables.
Definition: BasicSegmentRelationVarSet.cc:32