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/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11
12#include <tracking/trackFindingCDC/topology/CDCWire.h>
13
14#include <tracking/trackFindingCDC/utilities/Functional.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18
19namespace {
20 std::array<int, 8> getNHitsByILayer(const CDCSegment2D& segment)
21 {
22 std::array<int, 8> result{};
23 for (const CDCRecoHit2D& recoHit2D : segment) {
24 ++result[recoHit2D.getWire().getILayer()];
25 }
26 return result;
27 }
28}
29
31{
32 if (not ptrSegmentRelation) return false;
33
34 const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
35
36 const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
37 const CDCSegment2D* ptrToSegment = segmentPair.getTo();
38
39 const CDCSegment2D& fromSegment = *ptrFromSegment;
40 const CDCSegment2D& toSegment = *ptrToSegment;
41
42 var<named("stereo_kind")>() = static_cast<float>(fromSegment.getStereoKind());
43 var<named("sl_id")>() = fromSegment.getISuperLayer();
44
45 var<named("from_size")>() = fromSegment.size();
46 var<named("to_size")>() = toSegment.size();
47
48 std::array<int, 8> fromNHitsByILayer = getNHitsByILayer(fromSegment);
49 std::array<int, 8> toNHitsByILayer = getNHitsByILayer(toSegment);
50
51 var<named("from_n_layers")>() = std::count_if(fromNHitsByILayer.begin(), fromNHitsByILayer.end(), Id() > 0);;
52 var<named("to_n_layers")>() = std::count_if(toNHitsByILayer.begin(), toNHitsByILayer.end(), Id() > 0);
53
54 return true;
55}
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) override
Generate and assign the contained variables.
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
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
static constexpr 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