Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime pT input + low pT occupancies (rebase PR39 and PR54) #130

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@
namespace ALPAKA_ACCELERATOR_NAMESPACE {

class LSTModulesDevESProducer : public ESProducer {
private:
std::string ptCutLabel_;

public:
LSTModulesDevESProducer(edm::ParameterSet const& iConfig) : ESProducer(iConfig) { setWhatProduced(this); }
LSTModulesDevESProducer(edm::ParameterSet const& iConfig)
: ESProducer(iConfig), ptCutLabel_(iConfig.getParameter<std::string>("ptCutLabel")) {
setWhatProduced(this, ptCutLabel_);
}

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

std::unique_ptr<lst::LSTESData<DevHost>> produce(TrackerRecoGeometryRecord const& iRecord) {
return lst::loadAndFillESHost();
return lst::loadAndFillESHost(ptCutLabel_);
}
};

Expand Down
11 changes: 9 additions & 2 deletions RecoTracker/LST/plugins/alpaka/LSTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
LSTProducer(edm::ParameterSet const& config)
: lstPixelSeedInputToken_{consumes(config.getParameter<edm::InputTag>("pixelSeedInput"))},
lstPhase2OTHitsInputToken_{consumes(config.getParameter<edm::InputTag>("phase2OTHitsInput"))},
lstESToken_{esConsumes()},
lstESToken_{esConsumes(edm::ESInputTag("", config.getParameter<std::string>("ptCutLabel")))},
verbose_(config.getParameter<bool>("verbose")),
ptCut_(config.getParameter<double>("ptCut")),
nopLSDupClean_(config.getParameter<bool>("nopLSDupClean")),
tcpLSTriplets_(config.getParameter<bool>("tcpLSTriplets")),
lstOutputToken_{produces()} {}
Expand All @@ -43,6 +44,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

lst_.run(event.queue(),
verbose_,
static_cast<float>(ptCut_),
&lstESDeviceData,
pixelSeeds.px(),
pixelSeeds.py(),
Expand Down Expand Up @@ -78,6 +80,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
desc.add<edm::InputTag>("pixelSeedInput", edm::InputTag{"lstPixelSeedInputProducer"});
desc.add<edm::InputTag>("phase2OTHitsInput", edm::InputTag{"lstPhase2OTHitsInputProducer"});
desc.add<bool>("verbose", false);
desc.add<double>("ptCut", 0.8);
desc.add<std::string>("ptCutLabel", "0.8");
desc.add<bool>("nopLSDupClean", false);
desc.add<bool>("tcpLSTriplets", false);
descriptions.addWithDefaultLabel(desc);
Expand All @@ -87,7 +91,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
edm::EDGetTokenT<LSTPixelSeedInput> lstPixelSeedInputToken_;
edm::EDGetTokenT<LSTPhase2OTHitsInput> lstPhase2OTHitsInputToken_;
device::ESGetToken<lst::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
const bool verbose_, nopLSDupClean_, tcpLSTriplets_;
const bool verbose_;
const double ptCut_;
const bool nopLSDupClean_;
const bool tcpLSTriplets_;
edm::EDPutTokenT<LSTOutput> lstOutputToken_;

lst::LST lst_;
Expand Down
1 change: 0 additions & 1 deletion RecoTracker/LSTCore/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<use name="boost_header"/>
<use name="root"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<flags CXXFLAGS="-DPT_CUT=0.8"/>
<use name="RecoTracker/LSTCore" for="alpaka"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
Expand Down
5 changes: 0 additions & 5 deletions RecoTracker/LSTCore/interface/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ namespace lst {
// Named types for LST objects
enum LSTObjType { T5 = 4, pT3 = 5, pT5 = 7, pLS = 8 };

// If a compile time flag does not define PT_CUT, default to 0.8 (GeV)
#ifndef PT_CUT
constexpr float PT_CUT = 0.8f;
#endif

constexpr unsigned int max_blocks = 80;
constexpr unsigned int max_connected_modules = 40;

Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/LSTESData.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace lst {
pixelMapping(pixelMappingIn) {}
};

std::unique_ptr<LSTESData<alpaka_common::DevHost>> loadAndFillESHost();
std::unique_ptr<LSTESData<alpaka_common::DevHost>> loadAndFillESHost(std::string& ptCutLabel);

} // namespace lst

Expand Down
1 change: 0 additions & 1 deletion RecoTracker/LSTCore/interface/alpaka/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float k2Rinv1GeVf = (2.99792458e-3 * 3.8) / 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kR1GeVf = 1. / (2.99792458e-3 * 3.8);
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kSinAlphaMax = 0.95;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float ptCut = PT_CUT;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kDeltaZLum = 15.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPixelPSZpitch = 0.15;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kStripPSZpitch = 2.4;
Expand Down
4 changes: 3 additions & 1 deletion RecoTracker/LSTCore/interface/alpaka/LST.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

void run(Queue& queue,
bool verbose,
const float ptCut,
LSTESData<Device> const* deviceESData,
std::vector<float> const& see_px,
std::vector<float> const& see_py,
Expand Down Expand Up @@ -63,7 +64,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
std::vector<unsigned int> const& ph2_detId,
std::vector<float> const& ph2_x,
std::vector<float> const& ph2_y,
std::vector<float> const& ph2_z);
std::vector<float> const& ph2_z,
const float ptCut);

void getOutput(LSTEvent& event);

Expand Down
25 changes: 13 additions & 12 deletions RecoTracker/LSTCore/src/LSTESData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@ namespace {
void loadMapsHost(lst::MapPLStoLayer& pLStoLayer,
lst::EndcapGeometry& endcapGeometry,
lst::TiltedGeometry& tiltedGeometry,
lst::ModuleConnectionMap& moduleConnectionMap) {
lst::ModuleConnectionMap& moduleConnectionMap,
std::string& ptCutLabel) {
// Module orientation information (DrDz or phi angles)
auto endcap_geom =
get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin");
auto tilted_geom = get_absolute_path_after_check_file_exists(
geometryDataDir() + "/data/OT800_IT615_pt0.8/tilted_barrel_orientation.bin");
auto endcap_geom = get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt" +
ptCutLabel + "/endcap_orientation.bin");
auto tilted_geom = get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt" +
ptCutLabel + "/tilted_barrel_orientation.bin");
// Module connection map (for line segment building)
auto mappath = get_absolute_path_after_check_file_exists(
geometryDataDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin");
auto mappath = get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt" + ptCutLabel +
"/module_connection_tracing_merged.bin");

endcapGeometry.load(endcap_geom);
tiltedGeometry.load(tilted_geom);
moduleConnectionMap.load(mappath);

auto pLSMapDir = geometryDataDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map";
auto pLSMapDir = geometryDataDir() + "/data/OT800_IT615_pt" + ptCutLabel + "/pixelmap/pLS_map";
const std::array<std::string, 4> connects{
{"_layer1_subdet5", "_layer2_subdet5", "_layer1_subdet4", "_layer2_subdet4"}};
std::string path;
Expand All @@ -78,7 +79,7 @@ namespace {
}
} // namespace

std::unique_ptr<lst::LSTESData<alpaka_common::DevHost>> lst::loadAndFillESHost() {
std::unique_ptr<lst::LSTESData<alpaka_common::DevHost>> lst::loadAndFillESHost(std::string& ptCutLabel) {
uint16_t nModules;
uint16_t nLowerModules;
unsigned int nPixels;
Expand All @@ -87,7 +88,7 @@ std::unique_ptr<lst::LSTESData<alpaka_common::DevHost>> lst::loadAndFillESHost()
TiltedGeometry tiltedGeometry;
PixelMap pixelMapping;
ModuleConnectionMap moduleConnectionMap;
::loadMapsHost(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);
::loadMapsHost(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap, ptCutLabel);

auto endcapGeometryDev =
std::make_shared<EndcapGeometryDevHostCollection>(endcapGeometry.nEndCapMap, cms::alpakatools::host());
Expand All @@ -98,8 +99,8 @@ std::unique_ptr<lst::LSTESData<alpaka_common::DevHost>> lst::loadAndFillESHost()
endcapGeometry.geoMapPhi_buf.data(),
endcapGeometry.nEndCapMap * sizeof(float));

auto path =
get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt0.8/sensor_centroids.bin");
auto path = get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt" + ptCutLabel +
"/sensor_centroids.bin");
auto modulesBuffers = lst::loadModulesFromFile(pLStoLayer,
path.c_str(),
nModules,
Expand Down
13 changes: 8 additions & 5 deletions RecoTracker/LSTCore/src/alpaka/LST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void LST::prepareInput(std::vector<float> const& see_px,
std::vector<unsigned int> const& ph2_detId,
std::vector<float> const& ph2_x,
std::vector<float> const& ph2_y,
std::vector<float> const& ph2_z) {
std::vector<float> const& ph2_z,
float const ptCut) {
in_trkX_.clear();
in_trkY_.clear();
in_trkZ_.clear();
Expand Down Expand Up @@ -132,7 +133,7 @@ void LST::prepareInput(std::vector<float> const& see_px,
float eta = p3LH.eta();
float ptErr = see_ptErr[iSeed];

if ((ptIn > 0.8 - 2 * ptErr)) {
if ((ptIn > ptCut - 2 * ptErr)) {
XYZVector r3LH(see_stateTrajGlbX[iSeed], see_stateTrajGlbY[iSeed], see_stateTrajGlbZ[iSeed]);
XYZVector p3PCA(see_px[iSeed], see_py[iSeed], see_pz[iSeed]);
XYZVector r3PCA(calculateR3FromPCA(p3PCA, see_dxy[iSeed], see_dz[iSeed]));
Expand All @@ -149,7 +150,7 @@ void LST::prepareInput(std::vector<float> const& see_px,

if (ptIn >= 2.0)
pixtype = PixelType::kHighPt;
else if (ptIn >= (0.8 - 2 * ptErr) and ptIn < 2.0) {
else if (ptIn >= (ptCut - 2 * ptErr) and ptIn < 2.0) {
if (pixelSegmentDeltaPhiChange >= 0)
pixtype = PixelType::kLowPtPosCurv;
else
Expand Down Expand Up @@ -255,6 +256,7 @@ void LST::getOutput(LSTEvent& event) {

void LST::run(Queue& queue,
bool verbose,
float const ptCut,
LSTESData<Device> const* deviceESData,
std::vector<float> const& see_px,
std::vector<float> const& see_py,
Expand All @@ -277,7 +279,7 @@ void LST::run(Queue& queue,
std::vector<float> const& ph2_z,
bool no_pls_dupclean,
bool tc_pls_triplets) {
auto event = LSTEvent(verbose, queue, deviceESData);
auto event = LSTEvent(verbose, ptCut, queue, deviceESData);
prepareInput(see_px,
see_py,
see_pz,
Expand All @@ -296,7 +298,8 @@ void LST::run(Queue& queue,
ph2_detId,
ph2_x,
ph2_y,
ph2_z);
ph2_z,
ptCut);

event.addHitToEvent(in_trkX_, in_trkY_, in_trkZ_, in_hitId_, in_hitIdxs_);
event.addPixelSegmentToEvent(in_hitIndices_vec0_,
Expand Down
33 changes: 22 additions & 11 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ void LSTEvent::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndice
createMDArrayRangesGPU_workDiv,
CreateMDArrayRangesGPU{},
modules_.const_view<ModulesSoA>(),
rangesDC_->view());
rangesDC_->view(),
ptCut_);

auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
auto nTotalMDs_buf_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalMDs());
Expand Down Expand Up @@ -233,7 +234,8 @@ void LSTEvent::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndice
CreateSegmentArrayRanges{},
modules_.const_view<ModulesSoA>(),
rangesDC_->view(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>());
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
ptCut_);

auto rangesOccupancy = rangesDC_->view();
auto nTotalSegments_view_h = cms::alpakatools::make_host_view(nTotalSegments_);
Expand Down Expand Up @@ -346,7 +348,8 @@ void LSTEvent::createMiniDoublets() {
createMDArrayRangesGPU_workDiv,
CreateMDArrayRangesGPU{},
modules_.const_view<ModulesSoA>(),
rangesDC_->view());
rangesDC_->view(),
ptCut_);

auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
auto nTotalMDs_buf_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalMDs());
Expand Down Expand Up @@ -381,7 +384,8 @@ void LSTEvent::createMiniDoublets() {
hitsDC_->const_view<HitsRangesSoA>(),
miniDoubletsDC_->view<MiniDoubletsSoA>(),
miniDoubletsDC_->view<MiniDoubletsOccupancySoA>(),
rangesDC_->const_view());
rangesDC_->const_view(),
ptCut_);

WorkDiv1D const addMiniDoubletRangesToEventExplicit_workDiv = createWorkDiv<Vec1D>({1}, {1024}, {1});

Expand Down Expand Up @@ -427,7 +431,8 @@ void LSTEvent::createSegmentsWithModuleMap() {
miniDoubletsDC_->const_view<MiniDoubletsOccupancySoA>(),
segmentsDC_->view<SegmentsSoA>(),
segmentsDC_->view<SegmentsOccupancySoA>(),
rangesDC_->const_view());
rangesDC_->const_view(),
ptCut_);

WorkDiv1D const addSegmentRangesToEventExplicit_workDiv = createWorkDiv<Vec1D>({1}, {1024}, {1});

Expand All @@ -452,7 +457,8 @@ void LSTEvent::createTriplets() {
CreateTripletArrayRanges{},
modules_.const_view<ModulesSoA>(),
rangesDC_->view(),
segmentsDC_->const_view<SegmentsOccupancySoA>());
segmentsDC_->const_view<SegmentsOccupancySoA>(),
ptCut_);

// TODO: Why are we pulling this back down only to put it back on the device in a new struct?
auto rangesOccupancy = rangesDC_->view();
Expand Down Expand Up @@ -537,7 +543,8 @@ void LSTEvent::createTriplets() {
tripletsDC_->view<TripletsOccupancySoA>(),
rangesDC_->const_view(),
index_gpu_buf.data(),
nonZeroModules);
nonZeroModules,
ptCut_);

WorkDiv1D const addTripletRangesToEventExplicit_workDiv = createWorkDiv<Vec1D>({1}, {1024}, {1});

Expand Down Expand Up @@ -822,7 +829,8 @@ void LSTEvent::createPixelTriplets() {
pixelTripletsDC_->view(),
connectedPixelSize_dev_buf.data(),
connectedPixelIndex_dev_buf.data(),
nInnerSegments);
nInnerSegments,
ptCut_);

#ifdef WARNINGS
auto nPixelTriplets_buf = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
Expand Down Expand Up @@ -853,7 +861,8 @@ void LSTEvent::createQuintuplets() {
CreateEligibleModulesListForQuintuplets{},
modules_.const_view<ModulesSoA>(),
tripletsDC_->const_view<TripletsOccupancySoA>(),
rangesDC_->view());
rangesDC_->view(),
ptCut_);

auto nEligibleT5Modules_buf = cms::alpakatools::make_host_buffer<uint16_t>(queue_);
auto nTotalQuintuplets_buf = cms::alpakatools::make_host_buffer<unsigned int>(queue_);
Expand Down Expand Up @@ -904,7 +913,8 @@ void LSTEvent::createQuintuplets() {
quintupletsDC_->view<QuintupletsSoA>(),
quintupletsDC_->view<QuintupletsOccupancySoA>(),
rangesDC_->const_view(),
nEligibleT5Modules);
nEligibleT5Modules,
ptCut_);

Vec3D const threadsPerBlockDupQuint{1, 16, 16};
Vec3D const blocksPerGridDupQuint{max_blocks, 1, 1};
Expand Down Expand Up @@ -1065,7 +1075,8 @@ void LSTEvent::createPixelQuintuplets() {
connectedPixelSize_dev_buf.data(),
connectedPixelIndex_dev_buf.data(),
nInnerSegments,
rangesDC_->const_view());
rangesDC_->const_view(),
ptCut_);

Vec3D const threadsPerBlockDupPix{1, 16, 16};
Vec3D const blocksPerGridDupPix{1, max_blocks, 1};
Expand Down
11 changes: 9 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
class LSTEvent {
private:
Queue& queue_;
const float ptCut_;

std::array<unsigned int, 6> n_minidoublets_by_layer_barrel_{};
std::array<unsigned int, 5> n_minidoublets_by_layer_endcap_{};
Expand Down Expand Up @@ -81,16 +82,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

public:
// Constructor used for CMSSW integration. Uses an external queue.
LSTEvent(bool verbose, Queue& q, const LSTESData<Device>* deviceESData)
LSTEvent(bool verbose, const float pt_cut, Queue& q, const LSTESData<Device>* deviceESData)
: queue_(q),
ptCut_(pt_cut),
nModules_(deviceESData->nModules),
nLowerModules_(deviceESData->nLowerModules),
nPixels_(deviceESData->nPixels),
nEndCapMap_(deviceESData->nEndCapMap),
modules_(*deviceESData->modules),
pixelMapping_(*deviceESData->pixelMapping),
endcapGeometry_(*deviceESData->endcapGeometry),
addObjects_(verbose) {}
addObjects_(verbose) {
if (pt_cut < 0.6f) {
throw std::invalid_argument("Minimum pT cut must be at least 0.6 GeV. Provided value: " +
std::to_string(pt_cut));
}
}
void initSync(); // synchronizes, for standalone usage
void resetEventSync(); // synchronizes, for standalone usage
void wait() const { alpaka::wait(queue_); }
Expand Down
Loading