-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from all commits
ebe462b
2ac2da9
c0d30e4
7fb964f
b9029aa
bc77390
2e22e5d
93ebb23
efab2db
5a55ac5
a56cd9a
9dc2a21
9c4e8fb
a6a7eaa
87bf94d
06c607a
7ef38e5
4550410
f51ed63
f47b689
1ab5beb
4c02d33
62b58ad
ebace29
27ac879
012df14
e459d8c
749793a
08cdb55
94e9ef8
5cdde61
f1c358e
3edbb17
b525042
f203d0d
1b7463a
c6577b3
0863f52
8c29b60
0f5e3c8
5525ec1
d5649dd
c37f72d
bb28343
af73ec9
8ffd775
55fe4b3
0cd8f94
7fbcaa4
545ddea
a48c872
0abda2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> |
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 |
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; | ||
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 |
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 |
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/*"] | ||
) |
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 ) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mhm, this is probably not intended / wanted upstream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The switch to the latter happened in 2009 d61d086 IIUC, 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 |
---|---|---|
@@ -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); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)