16#include "frontend/GPUDisplayInfo.inc"
25const std::array<std::string, 7> GPUDisplay::ANIMATION_MODE_NAMES_SHORT = {
"Cartesian, quaternion",
"Cartesian, Euler angles",
"Spherical Rotation, quaternion",
"Spherical Rotation, Euler angles",
"Spherical, quaternion",
"Spherical, Euler angles",
"Spherical, centered on origin"};
26const std::array<std::string, 7> GPUDisplay::ANIMATION_MODE_NAMES_LONG = {
"Position: Cartesian, Direction: Quaternion",
"Position: Cartesian, Direction: Euler angles",
"Position: Spherical (spherical rotation), Direction: Quaternion",
"Position: Spherical (spherical rotation), Direction: Euler angles",
"Position: Spherical (Euler angles), Direction: Quaternion",
"Position: Spherical (Euler angles), Direction: Euler angles",
"Position: Spherical (Euler angles), Direction: Centered on origin"};
28constexpr hmm_mat4 MY_HMM_FROM(
float (&
v)[16]) {
return {{{
v[0],
v[1],
v[2],
v[3]}, {
v[4],
v[5],
v[6],
v[7]}, {
v[8],
v[9],
v[10],
v[11]}, {
v[12],
v[13],
v[14],
v[15]}}}; }
30static hmm_mat4 cameraViewMatrix(
const float (&xyz)[3],
const float (&angles)[3])
32 const float toDeg = 180.f / CAMath::Pi();
33 return HMM_Rotate(-angles[2] * toDeg, {{0, 0, 1}}) *
HMM_Rotate(-angles[0] * toDeg, {{1, 0, 0}}) *
HMM_Rotate(angles[1] * toDeg, {{0, 1, 0}}) *
HMM_Translate({{-xyz[0], -xyz[1], -xyz[2]}});
36void GPUDisplay::setAnimationPoint()
40 times.emplace_back(
times.size() ?
times.back() + ((int32_t)(
mCfgO.animationDelay * 20)) / 20.f : 0.f);
41 mAnimationVectors.push_back({{mXYZ[0], mXYZ[1], mXYZ[2], mAngle[0], mAngle[1], mAngle[2]}, mCfgL});
42 mCfgC.animationPoints.selected = -1;
45void GPUDisplay::animationPointValues(
const animationVector& p, int32_t
mode,
const float* last,
float (&vals)[8])
47 const float xyz[3] = {
p.v[0],
p.v[1],
p.v[2]}, angles[3] = {
p.v[3],
p.v[4],
p.v[5]};
50 float rxy = sqrtf(xyz[0] * xyz[0] + xyz[2] * xyz[2]);
51 float anglePhi = atan2f(xyz[0], xyz[2]);
52 float angleTheta = atan2f(xyz[1], rxy);
54 mAnimationCloseAngle(anglePhi, last[1]);
55 mAnimationCloseAngle(angleTheta, last[2]);
61 for (int32_t
i = 0;
i < 3;
i++) {
66 vals[3] = sqrtf(xyz[0] * xyz[0] + xyz[1] * xyz[1] + xyz[2] * xyz[2]);
69 for (int32_t
i = 0;
i < 3;
i++) {
70 float newangle = angles[
i];
72 mAnimationCloseAngle(newangle, last[
i + 4]);
74 vals[
i + 4] = newangle;
79 const hmm_mat4 viewMatrix = cameraViewMatrix(xyz, angles);
80 createQuaternionFromMatrix(
v, &viewMatrix.
Elements[0][0]);
82 mAnimateCloseQuaternion(
v, last[4], last[5], last[6], last[7]);
84 for (int32_t
i = 0;
i < 4;
i++) {
90static hmm_mat4 lookAtMatrix(
const float (&eye)[3],
const float (&
target)[3])
93 const bool alongY =
d[0] *
d[0] +
d[2] *
d[2] <= 1e-10f * (
d[0] *
d[0] +
d[1] *
d[1] +
d[2] *
d[2]);
94 return HMM_LookAt({{eye[0], eye[1], eye[2]}}, {{
target[0],
target[1],
target[2]}}, alongY ?
hmm_vec3{{0, 0, 1}} :
hmm_vec3{{0, 1, 0}});
97void GPUDisplay::setCamera(
const float (&xyz)[3],
const float (&angles)[3])
99 *mViewMatrix = cameraViewMatrix(xyz, angles);
100 calcXYZ(&mViewMatrix->Elements[0][0]);
103bool GPUDisplay::lookAt(
const float (&
target)[3])
108 *mViewMatrix = lookAtMatrix(mXYZ,
target);
109 calcXYZ(&mViewMatrix->Elements[0][0]);
113void GPUDisplay::rotateCamera(
const float (&angles)[3])
115 *mViewMatrix = cameraRotation(angles) * *mViewMatrix;
116 calcXYZ(&mViewMatrix->Elements[0][0]);
119hmm_mat4 GPUDisplay::cameraRotation(
const float (&angles)[3])
const
124void GPUDisplay::addAnimationPoint(
const float (&xyz)[3],
const float (&angles)[3])
126 const hmm_mat4 oldViewMatrix = *mViewMatrix;
127 setCamera(xyz, angles);
129 *mViewMatrix = oldViewMatrix;
130 calcXYZ(&mViewMatrix->Elements[0][0]);
133void GPUDisplay::resetAnimation()
135 mAnimationVectors.clear();
136 mCfgC.animationPoints.values.clear();
137 mCfgC.animationPoints.selected = -1;
141void GPUDisplay::removeAnimationPoint(int32_t
i)
145 i =
mCfgC.animationPoints.selected >= 0 ?
mCfgC.animationPoints.selected : (
int32_t)mAnimationVectors.size() - 1;
147 if (i < 0 || i >= (int32_t)mAnimationVectors.size()) {
151 mAnimationVectors.erase(mAnimationVectors.begin() +
i);
153 if (
i == 0 &&
times.size()) {
159 mCfgC.animationPoints.selected = -1;
162void GPUDisplay::selectAnimationPoint(int32_t
i)
165 if (i < 0 || i >= (int32_t)mAnimationVectors.size()) {
166 mCfgC.animationPoints.selected = -1;
169 mCfgC.animationPoints.selected =
i;
170 mCfgL = mAnimationVectors[
i].cfgL;
171 const auto&
v = mAnimationVectors[
i].v;
172 setCamera({
v[0],
v[1],
v[2]}, {
v[3],
v[4],
v[5]});
175void GPUDisplay::StopAnimation()
180 mAnimate =
mCfgO.animateScreenshot = 0;
181 mAnimationMixBase = -1;
182 mUpdateDrawCommands =
true;
183 SetInfo(
"Animation stopped", 1);
188 if (mAnimate || points.
values.size() != mAnimationVectors.size()) {
191 std::vector<uint32_t> order(points.
values.size());
192 std::iota(order.begin(), order.end(), 0);
193 std::stable_sort(order.begin(), order.end(), [&](
uint32_t a,
uint32_t b) { return points.values[a] < points.values[b]; });
203 sorted[
i] = mAnimationVectors[order[
i]];
204 sortedTimes[
i] = points.
values[order[
i]] - points.
values[order[0]];
207 const bool selectionChanged = points.
selected !=
mCfgC.animationPoints.selected;
208 mAnimationVectors = std::move(sorted);
209 mCfgC.animationPoints.values = std::move(sortedTimes);
210 if (selectionChanged) {
211 selectAnimationPoint(selected);
213 mCfgC.animationPoints.selected = selected;
217void GPUDisplay::updateAnimationPointsGUI()
219 auto& gui =
mCfgC.animationPoints;
220 gui.progress = mAnimate ? gui.progress : 0;
221 gui.max = (gui.values.size() ? gui.values.back() : 0.) + ((int32_t)(
mCfgO.animationDelay * 20)) / 20.f;
224void GPUDisplay::runAnimation()
226 if (mAnimationVectors.size() > 1) {
227 if (
mCfgO.animateScreenshot) {
231 SetInfo(
"Starting Animation", 1);
233 SetInfo(
"Insufficient Animation points to start Animation", 1);
237void GPUDisplay::startAnimation()
239 mAnimationSplines.resize(ANIMATION_MODE_NAMES_SHORT.size());
242 yi.resize(mAnimationVectors.size());
245 float vals[8], previous[8];
246 for (
uint32_t k = 0; k < mAnimationVectors.size(); k++) {
247 animationPointValues(mAnimationVectors[k],
mode, k ? previous : nullptr, vals);
248 for (int32_t
i = 0;
i < 8;
i++) {
249 y[
i][k] = previous[
i] = vals[
i];
252 for (int32_t
i = 0;
i < 8;
i++) {
253 mAnimationSplines[
mode][
i].create(
mCfgC.animationPoints.values,
y[
i]);
259 mCfgC.animationPoints.selected = -1;
260 mAnimationLastBase = 0;
261 mAnimationMixBase = -1;
264int32_t GPUDisplay::animateCamera(
bool suspended,
float& animateTime,
float& mixSlaveImage,
hmm_mat4& nextViewMatrix)
266 float time = animateTime;
267 if (mAnimate &&
time < 0) {
268 if (
mCfgO.animateScreenshot) {
269 time = mAnimationFrame / 30.f;
274 float maxTime =
mCfgC.animationPoints.values.back();
275 mCfgC.animationPoints.progress = std::lround(std::clamp(
time / maxTime, 0.f, 1.f) * 65535);
276 if (
time >= maxTime) {
278 mAnimate =
mCfgO.animateScreenshot = 0;
279 SetInfo(
"Animation finished. (%1.2f seconds, %d frames)",
time, mAnimationFrame);
281 SetInfo(
"Running mAnimation: time %1.2f/%1.2f, frames %d",
time, maxTime, mAnimationFrame);
288 if (
mCfgO.animationChangeConfig && animateTime < 0) {
290 const auto&
times =
mCfgC.animationPoints.values;
291 int32_t k = mAnimationVectors.size() - 1;
292 while (base < k && time >
times[base]) {
295 if (base > mAnimationLastBase + 1) {
296 mAnimationLastBase = base - 1;
299 const bool mixing = base != mAnimationLastBase &&
times[mAnimationLastBase] !=
times[base] && memcmp(&mAnimationVectors[base].
cfgL, &mAnimationVectors[mAnimationLastBase].
cfgL,
sizeof(mCfgL));
300 if ((mixing ? base : -1) != mAnimationMixBase) {
301 mAnimationMixBase = mixing ? base : -1;
302 mUpdateDrawCommands =
true;
305 mixSlaveImage = 1.f - (
time -
times[mAnimationLastBase]) / (
times[base] -
times[mAnimationLastBase]);
306 if (mixSlaveImage > 0) {
307 mCfgL = mAnimationVectors[mAnimationLastBase].cfgL;
309 DrawGLScene_internal(suspended,
time,
true);
313 if (memcmp(&mAnimationVectors[base].
cfgL, &mCfgL,
sizeof(mCfgL))) {
314 mCfgL = mAnimationVectors[base].cfgL;
316 mUpdateDrawCommands |= !mixing;
320 const auto&
times =
mCfgC.animationPoints.values;
325 const int32_t maxMode = mAnimationSplines.size() - 1;
326 const int32_t modeA = std::clamp(mAnimationVectors[k].
cfgL.animationMode, 0, maxMode), modeB = std::clamp(mAnimationVectors[k + 1].
cfgL.animationMode, 0, maxMode);
329 for (int32_t
i = 0;
i < 8;
i++) {
330 vals[
i] = mAnimationSplines[
mode][
i].evaluate(
time);
332 animationViewMatrix(vals,
mode, viewMatrix);
334 if (modeA == modeB) {
335 cameraOfMode(modeA, nextViewMatrix);
337 hmm_mat4 viewA = nextViewMatrix, viewB = nextViewMatrix;
338 cameraOfMode(modeA, viewA);
339 cameraOfMode(modeB, viewB);
340 const float s = sinf(std::clamp((
time -
times[k]) / (
times[k + 1] -
times[k]), 0.f, 1.f) * CAMath::Pi() / 2),
w =
s *
s;
341 float qA[4], qB[4], vals[8];
342 createQuaternionFromMatrix(qA, &viewA.
Elements[0][0]);
343 createQuaternionFromMatrix(qB, &viewB.Elements[0][0]);
344 const float sign = qA[0] * qB[0] + qA[1] * qB[1] + qA[2] * qB[2] + qA[3] * qB[3] < 0 ? -1.f : 1.f;
345 auto position = [](
const hmm_mat4&
m,
int32_t i) {
return -(
m.Elements[
i][0] *
m.Elements[3][0] +
m.Elements[
i][1] *
m.Elements[3][1] +
m.Elements[
i][2] *
m.Elements[3][2]); };
346 for (int32_t
i = 0;
i < 3;
i++) {
350 for (int32_t
i = 0;
i < 4;
i++) {
351 vals[4 +
i] = (1 -
w) * qA[
i] +
w * sign * qB[
i];
353 animationViewMatrix(vals, 0, nextViewMatrix);
358void GPUDisplay::animationViewMatrix(
float (&vals)[8], int32_t
mode,
hmm_mat4& nextViewMatrix)
const
363 nextViewMatrix = nextViewMatrix *
HMM_Rotate(-vals[6] * 180.f / CAMath::Pi(), {{0, 0, 1}}) *
HMM_Rotate(-vals[4] * 180.f / CAMath::Pi(), {{1, 0, 0}}) *
HMM_Rotate(vals[5] * 180.f / CAMath::Pi(), {{0, 1, 0}});
365 const float mag = sqrtf(vals[4] * vals[4] + vals[5] * vals[5] + vals[6] * vals[6] + vals[7] * vals[7]);
369 for (int32_t
i = 0;
i < 4;
i++) {
374 float xx = vals[4] * vals[4], xy = vals[4] * vals[5], xz = vals[4] * vals[6], xw = vals[4] * vals[7], yy = vals[5] * vals[5], yz = vals[5] * vals[6], yw = vals[5] * vals[7], zz = vals[6] * vals[6], zw = vals[6] * vals[7];
375 float mat[16] = {1 - 2 * (yy + zz), 2 * (xy - zw), 2 * (xz + yw), 0, 2 * (xy + zw), 1 - 2 * (xx + zz), 2 * (yz - xw), 0, 2 * (xz - yw), 2 * (yz + xw), 1 - 2 * (xx + yy), 0, 0, 0, 0, 1};
376 nextViewMatrix = nextViewMatrix *
MY_HMM_FROM(mat);
381 const float r = vals[3],
phi = vals[1], theta = vals[2];
382 vals[2] =
r * cosf(phi) * cosf(theta);
383 vals[0] =
r * sinf(phi) * cosf(theta);
384 vals[1] =
r * sinf(theta);
385 }
else if (
mode & 2) {
386 float r = sqrtf(vals[0] * vals[0] + vals[1] * vals[1] + vals[2] * vals[2]);
387 if (fabsf(
r) < 0.0001f) {
391 for (int32_t
i = 0;
i < 3;
i++) {
396 nextViewMatrix = lookAtMatrix({vals[0], vals[1], vals[2]}, {0.f, 0.f, 0.f});
398 nextViewMatrix = nextViewMatrix *
HMM_Translate({{-vals[0], -vals[1], -vals[2]}});
std::vector< unsigned long > times
constexpr hmm_mat4 MY_HMM_FROM(float(&v)[16])
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 s
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
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
HMM_INLINE hmm_mat4 HMM_Translate(hmm_vec3 Translation)
HMM_EXTERN hmm_mat4 HMM_LookAt(hmm_vec3 Eye, hmm_vec3 Center, hmm_vec3 Up)
HMM_EXTERN hmm_mat4 HMM_Rotate(float Angle, hmm_vec3 Axis)
double GetCurrentElapsedTime(bool reset=false)
const GPUSettingsDisplayLight & cfgL() const
GLboolean GLboolean GLboolean b
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLboolean GLboolean GLboolean GLboolean a
GLubyte GLubyte GLubyte GLubyte w
typename std::vector< T, vecpod_allocator< T > > vecpod