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