Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
get rid of unused maps, rename slopes to dxdy
Browse files Browse the repository at this point in the history
  • Loading branch information
GNiendorf committed Mar 8, 2024
1 parent 7e1d717 commit 5f0865d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19,337 deletions.
2 changes: 1 addition & 1 deletion SDL/Event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ SDL::modulesBuffer<alpaka::DevCpu>* SDL::Event::getFullModules() {
queue, modulesInCPUFull->moduleMap_buf, modulesBuffersES->moduleMap_buf, MAX_CONNECTED_MODULES * nModules);
alpaka::memcpy(queue, modulesInCPUFull->nConnectedModules_buf, modulesBuffersES->nConnectedModules_buf, nModules);
alpaka::memcpy(queue, modulesInCPUFull->drdzs_buf, modulesBuffersES->drdzs_buf, nModules);
alpaka::memcpy(queue, modulesInCPUFull->slopes_buf, modulesBuffersES->slopes_buf, nModules);
alpaka::memcpy(queue, modulesInCPUFull->dxdys_buf, modulesBuffersES->dxdys_buf, nModules);
alpaka::memcpy(queue, modulesInCPUFull->nLowerModules_buf, modulesBuffersES->nLowerModules_buf, 1);
alpaka::memcpy(queue, modulesInCPUFull->nModules_buf, modulesBuffersES->nModules_buf, 1);
alpaka::memcpy(queue, modulesInCPUFull->layers_buf, modulesBuffersES->layers_buf, nModules);
Expand Down
8 changes: 4 additions & 4 deletions SDL/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ namespace SDL {
mapIdx = alpaka::getPtrNative(modulesbuf.mapIdx_buf);
nConnectedModules = alpaka::getPtrNative(modulesbuf.nConnectedModules_buf);
drdzs = alpaka::getPtrNative(modulesbuf.drdzs_buf);
slopes = alpaka::getPtrNative(modulesbuf.slopes_buf);
slopes = alpaka::getPtrNative(modulesbuf.dxdys_buf);
nModules = alpaka::getPtrNative(modulesbuf.nModules_buf);
nLowerModules = alpaka::getPtrNative(modulesbuf.nLowerModules_buf);
partnerModuleIndices = alpaka::getPtrNative(modulesbuf.partnerModuleIndices_buf);
Expand Down Expand Up @@ -262,7 +262,7 @@ namespace SDL {
Buf<TDev, uint16_t> mapIdx_buf;
Buf<TDev, uint16_t> nConnectedModules_buf;
Buf<TDev, float> drdzs_buf;
Buf<TDev, float> slopes_buf;
Buf<TDev, float> dxdys_buf;
Buf<TDev, uint16_t> nModules_buf;
Buf<TDev, uint16_t> nLowerModules_buf;
Buf<TDev, uint16_t> partnerModuleIndices_buf;
Expand Down Expand Up @@ -291,7 +291,7 @@ namespace SDL {
mapIdx_buf(allocBufWrapper<uint16_t>(devAccIn, nMod)),
nConnectedModules_buf(allocBufWrapper<uint16_t>(devAccIn, nMod)),
drdzs_buf(allocBufWrapper<float>(devAccIn, nMod)),
slopes_buf(allocBufWrapper<float>(devAccIn, nMod)),
dxdys_buf(allocBufWrapper<float>(devAccIn, nMod)),
nModules_buf(allocBufWrapper<uint16_t>(devAccIn, 1)),
nLowerModules_buf(allocBufWrapper<uint16_t>(devAccIn, 1)),
partnerModuleIndices_buf(allocBufWrapper<uint16_t>(devAccIn, nMod)),
Expand Down Expand Up @@ -320,7 +320,7 @@ namespace SDL {
alpaka::memcpy(queue, mapIdx_buf, src.mapIdx_buf);
alpaka::memcpy(queue, nConnectedModules_buf, src.nConnectedModules_buf);
alpaka::memcpy(queue, drdzs_buf, src.drdzs_buf);
alpaka::memcpy(queue, slopes_buf, src.slopes_buf);
alpaka::memcpy(queue, dxdys_buf, src.dxdys_buf);
alpaka::memcpy(queue, nModules_buf, src.nModules_buf);
alpaka::memcpy(queue, nLowerModules_buf, src.nLowerModules_buf);
alpaka::memcpy(queue, partnerModuleIndices_buf, src.partnerModuleIndices_buf);
Expand Down
14 changes: 7 additions & 7 deletions SDL/ModuleMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace SDL {
auto isAnchor_buf = allocBufWrapper<bool>(devHost, nModules);
auto moduleType_buf = allocBufWrapper<ModuleType>(devHost, nModules);
auto moduleLayerType_buf = allocBufWrapper<ModuleLayerType>(devHost, nModules);
auto slopes_buf = allocBufWrapper<float>(devHost, nModules);
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);
Expand All @@ -294,7 +294,7 @@ namespace SDL {
bool* host_isAnchor = alpaka::getPtrNative(isAnchor_buf);
ModuleType* host_moduleType = alpaka::getPtrNative(moduleType_buf);
ModuleLayerType* host_moduleLayerType = alpaka::getPtrNative(moduleLayerType_buf);
float* host_slopes = alpaka::getPtrNative(slopes_buf);
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);
Expand Down Expand Up @@ -359,7 +359,7 @@ namespace SDL {
if (detId == 1) {
host_moduleType[index] = PixelModule;
host_moduleLayerType[index] = SDL::InnerPixelLayer;
host_slopes[index] = 0;
host_dxdys[index] = 0;
host_drdzs[index] = 0;
host_isAnchor[index] = false;
} else {
Expand All @@ -374,7 +374,7 @@ namespace SDL {
host_isAnchor[index] = false;
}

host_slopes[index] = (subdet == Endcap) ? endcapGeometry->getdxdy_slope(detId) : tiltedGeometry.getSlope(detId);
host_dxdys[index] = (subdet == Endcap) ? endcapGeometry->getdxdy_slope(detId) : tiltedGeometry.getDxDy(detId);
host_drdzs[index] = (subdet == Barrel) ? tiltedGeometry.getDrDz(detId) : 0;
}

Expand All @@ -393,8 +393,8 @@ namespace SDL {
if (host_drdzs[index] == 0) {
host_drdzs[index] = host_drdzs[host_partnerModuleIndices[index]];
}
if (host_slopes[index] == 0) {
host_slopes[index] = host_slopes[host_partnerModuleIndices[index]];
if (host_dxdys[index] == 0) {
host_dxdys[index] = host_dxdys[host_partnerModuleIndices[index]];
}
}
}
Expand All @@ -420,7 +420,7 @@ namespace SDL {
alpaka::memcpy(queue, modulesBuf->isInverted_buf, isInverted_buf);
alpaka::memcpy(queue, modulesBuf->isLower_buf, isLower_buf);
alpaka::memcpy(queue, modulesBuf->isAnchor_buf, isAnchor_buf);
alpaka::memcpy(queue, modulesBuf->slopes_buf, slopes_buf);
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);
Expand Down
19 changes: 9 additions & 10 deletions SDL/TiltedGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ SDL::TiltedGeometry::~TiltedGeometry() {}

void SDL::TiltedGeometry::load(std::string filename) {
drdzs_.clear();
slopes_.clear();
dxdys_.clear();

std::ifstream ifile;
ifile.open(filename.c_str());
std::string line;
std::ifstream ifile(filename);

std::string line;
while (std::getline(ifile, line)) {
unsigned int detid;
float drdz;
float slope;
float dxdy;

std::stringstream ss(line);

if (ss >> detid >> drdz >> slope) {
if (ss >> detid >> drdz >> dxdy) {
drdzs_[detid] = drdz;
slopes_[detid] = slope;
dxdys_[detid] = dxdy;
} else {
throw std::runtime_error("Failed to parse line: " + line);
}
Expand All @@ -40,9 +39,9 @@ float SDL::TiltedGeometry::getDrDz(unsigned int detid) {
}
}

float SDL::TiltedGeometry::getSlope(unsigned int detid) {
if (slopes_.find(detid) != slopes_.end()) {
return slopes_[detid];
float SDL::TiltedGeometry::getDxDy(unsigned int detid) {
if (dxdys_.find(detid) != dxdys_.end()) {
return dxdys_[detid];
} else {
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions SDL/TiltedGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
#include <fstream>
#include <sstream>
#include <string>
#include <stdexcept>

namespace SDL {
class TiltedGeometry {
private:
std::map<unsigned int, float> drdzs_;
std::map<unsigned int, float> slopes_;
std::map<unsigned int, float> drdzs_; // dr/dz slope
std::map<unsigned int, float> dxdys_; // dx/dy slope

public:
TiltedGeometry();
Expand All @@ -22,7 +23,7 @@ namespace SDL {
void load(std::string);

float getDrDz(unsigned int detid);
float getSlope(unsigned int detid);
float getDxDy(unsigned int detid);
};

extern TiltedGeometry tiltedGeometry;
Expand Down
Loading

0 comments on commit 5f0865d

Please sign in to comment.