Skip to content

Commit

Permalink
Merge pull request #72 from SegmentLinking/removalOfSDL
Browse files Browse the repository at this point in the history
Total removal of sdl/SDL
  • Loading branch information
slava77 authored Jul 31, 2024
2 parents d7689bb + a076afb commit ecd8e3e
Show file tree
Hide file tree
Showing 28 changed files with 526 additions and 579 deletions.
1 change: 0 additions & 1 deletion RecoTracker/LST/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<use name="DataFormats/TrackerRecHit2D"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name="RecoTracker/LSTCore"/>
<flags CXXFLAGS="-DLST_IS_CMSSW_PACKAGE"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
Expand Down
10 changes: 5 additions & 5 deletions RecoTracker/LSTCore/interface/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace lst {
const bool* isAnchor;
const ModuleType* moduleType;
const ModuleLayerType* moduleLayerType;
const int* sdlLayers;
const int* lstLayers;
const unsigned int* connectedPixels;

static bool parseIsInverted(short subdet, short side, short module, short layer) {
Expand Down Expand Up @@ -108,7 +108,7 @@ namespace lst {
isAnchor = alpaka::getPtrNative(buf.isAnchor_buf);
moduleType = alpaka::getPtrNative(buf.moduleType_buf);
moduleLayerType = alpaka::getPtrNative(buf.moduleLayerType_buf);
sdlLayers = alpaka::getPtrNative(buf.sdlLayers_buf);
lstLayers = alpaka::getPtrNative(buf.lstLayers_buf);
connectedPixels = alpaka::getPtrNative(buf.connectedPixels_buf);
}
};
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace lst {
Buf<TDev, bool> isAnchor_buf;
Buf<TDev, ModuleType> moduleType_buf;
Buf<TDev, ModuleLayerType> moduleLayerType_buf;
Buf<TDev, int> sdlLayers_buf;
Buf<TDev, int> lstLayers_buf;
Buf<TDev, unsigned int> connectedPixels_buf;

Modules data_;
Expand Down Expand Up @@ -169,7 +169,7 @@ namespace lst {
isAnchor_buf(allocBufWrapper<bool>(dev, nMod)),
moduleType_buf(allocBufWrapper<ModuleType>(dev, nMod)),
moduleLayerType_buf(allocBufWrapper<ModuleLayerType>(dev, nMod)),
sdlLayers_buf(allocBufWrapper<int>(dev, nMod)),
lstLayers_buf(allocBufWrapper<int>(dev, nMod)),
connectedPixels_buf(allocBufWrapper<unsigned int>(dev, nPixs)) {
data_.setData(*this);
}
Expand Down Expand Up @@ -209,7 +209,7 @@ namespace lst {
alpaka::memcpy(queue, moduleType_buf, src.moduleType_buf);
if (isFull) {
alpaka::memcpy(queue, moduleLayerType_buf, src.moduleLayerType_buf);
alpaka::memcpy(queue, sdlLayers_buf, src.sdlLayers_buf);
alpaka::memcpy(queue, lstLayers_buf, src.lstLayers_buf);
alpaka::memcpy(queue, connectedPixels_buf, src.connectedPixels_buf);
}
alpaka::wait(queue);
Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/LSTCore/src/ModuleMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace lst {
auto dxdys_buf = allocBufWrapper<float>(devHost, nModules);
auto drdzs_buf = allocBufWrapper<float>(devHost, nModules);
auto partnerModuleIndices_buf = allocBufWrapper<uint16_t>(devHost, nModules);
auto sdlLayers_buf = allocBufWrapper<int>(devHost, nModules);
auto lstLayers_buf = allocBufWrapper<int>(devHost, nModules);

// Getting the underlying data pointers
unsigned int* host_detIds = alpaka::getPtrNative(detIds_buf);
Expand All @@ -270,7 +270,7 @@ namespace lst {
float* host_dxdys = alpaka::getPtrNative(dxdys_buf);
float* host_drdzs = alpaka::getPtrNative(drdzs_buf);
uint16_t* host_partnerModuleIndices = alpaka::getPtrNative(partnerModuleIndices_buf);
int* host_sdlLayers = alpaka::getPtrNative(sdlLayers_buf);
int* host_lstLayers = alpaka::getPtrNative(lstLayers_buf);

//reassign detIdToIndex indices here
nLowerModules = (nModules - 1) / 2;
Expand Down Expand Up @@ -351,7 +351,7 @@ namespace lst {
host_drdzs[index] = (subdet == Barrel) ? tiltedGeometry->getDrDz(detId) : 0;
}

host_sdlLayers[index] =
host_lstLayers[index] =
layer + 6 * (subdet == lst::Endcap) + 5 * (subdet == lst::Endcap and host_moduleType[index] == lst::TwoS);
}

Expand Down Expand Up @@ -402,7 +402,7 @@ namespace lst {
alpaka::memcpy(queue, modulesBuf->dxdys_buf, dxdys_buf);
alpaka::memcpy(queue, modulesBuf->drdzs_buf, drdzs_buf);
alpaka::memcpy(queue, modulesBuf->partnerModuleIndices_buf, partnerModuleIndices_buf);
alpaka::memcpy(queue, modulesBuf->sdlLayers_buf, sdlLayers_buf);
alpaka::memcpy(queue, modulesBuf->lstLayers_buf, lstLayers_buf);
alpaka::wait(queue);

fillConnectedModuleArrayExplicit(modulesBuf.get(), nModules, queue, mmd, moduleConnectionMap);
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ lst::TripletsBuffer<DevHost>* lst::Event<Acc3D>::getTriplets() {
alpaka::memcpy(queue, tripletsInCPU->zHi_buf, tripletsBuffers->zHi_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->zLoPointed_buf, tripletsBuffers->zLoPointed_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->zHiPointed_buf, tripletsBuffers->zHiPointed_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->sdlCut_buf, tripletsBuffers->sdlCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->dPhiCut_buf, tripletsBuffers->dPhiCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->betaInCut_buf, tripletsBuffers->betaInCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->rtLo_buf, tripletsBuffers->rtLo_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->rtHi_buf, tripletsBuffers->rtHi_buf, nMemHost);
Expand Down
37 changes: 18 additions & 19 deletions RecoTracker/LSTCore/src/alpaka/PixelTriplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ namespace lst {
unsigned int secondMDIndex,
unsigned int thirdMDIndex,
unsigned int fourthMDIndex) {
float dPhi, betaIn, betaOut, pt_beta, zLo, zHi, zLoPointed, zHiPointed, sdlCut, betaOutCut;
float dPhi, betaIn, betaOut, pt_beta, zLo, zHi, zLoPointed, zHiPointed, dPhiCut, betaOutCut;

bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS);

Expand Down Expand Up @@ -1249,14 +1249,14 @@ namespace lst {

float drt_InSeg = rt_InOut - rt_InLo;

const float sdlThetaMulsF2 =
const float thetaMuls2 =
(kMulsInGeV * kMulsInGeV) * (0.1f + 0.2f * (rt_OutLo - rt_InUp) / 50.f) * (r3_InUp / rt_InUp);
const float sdlMuls2 = sdlThetaMulsF2 * 9.f / (ptCut * ptCut) * 16.f;
const float muls2 = thetaMuls2 * 9.f / (ptCut * ptCut) * 16.f;

float dzErr = (drt_OutLo_InUp * drt_OutLo_InUp) * (etaErr * etaErr) * cosh2Eta;
dzErr += 0.03f * 0.03f; // Approximately account for IT module size
dzErr *= 9.f; // 3 sigma
dzErr += sdlMuls2 * (drt_OutLo_InUp * drt_OutLo_InUp) / 3.f * cosh2Eta;
dzErr += muls2 * (drt_OutLo_InUp * drt_OutLo_InUp) / 3.f * cosh2Eta;
dzErr += zGeom * zGeom;
dzErr = alpaka::math::sqrt(acc, dzErr);

Expand All @@ -1272,8 +1272,8 @@ namespace lst {
if ((z_OutLo < zLoPointed) || (z_OutLo > zHiPointed))
return false;

const float sdlPVoff = 0.1f / rt_OutLo;
sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff);
const float pvOffset = 0.1f / rt_OutLo;
dPhiCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, muls2 + pvOffset * pvOffset);

//no dphipos cut
float midPointX = 0.5f * (x_InLo + x_OutLo);
Expand All @@ -1284,7 +1284,7 @@ namespace lst {

dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY);

if (alpaka::math::abs(acc, dPhi) > sdlCut)
if (alpaka::math::abs(acc, dPhi) > dPhiCut)
return false;

//lots of array accesses below this...
Expand Down Expand Up @@ -1380,7 +1380,7 @@ namespace lst {

float min_ptBeta_ptBetaMax = alpaka::math::min(
acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confirm the range-out value of 7 GeV
const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_ptBetaMax * min_ptBeta_ptBetaMax);
const float dBetaMuls2 = thetaMuls2 * 16.f / (min_ptBeta_ptBetaMax * min_ptBeta_ptBetaMax);
const float alphaInAbsReg =
alpaka::math::max(acc,
alpaka::math::abs(acc, alpha_InLo),
Expand Down Expand Up @@ -1442,7 +1442,7 @@ namespace lst {
unsigned int secondMDIndex,
unsigned int thirdMDIndex,
unsigned int fourthMDIndex) {
float dPhi, betaIn, betaOut, pt_beta, rtLo, rtHi, sdlCut, betaOutCut;
float dPhi, betaIn, betaOut, pt_beta, rtLo, rtHi, dPhiCut, betaOutCut;

bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS);

Expand Down Expand Up @@ -1484,9 +1484,8 @@ namespace lst {
float zpitch_OutLo = (isPS_OutLo ? kPixelPSZpitch : kStrip2SZpitch);
float zGeom = zpitch_InLo + zpitch_OutLo;

const float sdlSlope =
alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, kSinAlphaMax));
const float dzDrtScale = alpaka::math::tan(acc, sdlSlope) / sdlSlope; //FIXME: need approximate value
const float slope = alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, kSinAlphaMax));
const float dzDrtScale = alpaka::math::tan(acc, slope) / slope; //FIXME: need approximate value

const float dLum = alpaka::math::copysign(acc, kDeltaZLum, z_InUp);
bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS;
Expand All @@ -1511,14 +1510,14 @@ namespace lst {
const float cosh2Eta = 1.f + (pz * pz) / (ptIn * ptIn);
const float multDzDr2 = (dzOutInAbs * dzOutInAbs) * cosh2Eta / ((cosh2Eta - 1.f) * (cosh2Eta - 1.f));
const float r3_InUp = alpaka::math::sqrt(acc, z_InUp * z_InUp + rt_InUp * rt_InUp);
const float sdlThetaMulsF2 =
const float thetaMuls2 =
(kMulsInGeV * kMulsInGeV) * (0.1f + 0.2f * (rt_OutLo - rt_InUp) / 50.f) * (r3_InUp / rt_InUp);
const float sdlMuls2 = sdlThetaMulsF2 * 9.f / (ptCut * ptCut) * 16.f;
const float muls2 = thetaMuls2 * 9.f / (ptCut * ptCut) * 16.f;

float drtErr = (etaErr * etaErr) * multDzDr2;
drtErr += 0.03f * 0.03f; // Approximately account for IT module size
drtErr *= 9.f; // 3 sigma
drtErr += sdlMuls2 * multDzDr2 / 3.f * cosh2Eta;
drtErr += muls2 * multDzDr2 / 3.f * cosh2Eta;
drtErr = alpaka::math::sqrt(acc, drtErr);
const float drtDzIn = alpaka::math::abs(acc, ptIn / pz);

Expand All @@ -1537,8 +1536,8 @@ namespace lst {

const float alpha1GeV_OutLo =
alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, kSinAlphaMax));
const float sdlPVoff = 0.1f / rt_OutLo;
sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff);
const float pvOffset = 0.1f / rt_OutLo;
dPhiCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, muls2 + pvOffset * pvOffset);

float midPointX = 0.5f * (x_InLo + x_OutLo);
float midPointY = 0.5f * (y_InLo + y_OutLo);
Expand All @@ -1549,7 +1548,7 @@ namespace lst {
dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY);

// Cut #5: deltaPhiChange
if (alpaka::math::abs(acc, dPhi) > sdlCut)
if (alpaka::math::abs(acc, dPhi) > dPhiCut)
return false;

float alpha_InLo = __H2F(segmentsInGPU.dPhiChanges[innerSegmentIndex]);
Expand Down Expand Up @@ -1640,7 +1639,7 @@ namespace lst {

float min_ptBeta_ptBetaMax = alpaka::math::min(
acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confirm the range-out value of 7 GeV
const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_ptBetaMax * min_ptBeta_ptBetaMax);
const float dBetaMuls2 = thetaMuls2 * 16.f / (min_ptBeta_ptBetaMax * min_ptBeta_ptBetaMax);

const float alphaInAbsReg =
alpaka::math::max(acc,
Expand Down
Loading

0 comments on commit ecd8e3e

Please sign in to comment.