Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e36c573
Started implementing code in C++
ariostas Sep 16, 2025
9c72348
Finished with corners
ariostas Sep 17, 2025
0219a91
Added IO
ariostas Sep 17, 2025
7bac52c
Format
ariostas Sep 17, 2025
01e5f7d
Added centroid methods
ariostas Sep 17, 2025
6f5baf4
Added orientation methods
ariostas Sep 19, 2025
e30647c
Started implementing pixel maps
ariostas Sep 24, 2025
0c561d4
Finished with pixel maps
ariostas Sep 25, 2025
83f4f2e
Started implementing module maps
ariostas Sep 25, 2025
2477131
Some progress on module maps
ariostas Sep 26, 2025
5577697
Switched namespace to lstgeometry
ariostas Sep 26, 2025
048ec2b
A couple of fixes
ariostas Sep 26, 2025
650726e
Finished module maps
ariostas Sep 30, 2025
f61cbbf
Added standalone binary
ariostas Oct 21, 2025
1a336eb
Added a couple of outputs
ariostas Oct 21, 2025
54eca66
Write module maps
ariostas Oct 22, 2025
5a5f071
Some progress, but need to switch to gcc13
ariostas Oct 22, 2025
8c9cef1
Write pixel maps
ariostas Oct 22, 2025
52c7348
Fixed pixel maps
ariostas Oct 22, 2025
e1d8e33
Simplify pixel maps creation
ariostas Oct 27, 2025
7e14f20
Fixed straight line connections
ariostas Oct 27, 2025
d0ad743
Fixed curved line connections
ariostas Oct 28, 2025
7d92925
Format code
ariostas Oct 28, 2025
7db81b4
A bit of cleanup
ariostas Oct 31, 2025
3d144d8
Added eta-phi binning
ariostas Nov 3, 2025
a996ea4
format
ariostas Nov 3, 2025
a4770b6
Added cmssw scaffoling
ariostas Nov 6, 2025
539e085
Some progress getting required data
ariostas Nov 19, 2025
b5fb2de
Removed unused struct members
ariostas Nov 19, 2025
317653f
Everything mostly matches up now, but need to clean up
ariostas Nov 21, 2025
76dca60
Switched from mm to cm
ariostas Nov 24, 2025
6c74ad9
All CMSSW inputs work
ariostas Nov 24, 2025
d4dc0dc
Added LSTGeometry struct and moved constuctor to common place
ariostas Nov 25, 2025
057098a
Finished dump test
ariostas Dec 1, 2025
ed163cf
A few fixes
ariostas Dec 1, 2025
4bb1bad
Fixed orientations
ariostas Dec 2, 2025
84102a5
Adapted the LST ES producer
ariostas Dec 3, 2025
14afa6a
Fixed python file
ariostas Dec 3, 2025
d2682a7
Fixed typo
ariostas Dec 4, 2025
ffe91ba
Make pt cutoff selectable
ariostas Dec 5, 2025
6f64b0f
A bit of cleanup
ariostas Dec 5, 2025
2ababce
Fix typo
ariostas Dec 5, 2025
76ba095
Fix bug from original code
ariostas Dec 5, 2025
d609f43
Fix typo
ariostas Dec 5, 2025
dcf51e9
Fix typo
ariostas Dec 5, 2025
d860ac2
Fixed type issue
ariostas Dec 5, 2025
1df1a68
Remove kVerticalModuleSlope
ariostas Dec 8, 2025
1ea88fa
Minor cleanup
ariostas Dec 8, 2025
5d2a0e6
Add ptCut parameter to test
ariostas Dec 16, 2025
0517793
Add binary output option
ariostas Dec 17, 2025
6fb0015
Didn't actually need corner coordinates
ariostas Dec 17, 2025
9d306ca
Fixed sign of some angles
ariostas Dec 18, 2025
3d78e81
Merge branch 'master' into ariostas/lst_geometry
ariostas Dec 18, 2025
6697a68
Leave a note on how to match the csv files
ariostas Dec 19, 2025
a67a690
Figured out the sign
ariostas Dec 19, 2025
df1995c
Added cli options to test
ariostas Jan 6, 2026
1fba827
Tweak cmssw config
ariostas Jan 8, 2026
17744c5
Switch to numerical parameters
ariostas Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// LST includes
#include "RecoTracker/LSTCore/interface/alpaka/LST.h"
#include "RecoTracker/LSTCore/interface/LSTGeometry/LSTGeometry.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

Expand All @@ -14,22 +15,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

class LSTModulesDevESProducer : public ESProducer {
private:
std::string ptCutLabel_;
double ptCut_;
edm::ESGetToken<lstgeometry::LSTGeometry, TrackerRecoGeometryRecord> lstGeoToken_;

public:
LSTModulesDevESProducer(edm::ParameterSet const& iConfig)
: ESProducer(iConfig), ptCutLabel_(iConfig.getParameter<std::string>("ptCutLabel")) {
setWhatProduced(this, ptCutLabel_);
: ESProducer(iConfig), ptCut_(iConfig.getParameter<double>("ptCut")) {
auto cc = setWhatProduced(this, "LSTModuleMaps");
lstGeoToken_ = cc.consumes<lstgeometry::LSTGeometry>(edm::ESInputTag("", "LSTGeometry"));
}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("ptCutLabel", "0.8");
desc.add<double>("ptCut", 0.8);
descriptions.addWithDefaultLabel(desc);
}

std::unique_ptr<lst::LSTESData<DevHost>> produce(TrackerRecoGeometryRecord const& iRecord) {
return lst::loadAndFillESHost(ptCutLabel_);
const auto& lstg = iRecord.get(lstGeoToken_);
return lst::loadAndFillESHost(lstg);
}
};

Expand Down
5 changes: 2 additions & 3 deletions RecoTracker/LST/plugins/alpaka/LSTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
LSTProducer(edm::ParameterSet const& config)
: EDProducer(config),
lstInputToken_{consumes(config.getParameter<edm::InputTag>("lstInput"))},
lstESToken_{esConsumes(edm::ESInputTag("", config.getParameter<std::string>("ptCutLabel")))},
lstESToken_{esConsumes(edm::ESInputTag("", "LSTModuleMaps"))},
verbose_(config.getParameter<bool>("verbose")),
ptCut_(config.getParameter<double>("ptCut")),
clustSizeCut_(static_cast<uint16_t>(config.getParameter<uint32_t>("clustSizeCut"))),
Expand All @@ -42,7 +42,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

lst.run(iEvent.queue(),
verbose_,
static_cast<float>(ptCut_),
ptCut_,
clustSizeCut_,
&lstESDeviceData,
&lstInputDC,
Expand All @@ -60,7 +60,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
desc.add<bool>("verbose", false);
desc.add<double>("ptCut", 0.8);
desc.add<uint32_t>("clustSizeCut", 16);
desc.add<std::string>("ptCutLabel", "0.8");
desc.add<bool>("nopLSDupClean", false);
desc.add<bool>("tcpLSTriplets", false);
descriptions.addWithDefaultLabel(desc);
Expand Down
6 changes: 5 additions & 1 deletion RecoTracker/LST/python/lstProducerTask_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

from RecoTracker.LST.lstModulesDevESProducer_cfi import lstModulesDevESProducer

lstProducerTask = cms.Task(lstModulesDevESProducer, lstProducer)
from RecoTracker.LST.lstInputProducer_cfi import lstInputProducer

from RecoTracker.LSTCore.lstGeometryESProducer_cfi import lstGeometryESProducer

lstProducerTask = cms.Task(lstGeometryESProducer, lstModulesDevESProducer, lstInputProducer, lstProducer)
1 change: 1 addition & 0 deletions RecoTracker/LSTCore/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name="eigen"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
Expand Down
4 changes: 4 additions & 0 deletions RecoTracker/LSTCore/interface/EndcapGeometry.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoTracker_LSTCore_interface_EndcapGeometry_h
#define RecoTracker_LSTCore_interface_EndcapGeometry_h

#include "RecoTracker/LSTCore/interface/LSTGeometry/LSTGeometry.h"

#include <map>
#include <string>
#include <vector>
Expand All @@ -21,6 +23,8 @@ namespace lst {
EndcapGeometry(std::string const& filename);

void load(std::string const&);
void load(std::unordered_map<unsigned int, lstgeometry::SlopeData> const&,
std::unordered_map<unsigned int, lstgeometry::SensorInfo> const&);
void fillGeoMapArraysExplicit();
float getdxdy_slope(unsigned int detid) const;
};
Expand Down
2 changes: 2 additions & 0 deletions RecoTracker/LSTCore/interface/LSTESData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "RecoTracker/LSTCore/interface/EndcapGeometryDevHostCollection.h"
#include "RecoTracker/LSTCore/interface/ModulesHostCollection.h"
#include "RecoTracker/LSTCore/interface/PixelMap.h"
#include "RecoTracker/LSTCore/interface/LSTGeometry/LSTGeometry.h"

#include "HeterogeneousCore/AlpakaInterface/interface/CopyToDevice.h"

Expand Down Expand Up @@ -41,6 +42,7 @@ namespace lst {
};

std::unique_ptr<LSTESData<alpaka_common::DevHost>> loadAndFillESHost(std::string& ptCutLabel);
std::unique_ptr<LSTESData<alpaka_common::DevHost>> loadAndFillESHost(lstgeometry::LSTGeometry const& lstg);

} // namespace lst

Expand Down
15 changes: 15 additions & 0 deletions RecoTracker/LSTCore/interface/LSTGeometry/Centroid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef RecoTracker_LSTCore_interface_LSTGeometry_Centroid_h
#define RecoTracker_LSTCore_interface_LSTGeometry_Centroid_h

namespace lstgeometry {

struct Centroid {
unsigned int moduleType;
double x;
double y;
double z;
};

} // namespace lstgeometry

#endif
80 changes: 80 additions & 0 deletions RecoTracker/LSTCore/interface/LSTGeometry/CentroidMethods.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#ifndef RecoTracker_LSTCore_interface_LSTGeometry_CentroidMethods_h
#define RecoTracker_LSTCore_interface_LSTGeometry_CentroidMethods_h

#include <stdexcept>
#include <unordered_map>

#include "Common.h"
#include "RecoTracker/LSTCore/interface/LSTGeometry/Module.h"
#include "RecoTracker/LSTCore/interface/LSTGeometry/Centroid.h"
#include "RecoTracker/LSTCore/interface/LSTGeometry/SensorInfo.h"

namespace lstgeometry {

unsigned int extractBits(unsigned int value, unsigned int start, unsigned int end) {
unsigned int mask = (1 << (end - start + 1)) - 1;
return (value >> start) & mask;
}

unsigned int firstDigit(unsigned int n) {
while (n >= 10) {
n /= 10;
}
return n;
}

// TODO: refactor to use Module class better
int parseModuleType(unsigned int detId) {
// Check if the first digit of detId is '3' for inner tracker
if (firstDigit(detId) == 3)
return -1;

unsigned int subdet = extractBits(detId, 25, 27);
unsigned int layer = subdet == Module::SubDet::Barrel ? extractBits(detId, 20, 22) : extractBits(detId, 18, 20);
unsigned int ring = subdet == Module::SubDet::Endcap ? extractBits(detId, 12, 15) : 0;

bool is_even_det_id = detId % 2 == 0;
if (subdet == Module::SubDet::Barrel) {
if (layer <= 3)
return is_even_det_id ? Module::ModuleType::PSS : Module::ModuleType::PSP;
else
return Module::ModuleType::TwoS;
} else if (subdet == Module::SubDet::Endcap) {
if (layer <= 2)
return is_even_det_id && ring <= 10 ? Module::ModuleType::PSS
: (ring <= 10 ? Module::ModuleType::PSP : Module::ModuleType::TwoS);
else
return is_even_det_id && ring <= 7 ? Module::ModuleType::PSS
: (ring <= 7 ? Module::ModuleType::PSP : Module::ModuleType::TwoS);
} else {
throw std::runtime_error("Invalid subdetector type");
}
}

std::unordered_map<unsigned int, Centroid> computeCentroids(
std::unordered_map<unsigned int, SensorInfo> const& sensors) {
std::unordered_map<unsigned int, Centroid> centroids;
for (auto const& [detId, sensor] : sensors) {
int moduleType = parseModuleType(detId);

// Remove sensors from inner tracker
if (moduleType == -1) {
continue;
}

// Convert from mm to cm
double z = sensor.sensorCenterZ_cm;
double rho = sensor.sensorCenterRho_cm;
double phi = sensor.phi_rad;
double x = rho * cos(phi);
double y = rho * sin(phi);

Centroid centroid{static_cast<unsigned int>(moduleType), x, y, z};
centroids[detId] = centroid;
}
return centroids;
}

} // namespace lstgeometry

#endif
65 changes: 65 additions & 0 deletions RecoTracker/LSTCore/interface/LSTGeometry/Common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef RecoTracker_LSTCore_interface_LSTGeometry_Common_h
#define RecoTracker_LSTCore_interface_LSTGeometry_Common_h

#include <Eigen/Dense>
#include <limits>

namespace lstgeometry {

using MatrixD3x3 = Eigen::Matrix<double, 3, 3, Eigen::RowMajor>;
using MatrixD4x2 = Eigen::Matrix<double, 4, 2, Eigen::RowMajor>;
using MatrixD4x3 = Eigen::Matrix<double, 4, 3, Eigen::RowMajor>;
using MatrixD8x3 = Eigen::Matrix<double, 8, 3, Eigen::RowMajor>;
using MatrixDNx2 = Eigen::Matrix<double, Eigen::Dynamic, 2, Eigen::RowMajor>;
using MatrixDNx3 = Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor>;
using RowVectorD2 = Eigen::Matrix<double, 1, 2>;
using ColVectorD3 = Eigen::Matrix<double, 3, 1>;
using RowVectorD3 = Eigen::Matrix<double, 1, 3>;

// TODO: These should be moved to ../Common.h
constexpr double k2Rinv1GeVf = 0.00299792458;
constexpr double kB = 3.8112;

// For pixel maps
constexpr unsigned int kNEta = 25;
constexpr unsigned int kNPhi = 72;
constexpr unsigned int kNZ = 25;
constexpr std::array<double, 2> kPtBounds = {{2.0, 10'000.0}};

// This is defined as a constant in case the legacy value (123456789) needs to be used
double kDefaultSlope = std::numeric_limits<double>::infinity();

double degToRad(double degrees) { return degrees * (std::numbers::pi_v<double> / 180); }

double phi_mpi_pi(double phi) {
while (phi >= std::numbers::pi_v<double>)
phi -= 2 * std::numbers::pi_v<double>;
while (phi < -std::numbers::pi_v<double>)
phi += 2 * std::numbers::pi_v<double>;
return phi;
}

double roundAngle(double angle, double tol = 1e-3) {
const double pi = std::numbers::pi_v<double>;
if (std::fabs(angle) < tol) {
return 0.0;
} else if (std::fabs(angle - pi / 2) < tol) {
return pi / 2;
} else if (std::fabs(angle + pi / 2) < tol) {
return -pi / 2;
} else if (std::fabs(angle - pi) < tol || std::fabs(angle + pi) < tol) {
return -pi;
}
return angle;
}

double roundCoordinate(double coord, double tol = 1e-3) {
if (std::fabs(coord) < tol) {
return 0.0;
}
return coord;
}

} // namespace lstgeometry

#endif
Loading