Belle II Software development
BasicClusterVarSet.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/cluster/BasicClusterVarSet.h>
9
10#include <tracking/trackFindingCDC/eventdata/segments/CDCWireHitCluster.h>
11#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
12
13#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
14#include <tracking/trackFindingCDC/topology/ISuperLayer.h>
15
16#include <cdc/dataobjects/CDCHit.h>
17
18#include <cassert>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22
24{
25 if (not ptrCluster) return false;
26 const CDCWireHitCluster& cluster = *ptrCluster;
27
28 const CDCWireTopology& wireTopology = CDCWireTopology::getInstance();
29 ISuperLayer iSuperLayer = ISuperLayerUtil::getFrom(cluster.front());
30 if (not ISuperLayerUtil::isInCDC(iSuperLayer)) {
31 return false;
32 }
33 const CDCWireSuperLayer& superLayer = wireTopology.getWireSuperLayer(iSuperLayer);
34 double superLayerCenter = superLayer.getMiddleCylindricalR();
35 unsigned int size = cluster.size();
36
37 int totalNNeighbors = 0;
38 double totalInnerDistance = 0;
39 double totalDriftLength = 0;
40 double totalDriftLengthSquared = 0;
41 double driftVariance = 0;
42 double totalADCCount = 0;
43 double totalADCCountSquared = 0;
44 double adcCountVariance;
45
46 for (const CDCWireHit* wireHit : cluster) {
47 assert(wireHit);
48 // Clusterizer writes the number of neighbors into the cell weight
49 int nNeighbors = wireHit->getAutomatonCell().getCellWeight();
50 totalNNeighbors += nNeighbors;
51
52 // hit position information
53 totalInnerDistance += wireHit->getRefPos2D().norm();
54
55 // Drift circle information
56 double driftLength = wireHit->getRefDriftLength();
57 totalDriftLength += driftLength;
58 totalDriftLengthSquared += driftLength * driftLength;
59
60 // ADC information
61 double adc = static_cast<double>(wireHit->getHit()->getADCCount());
62 totalADCCount += adc;
63 totalADCCountSquared += adc * adc;
64 }
65 if (size > 1) {
66 double driftLengthVarianceSquared =
67 (totalDriftLengthSquared - totalDriftLength * totalDriftLength / size) / (size - 1.0);
68 double adcVarianceSquared =
69 (totalADCCountSquared - totalADCCount * totalADCCount / size) / (size - 1.0);
70
71 if (driftLengthVarianceSquared > 0) {
72 driftVariance = std::sqrt(driftLengthVarianceSquared);
73 } else {
74 driftVariance = 0;
75 }
76
77 if (adcVarianceSquared > 0) {
78 adcCountVariance = std::sqrt(adcVarianceSquared);
79 } else {
80 adcCountVariance = 0;
81 }
82
83 } else {
84 driftVariance = -1;
85 adcCountVariance = -1;
86 }
87
88 var<named("is_stereo")>() = not ISuperLayerUtil::isAxial(iSuperLayer);
89 var<named("size")>() = size;
90
91 var<named("total_number_of_neighbors")>() = totalNNeighbors;
92 var<named("total_drift_length")>() = totalDriftLength;
93 var<named("total_adc_count")>() = totalADCCount;
94 var<named("total_inner_distance")>() = totalInnerDistance;
95
96 var<named("variance_drift_length")>() = driftVariance;
97 var<named("variance_adc_count")>() = adcCountVariance;
98
99 var<named("distance_to_superlayer_center")>() = superLayerCenter - totalInnerDistance / size;
100 var<named("superlayer_id")>() = iSuperLayer;
101
102 var<named("mean_drift_length")>() = totalDriftLength / size;
103 var<named("mean_adc_count")>() = totalADCCount / size;
104 var<named("mean_inner_distance")>() = totalInnerDistance / size;
105 var<named("mean_number_of_neighbors")>() = 1.0 * totalNNeighbors / size;
106 return true;
107}
bool extract(const CDCWireHitCluster *ptrCluster) final
Generate and assign the contained variables.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:55
Class representing a sense wire superlayer in the central drift chamber.
double getMiddleCylindricalR() const
Getter for the radius in the middle of the layer.
Class representing the sense wire arrangement in the whole of the central drift chamber.
const CDCWireSuperLayer & getWireSuperLayer(const WireID &wireID) const
Getter for wire superlayer getter by wireID object.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
static constexpr int named(const char *name)
Definition VarSet.h:78
Abstract base class for different kinds of events.
static bool isAxial(ISuperLayer iSuperLayer)
Returns if the super layer with the given id is axial.
static bool isInCDC(ISuperLayer iSuperLayer)
Indicates if the given number corresponds to a true cdc superlayer - excludes the logic ids for inner...
static ISuperLayer getFrom(const T &t)
Returns the superlayer of an object.