8#include <tracking/trackFindingCDC/filters/track/BasicTrackVarSet.h>
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
12#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
13#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
14#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
15#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
17#include <tracking/trackFindingCDC/numerics/ToFinite.h>
19#include <tracking/trackFindingCDC/utilities/Algorithms.h>
20#include <tracking/trackFindingCDC/utilities/Functional.h>
24#include <cdc/dataobjects/CDCHit.h>
27using namespace TrackFindingCDC;
31 if (not track)
return false;
47 unsigned int size = track->size();
49 std::vector<unsigned int> cont_layer;
50 std::vector<unsigned int> super_layer;
53 drift_length_acc(recoHit.getWireHit().getRefDriftLength());
54 adc_acc(
static_cast<unsigned int>(recoHit.getWireHit().getHit()->getADCCount()));
55 tot_acc(
static_cast<unsigned int>(recoHit.getWireHit().getHit()->getTOT()));
56 cont_layer_acc(
static_cast<unsigned int>(recoHit.getWireHit().getHit()->getICLayer()));
57 super_layer_acc(
static_cast<unsigned int>(recoHit.getWireHit().getISuperLayer()));
58 cont_layer.push_back(
static_cast<unsigned int>(recoHit.getWireHit().getHit()->getICLayer()));
59 super_layer.push_back(
static_cast<unsigned int>(recoHit.getWireHit().getISuperLayer()));
63 unsigned int cont_layer_first = cont_layer.front();
64 unsigned int cont_layer_last = cont_layer.back();
65 unsigned int cont_layer_min = *std::min_element(cont_layer.begin(), cont_layer.end());
66 unsigned int cont_layer_max = *std::max_element(cont_layer.begin(), cont_layer.end());
67 unsigned int cont_layer_count = std::set<unsigned int>(cont_layer.begin(), cont_layer.end()).size();
68 double cont_layer_occupancy = (double)cont_layer_count / (
double)(cont_layer_max - cont_layer_min +
70 unsigned int super_layer_first = super_layer.front();
71 unsigned int super_layer_last = super_layer.back();
72 unsigned int super_layer_min = *std::min_element(super_layer.begin(), super_layer.end());
73 unsigned int super_layer_max = *std::max_element(super_layer.begin(), super_layer.end());
74 unsigned int super_layer_count = std::set<unsigned int>(super_layer.begin(), super_layer.end()).size();
75 double super_layer_occupancy = (double)super_layer_count / (
double)(super_layer_max - super_layer_min + 1);
77 double hits_per_layer = (double)size / (
double)cont_layer_count;
80 double s_range = track->back().getArcLength2D() - track->front().getArcLength2D();
81 double avg_hit_dist = s_range / (double)cont_layer_count;
84 std::vector<double> arc_lengths;
85 auto get_arc_length = [](
const CDCRecoHit3D & recoHit) {
return recoHit.getArcLength2D(); };
86 std::transform(begin(*track), end(*track), back_inserter(arc_lengths), get_arc_length);
88 erase_remove_if(arc_lengths,
IsNaN());
92 if (arc_lengths.size() > 1) {
93 std::vector<double> empty_s_gaps;
94 std::adjacent_difference(begin(arc_lengths), end(arc_lengths), back_inserter(empty_s_gaps));
98 auto empty_s_acc_ref = [&empty_s_acc](
double s) { empty_s_acc(s); };
100 std::for_each(next(begin(empty_s_gaps)), end(empty_s_gaps), empty_s_acc_ref);
103 unsigned int empty_s_size = bacc::count(empty_s_acc);
107 double drift_length_variance = -1;
108 double adc_variance = -1;
109 double tot_variance = -1;
110 double cont_layer_variance = -1;
111 double super_layer_variance = -1;
114 double bessel_corr = (double)size / (size - 1.0);
115 drift_length_variance = std::sqrt(bacc::variance(drift_length_acc) * bessel_corr);
116 adc_variance = std::sqrt(bacc::variance(adc_acc) * bessel_corr);
117 tot_variance = std::sqrt(bacc::variance(tot_acc) * bessel_corr);
118 cont_layer_variance = std::sqrt(bacc::variance(cont_layer_acc) * bessel_corr);
119 super_layer_variance = std::sqrt(bacc::variance(super_layer_acc) * bessel_corr);
121 double empty_s_variance = -1;
122 if (empty_s_size > 1) {
123 double empty_s_bessel_corr = (double)empty_s_size / (empty_s_size - 1.0);
124 empty_s_variance = std::sqrt(bacc::variance(empty_s_acc) * empty_s_bessel_corr);
133 var<
named(
"hits_per_layer")>() = hits_per_layer;
137 var<
named(
"s_range")>() = toFinite(s_range, 0);
138 var<
named(
"avg_hit_dist")>() = toFinite(avg_hit_dist, 0);
139 var<
named(
"has_matching_segment")>() = track->getHasMatchingSegment();
141 var<
named(
"cont_layer_mean")>() = toFinite(bacc::mean(cont_layer_acc), 0);
142 var<
named(
"cont_layer_variance")>() = toFinite(cont_layer_variance, 0);
143 var<
named(
"cont_layer_max")>() = toFinite(cont_layer_max, 0);
144 var<
named(
"cont_layer_min")>() = toFinite(cont_layer_min, 0);
145 var<
named(
"cont_layer_first")>() = toFinite(cont_layer_first, 0);
146 var<
named(
"cont_layer_last")>() = toFinite(cont_layer_last, 0);
147 var<
named(
"cont_layer_max_vs_last")>() = toFinite(cont_layer_max - cont_layer_last, 0);
148 var<
named(
"cont_layer_first_vs_min")>() = toFinite(cont_layer_first - cont_layer_min, 0);
149 var<
named(
"cont_layer_count")>() = toFinite(cont_layer_count, 0);
150 var<
named(
"cont_layer_occupancy")>() = toFinite(cont_layer_occupancy, 0);
152 var<
named(
"super_layer_mean")>() = toFinite(bacc::mean(super_layer_acc), 0);
153 var<
named(
"super_layer_variance")>() = toFinite(super_layer_variance, 0);
154 var<
named(
"super_layer_max")>() = toFinite(super_layer_max, 0);
155 var<
named(
"super_layer_min")>() = toFinite(super_layer_min, 0);
156 var<
named(
"super_layer_first")>() = toFinite(super_layer_first, 0);
157 var<
named(
"super_layer_last")>() = toFinite(super_layer_last, 0);
158 var<
named(
"super_layer_max_vs_last")>() = toFinite(super_layer_max - super_layer_last, 0);
159 var<
named(
"super_layer_first_vs_min")>() = toFinite(super_layer_first - super_layer_min, 0);
160 var<
named(
"super_layer_count")>() = toFinite(super_layer_count, 0);
161 var<
named(
"super_layer_occupancy")>() = toFinite(super_layer_occupancy, 0);
163 var<
named(
"drift_length_mean")>() = toFinite(bacc::mean(drift_length_acc), 0);
164 var<
named(
"drift_length_variance")>() = toFinite(drift_length_variance, 0);
165 var<
named(
"drift_length_max")>() = toFinite(bacc::max(drift_length_acc), 0);
166 var<
named(
"drift_length_min")>() = toFinite(bacc::min(drift_length_acc), 0);
167 var<
named(
"drift_length_sum")>() = toFinite(bacc::sum(drift_length_acc), 0);
169 var<
named(
"adc_mean")>() = toFinite(bacc::mean(adc_acc), 0);
170 var<
named(
"adc_variance")>() = toFinite(adc_variance, 0);
171 var<
named(
"adc_max")>() = toFinite(bacc::max(adc_acc), 0);
172 var<
named(
"adc_min")>() = toFinite(bacc::min(adc_acc), 0);
173 var<
named(
"adc_sum")>() = toFinite(bacc::sum(adc_acc), 0);
175 var<
named(
"tot_mean")>() = toFinite(bacc::mean(tot_acc), 0);
176 var<
named(
"tot_variance")>() = toFinite(tot_variance, 0);
177 var<
named(
"tot_max")>() = toFinite(bacc::max(tot_acc), 0);
178 var<
named(
"tot_min")>() = toFinite(bacc::min(tot_acc), 0);
179 var<
named(
"tot_sum")>() = toFinite(bacc::sum(tot_acc), 0);
181 var<
named(
"empty_s_mean")>() = toFinite(bacc::mean(empty_s_acc), 0);
182 var<
named(
"empty_s_sum")>() = toFinite(bacc::sum(empty_s_acc), 0);
183 var<
named(
"empty_s_variance")>() = toFinite(empty_s_variance, 0);
184 var<
named(
"empty_s_max")>() = toFinite(bacc::max(empty_s_acc), 0);
185 var<
named(
"empty_s_min")>() = toFinite(bacc::min(empty_s_acc), 0);
bool extract(const CDCTrack *track) override
Generate and assign the contained variables.
bacc::accumulator_set< double, statistics_set > statistics_accumulator
A boost accumulators set that aggregates statistics for the values it is called with.
Class representing a three dimensional reconstructed hit.
Class representing a sequence of three dimensional reconstructed hits.
Particle trajectory as it is seen in xy projection represented as a circle.
double getAbsMom2D(double bZ) const
Get the estimation for the absolute value of the transvers momentum.
Particle full three dimensional trajectory.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
Linear trajectory in sz space.
double getTanLambda() const
Getter for the slope over the travel distance coordinate.
double getZ0() const
Getter for the z coordinate at zero travel distance.
static constexpr int named(const char *name)
Getter for the index from the name.
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Abstract base class for different kinds of events.
Unary functor for equality comparison to NAN.