Skip to content

Commit

Permalink
Merge pull request #46967 from SegmentLinking/CMSSW_14_2_0_pre4_workf…
Browse files Browse the repository at this point in the history
…lowsAndGeneralFunctions_squashed

Improvements to the LST workflows and small general LST fixes
  • Loading branch information
cmsbuild authored Dec 21, 2024
2 parents 6c30957 + 1ff4d57 commit 74198d8
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Configuration/PyReleaseValidation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The offsets currently in use are:
* 0.701: DisplacedRegionalStep tracking iteration for Run-3
* 0.702: trackingMkFit modifier for Phase-2 (initialStep only)
* 0.703: LST tracking (Phase-2 only), initialStep+HighPtTripletStep only, on CPU
* 0.704: LST tracking (Phase-2 only), initialStep+HighPtTripletStep only, on GPU
* 0.704: LST tracking (Phase-2 only), initialStep+HighPtTripletStep only, on GPU (if available)
* 0.75: HLT phase-2 timing menu
* 0.751: HLT phase-2 timing menu Alpaka variant
* 0.752: HLT phase-2 timing menu ticl_v5 variant
Expand Down
5 changes: 2 additions & 3 deletions Configuration/PyReleaseValidation/python/relval_Run4.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@
numWFIB.extend([32034.0]) #Run4D115
numWFIB.extend([32434.0]) #Run4D116

# Temporary placement for LST workflow to workaround PR conflicts - to be formatted and placed in an upcoming PR
numWFIB.extend([24834.703]) #Run4D98 LST tracking (initialStep+HighPtTripletStep only)

#Additional sample for short matrix and IB
#Default Phase-2 Det NoPU
numWFIB.extend([prefixDet+34.911]) #DD4hep XML
numWFIB.extend([prefixDet+34.702]) #mkFit tracking (initialStep)
numWFIB.extend([prefixDet+34.5]) #pixelTrackingOnly
numWFIB.extend([prefixDet+34.9]) #vector hits
numWFIB.extend([prefixDet+34.402]) #Alpaka local reconstruction offloaded on device (GPU if available)
numWFIB.extend([prefixDet+34.703]) #LST tracking on CPU (initialStep+HighPtTripletStep only)
numWFIB.extend([prefixDet+34.21]) #prodlike
numWFIB.extend([prefixDet+96.0]) #CloseByPGun CE_E_Front_120um
numWFIB.extend([prefixDet+100.0]) #CloseByPGun CE_H_Coarse_Scint
Expand All @@ -60,6 +58,7 @@
numWFIB.extend([prefixDet+234.21]) #prodlike PU
numWFIB.extend([prefixDet+234.9921]) #prodlike premix stage1+stage2
numWFIB.extend([prefixDet+234.114]) #PU, with 10% OT inefficiency
numWFIB.extend([prefixDet+234.703]) #LST tracking on CPU (initialStep+HighPtTripletStep only)
#
numWFIB.extend([24834.911]) #D98 XML, to monitor instability of DD4hep
for numWF in numWFIB:
Expand Down
6 changes: 2 additions & 4 deletions Configuration/PyReleaseValidation/python/relval_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@
13061.402,

# Run4, Alpaka-based noPU
29634.402, 29634.403, 29634.404, 29634.406,
29634.402, 29634.403, 29634.404, 29634.406, 29634.704,
29661.402,
# Run4, Alpaka-based noPU GPU LST tracking D98
24834.704,

# Run4, Alpaka-based PU
29834.402, 29834.403, 29834.404
29834.402, 29834.403, 29834.404, 29834.704
]

for numWF in numWFIB:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,9 @@ def setup__(self, step, stepName, stepDict, k, properties):
if 'Reco' in step: stepDict[stepName][k] = merge([self.step3, stepDict[step][k]])
elif 'HARVEST' in step: stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM'}, stepDict[step][k]])
elif 'ALCA' in step: stepDict[stepName][k] = None
def condition_(self, fragment, stepList, key, hasHarvest):
return ('Run4' in key)
def condition(self, fragment, stepList, key, hasHarvest):
result = (fragment=="TTbar_14TeV") and hasHarvest and ('Run4' in key)
return result
upgradeWFs['lstOnCPUIters01TrackingOnly'] = UpgradeWorkflow_lstOnCPUIters01TrackingOnly(
steps = [
'RecoGlobal',
Expand All @@ -508,7 +509,10 @@ def condition_(self, fragment, stepList, key, hasHarvest):
'ALCA',
'ALCAPhase2'
],
PU = [],
PU = [
'RecoGlobal',
'HARVESTGlobal',
],
suffix = '_lstOnCPUIters01TrackingOnly',
offset = 0.703,
)
Expand All @@ -517,14 +521,15 @@ def condition_(self, fragment, stepList, key, hasHarvest):
'--accelerators' : 'cpu'
}

# LST on GPU, initialStep+highPtTripletStep-only tracking-only
# LST on GPU (if available), initialStep+highPtTripletStep-only tracking-only
class UpgradeWorkflow_lstOnGPUIters01TrackingOnly(UpgradeWorkflowTracking):
def setup__(self, step, stepName, stepDict, k, properties):
if 'Reco' in step: stepDict[stepName][k] = merge([self.step3, stepDict[step][k]])
elif 'HARVEST' in step: stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM'}, stepDict[step][k]])
elif 'ALCA' in step: stepDict[stepName][k] = None
def condition_(self, fragment, stepList, key, hasHarvest):
return ('Run4' in key)
def condition(self, fragment, stepList, key, hasHarvest):
result = (fragment=="TTbar_14TeV") and hasHarvest and ('Run4' in key)
return result
upgradeWFs['lstOnGPUIters01TrackingOnly'] = UpgradeWorkflow_lstOnGPUIters01TrackingOnly(
steps = [
'RecoGlobal',
Expand All @@ -533,13 +538,15 @@ def condition_(self, fragment, stepList, key, hasHarvest):
'ALCA',
'ALCAPhase2'
],
PU = [],
PU = [
'RecoGlobal',
'HARVESTGlobal',
],
suffix = '_lstOnGPUIters01TrackingOnly',
offset = 0.704,
)
upgradeWFs['lstOnGPUIters01TrackingOnly'].step3 = upgradeWFs['trackingOnly'].step3 | {
'--procModifiers': 'trackingIters01,trackingLST',
'--accelerators' : 'gpu-*'
}

#DeepCore seeding for JetCore iteration workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ def _copyIfExists(mod, pset, name):
from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
seedingDeepCore.toReplaceWith(TrackSeedMonSequence,_seedingDeepCore_TrackSeedMonSequence)

from Configuration.ProcessModifiers.trackingLST_cff import trackingLST
trackingLST.toModify(locals()["TrackSeedMonhighPtTripletStep"],
SeedProducer = "lstPixelSeedInputProducer"
)

TrackingDQMSourceTier0 += TrackSeedMonSequence

from DQM.TrackingMonitorSource.shortTrackResolution_cff import *
Expand Down
3 changes: 2 additions & 1 deletion RecoTracker/LST/plugins/LSTOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet

LogDebug("LSTOutputConverter") << "done with conversion: Track candidate output size = " << outputpTC.size()
<< " (p* objects) + " << outputT5TC.size() << " (T5 objects)";
std::vector<SeedStopInfo> outputSeedStopInfo(pixelSeeds.size());
iEvent.emplace(trajectorySeedPutToken_, std::move(outputTS));
iEvent.emplace(trajectorySeedpLSPutToken_, std::move(outputpLSTS));
iEvent.emplace(trackCandidatePutToken_, std::move(outputTC));
Expand All @@ -267,7 +268,7 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
iEvent.emplace(trackCandidateNopLSTCPutToken_, std::move(outputNopLSTC));
iEvent.emplace(trackCandidatepTTCPutToken_, std::move(outputpTTC));
iEvent.emplace(trackCandidatepLSTCPutToken_, std::move(outputpLSTC));
iEvent.emplace(seedStopInfoPutToken_, 0U); //dummy stop info
iEvent.emplace(seedStopInfoPutToken_, std::move(outputSeedStopInfo)); //dummy stop info
}

DEFINE_FWK_MODULE(LSTOutputConverter);
1 change: 1 addition & 0 deletions RecoTracker/LSTCore/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="alpaka"/>
<use name="boost_header"/>
<use name="root"/>
<use name="FWCore/MessageLogger"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/Common.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef RecoTracker_LSTCore_interface_Common_h
#define RecoTracker_LSTCore_interface_Common_h

#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "DataFormats/Common/interface/StdArray.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

#if defined(FP16_Base)
#if defined ALPAKA_ACC_GPU_CUDA_ENABLED
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/interface/QuintupletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace lst {
SOA_COLUMN(bool, tightCutFlag), // tight pass to be a TC
SOA_COLUMN(bool, partOfPT5),
SOA_COLUMN(float, regressionRadius),
SOA_COLUMN(float, regressionG),
SOA_COLUMN(float, regressionF),
SOA_COLUMN(float, regressionCenterX),
SOA_COLUMN(float, regressionCenterY),
SOA_COLUMN(float, rzChiSquared), // r-z only chi2
SOA_COLUMN(float, chiSquared),
SOA_COLUMN(float, nonAnchorChiSquared),
Expand Down
6 changes: 6 additions & 0 deletions RecoTracker/LSTCore/interface/alpaka/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <numbers>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "RecoTracker/LSTCore/interface/Common.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
Expand All @@ -11,6 +12,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

Vec3D constexpr elementsPerThread(Vec3D::all(static_cast<Idx>(1)));

ALPAKA_FN_HOST ALPAKA_FN_INLINE void lstWarning(std::string warning) {
edm::LogWarning("LST") << warning;
return;
}

// Adjust grid and block sizes based on backend configuration
template <typename Vec, typename TAcc = Acc<typename Vec::Dim>>
ALPAKA_FN_HOST ALPAKA_FN_INLINE WorkDiv<typename Vec::Dim> createWorkDiv(const Vec& blocksPerGrid,
Expand Down
5 changes: 2 additions & 3 deletions RecoTracker/LSTCore/src/ModuleMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,8 @@ namespace lst {
host_moduleType[index] = (m_t == 25 ? lst::TwoS : lst::PS);
host_moduleLayerType[index] = (m_t == 23 ? lst::Pixel : lst::Strip);

if (host_moduleType[index] == lst::PS and host_moduleLayerType[index] == lst::Pixel) {
host_isAnchor[index] = true;
} else if (host_moduleType[index] == lst::TwoS and host_isLower[index]) {
if ((host_moduleType[index] == lst::PS and host_moduleLayerType[index] == lst::Pixel) ||
(host_moduleType[index] == lst::TwoS and host_isLower[index])) {
host_isAnchor[index] = true;
} else {
host_isAnchor[index] = false;
Expand Down
31 changes: 8 additions & 23 deletions RecoTracker/LSTCore/src/alpaka/Hit.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
return dPhi;
}

ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE int binary_search(const unsigned int* data, // Array that we are searching over
unsigned int search_val, // Value we want to find in data array
unsigned int ndata) // Number of elements in data array
{
unsigned int low = 0;
unsigned int high = ndata - 1;

while (low <= high) {
unsigned int mid = (low + high) / 2;
unsigned int test_val = data[mid];
if (test_val == search_val)
return mid;
else if (test_val > search_val)
high = mid - 1;
else
low = mid + 1;
}
// Couldn't find search value in array.
return -1;
}

struct ModuleRangesKernel {
template <typename TAcc>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
Expand Down Expand Up @@ -129,13 +108,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
((ihit_z > 0) - (ihit_z < 0)) *
alpaka::math::acosh(
acc, alpaka::math::sqrt(acc, ihit_x * ihit_x + ihit_y * ihit_y + ihit_z * ihit_z) / hits.rts()[ihit]);
int found_index = binary_search(modules.mapdetId(), iDetId, nModules);
auto found_pointer = std::lower_bound(modules.mapdetId(), modules.mapdetId() + nModules, iDetId);
int found_index = std::distance(modules.mapdetId(), found_pointer);
if (found_pointer == modules.mapdetId() + nModules)
found_index = -1;
uint16_t lastModuleIndex = modules.mapIdx()[found_index];

hits.moduleIndices()[ihit] = lastModuleIndex;

if (modules.subdets()[lastModuleIndex] == Endcap && modules.moduleType()[lastModuleIndex] == TwoS) {
found_index = binary_search(geoMapDetId, iDetId, nEndCapMap);
found_pointer = std::lower_bound(geoMapDetId, geoMapDetId + nEndCapMap, iDetId);
found_index = std::distance(geoMapDetId, found_pointer);
if (found_pointer == geoMapDetId + nEndCapMap)
found_index = -1;
float phi = geoMapPhi[found_index];
float cos_phi = alpaka::math::cos(acc, phi);
hits.highEdgeXs()[ihit] = ihit_x + 2.5f * cos_phi;
Expand Down
24 changes: 13 additions & 11 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ void LSTEvent::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndice
unsigned int size = ptIn.size();

if (size > n_max_pixel_segments_per_module) {
printf(
"*********************************************************\n"
"* Warning: Pixel line segments will be truncated. *\n"
"* You need to increase n_max_pixel_segments_per_module. *\n"
"*********************************************************\n");
lstWarning(
"\
*********************************************************\n\
* Warning: Pixel line segments will be truncated. *\n\
* You need to increase n_max_pixel_segments_per_module. *\n\
*********************************************************");
size = n_max_pixel_segments_per_module;
}

Expand Down Expand Up @@ -714,12 +715,13 @@ void LSTEvent::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets)
auto nTrackCandidatesT5 = *nTrackCanT5Host_buf.data();
if ((nTrackCandidatespT5 + nTrackCandidatespT3 + nTrackCandidatespLS == n_max_pixel_track_candidates) ||
(nTrackCandidatesT5 == n_max_nonpixel_track_candidates)) {
printf(
"****************************************************************************************************\n"
"* Warning: Track candidates were possibly truncated. *\n"
"* You may need to increase either n_max_pixel_track_candidates or n_max_nonpixel_track_candidates. *\n"
"* Run the code with the WARNINGS flag activated for more details. *\n"
"****************************************************************************************************\n");
lstWarning(
"\
****************************************************************************************************\n\
* Track candidates were possibly truncated. *\n\
* You may need to increase either n_max_pixel_track_candidates or n_max_nonpixel_track_candidates. *\n\
* Run the code with the WARNINGS flag activated for more details. *\n\
****************************************************************************************************");
}
}

Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
centerX = segmentsPixel.circleCenterX()[pixelSegmentArrayIndex];
centerY = segmentsPixel.circleCenterY()[pixelSegmentArrayIndex];

float T5CenterX = quintuplets.regressionG()[quintupletIndex];
float T5CenterY = quintuplets.regressionF()[quintupletIndex];
float T5CenterX = quintuplets.regressionCenterX()[quintupletIndex];
float T5CenterY = quintuplets.regressionCenterY()[quintupletIndex];
quintupletRadius = quintuplets.regressionRadius()[quintupletIndex];

rPhiChiSquared = computePT5RPhiChiSquared(acc, modules, lowerModuleIndices, centerX, centerY, pixelRadius, xs, ys);
Expand Down
Loading

0 comments on commit 74198d8

Please sign in to comment.