Belle II Software development
BasicSegmentRelationVarSet.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/segmentRelation/BasicSegmentRelationVarSet.h>
9
10#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
11
12#include <cdc/topology/CDCWire.h>
13
14#include <tracking/trackingUtilities/utilities/Functional.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18using namespace TrackingUtilities;
19
20namespace {
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.getWire().getILayer()];
26 }
27 return result;
28 }
29}
30
32{
33 if (not ptrSegmentRelation) return false;
34
35 const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
36
37 const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
38 const CDCSegment2D* ptrToSegment = segmentPair.getTo();
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 TrackingUtilities::Relation< const TrackingUtilities::CDCSegment2D > *ptrSegmentRelation) override
Generate and assign the contained variables.
Class representing a two dimensional reconstructed hit in the central drift chamber.
A reconstructed sequence of two dimensional hits in one super layer.
CDC::ISuperLayer getISuperLayer() const
Returns the common super layer id of all stored tracking hits.
Definition CDCSegment.h:57
CDC::EStereoKind getStereoKind() const
Returns the common stereo type of all hits.
Definition CDCSegment.h:39
Type for two related objects.
Definition Relation.h:21
From * getFrom() const
Getter for the pointer to the from side object.
Definition Relation.h:59
To * getTo() const
Getter for the pointer to the to side object.
Definition Relation.h:65
Abstract base class for different kinds of events.
Generic identity functor.
Definition Functional.h:25