Skip to content

Commit

Permalink
Work on pixelType and removal of deprecated functions in standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
VourMa committed Aug 20, 2024
1 parent 9544a58 commit fcb5e32
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 254 deletions.
5 changes: 4 additions & 1 deletion RecoTracker/LSTCore/interface/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ namespace lst {
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
}

// Named constants for pixelTypes
enum kPixelType { highPt = 0, lowPtPosCurv = 1, lowPtNegCurv = 2 };

// If a compile time flag does not define PT_CUT, default to 0.8 (GeV)
#ifndef PT_CUT
constexpr float PT_CUT = 0.8f;
Expand All @@ -52,7 +55,7 @@ namespace lst {

constexpr unsigned int size_superbins = 45000;

//defining the constant host device variables right up here
// Defining the constant host device variables right up here
// Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future.
struct Params_pLS {
static constexpr int kLayers = 2, kHits = 4;
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/PixelMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace lst {
std::vector<unsigned int> connectedPixelsIndexNeg;
std::vector<unsigned int> connectedPixelsSizesNeg;

int* pixelType;
const int* pixelType;

PixelMap(unsigned int sizef = size_superbins)
: pixelModuleIndex(0),
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<int> 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
33 changes: 17 additions & 16 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<int> 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<int>(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,28 +735,28 @@ 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
int8_t 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 > 2) or (pixelType < 0)) {
for (unsigned int i = 0; i < nInnerSegments; i++) { // loop over # pLS
int 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::kPixelType::highPt) and (pixelType != ::lst::kPixelType::lowPtPosCurv) and (pixelType != ::lst::kPixelType::lowPtNegCurv))) {
connectedPixelSize_host[i] = 0;
connectedPixelIndex_host[i] = 0;
continue;
}

// Used pixel type to select correct size-index arrays
if (pixelType == 0) {
if (pixelType == static_cast<int>(::lst::kPixelType::highPt)) {
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizes[superbin]; // number of connected modules to this pixel
auto connectedIdxBase = pixelMapping_.connectedPixelsIndex[superbin];
connectedPixelIndex_host[i] =
connectedIdxBase; // index to get start of connected modules for this superbin in map
} else if (pixelType == 1) {
} else if (pixelType == static_cast<int>(::lst::kPixelType::lowPtPosCurv)) {
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizesPos[superbin]; // number of pixel connected modules
auto connectedIdxBase = pixelMapping_.connectedPixelsIndexPos[superbin] + pixelIndexOffsetPos;
connectedPixelIndex_host[i] = connectedIdxBase; // index to get start of connected pixel modules
} else if (pixelType == 2) {
} else if (pixelType == static_cast<int>(::lst::kPixelType::lowPtNegCurv)) {
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizesNeg[superbin]; // number of pixel connected modules
auto connectedIdxBase = pixelMapping_.connectedPixelsIndexNeg[superbin] + pixelIndexOffsetNeg;
Expand Down Expand Up @@ -900,7 +900,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<int>(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 @@ -931,24 +931,25 @@ void Event::createPixelQuintuplets() {

// Loop over # pLS
for (unsigned int i = 0; i < nInnerSegments; i++) {
int8_t 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 > 2) or (pixelType < 0)) {
int 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::kPixelType::highPt) and (pixelType != ::lst::kPixelType::lowPtPosCurv) and (pixelType != ::lst::kPixelType::lowPtNegCurv))) {
connectedPixelIndex_host[i] = 0;
connectedPixelSize_host[i] = 0;
continue;
}

// Used pixel type to select correct size-index arrays
if (pixelType == 0) {
if (pixelType == static_cast<int>(::lst::kPixelType::highPt)) {
connectedPixelSize_host[i] =
pixelMapping_.connectedPixelsSizes[superbin]; //number of connected modules to this pixel
unsigned int connectedIdxBase = pixelMapping_.connectedPixelsIndex[superbin];
connectedPixelIndex_host[i] = connectedIdxBase;
} else if (pixelType == 1) {
} else if (pixelType == static_cast<int>(::lst::kPixelType::lowPtPosCurv)) {
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizesPos[superbin]; //number of pixel connected modules
unsigned int connectedIdxBase = pixelMapping_.connectedPixelsIndexPos[superbin] + pixelIndexOffsetPos;
connectedPixelIndex_host[i] = connectedIdxBase;
} else if (pixelType == 2) {
} else if (pixelType == static_cast<int>(::lst::kPixelType::lowPtNegCurv)) {
connectedPixelSize_host[i] = pixelMapping_.connectedPixelsSizesNeg[superbin]; //number of pixel connected modules
unsigned int connectedIdxBase = pixelMapping_.connectedPixelsIndexNeg[superbin] + pixelIndexOffsetNeg;
connectedPixelIndex_host[i] = connectedIdxBase;
Expand Down
5 changes: 1 addition & 4 deletions RecoTracker/LSTCore/src/alpaka/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

void initSync(bool verbose);

int* superbinCPU;
int8_t* pixelTypeCPU;

const uint16_t nModules_;
const uint16_t nLowerModules_;
const unsigned int nPixels_;
Expand Down Expand Up @@ -131,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<int> const& pixelType,
std::vector<char> const& isQuad);

void createMiniDoublets();
Expand Down
11 changes: 5 additions & 6 deletions RecoTracker/LSTCore/src/alpaka/LST.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,13 @@ 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<int> pixelType_vec;
std::vector<char> isQuad_vec;
std::iota(hitIdxs.begin(), hitIdxs.end(), 0);
const int hit_size = trkX.size();

for (size_t iSeed = 0; iSeed < n_see; iSeed++) {
XYZVector p3LH(see_stateTrajGlbPx[iSeed], see_stateTrajGlbPy[iSeed], see_stateTrajGlbPz[iSeed]);
XYZVector p3LH_helper(see_stateTrajGlbPx[iSeed], see_stateTrajGlbPy[iSeed], see_stateTrajGlbPz[iSeed]);
float ptIn = p3LH.rho();
float eta = p3LH.eta();
float ptErr = see_ptErr[iSeed];
Expand All @@ -94,7 +93,7 @@ void ALPAKA_ACCELERATOR_NAMESPACE::lst::LST::prepareInput(std::vector<float> con
XYZVector p3PCA(see_px[iSeed], see_py[iSeed], see_pz[iSeed]);
XYZVector r3PCA(calculateR3FromPCA(p3PCA, see_dxy[iSeed], see_dz[iSeed]));

float pixelSegmentDeltaPhiChange = (r3LH - p3LH_helper).phi(); //FIXME: this looks like a bug
float pixelSegmentDeltaPhiChange = (r3LH - p3LH).phi();
float etaErr = see_etaErr[iSeed];
float px = p3LH.x();
float py = p3LH.y();
Expand All @@ -104,12 +103,12 @@ void ALPAKA_ACCELERATOR_NAMESPACE::lst::LST::prepareInput(std::vector<float> con
int pixtype = -1;

if (ptIn >= 2.0)
pixtype = 0;
pixtype = static_cast<int>(::lst::kPixelType::highPt);
else if (ptIn >= (0.8 - 2 * ptErr) and ptIn < 2.0) {
if (pixelSegmentDeltaPhiChange >= 0)
pixtype = 1;
pixtype = static_cast<int>(::lst::kPixelType::lowPtPosCurv);
else
pixtype = 2;
pixtype = static_cast<int>(::lst::kPixelType::lowPtNegCurv);
} 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;
int* 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, int> 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<int>(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<int>> out_pixelType_vec;
std::vector<std::vector<char>> out_isQuad_vec;
std::vector<int> evt_num;
std::vector<TString> file_name;
Expand Down
Loading

0 comments on commit fcb5e32

Please sign in to comment.