Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
'keep recoCentrality_hiCentrality_*_*',
'keep int_centralityBin_*_*',
'keep recoHFFilterInfo_hiHFfilters_*_*',
'keep *_offlineSlimmedPrimaryVerticesRecovery_*_*',
'keep *_hiEvtPlane_*_*',
'keep *_hiEvtPlaneFlat_*_*'
]
Expand Down
5 changes: 5 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimming_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
from Configuration.ProcessModifiers.run2_miniAOD_pp_on_AA_103X_cff import run2_miniAOD_pp_on_AA_103X
run2_miniAOD_pp_on_AA_103X.toReplaceWith(slimmingTask,cms.Task(primaryVertexAssociationCleaned,slimmingTask.copy()))

from RecoHI.HiTracking.miniAODVertexRecovery_cff import offlinePrimaryVerticesRecovery, offlineSlimmedPrimaryVerticesRecovery
pp_on_AA_2018.toReplaceWith(
slimmingTask,
cms.Task(slimmingTask.copy(), offlinePrimaryVerticesRecovery, offlineSlimmedPrimaryVerticesRecovery))

from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing
_phase2_timing_slimmingTask = cms.Task(slimmingTask.copy(),
offlineSlimmedPrimaryVertices4D)
Expand Down
34 changes: 34 additions & 0 deletions RecoHI/HiTracking/python/miniAODVertexRecovery_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import FWCore.ParameterSet.Config as cms

from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices

offlinePrimaryVerticesRecovery = offlinePrimaryVertices.clone(

isRecoveryIteration = True,
recoveryVtxCollection = "offlinePrimaryVertices",

TkFilterParameters = dict(
maxNormalizedChi2 = 999.0,
minPixelLayersWithHits= 0,
minSiliconLayersWithHits = 0,
maxD0Significance = 999.0,
minPt = 0.0,
maxEta = 999.0,
trackQuality = "any"
),

TkClusParameters = dict(
algorithm = "gap",
TkGapClusParameters = cms.PSet(
zSeparation = cms.double(1.0)
)
),

vertexCollections = [offlinePrimaryVertices.vertexCollections[0].clone()]
)

from PhysicsTools.PatAlgos.slimming.offlineSlimmedPrimaryVertices_cfi import offlineSlimmedPrimaryVertices
offlineSlimmedPrimaryVerticesRecovery = offlineSlimmedPrimaryVertices.clone(
src = "offlinePrimaryVerticesRecovery",
score = None
)
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class PrimaryVertexProducer : public edm::stream::EDProducer<> {
edm::ParameterSet theConfig;
bool fVerbose;

bool fRecoveryIteration;
edm::EDGetTokenT<reco::VertexCollection> recoveryVtxToken;

edm::EDGetTokenT<reco::BeamSpot> bsToken;
edm::EDGetTokenT<reco::TrackCollection> trkToken;
edm::EDGetTokenT<edm::ValueMap<float> > trkTimesToken;
Expand Down
31 changes: 31 additions & 0 deletions RecoVertex/PrimaryVertexProducer/plugins/PrimaryVertexProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ PrimaryVertexProducer::PrimaryVertexProducer(const edm::ParameterSet& conf) : th
algorithms.push_back(algorithm);
produces<reco::VertexCollection>(algorithm.label);
}

//check if this is a recovery iteration
fRecoveryIteration = conf.getParameter<bool>("isRecoveryIteration");
if (fRecoveryIteration) {
if (algorithms.empty()) {
throw VertexException("PrimaryVertexProducerAlgorithm: No algorithm specified. ");
} else if (algorithms.size() > 1) {
throw VertexException(
"PrimaryVertexProducerAlgorithm: Running in Recovery mode and more than one algorithm specified. Please "
"only one algorithm.");
}
recoveryVtxToken = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("recoveryVtxCollection"));
}
}

PrimaryVertexProducer::~PrimaryVertexProducer() {
Expand Down Expand Up @@ -149,6 +162,22 @@ void PrimaryVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& i
edm::LogError("UnusableBeamSpot") << "Beamspot with invalid errors " << beamVertexState.error().matrix();
}

//if this is a recovery iteration, check if we already have a valid PV
if (fRecoveryIteration) {
auto const& oldVertices = iEvent.get(recoveryVtxToken);
//look for the first valid (not-BeamSpot) vertex
for (auto const& old : oldVertices) {
if (!(old.isFake())) {
//found a valid vertex, write the first one to the collection and return
//otherwise continue with regular vertexing procedure
auto result = std::make_unique<reco::VertexCollection>();
result->push_back(old);
iEvent.put(std::move(result), algorithms.begin()->label);
Copy link
Contributor

Choose a reason for hiding this comment

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

the same should be done for all available algorithms or there should be an assert in the constructor that only one algorithm exists if isRecoveryIteration is set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added an assert() in the constructor. For our purposes of event selection, we only need one algorithm run for the recovery.

return;
}
}
}

// get RECO tracks from the event
// `tks` can be used as a ptr to a reco::TrackCollection
edm::Handle<reco::TrackCollection> tks;
Expand Down Expand Up @@ -414,6 +443,8 @@ void PrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& des
psd0.add<std::string>("algorithm", "DA_vect");
desc.add<edm::ParameterSetDescription>("TkClusParameters", psd0);
}
desc.add<bool>("isRecoveryIteration", false);
desc.add<edm::InputTag>("recoveryVtxCollection", {""});

descriptions.add("primaryVertexProducer", desc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
maxDistanceToBeam = cms.double(1.0),
)
]
)

),

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


)
Expand Down