Skip to content

Commit

Permalink
Addressing review comments on PixelType
Browse files Browse the repository at this point in the history
  • Loading branch information
VourMa committed Aug 25, 2024
1 parent 1b6a0e1 commit bb8402d
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 57 deletions.
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace lst {
}

// Named constants for pixelTypes
enum PixelType : int8_t { kHighPt = 0, kLowPtPosCurv = 1, kLowPtNegCurv = 2 };
enum PixelType : int8_t { kInvalid = -1, kHighPt = 0, kLowPtPosCurv = 1, kLowPtNegCurv = 2 };

// If a compile time flag does not define PT_CUT, default to 0.8 (GeV)
#ifndef PT_CUT
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/alpaka/LST.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
std::vector<int> in_charge_vec_;
std::vector<unsigned int> in_seedIdx_vec_;
std::vector<int> in_superbin_vec_;
std::vector<int8_t> in_pixelType_vec_;
std::vector<::lst::PixelType> in_pixelType_vec_;
std::vector<char> in_isQuad_vec_;
std::vector<std::vector<unsigned int>> out_tc_hitIdxs_;
std::vector<unsigned int> out_tc_len_;
Expand Down
73 changes: 37 additions & 36 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void Event::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
std::vector<int> const& charge,
std::vector<unsigned int> const& seedIdx,
std::vector<int> const& superbin,
std::vector<int8_t> const& pixelType,
std::vector<::lst::PixelType> const& pixelType,
std::vector<char> const& isQuad) {
unsigned int size = ptIn.size();

Expand Down Expand Up @@ -704,7 +704,7 @@ void Event::createPixelTriplets() {
}

auto superbins_buf = allocBufWrapper<int>(devHost, n_max_pixel_segments_per_module, queue);
auto pixelTypes_buf = allocBufWrapper<int8_t>(devHost, n_max_pixel_segments_per_module, queue);
auto pixelTypes_buf = allocBufWrapper<::lst::PixelType>(devHost, n_max_pixel_segments_per_module, queue);

alpaka::memcpy(queue, superbins_buf, segmentsBuffers->superbin_buf);
alpaka::memcpy(queue, pixelTypes_buf, segmentsBuffers->pixelType_buf);
Expand Down Expand Up @@ -735,9 +735,9 @@ void Event::createPixelTriplets() {

// TODO: check if a map/reduction to just eligible pLSs would speed up the kernel
// the current selection still leaves a significant fraction of unmatchable pLSs
for (unsigned int i = 0; i < nInnerSegments; i++) { // loop over # pLS
::lst::PixelType pixelType = static_cast<::lst::PixelType>(pixelTypes[i]); // Get pixel type for this pLS
int superbin = superbins[i]; // Get superbin for this pixel
for (unsigned int i = 0; i < nInnerSegments; i++) { // loop over # pLS
::lst::PixelType pixelType = pixelTypes[i]; // Get pixel type for this pLS
int superbin = superbins[i]; // Get superbin for this pixel
if ((superbin < 0) or (superbin >= (int)size_superbins) or
((pixelType != ::lst::PixelType::kHighPt) and (pixelType != ::lst::PixelType::kLowPtPosCurv) and
(pixelType != ::lst::PixelType::kLowPtNegCurv))) {
Expand All @@ -747,26 +747,26 @@ void Event::createPixelTriplets() {
}

// Used pixel type to select correct size-index arrays
unsigned int connectedIdxBase;
switch (pixelType) {
case ::lst::PixelType::kInvalid:
break;
case ::lst::PixelType::kHighPt:
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizes[superbin]; // number of connected modules to this pixel
connectedIdxBase = pixelMapping_.connectedPixelsIndex[superbin];
connectedPixelIndex_host[i] =
connectedIdxBase; // index to get start of connected modules for this superbin in map
// number of connected modules to this pixel
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizes[superbin];
// index to get start of connected modules for this superbin in map
connectedPixelIndex_host[i] = pixelMapping_.connectedPixelsIndex[superbin];
break;
case ::lst::PixelType::kLowPtPosCurv:
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizesPos[superbin]; // number of pixel connected modules
connectedIdxBase = pixelMapping_.connectedPixelsIndexPos[superbin] + pixelIndexOffsetPos;
connectedPixelIndex_host[i] = connectedIdxBase; // index to get start of connected pixel modules
// number of connected modules to this pixel
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizesPos[superbin];
// index to get start of connected modules for this superbin in map
connectedPixelIndex_host[i] = pixelMapping_.connectedPixelsIndexPos[superbin] + pixelIndexOffsetPos;
break;
case ::lst::PixelType::kLowPtNegCurv:
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizesNeg[superbin]; // number of pixel connected modules
connectedIdxBase = pixelMapping_.connectedPixelsIndexNeg[superbin] + pixelIndexOffsetNeg;
connectedPixelIndex_host[i] = connectedIdxBase; // index to get start of connected pixel modules
// number of connected modules to this pixel
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizesNeg[superbin];
// index to get start of connected modules for this superbin in map
connectedPixelIndex_host[i] = pixelMapping_.connectedPixelsIndexNeg[superbin] + pixelIndexOffsetNeg;
break;
}
}
Expand Down Expand Up @@ -907,7 +907,7 @@ void Event::createPixelQuintuplets() {
}

auto superbins_buf = allocBufWrapper<int>(devHost, n_max_pixel_segments_per_module, queue);
auto pixelTypes_buf = allocBufWrapper<int8_t>(devHost, n_max_pixel_segments_per_module, queue);
auto pixelTypes_buf = allocBufWrapper<::lst::PixelType>(devHost, n_max_pixel_segments_per_module, queue);

alpaka::memcpy(queue, superbins_buf, segmentsBuffers->superbin_buf);
alpaka::memcpy(queue, pixelTypes_buf, segmentsBuffers->pixelType_buf);
Expand Down Expand Up @@ -938,36 +938,37 @@ void Event::createPixelQuintuplets() {

// Loop over # pLS
for (unsigned int i = 0; i < nInnerSegments; i++) {
::lst::PixelType pixelType = static_cast<::lst::PixelType>(pixelTypes[i]); // Get pixel type for this pLS
int superbin = superbins[i]; // Get superbin for this pixel
::lst::PixelType pixelType = pixelTypes[i]; // Get pixel type for this pLS
int superbin = superbins[i]; // Get superbin for this pixel
if ((superbin < 0) or (superbin >= (int)size_superbins) or
((pixelType != ::lst::PixelType::kHighPt) and (pixelType != ::lst::PixelType::kLowPtPosCurv) and
(pixelType != ::lst::PixelType::kLowPtNegCurv))) {
connectedPixelIndex_host[i] = 0;
connectedPixelSize_host[i] = 0;
connectedPixelIndex_host[i] = 0;
continue;
}

// Used pixel type to select correct size-index arrays
unsigned int connectedIdxBase;
switch (pixelType) {
case ::lst::PixelType::kInvalid:
break;
case ::lst::PixelType::kHighPt:
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizes[superbin]; //number of connected modules to this pixel
connectedIdxBase = pixelMapping_.connectedPixelsIndex[superbin];
connectedPixelIndex_host[i] = connectedIdxBase;
// number of connected modules to this pixel
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizes[superbin];
// index to get start of connected modules for this superbin in map
connectedPixelIndex_host[i] = pixelMapping_.connectedPixelsIndex[superbin];
break;
case ::lst::PixelType::kLowPtPosCurv:
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizesPos[superbin]; //number of pixel connected modules
connectedIdxBase = pixelMapping_.connectedPixelsIndexPos[superbin] + pixelIndexOffsetPos;
connectedPixelIndex_host[i] = connectedIdxBase;
// number of connected modules to this pixel
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizesPos[superbin];
// index to get start of connected modules for this superbin in map
connectedPixelIndex_host[i] = pixelMapping_.connectedPixelsIndexPos[superbin] + pixelIndexOffsetPos;
break;
case ::lst::PixelType::kLowPtNegCurv:
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizesNeg[superbin]; //number of pixel connected modules
connectedIdxBase = pixelMapping_.connectedPixelsIndexNeg[superbin] + pixelIndexOffsetNeg;
connectedPixelIndex_host[i] = connectedIdxBase;
// number of connected modules to this pixel
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizesNeg[superbin];
// index to get start of connected modules for this superbin in map
connectedPixelIndex_host[i] = pixelMapping_.connectedPixelsIndexNeg[superbin] + pixelIndexOffsetNeg;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/alpaka/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
std::vector<int> const& charge,
std::vector<unsigned int> const& seedIdx,
std::vector<int> const& superbin,
std::vector<int8_t> const& pixelType,
std::vector<::lst::PixelType> const& pixelType,
std::vector<char> const& isQuad);

void createMiniDoublets();
Expand Down
10 changes: 5 additions & 5 deletions RecoTracker/LSTCore/src/alpaka/LST.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void ALPAKA_ACCELERATOR_NAMESPACE::lst::LST::prepareInput(std::vector<float> con
std::vector<unsigned int> hitIdxs(ph2_detId.size());

std::vector<int> superbin_vec;
std::vector<int8_t> pixelType_vec;
std::vector<::lst::PixelType> pixelType_vec;
std::vector<char> isQuad_vec;
std::iota(hitIdxs.begin(), hitIdxs.end(), 0);
const int hit_size = trkX.size();
Expand All @@ -100,15 +100,15 @@ void ALPAKA_ACCELERATOR_NAMESPACE::lst::LST::prepareInput(std::vector<float> con
float pz = p3LH.z();

int charge = see_q[iSeed];
int pixtype = -1;
::lst::PixelType pixtype = ::lst::PixelType::kInvalid;

if (ptIn >= 2.0)
pixtype = static_cast<int8_t>(::lst::PixelType::kHighPt);
pixtype = ::lst::PixelType::kHighPt;
else if (ptIn >= (0.8 - 2 * ptErr) and ptIn < 2.0) {
if (pixelSegmentDeltaPhiChange >= 0)
pixtype = static_cast<int8_t>(::lst::PixelType::kLowPtPosCurv);
pixtype = ::lst::PixelType::kLowPtPosCurv;
else
pixtype = static_cast<int8_t>(::lst::PixelType::kLowPtNegCurv);
pixtype = ::lst::PixelType::kLowPtNegCurv;
} else
continue;

Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/src/alpaka/Segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
unsigned int* nSegments; //number of segments per inner lower module
unsigned int* totOccupancySegments; //number of segments per inner lower module
uint4* pLSHitsIdxs;
int8_t* pixelType;
::lst::PixelType* pixelType;
char* isQuad;
char* isDup;
bool* partOfPT5;
Expand Down Expand Up @@ -107,7 +107,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
Buf<TDev, unsigned int> nSegments_buf;
Buf<TDev, unsigned int> totOccupancySegments_buf;
Buf<TDev, uint4> pLSHitsIdxs_buf;
Buf<TDev, int8_t> pixelType_buf;
Buf<TDev, ::lst::PixelType> pixelType_buf;
Buf<TDev, char> isQuad_buf;
Buf<TDev, char> isDup_buf;
Buf<TDev, bool> partOfPT5_buf;
Expand Down Expand Up @@ -150,7 +150,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
nSegments_buf(allocBufWrapper<unsigned int>(devAccIn, nLowerModules + 1, queue)),
totOccupancySegments_buf(allocBufWrapper<unsigned int>(devAccIn, nLowerModules + 1, queue)),
pLSHitsIdxs_buf(allocBufWrapper<uint4>(devAccIn, maxPixelSegments, queue)),
pixelType_buf(allocBufWrapper<int8_t>(devAccIn, maxPixelSegments, queue)),
pixelType_buf(allocBufWrapper<::lst::PixelType>(devAccIn, maxPixelSegments, queue)),
isQuad_buf(allocBufWrapper<char>(devAccIn, maxPixelSegments, queue)),
isDup_buf(allocBufWrapper<char>(devAccIn, maxPixelSegments, queue)),
partOfPT5_buf(allocBufWrapper<bool>(devAccIn, maxPixelSegments, queue)),
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/standalone/bin/lst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void run_lst() {
std::vector<std::vector<int>> out_charge_vec;
std::vector<std::vector<unsigned int>> out_seedIdx_vec;
std::vector<std::vector<int>> out_superbin_vec;
std::vector<std::vector<int8_t>> out_pixelType_vec;
std::vector<std::vector<::lst::PixelType>> out_pixelType_vec;
std::vector<std::vector<char>> out_isQuad_vec;
std::vector<int> evt_num;
std::vector<TString> file_name;
Expand Down
14 changes: 7 additions & 7 deletions RecoTracker/LSTCore/standalone/code/core/trkCore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ void addInputsToLineSegmentTrackingPreLoad(std::vector<std::vector<float>> &out_
std::vector<std::vector<int>> &out_charge_vec,
std::vector<std::vector<unsigned int>> &out_seedIdx_vec,
std::vector<std::vector<int>> &out_superbin_vec,
std::vector<std::vector<int8_t>> &out_pixelType_vec,
std::vector<std::vector<::lst::PixelType>> &out_pixelType_vec,
std::vector<std::vector<char>> &out_isQuad_vec) {
unsigned int count = 0;
auto n_see = trk.see_stateTrajGlbPx().size();
Expand Down Expand Up @@ -651,7 +651,7 @@ void addInputsToLineSegmentTrackingPreLoad(std::vector<std::vector<float>> &out_
std::vector<unsigned int> hitIdxs(trk.ph2_detId().size());

std::vector<int> superbin_vec;
std::vector<int8_t> pixelType_vec;
std::vector<::lst::PixelType> pixelType_vec;
std::vector<char> isQuad_vec;
std::iota(hitIdxs.begin(), hitIdxs.end(), 0);
const int hit_size = trkX.size();
Expand Down Expand Up @@ -718,14 +718,14 @@ void addInputsToLineSegmentTrackingPreLoad(std::vector<std::vector<float>> &out_
int charge = trk.see_q()[iSeed];
unsigned int seedIdx = iSeed;

int pixtype = -1;
::lst::PixelType pixtype = ::lst::PixelType::kInvalid;
if (ptIn >= 2.0) {
pixtype = static_cast<int8_t>(::lst::PixelType::kHighPt);
pixtype = ::lst::PixelType::kHighPt;
} else if (ptIn >= (PT_CUT - 2 * ptErr) and ptIn < 2.0) {
if (pixelSegmentDeltaPhiChange >= 0) {
pixtype = static_cast<int8_t>(::lst::PixelType::kLowPtPosCurv);
pixtype = ::lst::PixelType::kLowPtPosCurv;
} else {
pixtype = static_cast<int8_t>(::lst::PixelType::kLowPtNegCurv);
pixtype = ::lst::PixelType::kLowPtNegCurv;
}
} else {
continue;
Expand Down Expand Up @@ -865,7 +865,7 @@ float addInputsToEventPreLoad(LSTEvent *event,
std::vector<int> charge_vec,
std::vector<unsigned int> seedIdx_vec,
std::vector<int> superbin_vec,
std::vector<int8_t> pixelType_vec,
std::vector<::lst::PixelType> pixelType_vec,
std::vector<char> isQuad_vec) {
TStopwatch my_timer;

Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/standalone/code/core/trkCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void addInputsToLineSegmentTrackingPreLoad(std::vector<std::vector<float>> &out_
std::vector<std::vector<int>> &out_charge_vec,
std::vector<std::vector<unsigned int>> &out_seedIdx_vec,
std::vector<std::vector<int>> &out_superbin_vec,
std::vector<std::vector<int8_t>> &out_pixelType_vec,
std::vector<std::vector<::lst::PixelType>> &out_pixelType_vec,
std::vector<std::vector<char>> &out_isQuad_vec);

float addInputsToEventPreLoad(LSTEvent *event,
Expand All @@ -94,7 +94,7 @@ float addInputsToEventPreLoad(LSTEvent *event,
std::vector<int> charge_vec,
std::vector<unsigned int> seedIdx_vec,
std::vector<int> superbin_vec,
std::vector<int8_t> pixelType_vec,
std::vector<::lst::PixelType> pixelType_vec,
std::vector<char> isQuad_vec);

void printTimingInformation(std::vector<std::vector<float>> &timing_information, float fullTime, float fullavg);
Expand Down

0 comments on commit bb8402d

Please sign in to comment.