Project
Loading...
Searching...
No Matches
ClusterAccumulator.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "ClusterAccumulator.h"
16#include "CfUtils.h"
17#include "GPUParam.h"
18#include "GPUTPCGeometry.h"
20
21using namespace o2::gpu;
22using namespace o2::gpu::tpccf;
23
24GPUd() void ClusterAccumulator::update(Charge splitCharge, Delta2 d)
25{
26 mQtot += splitCharge;
27 mPadMean += splitCharge * d.x;
28 mTimeMean += splitCharge * d.y;
29 mPadSigma += splitCharge * d.x * d.x;
30 mTimeSigma += splitCharge * d.y * d.y;
31}
32
34{
35 Charge q = charge.unpack();
36
37 update(q, d);
38
39 bool split = charge.isSplit();
40 mSplitInTime += (d.y != 0 && split);
41 mSplitInPad += (d.x != 0 && split);
42
43 return q;
44}
45
47{
48 Charge q = charge.unpack();
49
50 bool split = charge.isSplit();
51 bool has3x3 = charge.has3x3Peak();
52
53 update((has3x3) ? 0.f : q, d);
54
55 mSplitInTime += (d.y != 0 && split && !has3x3);
56 mSplitInPad += (d.x != 0 && split && !has3x3);
57
58 return q;
59}
60
61GPUd() void ClusterAccumulator::finalize(const CfChargePos& pos, const Charge q, TPCTime timeOffset)
62{
63 mQtot += q;
64
65 mPadMean /= mQtot;
66 mTimeMean /= mQtot;
67 mPadSigma /= mQtot;
68 mTimeSigma /= mQtot;
69
70 mPadSigma = CAMath::Sqrt(mPadSigma - mPadMean * mPadMean);
71 mTimeSigma = CAMath::Sqrt(mTimeSigma - mTimeMean * mTimeMean);
72
73 Pad pad = pos.pad();
74 mPadMean += pad;
75 mTimeMean += timeOffset + pos.time();
76}
77
78GPUd() bool ClusterAccumulator::toNative(const CfChargePos& pos, const Charge q, tpc::ClusterNative& cn, const GPUParam& param, const CfArray2D<PackedCharge>& chargeMap)
79{
80 Pad pad = pos.pad();
81
82 bool isEdgeCluster;
83 if (param.rec.tpc.cfEdgeTwoPads) {
84 isEdgeCluster = pad < 2 || pad >= GPUTPCGeometry::NPads(pos.row()) - 2; // Geometrical edge check, peak within 2 pads of sector edge
85 if (isEdgeCluster) {
86 bool leftEdge = (pad < 2);
87 if (leftEdge ? (pad == 1 && chargeMap[pos.delta({-1, 0})].unpack() < 1) : (pad == (GPUTPCGeometry::NPads(pos.row()) - 2) && chargeMap[pos.delta({1, 0})].unpack() < 1)) {
88 isEdgeCluster = false; // No edge cluster if peak is close to edge but no charge at the edge.
89 } else if (leftEdge ? (pad < mPadMean) : (pad > mPadMean)) {
90 mPadMean = pad; // Correct to peak position if COG is close to middle of pad than peak
91 }
92 }
93 } else {
94 isEdgeCluster = pad == 0 || pad == GPUTPCGeometry::NPads(pos.row()) - 1;
95 }
96
97 cn.qTotPacked = CAMath::Float2UIntRn(mQtot);
98 if (cn.qTotPacked <= param.rec.tpc.cfQTotCutoff) {
99 return false;
100 }
101 cn.qMax = q; // cfQMaxCutoff check already done at PeakFinder level
102 if (mTimeMean < param.rec.tpc.clustersShiftTimebinsClusterizer) {
103 return false;
104 }
105 if (q <= param.rec.tpc.cfQMaxCutoffSingleTime && mTimeSigma == 0) {
106 return false;
107 }
108 if (q <= param.rec.tpc.cfQMaxCutoffSinglePad && mPadSigma == 0) {
109 return false;
110 }
111
112 bool wasSplitInTime = mSplitInTime >= param.rec.tpc.cfMinSplitNum;
113 bool wasSplitInPad = mSplitInPad >= param.rec.tpc.cfMinSplitNum;
114 bool isSingleCluster = (mPadSigma == 0) || (mTimeSigma == 0);
115
116 uint8_t flags = 0;
117 flags |= (isEdgeCluster) ? tpc::ClusterNative::flagEdge : 0;
118 flags |= (wasSplitInTime) ? tpc::ClusterNative::flagSplitTime : 0;
119 flags |= (wasSplitInPad) ? tpc::ClusterNative::flagSplitPad : 0;
120 flags |= (isSingleCluster) ? tpc::ClusterNative::flagSingle : 0;
121
122 cn.setTimeFlags(mTimeMean - param.rec.tpc.clustersShiftTimebinsClusterizer, flags);
123 cn.setPad(mPadMean);
124 cn.setSigmaTime(mTimeSigma);
125 cn.setSigmaPad(mPadSigma);
126
127 return true;
128}
GPUd() void ClusterAccumulator
Class of a TPC cluster in TPC-native coordinates (row, time)
int16_t charge
Definition RawEventData.h:5
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
uint16_t pos
Definition RawData.h:3
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLfloat param
Definition glcorearb.h:271
T unpack(BitPtr pos, size_t packingWidth)
Definition pack.h:101
std::vector< std::string > split(const std::string &str, char delimiter=',')