Skip to content
Merged
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
43 changes: 34 additions & 9 deletions DQM/TrackingMonitor/src/PrimaryVertexResolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace {
class PrimaryVertexResolution : public DQMEDAnalyzer {
public:
PrimaryVertexResolution(const edm::ParameterSet& iConfig);
~PrimaryVertexResolution() override;
~PrimaryVertexResolution() override = default;

void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
Expand All @@ -60,12 +60,15 @@ class PrimaryVertexResolution : public DQMEDAnalyzer {
const reco::BeamSpot& beamspot);

const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> ttbToken_;
edm::EDGetTokenT<reco::VertexCollection> vertexSrc_;
edm::EDGetTokenT<reco::BeamSpot> beamspotSrc_;
edm::EDGetTokenT<LumiScalersCollection> lumiScalersSrc_;
edm::EDGetTokenT<OnlineLuminosityRecord> metaDataSrc_;

const edm::InputTag vertexInputTag_;
const edm::EDGetTokenT<reco::VertexCollection> vertexSrc_;
const edm::EDGetTokenT<reco::BeamSpot> beamspotSrc_;
const edm::EDGetTokenT<LumiScalersCollection> lumiScalersSrc_;
const edm::EDGetTokenT<OnlineLuminosityRecord> metaDataSrc_;
const bool forceSCAL_;
std::string rootFolder_;
const std::string rootFolder_;
bool errorPrinted_;

AdaptiveVertexFitter fitter_;

Expand Down Expand Up @@ -327,19 +330,19 @@ class PrimaryVertexResolution : public DQMEDAnalyzer {

PrimaryVertexResolution::PrimaryVertexResolution(const edm::ParameterSet& iConfig)
: ttbToken_(esConsumes(edm::ESInputTag("", iConfig.getUntrackedParameter<std::string>("transientTrackBuilder")))),
vertexSrc_(consumes<reco::VertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("vertexSrc"))),
vertexInputTag_(iConfig.getUntrackedParameter<edm::InputTag>("vertexSrc")),
vertexSrc_(consumes<reco::VertexCollection>(vertexInputTag_)),
beamspotSrc_(consumes<reco::BeamSpot>(iConfig.getUntrackedParameter<edm::InputTag>("beamspotSrc"))),
lumiScalersSrc_(consumes<LumiScalersCollection>(iConfig.getUntrackedParameter<edm::InputTag>("lumiScalersSrc"))),
metaDataSrc_(consumes<OnlineLuminosityRecord>(iConfig.getUntrackedParameter<edm::InputTag>("metaDataSrc"))),
forceSCAL_(iConfig.getUntrackedParameter<bool>("forceSCAL")),
rootFolder_(iConfig.getUntrackedParameter<std::string>("rootFolder")),
errorPrinted_(false),
binningX_(iConfig),
binningY_(iConfig),
hPV_(binningX_, binningY_),
hOtherV_(binningX_, binningY_) {}

PrimaryVertexResolution::~PrimaryVertexResolution() {}

void PrimaryVertexResolution::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<edm::InputTag>("vertexSrc", edm::InputTag("trackingDQMgoodOfflinePrimaryVertices"));
Expand Down Expand Up @@ -399,6 +402,28 @@ void PrimaryVertexResolution::analyze(const edm::Event& iEvent, const edm::Event
if (vertices.empty())
return;

// check upfront that refs to track are (likely) to be valid
{
bool ok = true;
for (const auto& v : vertices) {
if (v.tracksSize() > 0) {
const auto& ref = v.trackRefAt(0);
if (ref.isNull() || !ref.isAvailable()) {
if (!errorPrinted_)
edm::LogWarning("PrimaryVertexResolution")
<< "Skipping vertex collection: " << vertexInputTag_
<< " since likely the track collection the vertex has refs pointing to is missing (at least the first "
"TrackBaseRef is null or not available)";
else
errorPrinted_ = true;
ok = false;
}
}
}
if (!ok)
return;
}

edm::Handle<reco::BeamSpot> hbeamspot = iEvent.getHandle(beamspotSrc_);
const reco::BeamSpot& beamspot = *hbeamspot;

Expand Down