diff --git a/RecoTracker/LSTCore/BuildFile.xml b/RecoTracker/LSTCore/BuildFile.xml index 45a3932180439..e06a5b6d684de 100644 --- a/RecoTracker/LSTCore/BuildFile.xml +++ b/RecoTracker/LSTCore/BuildFile.xml @@ -3,6 +3,7 @@ + diff --git a/RecoTracker/LSTCore/interface/Constants.h b/RecoTracker/LSTCore/interface/Constants.h new file mode 100644 index 0000000000000..b7e98ad32e1bc --- /dev/null +++ b/RecoTracker/LSTCore/interface/Constants.h @@ -0,0 +1,50 @@ +#ifndef RecoTracker_LSTCore_interface_Constants_h +#define RecoTracker_LSTCore_interface_Constants_h + + +namespace SDL { + +// 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; + + constexpr unsigned int N_MAX_PIXEL_SEGMENTS_PER_MODULE = 50000; + + constexpr unsigned int N_MAX_PIXEL_MD_PER_MODULES = 2 * N_MAX_PIXEL_SEGMENTS_PER_MODULE; + + constexpr unsigned int N_MAX_PIXEL_TRIPLETS = 5000; + constexpr unsigned int N_MAX_PIXEL_QUINTUPLETS = 15000; + + constexpr unsigned int N_MAX_PIXEL_TRACK_CANDIDATES = 30000; + constexpr unsigned int N_MAX_NONPIXEL_TRACK_CANDIDATES = 1000; + + constexpr unsigned int size_superbins = 45000; + + //defining the constant host device variables right up here + // Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future. + struct Params_pLS { + static constexpr int kLayers = 2, kHits = 4; + }; + struct Params_LS { + static constexpr int kLayers = 2, kHits = 4; + }; + struct Params_T3 { + static constexpr int kLayers = 3, kHits = 6; + }; + struct Params_pT3 { + static constexpr int kLayers = 5, kHits = 10; + }; + struct Params_T5 { + static constexpr int kLayers = 5, kHits = 10; + }; + struct Params_pT5 { + static constexpr int kLayers = 7, kHits = 14; + }; + +} //namespace SDL + +#endif diff --git a/RecoTracker/LSTCore/src/alpaka/EndcapGeometry.h b/RecoTracker/LSTCore/interface/EndcapGeometry.h similarity index 76% rename from RecoTracker/LSTCore/src/alpaka/EndcapGeometry.h rename to RecoTracker/LSTCore/interface/EndcapGeometry.h index 56b51aa8cb194..25d5315a61e7c 100644 --- a/RecoTracker/LSTCore/src/alpaka/EndcapGeometry.h +++ b/RecoTracker/LSTCore/interface/EndcapGeometry.h @@ -1,5 +1,5 @@ -#ifndef EndcapGeometry_h -#define EndcapGeometry_h +#ifndef RecoTracker_LSTCore_interface_EndcapGeometry_h +#define RecoTracker_LSTCore_interface_EndcapGeometry_h #include #include @@ -9,13 +9,8 @@ #include #include -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" - namespace SDL { - template - class EndcapGeometry; - template <> - class EndcapGeometry { + class EndcapGeometry { private: std::map dxdy_slope_; // dx/dy slope std::map centroid_phis_; // centroid phi diff --git a/RecoTracker/LSTCore/src/alpaka/ModuleConnectionMap.h b/RecoTracker/LSTCore/interface/ModuleConnectionMap.h similarity index 67% rename from RecoTracker/LSTCore/src/alpaka/ModuleConnectionMap.h rename to RecoTracker/LSTCore/interface/ModuleConnectionMap.h index aea59aa5c4ff0..3798690016c99 100644 --- a/RecoTracker/LSTCore/src/alpaka/ModuleConnectionMap.h +++ b/RecoTracker/LSTCore/interface/ModuleConnectionMap.h @@ -1,5 +1,5 @@ -#ifndef ModuleConnectionMap_h -#define ModuleConnectionMap_h +#ifndef RecoTracker_LSTCore_interface_ModuleConnectionMap_h +#define RecoTracker_LSTCore_interface_ModuleConnectionMap_h #include #include @@ -8,14 +8,8 @@ #include #include -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" - namespace SDL { - //FIXME: move to non-alpaka single arch build - template - class ModuleConnectionMap; - template <> - class ModuleConnectionMap { + class ModuleConnectionMap { private: std::map> moduleConnections_; @@ -32,7 +26,7 @@ namespace SDL { int size() const; }; - using MapPLStoLayer = std::array, 4>, 3>; + using MapPLStoLayer = std::array, 3>; } // namespace SDL #endif diff --git a/RecoTracker/LSTCore/src/alpaka/PixelMap.h b/RecoTracker/LSTCore/interface/PixelMap.h similarity index 78% rename from RecoTracker/LSTCore/src/alpaka/PixelMap.h rename to RecoTracker/LSTCore/interface/PixelMap.h index f81e58860af90..40d5bbbdfab84 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelMap.h +++ b/RecoTracker/LSTCore/interface/PixelMap.h @@ -1,14 +1,12 @@ -#ifndef PixelMap_h -#define PixelMap_h +#ifndef RecoTracker_LSTCore_interface_PixelMap_h +#define RecoTracker_LSTCore_interface_PixelMap_h #include #include -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/Constants.h" namespace SDL { - // PixelMap is never allocated on the device. - // This is also not passed to any of the kernels, so we can combine the structs. struct pixelMap { uint16_t pixelModuleIndex; diff --git a/RecoTracker/LSTCore/src/alpaka/TiltedGeometry.h b/RecoTracker/LSTCore/interface/TiltedGeometry.h similarity index 72% rename from RecoTracker/LSTCore/src/alpaka/TiltedGeometry.h rename to RecoTracker/LSTCore/interface/TiltedGeometry.h index 258e9333c17a3..5d565fe789af5 100644 --- a/RecoTracker/LSTCore/src/alpaka/TiltedGeometry.h +++ b/RecoTracker/LSTCore/interface/TiltedGeometry.h @@ -1,5 +1,5 @@ -#ifndef TiltedGeometry_h -#define TiltedGeometry_h +#ifndef RecoTracker_LSTCore_interface_TiltedGeometry_h +#define RecoTracker_LSTCore_interface_TiltedGeometry_h #include #include @@ -9,13 +9,8 @@ #include #include -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" - namespace SDL { - template - class TiltedGeometry; - template <> - class TiltedGeometry { + class TiltedGeometry { private: std::map drdzs_; // dr/dz slope std::map dxdys_; // dx/dy slope diff --git a/RecoTracker/LSTCore/interface/alpaka/Constants.h b/RecoTracker/LSTCore/interface/alpaka/Constants.h index 8ad42ce48ea7d..345cc7003831e 100644 --- a/RecoTracker/LSTCore/interface/alpaka/Constants.h +++ b/RecoTracker/LSTCore/interface/alpaka/Constants.h @@ -3,6 +3,7 @@ #include +#include "RecoTracker/LSTCore/interface/Constants.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" #ifdef CACHE_ALLOC @@ -99,47 +100,6 @@ namespace SDL { return WorkDiv(adjustedBlocks, adjustedThreads, elementsPerThreadArg); } -// 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; - - constexpr unsigned int N_MAX_PIXEL_SEGMENTS_PER_MODULE = 50000; - - constexpr unsigned int N_MAX_PIXEL_MD_PER_MODULES = 2 * N_MAX_PIXEL_SEGMENTS_PER_MODULE; - - constexpr unsigned int N_MAX_PIXEL_TRIPLETS = 5000; - constexpr unsigned int N_MAX_PIXEL_QUINTUPLETS = 15000; - - constexpr unsigned int N_MAX_PIXEL_TRACK_CANDIDATES = 30000; - constexpr unsigned int N_MAX_NONPIXEL_TRACK_CANDIDATES = 1000; - - constexpr unsigned int size_superbins = 45000; - - //defining the constant host device variables right up here - // Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future. - struct Params_pLS { - static constexpr int kLayers = 2, kHits = 4; - }; - struct Params_LS { - static constexpr int kLayers = 2, kHits = 4; - }; - struct Params_T3 { - static constexpr int kLayers = 3, kHits = 6; - }; - struct Params_pT3 { - static constexpr int kLayers = 5, kHits = 10; - }; - struct Params_T5 { - static constexpr int kLayers = 5, kHits = 10; - }; - struct Params_pT5 { - static constexpr int kLayers = 7, kHits = 14; - }; - // 15 MeV constant from the approximate Bethe-Bloch formula ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMulsInGeV = 0.015; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleBarrel[6] = { diff --git a/RecoTracker/LSTCore/src/alpaka/EndcapGeometry.dev.cc b/RecoTracker/LSTCore/src/EndcapGeometry.cc similarity index 80% rename from RecoTracker/LSTCore/src/alpaka/EndcapGeometry.dev.cc rename to RecoTracker/LSTCore/src/EndcapGeometry.cc index 6e185abda5973..db31121267703 100644 --- a/RecoTracker/LSTCore/src/alpaka/EndcapGeometry.dev.cc +++ b/RecoTracker/LSTCore/src/EndcapGeometry.cc @@ -1,8 +1,8 @@ -#include "EndcapGeometry.h" +#include "RecoTracker/LSTCore/interface/EndcapGeometry.h" -SDL::EndcapGeometry::EndcapGeometry(std::string filename) { load(filename); } +SDL::EndcapGeometry::EndcapGeometry(std::string filename) { load(filename); } -void SDL::EndcapGeometry::load(std::string filename) { +void SDL::EndcapGeometry::load(std::string filename) { dxdy_slope_.clear(); centroid_phis_.clear(); @@ -34,7 +34,7 @@ void SDL::EndcapGeometry::load(std::string filename) { fillGeoMapArraysExplicit(); } -void SDL::EndcapGeometry::fillGeoMapArraysExplicit() { +void SDL::EndcapGeometry::fillGeoMapArraysExplicit() { nEndCapMap = centroid_phis_.size(); geoMapDetId_buf.reserve(nEndCapMap); @@ -48,7 +48,7 @@ void SDL::EndcapGeometry::fillGeoMapArraysExplicit() { } } -float SDL::EndcapGeometry::getdxdy_slope(unsigned int detid) const { +float SDL::EndcapGeometry::getdxdy_slope(unsigned int detid) const { if (dxdy_slope_.find(detid) != dxdy_slope_.end()) { return dxdy_slope_.at(detid); } else { diff --git a/RecoTracker/LSTCore/src/alpaka/ModuleConnectionMap.dev.cc b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc similarity index 80% rename from RecoTracker/LSTCore/src/alpaka/ModuleConnectionMap.dev.cc rename to RecoTracker/LSTCore/src/ModuleConnectionMap.cc index 9a1ee2dedf52c..eddd87fcaa657 100644 --- a/RecoTracker/LSTCore/src/alpaka/ModuleConnectionMap.dev.cc +++ b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc @@ -1,12 +1,12 @@ -#include "ModuleConnectionMap.h" +#include "RecoTracker/LSTCore/interface/ModuleConnectionMap.h" -SDL::ModuleConnectionMap::ModuleConnectionMap() {} +SDL::ModuleConnectionMap::ModuleConnectionMap() {} -SDL::ModuleConnectionMap::ModuleConnectionMap(std::string filename) { load(filename); } +SDL::ModuleConnectionMap::ModuleConnectionMap(std::string filename) { load(filename); } -SDL::ModuleConnectionMap::~ModuleConnectionMap() {} +SDL::ModuleConnectionMap::~ModuleConnectionMap() {} -void SDL::ModuleConnectionMap::load(std::string filename) { +void SDL::ModuleConnectionMap::load(std::string filename) { moduleConnections_.clear(); std::ifstream ifile(filename, std::ios::binary); @@ -49,7 +49,7 @@ void SDL::ModuleConnectionMap::load(std::string filename) { } } -void SDL::ModuleConnectionMap::add(std::string filename) { +void SDL::ModuleConnectionMap::add(std::string filename) { std::ifstream ifile; ifile.open(filename.c_str()); std::string line; @@ -81,7 +81,7 @@ void SDL::ModuleConnectionMap::add(std::string filename) { } } -void SDL::ModuleConnectionMap::print() { +void SDL::ModuleConnectionMap::print() { std::cout << "Printing ModuleConnectionMap" << std::endl; for (auto& pair : moduleConnections_) { unsigned int detid = pair.first; @@ -93,9 +93,9 @@ void SDL::ModuleConnectionMap::print() { } } -const std::vector& SDL::ModuleConnectionMap::getConnectedModuleDetIds(unsigned int detid) const { +const std::vector& SDL::ModuleConnectionMap::getConnectedModuleDetIds(unsigned int detid) const { static const std::vector dummy; auto const mList = moduleConnections_.find(detid); return mList != moduleConnections_.end() ? mList->second : dummy; } -int SDL::ModuleConnectionMap::size() const { return moduleConnections_.size(); } +int SDL::ModuleConnectionMap::size() const { return moduleConnections_.size(); } diff --git a/RecoTracker/LSTCore/src/alpaka/TiltedGeometry.dev.cc b/RecoTracker/LSTCore/src/TiltedGeometry.cc similarity index 74% rename from RecoTracker/LSTCore/src/alpaka/TiltedGeometry.dev.cc rename to RecoTracker/LSTCore/src/TiltedGeometry.cc index 862155abeba65..564f1c8befeda 100644 --- a/RecoTracker/LSTCore/src/alpaka/TiltedGeometry.dev.cc +++ b/RecoTracker/LSTCore/src/TiltedGeometry.cc @@ -1,8 +1,8 @@ -#include "TiltedGeometry.h" +#include "RecoTracker/LSTCore/interface/TiltedGeometry.h" -SDL::TiltedGeometry::TiltedGeometry(std::string filename) { load(filename); } +SDL::TiltedGeometry::TiltedGeometry(std::string filename) { load(filename); } -void SDL::TiltedGeometry::load(std::string filename) { +void SDL::TiltedGeometry::load(std::string filename) { drdzs_.clear(); dxdys_.clear(); @@ -32,7 +32,7 @@ void SDL::TiltedGeometry::load(std::string filename) { } } -float SDL::TiltedGeometry::getDrDz(unsigned int detid) const { +float SDL::TiltedGeometry::getDrDz(unsigned int detid) const { if (drdzs_.find(detid) != drdzs_.end()) { return drdzs_.at(detid); } else { @@ -40,7 +40,7 @@ float SDL::TiltedGeometry::getDrDz(unsigned int detid) const { } } -float SDL::TiltedGeometry::getDxDy(unsigned int detid) const { +float SDL::TiltedGeometry::getDxDy(unsigned int detid) const { if (dxdys_.find(detid) != dxdys_.end()) { return dxdys_.at(detid); } else { diff --git a/RecoTracker/LSTCore/src/alpaka/LSTESData.dev.cc b/RecoTracker/LSTCore/src/alpaka/LSTESData.dev.cc index 6b635673837ae..a920f8e78a073 100644 --- a/RecoTracker/LSTCore/src/alpaka/LSTESData.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/LSTESData.dev.cc @@ -1,9 +1,9 @@ #include "RecoTracker/LSTCore/interface/alpaka/LSTESData.h" +#include "RecoTracker/LSTCore/interface/EndcapGeometry.h" +#include "RecoTracker/LSTCore/interface/ModuleConnectionMap.h" +#include "RecoTracker/LSTCore/interface/TiltedGeometry.h" +#include "RecoTracker/LSTCore/interface/PixelMap.h" -#include "EndcapGeometry.h" -#include "ModuleConnectionMap.h" -#include "TiltedGeometry.h" -#include "PixelMap.h" #include "ModuleMethods.h" namespace { @@ -40,9 +40,9 @@ namespace { } void loadMapsHost(SDL::MapPLStoLayer& pLStoLayer, - std::shared_ptr> endcapGeometry, - std::shared_ptr> tiltedGeometry, - std::shared_ptr> moduleConnectionMap) { + std::shared_ptr endcapGeometry, + std::shared_ptr tiltedGeometry, + std::shared_ptr moduleConnectionMap) { // Module orientation information (DrDz or phi angles) auto endcap_geom = get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin"); @@ -66,13 +66,13 @@ namespace { auto connectData = connects[i].data(); path = pLSMapDir + connectData + ".bin"; - pLStoLayer[0][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + pLStoLayer[0][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); path = pLSMapDir + "_pos" + connectData + ".bin"; - pLStoLayer[1][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + pLStoLayer[1][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); path = pLSMapDir + "_neg" + connectData + ".bin"; - pLStoLayer[2][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + pLStoLayer[2][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); } } } // namespace @@ -83,10 +83,10 @@ std::unique_ptr> SDL::loadAndFillESHost() { unsigned int nPixels; std::shared_ptr> modulesBuffers = nullptr; auto pLStoLayer = std::make_shared(); - auto endcapGeometry = std::make_shared>(); - auto tiltedGeometry = std::make_shared>(); + auto endcapGeometry = std::make_shared(); + auto tiltedGeometry = std::make_shared(); auto pixelMapping = std::make_shared(); - auto moduleConnectionMap = std::make_shared>(); + auto moduleConnectionMap = std::make_shared(); ::loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap); auto endcapGeometryBuffers = diff --git a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h index f6d15e6216010..beb618ab95cce 100644 --- a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h +++ b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h @@ -3,8 +3,8 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/Module.h" +#include "RecoTracker/LSTCore/interface/EndcapGeometry.h" -#include "EndcapGeometry.h" #include "Hit.h" namespace SDL { diff --git a/RecoTracker/LSTCore/src/alpaka/ModuleMethods.h b/RecoTracker/LSTCore/src/alpaka/ModuleMethods.h index 5d8b40bf3dda2..3a7a90f9dc706 100644 --- a/RecoTracker/LSTCore/src/alpaka/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/alpaka/ModuleMethods.h @@ -6,11 +6,10 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/Module.h" - -#include "TiltedGeometry.h" -#include "EndcapGeometry.h" -#include "ModuleConnectionMap.h" -#include "PixelMap.h" +#include "RecoTracker/LSTCore/interface/TiltedGeometry.h" +#include "RecoTracker/LSTCore/interface/EndcapGeometry.h" +#include "RecoTracker/LSTCore/interface/ModuleConnectionMap.h" +#include "RecoTracker/LSTCore/interface/PixelMap.h" #include "HeterogeneousCore/AlpakaInterface/interface/host.h" @@ -110,7 +109,7 @@ namespace SDL { unsigned int nMod, TQueue queue, struct ModuleMetaData& mmd, - const ModuleConnectionMap* moduleConnectionMap) { + const ModuleConnectionMap* moduleConnectionMap) { DevHost const& devHost = cms::alpakatools::host(); auto moduleMap_buf = allocBufWrapper(devHost, nMod * MAX_CONNECTED_MODULES); uint16_t* moduleMap = alpaka::getPtrNative(moduleMap_buf); @@ -226,9 +225,9 @@ namespace SDL { unsigned int& nPixels, std::shared_ptr>& modulesBuf, pixelMap* pixelMapping, - const EndcapGeometry* endcapGeometry, - const TiltedGeometry* tiltedGeometry, - const ModuleConnectionMap* moduleConnectionMap) { + const EndcapGeometry* endcapGeometry, + const TiltedGeometry* tiltedGeometry, + const ModuleConnectionMap* moduleConnectionMap) { ModuleMetaData mmd; loadCentroidsFromFile(moduleMetaDataFilePath, mmd, nModules); diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index 99be477d167c4..0530a6635851a 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -3,9 +3,9 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/Module.h" +#include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "NeuralNetwork.h" -#include "EndcapGeometry.h" #include "Segment.h" #include "MiniDoublet.h" #include "Hit.h" diff --git a/RecoTracker/LSTCore/src/alpaka/Segment.h b/RecoTracker/LSTCore/src/alpaka/Segment.h index 0acf2623b4675..d35d93aa1c395 100644 --- a/RecoTracker/LSTCore/src/alpaka/Segment.h +++ b/RecoTracker/LSTCore/src/alpaka/Segment.h @@ -3,8 +3,8 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/Module.h" +#include "RecoTracker/LSTCore/interface/EndcapGeometry.h" -#include "EndcapGeometry.h" #include "MiniDoublet.h" #include "Hit.h"