Skip to content

Commit

Permalink
Fixed include issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Jan 17, 2025
1 parent 7929700 commit 1416747
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 64 deletions.
46 changes: 46 additions & 0 deletions RecoTracker/LSTCore/interface/Circle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef RecoTracker_LSTCore_interface_Circle_h
#define RecoTracker_LSTCore_interface_Circle_h

#include <tuple>

#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

namespace lst {

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE std::tuple<float, float, float> computeRadiusFromThreeAnchorHits(
TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3) {
float radius = 0.f;

//first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3)

float denomInv = 1.0f / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3));

float xy1sqr = x1 * x1 + y1 * y1;

float xy2sqr = x2 * x2 + y2 * y2;

float xy3sqr = x3 * x3 + y3 * y3;

float regressionCenterX = 0.5f * ((y3 - y2) * xy1sqr + (y1 - y3) * xy2sqr + (y2 - y1) * xy3sqr) * denomInv;

float regressionCenterY = 0.5f * ((x2 - x3) * xy1sqr + (x3 - x1) * xy2sqr + (x1 - x2) * xy3sqr) * denomInv;

float c = ((x2 * y3 - x3 * y2) * xy1sqr + (x3 * y1 - x1 * y3) * xy2sqr + (x1 * y2 - x2 * y1) * xy3sqr) * denomInv;

if (((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) ||
(regressionCenterX * regressionCenterX + regressionCenterY * regressionCenterY - c < 0)) {
#ifdef WARNINGS
printf("three collinear points or FATAL! r^2 < 0!\n");
#endif
radius = -1.f;
} else
radius =
alpaka::math::sqrt(acc, regressionCenterX * regressionCenterX + regressionCenterY * regressionCenterY - c);

return std::make_tuple(radius, regressionCenterX, regressionCenterY);
}

} //namespace lst

#endif
2 changes: 2 additions & 0 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "LSTEvent.h"

#include "Hit.h"
#include "Kernels.h"
#include "MiniDoublet.h"
#include "PixelQuintuplet.h"
#include "PixelTriplet.h"
Expand Down
4 changes: 1 addition & 3 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "RecoTracker/LSTCore/interface/ModulesHostCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/alpaka/LST.h"
#include "RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h"
Expand All @@ -26,9 +27,6 @@
#include "RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h"

#include "Hit.h"
#include "Kernels.h"

#include "HeterogeneousCore/AlpakaInterface/interface/host.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
Expand Down
3 changes: 1 addition & 2 deletions RecoTracker/LSTCore/src/alpaka/MiniDoublet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
#include "FWCore/Utilities/interface/isFinite.h"

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"

#include "Hit.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addMDToMemory(TAcc const& acc,
Expand Down
3 changes: 2 additions & 1 deletion RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
Expand All @@ -10,7 +11,7 @@
#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"

#include "Hit.h"
#include "Quintuplet.h"
#include "PixelTriplet.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
Expand Down
5 changes: 2 additions & 3 deletions RecoTracker/LSTCore/src/alpaka/Quintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"
#include "RecoTracker/LSTCore/interface/Circle.h"

#include "NeuralNetwork.h"
#include "Hit.h"
#include "Triplet.h" // FIXME: need to refactor common functions to a common place

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(TripletsConst triplets,
Expand Down Expand Up @@ -1502,7 +1501,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

float g, f;
outerRadius = triplets.radius()[outerTripletIndex];
bridgeRadius = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4, g, f);
std::tie(bridgeRadius, g, f) = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4);
innerRadius = triplets.radius()[innerTripletIndex];

bool inference = lst::t5dnn::runInference(acc,
Expand Down
5 changes: 2 additions & 3 deletions RecoTracker/LSTCore/src/alpaka/Segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"
#include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"

#include "MiniDoublet.h"
#include "Hit.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isTighterTiltedModules_seg(ModulesConst modules, unsigned int moduleIndex) {
Expand Down
3 changes: 1 addition & 2 deletions RecoTracker/LSTCore/src/alpaka/TrackCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h"
Expand All @@ -13,8 +14,6 @@
#include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"

#include "Hit.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addpLSTrackCandidateToMemory(TrackCandidates& cands,
unsigned int trackletIndex,
Expand Down
41 changes: 3 additions & 38 deletions RecoTracker/LSTCore/src/alpaka/Triplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"

#include "Segment.h"
#include "MiniDoublet.h"
#include "Hit.h"
#include "RecoTracker/LSTCore/interface/Circle.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

Expand Down Expand Up @@ -628,39 +625,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
return false; // failsafe
}

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHits(
TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) {
float radius = 0.f;

//(g,f) -> center
//first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3)

float denomInv = 1.0f / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3));

float xy1sqr = x1 * x1 + y1 * y1;

float xy2sqr = x2 * x2 + y2 * y2;

float xy3sqr = x3 * x3 + y3 * y3;

g = 0.5f * ((y3 - y2) * xy1sqr + (y1 - y3) * xy2sqr + (y2 - y1) * xy3sqr) * denomInv;

f = 0.5f * ((x2 - x3) * xy1sqr + (x3 - x1) * xy2sqr + (x1 - x2) * xy3sqr) * denomInv;

float c = ((x2 * y3 - x3 * y2) * xy1sqr + (x3 * y1 - x1 * y3) * xy2sqr + (x1 * y2 - x2 * y1) * xy3sqr) * denomInv;

if (((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) || (g * g + f * f - c < 0)) {
#ifdef WARNINGS
printf("three collinear points or FATAL! r^2 < 0!\n");
#endif
radius = -1.f;
} else
radius = alpaka::math::sqrt(acc, g * g + f * f - c);

return radius;
}

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletConstraintsAndAlgo(TAcc const& acc,
ModulesConst modules,
Expand Down Expand Up @@ -694,7 +658,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
float y2 = mds.anchorY()[secondMDIndex];
float y3 = mds.anchorY()[thirdMDIndex];

circleRadius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, circleCenterX, circleCenterY);
std::tie(circleRadius, circleCenterX, circleCenterY) =
computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3);

if (not passRZConstraint(acc,
modules,
Expand Down
21 changes: 9 additions & 12 deletions RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// to use computeRadiusFromThreeAnchorHits
#include "LSTEvent.h"
#include "Triplet.h"
#include "Circle.h"

#include "write_lst_ntuple.h"

Expand Down Expand Up @@ -672,17 +671,15 @@ void fillT5DNNBranches(LSTEvent* event, unsigned int iT3) {
ana.tx->pushbackToBranch<int>("t5_t3_" + idx + "_moduleType", modules.moduleType()[module]);
}

float g, f;
float radius;
auto const& devHost = cms::alpakatools::host();
float radius = computeRadiusFromThreeAnchorHits(devHost,
hitObjects[0].x(),
hitObjects[0].y(),
hitObjects[1].x(),
hitObjects[1].y(),
hitObjects[2].x(),
hitObjects[2].y(),
g,
f);
std::tie(radius, std::ignore, std::ignore) = computeRadiusFromThreeAnchorHits(devHost,
hitObjects[0].x(),
hitObjects[0].y(),
hitObjects[1].x(),
hitObjects[1].y(),
hitObjects[2].x(),
hitObjects[2].y());
ana.tx->pushbackToBranch<float>("t5_t3_pt", k2Rinv1GeVf * 2 * radius);

// Angles
Expand Down

0 comments on commit 1416747

Please sign in to comment.