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

Primary vertex reconstruction: update configuration handling #43846

Merged
merged 1 commit into from
Feb 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
#include "Geometry/TrackerGeometryBuilder/interface/PixelTopologyMap.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "RecoVertex/PrimaryVertexProducer/interface/TrackFilterForPVFinding.h"
#include "RecoVertex/PrimaryVertexProducer/interface/HITrackFilterForPVFinding.h"
#include "RecoVertex/PrimaryVertexProducer/interface/DAClusterizerInZ_vect.h"
#include "RecoVertex/PrimaryVertexProducer/interface/DAClusterizerInZT_vect.h"
#include "RecoVertex/PrimaryVertexProducer/interface/GapClusterizerInZ.h"
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
Expand Down Expand Up @@ -3696,15 +3694,15 @@ void PrimaryVertexValidation::fillDescriptions(edm::ConfigurationDescriptions& d
// track filtering
edm::ParameterSetDescription psd0;
TrackFilterForPVFinding::fillPSetDescription(psd0);
HITrackFilterForPVFinding::fillPSetDescription(psd0); // HI only
psd0.add<int>("numTracksThreshold", 0); // HI only
desc.add<edm::ParameterSetDescription>("TkFilterParameters", psd0);

// PV Clusterization
{
edm::ParameterSetDescription psd0;
{
edm::ParameterSetDescription psd1;
DAClusterizerInZT_vect::fillPSetDescription(psd1);
DAClusterizerInZ_vect::fillPSetDescription(psd1);
psd0.add<edm::ParameterSetDescription>("TkDAClusParameters", psd1);

edm::ParameterSetDescription psd2;
Expand Down
11 changes: 6 additions & 5 deletions RecoHI/HiTracking/python/HIPixelAdaptiveVertex_cfi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FWCore.ParameterSet.Config as cms
import RecoVertex.PrimaryVertexProducer.primaryVertexProducer_cfi as _mod
from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices

hiPixelAdaptiveVertex = _mod.primaryVertexProducer.clone(
hiPixelAdaptiveVertex = offlinePrimaryVertices.clone(
verbose = False,
TkFilterParameters = dict(
algorithm = 'filterWithThreshold',
Expand All @@ -11,13 +11,12 @@
maxD0Significance = 3.0, ## keep most primary tracks (was 5.0)
minPt = 0.0, ## better for softish events
maxEta = 100.,
numTracksThreshold = 2
),
# label of tracks to be used
TrackLabel = "hiSelectedProtoTracks",
# clustering
TkClusParameters = dict(
algorithm = "gap",
TkClusParameters = cms.PSet(
algorithm = cms.string("gap"),
TkGapClusParameters = cms.PSet(
zSeparation = cms.double(1.0) ## 1 cm max separation between clusters
)
Expand All @@ -33,3 +32,5 @@
)
)
)

hiPixelAdaptiveVertex.TkFilterParameters.numTracksThreshold = cms.int32(2)
18 changes: 8 additions & 10 deletions RecoVertex/Configuration/python/RecoVertex_phase2_timing_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
from RecoVertex.Configuration.RecoVertex_cff import unsortedOfflinePrimaryVertices, trackWithVertexRefSelector, trackRefsForJets, sortedPrimaryVertices, offlinePrimaryVertices, offlinePrimaryVerticesWithBS,vertexrecoTask

unsortedOfflinePrimaryVertices4D = unsortedOfflinePrimaryVertices.clone(
TkClusParameters = dict(
algorithm = "DA2D_vect",
TkDAClusParameters = dict(
Tmin = 4.0,
Tpurge = 4.0,
Tstop = 2.0
),
TkClusParameters = cms.PSet(algorithm = cms.string("DA2D_vect"),
TkDAClusParameters = cms.PSet(
Tmin = cms.double(4.0),
Tpurge = cms.double(4.0),
Tstop = cms.double(2.0),
)
),
TrackTimesLabel = cms.InputTag("trackTimeValueMapProducer","generalTracksConfigurableFlatResolutionModel"),
TrackTimeResosLabel = cms.InputTag("trackTimeValueMapProducer","generalTracksConfigurableFlatResolutionModelResolution"),
vertexCollections = {0: dict(vertexTimeParameters = cms.PSet( algorithm = cms.string('legacy4D'))),
1: dict(vertexTimeParameters = cms.PSet( algorithm = cms.string('legacy4D')))}
)
)
trackWithVertexRefSelectorBeforeSorting4D = trackWithVertexRefSelector.clone(
vertexTag = "unsortedOfflinePrimaryVertices4D",
ptMax = 9e99,
Expand Down Expand Up @@ -68,8 +67,7 @@
from Configuration.Eras.Modifier_phase2_timing_layer_cff import phase2_timing_layer
phase2_timing_layer.toModify(tofPID, vtxsSrc='unsortedOfflinePrimaryVertices4D', vertexReassignment=False)
phase2_timing_layer.toModify(tofPID3D, vertexReassignment=False)
phase2_timing_layer.toModify(unsortedOfflinePrimaryVertices,
phase2_timing_layer.toModify(unsortedOfflinePrimaryVertices,
vertexCollections = {0: dict(vertexTimeParameters = cms.PSet( algorithm = cms.string('fromTracksPID'))),
1: dict(vertexTimeParameters = cms.PSet( algorithm = cms.string('fromTracksPID')))}
)

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class HITrackFilterForPVFinding : public TrackFilterForPVFinding {
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
TrackFilterForPVFinding::fillPSetDescription(desc);
desc.add<int>("numTracksThreshold", 0); // HI only
desc.add<int>("maxNumTracksThreshold", std::numeric_limits<int>::max());
desc.add<double>("minPtTight", 0.0);
Expand Down
22 changes: 14 additions & 8 deletions RecoVertex/PrimaryVertexProducer/plugins/PrimaryVertexProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ void PrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& des
desc.addUntracked<bool>("verbose", false);
{
edm::ParameterSetDescription psd0;
TrackFilterForPVFinding::fillPSetDescription(psd0);
HITrackFilterForPVFinding::fillPSetDescription(psd0); // HI only
HITrackFilterForPVFinding::fillPSetDescription(psd0); // extension of TrackFilterForPVFinding
desc.add<edm::ParameterSetDescription>("TkFilterParameters", psd0);
}
desc.add<edm::InputTag>("beamSpotLabel", edm::InputTag("offlineBeamSpot"));
Expand All @@ -435,14 +434,21 @@ void PrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& des
edm::ParameterSetDescription psd0;
{
edm::ParameterSetDescription psd1;
DAClusterizerInZT_vect::fillPSetDescription(psd1);
psd0.add<edm::ParameterSetDescription>("TkDAClusParameters", psd1);
DAClusterizerInZ_vect::fillPSetDescription(psd1);

edm::ParameterSetDescription psd2;
GapClusterizerInZ::fillPSetDescription(psd2);
psd0.add<edm::ParameterSetDescription>("TkGapClusParameters", psd2);
DAClusterizerInZT_vect::fillPSetDescription(psd2);

edm::ParameterSetDescription psd3;
GapClusterizerInZ::fillPSetDescription(psd3);

psd0.ifValue(
edm::ParameterDescription<std::string>("algorithm", "DA_vect", true),
"DA_vect" >> edm::ParameterDescription<edm::ParameterSetDescription>("TkDAClusParameters", psd1, true) or
"DA2D_vect" >>
edm::ParameterDescription<edm::ParameterSetDescription>("TkDAClusParameters", psd2, true) or
"gap" >> edm::ParameterDescription<edm::ParameterSetDescription>("TkGapClusParameters", psd3, true));
}
psd0.add<std::string>("algorithm", "DA_vect");
desc.add<edm::ParameterSetDescription>("TkClusParameters", psd0);
}

Expand All @@ -451,7 +457,7 @@ void PrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& des
desc.add<bool>("useMVACut", false);
desc.add<double>("minTrackTimeQuality", 0.8);

descriptions.add("primaryVertexProducer", desc);
descriptions.addDefault(desc);
Copy link
Contributor

@Martin-Grunewald Martin-Grunewald Mar 3, 2024

Choose a reason for hiding this comment

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

This change messes up ConfDB parsing because no explicit cfi file is generated. I assume descriptions.addWithDefaultLabel would work?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed by #44287

Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC this change was intedended @fabiocos FYI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Martin-Grunewald the whole point of the work behind this PR was to get rid of duplicated definitions of the PV configuration, already achieved in #43592 , without the need to carry forward in any case the complete configuration for all cases as it was in this PR, following the discussion #43592 (comment) .

From you action I understand that in ConfDB you do not only need an explicit definition of offlinePrimaryVertex, obviously granted by this PR, but also of primaryVertexProducer, am I correct? In this case keeping the construction of any other configuration from this latter, as it was in #43592 , was the appropriate thing. Your fix on top of this PR basically vanishes the goal, although I understand it is needed.

I need to verify whether the original target might be recovered in some way exploiting the new was in which the fillDescription is now written.

Copy link
Contributor

@Martin-Grunewald Martin-Grunewald Mar 3, 2024

Choose a reason for hiding this comment

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

@fabiocos
I think the only effect of changing from addDefault to addWithDefaultLabel is writing out a cfi file primaryVertexProducer_cfi.py in ../cfipython. Since such a file does not exist elsewhere in CMSSW nor is included/imported in any other cfi/cff/cfg file, this change should be safe as it does not change any behaviour. AFAIK addDefault does still enforce fillDescriptions (and supplies missing parameters), while for ConfDb parsing we need the full list of all possible top-level parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Martin-Grunewald it is not used now because I removed it form some configurations, but sooner or later it might come back, as it already happened. At this point I would like a confirmation that the alternative definitions of TkClusParameters I have put in fillDescritption is compatible with ConfDB needs. It defines three possible alternatives depending on the algortihm value, but just one is present by default in the output _cfi.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, is there in the IB integration a test where this issue can be possibly caught in time?

Copy link
Contributor

@Martin-Grunewald Martin-Grunewald Mar 4, 2024

Choose a reason for hiding this comment

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

We (only) need the full set of top-level parameters in the cfi file for ConfDb parsing, as those are fixed by ConfDb. Any parameters within PSets etc. we can freely change/add/remove. So any variant of TkClusParameters content in the cfi file should be fine for ConfDb parsing.
Of course, the parameters used at HLT would need to be those supposed to be used at HLT, but that is a manual thing to check and to adjust (if it is not the default value).
Unfortunately for the ConfDb issue/problems related to not having all top-level parameters in the cfi file, or no cfi file at all, there is no test.

}

//define this as a plug-in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FWCore.ParameterSet.Config as cms
import RecoVertex.PrimaryVertexProducer.primaryVertexProducer_cfi as _mod
from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices

pixelVertices = _mod.primaryVertexProducer.clone(
pixelVertices = offlinePrimaryVertices.clone(
TrackLabel = "pixelTracks",

TkFilterParameters = dict(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import FWCore.ParameterSet.Config as cms
import RecoVertex.PrimaryVertexProducer.primaryVertexProducer_cfi as _mod
from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices

offlinePrimaryVerticesFromCosmicTracks = _mod.primaryVertexProducer.clone(
offlinePrimaryVerticesFromCosmicTracks = offlinePrimaryVertices.clone(
TrackLabel = "ctfWithMaterialTracksP5",
beamSpotLabel = "offlineBeamSpot",

TkFilterParameters = dict(
maxNormalizedChi2 = 5.0,
minSiliconLayersWithHits = 7, ## hits > 7
Expand All @@ -15,11 +15,11 @@
minPixelLayersWithHits = 2, ## hits > 2
),

TkClusParameters = dict(
algorithm = "gap",
TkGapClusParameters = dict(
zSeparation = 0.1 ## 1 mm max separation betw. clusters
)
TkClusParameters = cms.PSet(
algorithm = cms.string("gap"),
TkGapClusParameters = cms.PSet(
zSeparation = cms.double(0.1) ## 1 mm max separation betw. clusters
)
),

vertexCollections = cms.VPSet(
Expand Down
109 changes: 88 additions & 21 deletions RecoVertex/PrimaryVertexProducer/python/OfflinePrimaryVertices_cfi.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,90 @@
import FWCore.ParameterSet.Config as cms

from RecoVertex.PrimaryVertexProducer.primaryVertexProducer_cfi import primaryVertexProducer
offlinePrimaryVertices = cms.EDProducer(
"PrimaryVertexProducer",

offlinePrimaryVertices = primaryVertexProducer.clone()
verbose = cms.untracked.bool(False),
TrackLabel = cms.InputTag("generalTracks"),
beamSpotLabel = cms.InputTag("offlineBeamSpot"),

DA_vectParameters = cms.PSet(primaryVertexProducer.TkClusParameters.clone())
TkFilterParameters = cms.PSet(
algorithm=cms.string('filter'),
maxNormalizedChi2 = cms.double(10.0),
minPixelLayersWithHits=cms.int32(2),
minSiliconLayersWithHits = cms.int32(5),
maxD0Significance = cms.double(4.0),
maxD0Error = cms.double(1.0),
maxDzError = cms.double(1.0),
minPt = cms.double(0.0),
maxEta = cms.double(2.4),
trackQuality = cms.string("any")
),

TkClusParameters = cms.PSet(
algorithm = cms.string("DA_vect"),
TkDAClusParameters = cms.PSet(
coolingFactor = cms.double(0.6), # moderate annealing speed
zrange = cms.double(4.), # consider only clusters within 4 sigma*sqrt(T) of a track
delta_highT = cms.double(1.e-2), # convergence requirement at high T
delta_lowT = cms.double(1.e-3), # convergence requirement at low T
convergence_mode = cms.int32(0), # 0 = two steps, 1 = dynamic with sqrt(T)
Tmin = cms.double(2.0), # end of vertex splitting
Tpurge = cms.double(2.0), # cleaning
Tstop = cms.double(0.5), # end of annealing
vertexSize = cms.double(0.006), # added in quadrature to track-z resolutions
d0CutOff = cms.double(3.), # downweight high IP tracks
dzCutOff = cms.double(3.), # outlier rejection after freeze-out (T<Tmin)
zmerge = cms.double(1e-2), # merge intermediat clusters separated by less than zmerge
uniquetrkweight = cms.double(0.8),# require at least two tracks with this weight at T=Tpurge
uniquetrkminp = cms.double(0.0), # minimal a priori track weight for counting unique tracks
runInBlocks = cms.bool(False), # activate the DA running in blocks of z sorted tracks
block_size = cms.uint32(10000), # block size in tracks
overlap_frac = cms.double(0.0) # overlap between consecutive blocks (blocks_size*overlap_frac)
)
),

vertexCollections = cms.VPSet(
[cms.PSet(label=cms.string(""),
algorithm=cms.string("AdaptiveVertexFitter"),
chi2cutoff = cms.double(2.5),
minNdof=cms.double(0.0),
useBeamConstraint = cms.bool(False),
maxDistanceToBeam = cms.double(1.0)
),
cms.PSet(label=cms.string("WithBS"),
algorithm = cms.string('AdaptiveVertexFitter'),
chi2cutoff = cms.double(2.5),
minNdof=cms.double(2.0),
useBeamConstraint = cms.bool(True),
maxDistanceToBeam = cms.double(1.0),
)
]
),

isRecoveryIteration = cms.bool(False),
recoveryVtxCollection = cms.InputTag("")


)

from Configuration.ProcessModifiers.vertexInBlocks_cff import vertexInBlocks
vertexInBlocks.toModify(offlinePrimaryVertices,
TkClusParameters = dict(
TkDAClusParameters = dict(
runInBlocks = True,
block_size = 128,
overlap_frac = 0.5
runInBlocks = True,
block_size = 128,
overlap_frac = 0.5
)
)
)

from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
(phase2_tracker & vertexInBlocks).toModify(offlinePrimaryVertices,
TkClusParameters = dict(
TkDAClusParameters = dict(
block_size = 512,
overlap_frac = 0.5)
)
TkClusParameters = dict(
TkDAClusParameters = dict(
block_size = 512,
overlap_frac = 0.5)
)
)

from Configuration.Eras.Modifier_highBetaStar_2018_cff import highBetaStar_2018
Expand All @@ -38,10 +99,12 @@
dzCutOff = 5.,
zmerge = 2.e-2,
uniquetrkweight = 0.9
)
)
)
)

DA_vectParameters = cms.PSet(offlinePrimaryVertices.TkClusParameters.clone())

from Configuration.ProcessModifiers.weightedVertexing_cff import weightedVertexing
weightedVertexing.toModify(offlinePrimaryVertices,
vertexCollections = cms.VPSet(
Expand Down Expand Up @@ -72,8 +135,8 @@


# higher eta cut for the phase 2 tracker
from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
phase2_tracker.toModify(offlinePrimaryVertices,
from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
phase2_tracker.toModify(offlinePrimaryVertices,
TkFilterParameters = dict(maxEta = 4.0))

from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017
Expand All @@ -82,33 +145,37 @@
TkFilterParameters = dict(
algorithm="filterWithThreshold",
maxD0Significance = 2.0,
maxD0Error = 10.0,
maxDzError = 10.0,
maxD0Error = 10.0,
maxDzError = 10.0,
minPixelLayersWithHits=3,
minPt = 0.7,
trackQuality = "highPurity",
numTracksThreshold = cms.int32(10),
maxNumTracksThreshold = cms.int32(1000),
minPtTight = cms.double(1.0)
),
TkClusParameters = dict(
algorithm = "gap"
TkClusParameters = cms.PSet(
algorithm = cms.string("gap"),
TkGapClusParameters = cms.PSet(
zSeparation = cms.double(1.0)
)
)
)

from Configuration.Eras.Modifier_highBetaStar_2018_cff import highBetaStar_2018
highBetaStar_2018.toModify(offlinePrimaryVertices,
TkFilterParameters = dict(
maxNormalizedChi2 = 80.0,
minPixelLayersWithHits = 1,
minSiliconLayersWithHits = 3,
maxD0Significance = 7.0,
maxD0Error = 10.0,
maxDzError = 10.0,
maxD0Error = 10.0,
maxDzError = 10.0,
maxEta = 2.5
),
vertexCollections = {
0: dict(chi2cutoff = 4.0, minNdof = -1.1),
1: dict(chi2cutoff = 4.0, minNdof = -2.0),
}
)

6 changes: 3 additions & 3 deletions Validation/RecoVertex/python/pvRecoSequence_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import *

# 2010-like PV reconstruction
import RecoVertex.PrimaryVertexProducer.primaryVertexProducer_cfi as _mod
offlinePrimaryVerticesGAP = _mod.primaryVertexProducer.clone(
from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
offlinePrimaryVerticesGAP = offlinePrimaryVertices.clone(
TrackLabel = "generalTracks", # label of tracks to be used
TkFilterParameters = dict(
maxNormalizedChi2 = 20.0, #
Expand Down Expand Up @@ -53,7 +53,7 @@
)
)

offlinePrimaryVerticesDA100um = _mod.primaryVertexProducer.clone(
offlinePrimaryVerticesDA100um = offlinePrimaryVertices.clone(
TrackLabel = "generalTracks",
TkFilterParameters = dict(
maxNormalizedChi2 = 20.0,
Expand Down