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

[14.1.X] Miscellaneous backports to DQM/TrackingMonitorSource #46280

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
DQM/TrackingMonitorSource: add missing fillDescription parameters and…
… put early returns in case of missing input data in various plugins
mmusich committed Oct 1, 2024
commit 199548dfdc867040529a6e9364abdaf9d743801a
19 changes: 12 additions & 7 deletions DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc
Original file line number Diff line number Diff line change
@@ -387,11 +387,11 @@ void StandaloneTrackMonitor::fillDescriptions(edm::ConfigurationDescriptions& de
desc.addUntracked<bool>("haveAllHistograms", false);
desc.addUntracked<std::string>("puScaleFactorFile", "PileupScaleFactor.root");
desc.addUntracked<std::string>("trackScaleFactorFile", "PileupScaleFactor.root");
desc.addUntracked<std::vector<std::string> >("MVAProducers");
desc.addUntracked<edm::InputTag>("TrackProducerForMVA");
desc.addUntracked<std::vector<std::string> >("MVAProducers", {"initialStepClassifier1", "initialStepClassifier2"});
desc.addUntracked<edm::InputTag>("TrackProducerForMVA", edm::InputTag("initialStepTracks"));

desc.addUntracked<edm::InputTag>("TCProducer");
desc.addUntracked<std::string>("AlgoName");
desc.addUntracked<edm::InputTag>("TCProducer", edm::InputTag("initialStepTrackCandidates"));
desc.addUntracked<std::string>("AlgoName", "GenTk");
desc.addUntracked<bool>("verbose", false);

{
@@ -1315,7 +1315,8 @@ void StandaloneTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup c
edm::Handle<reco::VertexCollection> vertexColl;
iEvent.getByToken(vertexToken_, vertexColl);
if (!vertexColl.isValid()) {
edm::LogError("DqmTrackStudy") << "Error! Failed to get reco::Vertex Collection, " << vertexTag_;
edm::LogError("StandaloneTrackMonitor") << "Error! Failed to get reco::Vertex Collection, " << vertexTag_;
return;
}
if (vertexColl->empty()) {
edm::LogError("StandalonaTrackMonitor") << "No good vertex in the event!!" << std::endl;
@@ -1326,14 +1327,18 @@ void StandaloneTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup c
// Beam spot
edm::Handle<reco::BeamSpot> beamSpot;
iEvent.getByToken(bsToken_, beamSpot);
if (!beamSpot.isValid())
if (!beamSpot.isValid()) {
edm::LogError("StandalonaTrackMonitor") << "Beamspot for input tag: " << bsTag_ << " not found!!";
return;
}

// Track collection
edm::Handle<reco::TrackCollection> tracks;
iEvent.getByToken(trackToken_, tracks);
if (!tracks.isValid())
if (!tracks.isValid()) {
edm::LogError("StandalonaTrackMonitor") << "TrackCollection for input tag: " << trackTag_ << " not found!!";
return;
}

// Access PU information
double wfac = 1.0; // for data
7 changes: 7 additions & 0 deletions DQM/TrackingMonitorSource/plugins/TrackMultiplicityFilter.cc
Original file line number Diff line number Diff line change
@@ -62,6 +62,13 @@ bool TrackMultiplicityFilter::filter(edm::StreamID iStream, edm::Event& iEvent,
bool pass = false;
edm::Handle<reco::TrackCollection> tracks;
iEvent.getByToken(tracksToken_, tracks);

if (!tracks.isValid()) {
edm::LogError("TrackMultiplicityFilter")
<< "Error >> Failed to get TrackMultiplicityFilter for label: " << tracksTag_;
return false;
}

double count = std::count_if(tracks->begin(), tracks->end(), selector_);
pass = (count >= nmin_);

23 changes: 13 additions & 10 deletions DQM/TrackingMonitorSource/plugins/TtbarTrackProducer.cc
Original file line number Diff line number Diff line change
@@ -250,16 +250,19 @@ void TtbarTrackProducer::produce(edm::StreamID streamID, edm::Event& iEvent, edm

edm::Handle<reco::JetTagCollection> bTagHandle;
iEvent.getByToken(bjetsToken_, bTagHandle);
const reco::JetTagCollection& bTags = *(bTagHandle.product());
std::vector<TLorentzVector> list_bjets;

if (!bTags.empty()) {
for (unsigned bj = 0; bj != bTags.size(); ++bj) {
TLorentzVector lv_bjets;
lv_bjets.SetPtEtaPhiE(
bTags[bj].first->pt(), bTags[bj].first->eta(), bTags[bj].first->phi(), bTags[bj].first->energy());
if (bTags[bj].second > btagFactor_)
list_bjets.push_back(lv_bjets);

if (bTagHandle.isValid()) {
const reco::JetTagCollection& bTags = *(bTagHandle.product());
std::vector<TLorentzVector> list_bjets;

if (!bTags.empty()) {
for (unsigned bj = 0; bj != bTags.size(); ++bj) {
TLorentzVector lv_bjets;
lv_bjets.SetPtEtaPhiE(
bTags[bj].first->pt(), bTags[bj].first->eta(), bTags[bj].first->phi(), bTags[bj].first->energy());
if (bTags[bj].second > btagFactor_)
list_bjets.push_back(lv_bjets);
}
}
}

7 changes: 6 additions & 1 deletion DQM/TrackingMonitorSource/plugins/V0EventSelector.cc
Original file line number Diff line number Diff line change
@@ -37,9 +37,14 @@ V0EventSelector::V0EventSelector(const edm::ParameterSet& iConfig)
bool V0EventSelector::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::Handle<reco::VertexCompositeCandidateCollection> vccHandle;
iEvent.getByToken(vccToken_, vccHandle);

auto filteredVCC = std::make_unique<reco::VertexCompositeCandidateCollection>();

// early return if the input collection is empty
if (!vccHandle.isValid()) {
iEvent.put(std::move(filteredVCC));
return false;
}

for (const auto& vcc : *vccHandle) {
if (vcc.mass() >= massMin_ && vcc.mass() <= massMax_) {
filteredVCC->push_back(vcc);
11 changes: 6 additions & 5 deletions DQM/TrackingMonitorSource/plugins/ZEEDetails.cc
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ void ZEEDetails::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup
if (beamSpot.isValid()) {
trkd0 = -(trk->dxy(beamSpot->position()));
} else {
edm::LogError("ElectronTrackProducer") << "Error >> Failed to get BeamSpot for label: " << bsTag_;
edm::LogError("ZEEDetails") << "Error >> Failed to get BeamSpot for label: " << bsTag_;
}
if (std::fabs(trkd0) >= maxD0_)
continue;
@@ -261,16 +261,17 @@ void ZEEDetails::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup
finalelectrons.push_back(ele);
}
} else {
edm::LogError("ElectronTrackProducer") << "Error >> Failed to get ElectronCollection for label: " << electronTag_;
edm::LogError("ZEEDetails") << "Error >> Failed to get ElectronCollection for label: " << electronTag_;
}

edm::Handle<reco::VertexCollection> vertexColl;
iEvent.getByToken(vertexToken_, vertexColl);
if (!vertexColl.isValid()) {
edm::LogError("DqmTrackStudy") << "Error! Failed to get reco::Vertex Collection, " << vertexTag_;
edm::LogError("ZEEDetails") << "Error! Failed to get reco::Vertex Collection, " << vertexTag_;
return;
}
if (vertexColl->empty()) {
edm::LogError("DqmTrackStudy") << "No good vertex in the event!!";
edm::LogError("ZEEDetails") << "No good vertex in the event!!";
return;
}

@@ -294,7 +295,7 @@ void ZEEDetails::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup
}
}
} else
edm::LogError("DqmTrackStudy") << "PUSummary for input tag: " << puSummaryTag_ << " not found!!";
edm::LogError("ZEEDetails") << "PUSummary for input tag: " << puSummaryTag_ << " not found!!";
}

for (unsigned int I = 0; I != finalelectrons.size(); I++) {