1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include <algorithm>
#include <cmath>
SiStripApproximateCluster::SiStripApproximateCluster(const SiStripCluster& cluster,
unsigned int maxNSat,
float hitPredPos,
bool peakFilter) {
barycenter_ = std::round(cluster.barycenter() * 10);
width_ = cluster.size();
avgCharge_ = cluster.charge() / cluster.size();
filter_ = false;
isSaturated_ = false;
peakFilter_ = peakFilter;
//mimicing the algorithm used in StripSubClusterShapeTrajectoryFilter...
//Looks for 3 adjacent saturated strips (ADC>=254)
const auto& ampls = cluster.amplitudes();
unsigned int thisSat = (ampls[0] >= 254), maxSat = thisSat;
for (unsigned int i = 1, n = ampls.size(); i < n; ++i) {
if (ampls[i] >= 254) {
thisSat++;
} else if (thisSat > 0) {
maxSat = std::max<int>(maxSat, thisSat);
thisSat = 0;
}
}
if (thisSat > 0) {
maxSat = std::max<int>(maxSat, thisSat);
}
if (maxSat >= maxNSat) {
filter_ = true;
isSaturated_ = true;
}
unsigned int hitStripsTrim = ampls.size();
int sum = std::accumulate(ampls.begin(), ampls.end(), 0);
uint8_t trimCut = std::min<uint8_t>(trimMaxADC_, std::floor(trimMaxFracTotal_ * sum));
auto begin = ampls.begin();
auto last = ampls.end() - 1;
while (hitStripsTrim > 1 && (*begin < std::max<uint8_t>(trimCut, trimMaxFracNeigh_ * (*(begin + 1))))) {
hitStripsTrim--;
++begin;
}
while (hitStripsTrim > 1 && (*last < std::max<uint8_t>(trimCut, trimMaxFracNeigh_ * (*(last - 1))))) {
hitStripsTrim--;
--last;
}
if (hitStripsTrim < std::floor(std::abs(hitPredPos) - maxTrimmedSizeDiffNeg_)) {
filter_ = false;
} else if (hitStripsTrim <= std::ceil(std::abs(hitPredPos) + maxTrimmedSizeDiffPos_)) {
filter_ = true;
} else {
filter_ = peakFilter_;
}
}
|