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

Patatrack integration - Pixel vertex reconstruction (11/N) #31723

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ebe462b
Add new concurrent vertex algo (cms-patatrack#158)
VinInn Sep 12, 2018
2ac2da9
Disable vertex reconstruction on GPU (cms-patatrack#177)
fwyzard Sep 26, 2018
c0d30e4
Introduce Cluster Charge Cut, optimize Histogram (bucket sorting) (cm…
VinInn Sep 26, 2018
7fb964f
Migrate tracker local reconstruction and pixel tracking to Tasks (bac…
fwyzard Nov 28, 2018
b9029aa
Full workflow from raw data to pixel tracks and vertices on GPUs (cms…
VinInn Jan 8, 2019
bc77390
Skip CUDA-related tests if no GPU is present (cms-patatrack#252)
fwyzard Jan 17, 2019
2e22e5d
Various updates to pixel track/vertex DQM and MTV (cms-patatrack#285)
makortel Mar 15, 2019
93ebb23
Rework the GPU pixel track clusterizer and vertex finder (cms-patatra…
VinInn Feb 14, 2019
efab2db
Clean up by clang-format (cms-patatrack#338)
fwyzard May 14, 2019
5a55ac5
Synchronise with CMSSW_10_6_0
fwyzard May 15, 2019
a56cd9a
Port the whole pixel workflow to new heterogeneous framework (cms-pat…
VinInn Jul 5, 2019
9dc2a21
Move event and stream caches, and caching allocators out from CUDASer…
makortel Sep 10, 2019
9c4e8fb
Apply clang-format style formatting
fwyzard Sep 11, 2019
a6a7eaa
Synchronise with CMSSW_11_0_0_pre7
fwyzard Sep 12, 2019
87bf94d
Implement library-only wrappers for launching CUDA kernels (cms-patat…
fwyzard Oct 24, 2019
06c607a
Replace use of API wrapper stream and event with plain CUDA, part 1 (…
makortel Oct 26, 2019
7ef38e5
Replace CUDA API wrapper memory operations with native CUDA calls (cm…
waredjeb Oct 29, 2019
4550410
Synchronize event in the CUDAProductBase destructor (cms-patatrack#391)
makortel Oct 29, 2019
f51ed63
Replace use of CUDA API wrapper unique_ptrs with CUDAUtilities unique…
waredjeb Oct 31, 2019
f47b689
Synchronise with CMSSW_11_0_0_pre11
fwyzard Nov 4, 2019
1ab5beb
Replace cuda::device operations with native CUDA calls (cms-patatrack…
waredjeb Nov 26, 2019
4c02d33
Drop obsolete heterogenous framework (cms-patatrack#416)
fwyzard Nov 27, 2019
62b58ad
Synchronise with CMSSW_11_0_0_pre12
fwyzard Nov 28, 2019
ebace29
Synchronise with CMSSW_11_0_0_pre13
fwyzard Nov 30, 2019
27ac879
Rename exitSansCUDADevices to requireCUDADevices (cms-patatrack#423)
fwyzard Dec 2, 2019
012df14
Fix possible memory corruption in gpuVertexFinder (cms-patatrack#419)
VinInn Dec 3, 2019
e459d8c
Implement GPU vertex finder with a single kernel (cms-patatrack#413)
VinInn Dec 3, 2019
749793a
Apply code-format fixes (cms-patatrack#427)
fwyzard Dec 3, 2019
08cdb55
Implement changes from the CUDA framework review (cms-patatrack#429)
makortel Jan 17, 2020
94e9ef8
Synchronise with CMSSW_11_1_0_pre2
fwyzard Jan 27, 2020
5cdde61
Synchronise with CMSSW_11_1_0_pre4
fwyzard Mar 5, 2020
f1c358e
Integrate the comments from the upstream PRs (cms-patatrack#442)
fwyzard Mar 24, 2020
3edbb17
Synchronise with CMSSW_11_1_0_pre5
fwyzard Mar 26, 2020
b525042
Backport remove unneeded dependencies in Reco subsystems (#29295)
fwyzard Apr 6, 2020
f203d0d
Fix use of namespaces (cms-patatrack#446)
fwyzard Apr 7, 2020
1b7463a
Synchronise with CMSSW_11_1_0_pre7
fwyzard May 11, 2020
c6577b3
Fix max track size in vertex SoA (cms-patatrack#499)
VinInn Jul 7, 2020
0863f52
Backport: add ECAL-only and HCAL-only workflows for MC and data (#30350)
mariadalfonso Jun 5, 2020
8c29b60
Synchronise with CMSSW_11_2_0_pre2
fwyzard Jul 12, 2020
0f5e3c8
Update the validation sequence for pixel-only tracking workflows (cms…
sroychow Oct 12, 2020
5525ec1
Synchronise with CMSSW_11_2_0_pre8
fwyzard Oct 23, 2020
d5649dd
Synchronise with CMSSW_11_2_0_pre9
fwyzard Nov 16, 2020
c37f72d
Remove spurious empty lines
fwyzard Nov 26, 2020
bb28343
Simplify cudacompat layer to use a 1-dimensional grid (cms-patatrack#…
fwyzard Dec 1, 2020
af73ec9
Clean up the pixel local reconstruction code (cms-patatrack#593)
fwyzard Dec 18, 2020
8ffd775
Synchronise with CMSSW_11_3_0_pre5
fwyzard Mar 23, 2021
55fe4b3
Clean up the pixel track reconstruction code (cms-patatrack#606)
ericcano Mar 23, 2021
0cd8f94
Clean up the pixel vertex reconstruction code (cms-patatrack#609)
ericcano Mar 26, 2021
7fbcaa4
Synchronise with CMSSW_11_3_X
fwyzard Apr 1, 2021
545ddea
Add the vertex reconstruction to the Pixel SoA workflow on CPU
fwyzard Apr 1, 2021
a48c872
Address more review comments to the vertex finding code (cms-patatrac…
fwyzard Apr 6, 2021
0abda2e
Update include guards and include files in the pixel vertex reconstru…
fwyzard Apr 6, 2021
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
9 changes: 9 additions & 0 deletions CUDADataFormats/Vertex/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<use name="cuda"/>
<use name="eigen"/>
<use name="rootcore"/>
<use name="CUDADataFormats/Common"/>
<use name="DataFormats/Common"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
<export>
<lib name="1"/>
</export>
14 changes: 14 additions & 0 deletions CUDADataFormats/Vertex/interface/ZVertexHeterogeneous.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef CUDADataFormatsVertexZVertexHeterogeneous_H
#define CUDADataFormatsVertexZVertexHeterogeneous_H

#include "CUDADataFormats/Vertex/interface/ZVertexSoA.h"
#include "CUDADataFormats/Common/interface/HeterogeneousSoA.h"
#include "CUDADataFormats/Track/interface/PixelTrackHeterogeneous.h"

using ZVertexHeterogeneous = HeterogeneousSoA<ZVertexSoA>;
#ifndef __CUDACC__
#include "CUDADataFormats/Common/interface/Product.h"
using ZVertexCUDAProduct = cms::cuda::Product<ZVertexHeterogeneous>;
#endif

#endif
26 changes: 26 additions & 0 deletions CUDADataFormats/Vertex/interface/ZVertexSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef CUDADataFormats_Vertex_ZVertexSoA_h
#define CUDADataFormats_Vertex_ZVertexSoA_h

#include <cstdint>
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h"

// SOA for vertices
// These vertices are clusterized and fitted only along the beam line (z)
// to obtain their global coordinate the beam spot position shall be added (eventually correcting for the beam angle as well)
struct ZVertexSoA {
static constexpr uint32_t MAXTRACKS = 32 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enough for Phase2 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is NOT Phase2 ready (yet)

static constexpr uint32_t MAXVTX = 1024;

int16_t idv[MAXTRACKS]; // vertex index for each associated (original) track (-1 == not associate)
float zv[MAXVTX]; // output z-posistion of found vertices
float wv[MAXVTX]; // output weight (1/error^2) on the above
float chi2[MAXVTX]; // vertices chi2
float ptv2[MAXVTX]; // vertices pt^2
int32_t ndof[MAXTRACKS]; // vertices number of dof (reused as workspace for the number of nearest neighbours FIXME)
uint16_t sortInd[MAXVTX]; // sorted index (by pt2) ascending
uint32_t nvFinal; // the number of vertices

__host__ __device__ void init() { nvFinal = 0; }
};

#endif // CUDADataFormats_Vertex_ZVertexSoA_h
8 changes: 8 additions & 0 deletions CUDADataFormats/Vertex/src/classes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CUDADataFormats_Vertex_src_classes_h
#define CUDADataFormats_Vertex_src_classes_h

#include "CUDADataFormats/Vertex/interface/ZVertexHeterogeneous.h"
#include "CUDADataFormats/Common/interface/Product.h"
#include "DataFormats/Common/interface/Wrapper.h"

#endif // CUDADataFormats_Vertex_src_classes_h
6 changes: 6 additions & 0 deletions CUDADataFormats/Vertex/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<lcgdict>
<class name="cms::cuda::Product<ZVertexHeterogeneous>" persistent="false"/>
<class name="edm::Wrapper<ZVertexCUDAProduct>" persistent="false"/>
<class name="ZVertexHeterogeneous" persistent="false"/>
<class name="edm::Wrapper<ZVertexHeterogeneous>" persistent="false"/>
</lcgdict>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import FWCore.ParameterSet.Config as cms

from DQM.TrackingMonitorClient.primaryVertexResolutionClient_cfi import primaryVertexResolutionClient as _primaryVertexResolutionClient

pixelVertexResolutionClient = _primaryVertexResolutionClient.clone(
subDirs = ["OfflinePixelPV/Resolution/*"]
)
4 changes: 3 additions & 1 deletion DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
from DQM.CTPPS.ctppsDQM_cff import *
from Validation.RecoTau.DQMSequences_cfi import *
from DQM.TrackingMonitorClient.pixelTrackingEffFromHitPattern_cff import *
from DQM.TrackingMonitorClient.pixelVertexResolutionClient_cfi import *

DQMHarvestTrackerStrip = cms.Sequence ( SiStripOfflineDQMClient )

Expand Down Expand Up @@ -179,7 +180,8 @@
DQMHarvestTrackingZeroBias = cms.Sequence( TrackingOfflineDQMClientZeroBias *
dqmFastTimerServiceClient )

DQMHarvestPixelTracking = cms.Sequence( pixelTrackingEffFromHitPattern )
DQMHarvestPixelTracking = cms.Sequence( pixelTrackingEffFromHitPattern *
pixelVertexResolutionClient )

DQMHarvestOuterTracker = cms.Sequence(
OuterTrackerClient *
Expand Down
4 changes: 3 additions & 1 deletion DQMOffline/Configuration/python/DQMOffline_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@

#DQMOfflineCommon
from DQM.TrackingMonitorSource.pixelTracksMonitoring_cff import *
from DQMOffline.RecoB.PixelVertexMonitor_cff import *
from DQM.SiOuterTracker.OuterTrackerSourceConfig_cff import *
from Validation.RecoTau.DQMSequences_cfi import *

DQMOfflinePixelTracking = cms.Sequence( pixelTracksMonitoring )
DQMOfflinePixelTracking = cms.Sequence( pixelTracksMonitoring *
pixelPVMonitor )

DQMOuterTracker = cms.Sequence( DQMOfflineDCS *
OuterTrackerSource *
Expand Down
8 changes: 8 additions & 0 deletions DQMOffline/RecoB/python/PixelVertexMonitor_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import FWCore.ParameterSet.Config as cms

from DQMOffline.RecoB.PrimaryVertexMonitor_cff import pvMonitor as _pvMonitor
pixelPVMonitor = _pvMonitor.clone(
TopFolderName = "OfflinePixelPV",
vertexLabel = "pixelVertices",
ndof = cms.int32( 1 )
)
18 changes: 16 additions & 2 deletions RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@
#
# for STARTUP ONLY use try and use Offline 3D PV from pixelTracks, with adaptive vertex
#
#from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cff import *
from RecoVertex.PrimaryVertexProducer.OfflinePixel3DPrimaryVertices_cfi import *
from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cff import *
#from RecoVertex.PrimaryVertexProducer.OfflinePixel3DPrimaryVertices_cfi import *
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhm, this is probably not intended / wanted upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slava77 @jpata @mtosi @vmariani can you let me know if this change is OK ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • PixelVertexes_cff leads to a definition of pixelVertices = cms.EDProducer("PixelVertexProducer", with DivisiveVertexFinder
  • OfflinePixel3DPrimaryVertices_cfi defines pixelVertices = cms.EDProducer("PrimaryVertexProducer" with DA_vect algorithm

The switch to the latter happened in 2009 d61d086
Currently, the pixelVertices are not running in anything offline that's used for analysis/production.

IIUC, pixelVertexFromSoA is more representative of DivisiveVertexFinder (only Z is computed, x,y is set by the beamline).

So, for the purpose of comparing CPU and GPU variants, the update is perhaps OK.

It would be nice to have a confirmation from the TRK POG @mtosi @vmariani

recopixelvertexingTask = cms.Task(pixelTracksTask,pixelVertices)
recopixelvertexing = cms.Sequence(recopixelvertexingTask)

from Configuration.ProcessModifiers.gpu_cff import gpu

from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA
from RecoPixelVertexing.PixelVertexFinding.pixelVertexSoA_cfi import pixelVertexSoA
from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA

_pixelVertexingCUDATask = cms.Task(pixelTracksTask,pixelVertexCUDA,pixelVertexSoA,pixelVertices)

# pixelVertexSoAonCPU = pixelVertexCUDA.clone()
# pixelVertexSoAonCPU.onGPU = False;

gpu.toReplaceWith(pixelVertices,_pixelVertexFromSoA)
gpu.toReplaceWith(recopixelvertexingTask,_pixelVertexingCUDATask)
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ def customizePixelTracksSoAonCPU(process):
pixelRecHitSrc = 'siPixelRecHitsPreSplitting'
)

from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA
process.pixelVertexSoA = pixelVertexCUDA.clone(
onGPU = False,
pixelTrackSrc = 'pixelTrackSoA'
)

from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA
process.pixelTracks = pixelTrackProducerFromSoA.clone(
pixelRecHitLegacySrc = 'siPixelRecHitsPreSplitting'
)

process.reconstruction_step += process.siPixelRecHitsPreSplitting + process.pixelTrackSoA
from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA
process.pixelVertices = pixelVertexFromSoA.clone()

process.reconstruction_step += process.siPixelRecHitsPreSplitting + process.pixelTrackSoA + process.pixelVertexSoA

return process

Expand All @@ -46,7 +55,7 @@ def customizePixelTracksSoAonCPUForProfiling(process):

process.siPixelRecHitSoAFromLegacy.convertToLegacy = False

process.TkSoA = cms.Path(process.offlineBeamSpot + process.siPixelDigis + process.siPixelClustersPreSplitting + process.siPixelRecHitSoAFromLegacy + process.pixelTrackSoA)
process.TkSoA = cms.Path(process.offlineBeamSpot + process.siPixelDigis + process.siPixelClustersPreSplitting + process.siPixelRecHitSoAFromLegacy + process.pixelTrackSoA + process.pixelVertexSoA)

process.schedule = cms.Schedule(process.TkSoA)

Expand Down
86 changes: 86 additions & 0 deletions RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackDumpCUDA.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <cuda_runtime.h>

#include "CUDADataFormats/Common/interface/Product.h"
#include "CUDADataFormats/Track/interface/PixelTrackHeterogeneous.h"
#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h"
#include "CUDADataFormats/Vertex/interface/ZVertexHeterogeneous.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/RunningAverage.h"
#include "HeterogeneousCore/CUDACore/interface/ScopedContext.h"
#include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h"

class PixelTrackDumpCUDA : public edm::global::EDAnalyzer<> {
public:
explicit PixelTrackDumpCUDA(const edm::ParameterSet& iConfig);
~PixelTrackDumpCUDA() override = default;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void analyze(edm::StreamID streamID, edm::Event const& iEvent, const edm::EventSetup& iSetup) const override;
const bool m_onGPU;
edm::EDGetTokenT<cms::cuda::Product<PixelTrackHeterogeneous>> tokenGPUTrack_;
edm::EDGetTokenT<cms::cuda::Product<ZVertexHeterogeneous>> tokenGPUVertex_;
edm::EDGetTokenT<PixelTrackHeterogeneous> tokenSoATrack_;
edm::EDGetTokenT<ZVertexHeterogeneous> tokenSoAVertex_;
};

PixelTrackDumpCUDA::PixelTrackDumpCUDA(const edm::ParameterSet& iConfig)
: m_onGPU(iConfig.getParameter<bool>("onGPU")) {
if (m_onGPU) {
tokenGPUTrack_ =
consumes<cms::cuda::Product<PixelTrackHeterogeneous>>(iConfig.getParameter<edm::InputTag>("pixelTrackSrc"));
tokenGPUVertex_ =
consumes<cms::cuda::Product<ZVertexHeterogeneous>>(iConfig.getParameter<edm::InputTag>("pixelVertexSrc"));
} else {
tokenSoATrack_ = consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelTrackSrc"));
tokenSoAVertex_ = consumes<ZVertexHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelVertexSrc"));
}
}

void PixelTrackDumpCUDA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<bool>("onGPU", true);
desc.add<edm::InputTag>("pixelTrackSrc", edm::InputTag("caHitNtupletCUDA"));
desc.add<edm::InputTag>("pixelVertexSrc", edm::InputTag("pixelVertexCUDA"));
descriptions.add("pixelTrackDumpCUDA", desc);
}

void PixelTrackDumpCUDA::analyze(edm::StreamID streamID,
edm::Event const& iEvent,
const edm::EventSetup& iSetup) const {
if (m_onGPU) {
auto const& hTracks = iEvent.get(tokenGPUTrack_);
cms::cuda::ScopedContextProduce ctx{hTracks};

auto const& tracks = ctx.get(hTracks);
auto const* tsoa = tracks.get();
assert(tsoa);

auto const& vertices = ctx.get(iEvent.get(tokenGPUVertex_));
auto const* vsoa = vertices.get();
assert(vsoa);

} else {
auto const* tsoa = iEvent.get(tokenSoATrack_).get();
assert(tsoa);

auto const* vsoa = iEvent.get(tokenSoAVertex_).get();
assert(vsoa);
}
}

DEFINE_FWK_MODULE(PixelTrackDumpCUDA);
5 changes: 4 additions & 1 deletion RecoPixelVertexing/PixelVertexFinding/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<use name="CUDADataFormats/Vertex"/>
<use name="CommonTools/Clustering1D"/>
<use name="DataFormats/BeamSpot"/>
<use name="DataFormats/GeometryCommonDetAlgo"/>
Expand All @@ -15,10 +16,12 @@
<use name="FWCore/Utilities"/>
<use name="Geometry/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="HeterogeneousCore/CUDACore"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
<use name="RecoLocalTracker/ClusterParameterEstimator"/>
<use name="RecoLocalTracker/Records"/>
<use name="RecoPixelVertexing/PixelVertexFinding"/>
<use name="SimDataFormats/PileupSummaryInfo"/>
<library file="*.cc" name="RecoPixelVertexingPixelVertexFindingPlugins">
<library file="*.cc *.cu" name="RecoPixelVertexingPixelVertexFindingPlugins">
<flags EDM_PLUGIN="1"/>
</library>
Loading