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

Commit

Permalink
more descriptive variable names and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GNiendorf committed Mar 8, 2024
1 parent 4cbb861 commit 7e1d717
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
14 changes: 8 additions & 6 deletions SDL/EndcapGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SDL::EndcapGeometry::EndcapGeometry(std::string filename, unsigned int sizef)
SDL::EndcapGeometry::~EndcapGeometry() {}

void SDL::EndcapGeometry::load(std::string filename) {
sls_.clear();
dxdy_slope_.clear();
centroid_phis_.clear();

std::ifstream ifile(filename);
Expand All @@ -31,11 +31,13 @@ void SDL::EndcapGeometry::load(std::string filename) {
while (std::getline(ifile, line)) {
std::istringstream ss(line);
unsigned int detid;
float sl, cp;
float dxdy_slope, centroid_phi;

if (ss >> detid >> sl >> cp) {
sls_[detid] = sl;
centroid_phis_[detid] = cp;
if (ss >> detid >> dxdy_slope >> centroid_phi) {
dxdy_slope_[detid] = dxdy_slope;
centroid_phis_[detid] = centroid_phi;
} else {
throw std::runtime_error("Failed to parse line: " + line);
}
}

Expand Down Expand Up @@ -80,4 +82,4 @@ void SDL::EndcapGeometry::fillGeoMapArraysExplicit() {
alpaka::wait(queue);
}

float SDL::EndcapGeometry::getSlopeLower(unsigned int detid) { return sls_[detid]; }
float SDL::EndcapGeometry::getdxdy_slope(unsigned int detid) { return dxdy_slope_[detid]; }
7 changes: 3 additions & 4 deletions SDL/EndcapGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
#include <sstream>
#include <string>
#include <vector>
#include <stdexcept>

#include "Constants.h"

namespace SDL {
class EndcapGeometry {
private:
std::map<unsigned int, float> sls_; // lower slope
std::map<unsigned int, float> dxdy_slope_; // dx/dy slope
std::map<unsigned int, float> centroid_phis_; // centroid phi

public:
Expand All @@ -30,9 +31,7 @@ namespace SDL {

void fillGeoMapArraysExplicit();
void CreateGeoMapArraysExplicit();
float getAverageR2(unsigned int detid);
float getYInterceptLower(unsigned int detid);
float getSlopeLower(unsigned int detid);
float getdxdy_slope(unsigned int detid);
};
void freeEndcap();
extern EndcapGeometry* endcapGeometry;
Expand Down
2 changes: 1 addition & 1 deletion SDL/ModuleMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ namespace SDL {
host_isAnchor[index] = false;
}

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

Expand Down
10 changes: 6 additions & 4 deletions SDL/TiltedGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ void SDL::TiltedGeometry::load(std::string filename) {

std::stringstream ss(line);

ss >> detid >> drdz >> slope;

drdzs_[detid] = drdz;
slopes_[detid] = slope;
if (ss >> detid >> drdz >> slope) {
drdzs_[detid] = drdz;
slopes_[detid] = slope;
} else {
throw std::runtime_error("Failed to parse line: " + line);
}
}
}

Expand Down

0 comments on commit 7e1d717

Please sign in to comment.