From 7e32cc16f4644d86336f041fbfdebe390c1ce5a4 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 24 Mar 2021 18:27:07 +0100 Subject: [PATCH] address remaining static analyzer complaints in Validation/RecoTrack and Validation/RecoVertex --- .../plugins/JetCoreMCtruthSeedGenerator.cc | 2 +- .../RecoTrack/src/SiStripTrackingRecHitsValid.cc | 16 ++++++++++++++++ .../interface/TrackParameterAnalyzer.h | 4 ++-- .../src/AnotherPrimaryVertexAnalyzer.cc | 4 ++-- Validation/RecoVertex/src/BSvsPVAnalyzer.cc | 4 ++-- Validation/RecoVertex/src/BeamSpotAnalyzer.cc | 4 ++-- .../RecoVertex/src/BeamSpotHistogramMaker.cc | 4 +++- Validation/RecoVertex/src/V0Validator.cc | 6 ------ 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc b/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc index e153370563a78..9702a2a955eab 100644 --- a/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc +++ b/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc @@ -344,7 +344,7 @@ const GeomDet* JetCoreMCtruthSeedGenerator::DetectorSelector(int llay, auto localInter = det->specificSurface().toLocal((GlobalPoint)inter); if ((minDist == 0.0 || std::abs(localInter.x()) < minDist) && std::abs(localInter.y()) < 3.35) { minDist = std::abs(localInter.x()); - output = (GeomDet*)det; + output = const_cast(det); } } //detset return output; diff --git a/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc b/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc index 234fd3010b9a0..876e210240e71 100644 --- a/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc +++ b/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc @@ -1217,6 +1217,10 @@ void SiStripTrackingRecHitsValid::rechitanalysis_matched(LocalVector ldir, closest = &m; } } + + if (!closest) + return; + float closestX = closest->localPosition().x(); rechitpro.resx = rechitpro.x - closestX; rechitpro.resxMF = Mposition.x() - (topol.measurementPosition(closest->localPosition())).x(); @@ -1232,6 +1236,10 @@ void SiStripTrackingRecHitsValid::rechitanalysis_matched(LocalVector ldir, closest = &m; } } + + if (!closest) + return; + float closestX = closest->localPosition().x(); rechitpro.resx = rechitpro.x - closestX; rechitpro.resxMF = Mposition.x() - (topol.measurementPosition(closest->localPosition())).x(); @@ -1333,6 +1341,10 @@ void SiStripTrackingRecHitsValid::rechitanalysis(LocalVector ldir, closest = &m; } } + + if (!closest) + return; + float closestX = closest->localPosition().x(); rechitpro.resx = rechitpro.x - closestX; rechitpro.resxMF = Mposition.x() - (topol.measurementPosition(closest->localPosition())).x(); @@ -1349,6 +1361,10 @@ void SiStripTrackingRecHitsValid::rechitanalysis(LocalVector ldir, closest = &m; } } + + if (!closest) + return; + float closestX = closest->localPosition().x(); rechitpro.resx = rechitpro.x - closestX; rechitpro.resxMF = Mposition.x() - (topol.measurementPosition(closest->localPosition())).x(); diff --git a/Validation/RecoVertex/interface/TrackParameterAnalyzer.h b/Validation/RecoVertex/interface/TrackParameterAnalyzer.h index 18947f804db36..d4eebb2829be9 100644 --- a/Validation/RecoVertex/interface/TrackParameterAnalyzer.h +++ b/Validation/RecoVertex/interface/TrackParameterAnalyzer.h @@ -21,7 +21,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" // simulated vertex @@ -43,7 +43,7 @@ class TH2; // typedef reco::TrackBase::ParameterVector ParameterVector; -class TrackParameterAnalyzer : public edm::EDAnalyzer { +class TrackParameterAnalyzer : public edm::one::EDAnalyzer<> { public: explicit TrackParameterAnalyzer(const edm::ParameterSet&); ~TrackParameterAnalyzer() override; diff --git a/Validation/RecoVertex/src/AnotherPrimaryVertexAnalyzer.cc b/Validation/RecoVertex/src/AnotherPrimaryVertexAnalyzer.cc index 1436c3fcba2c3..89596c70fbb26 100644 --- a/Validation/RecoVertex/src/AnotherPrimaryVertexAnalyzer.cc +++ b/Validation/RecoVertex/src/AnotherPrimaryVertexAnalyzer.cc @@ -27,7 +27,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Run.h" @@ -47,7 +47,7 @@ // class decleration // -class AnotherPrimaryVertexAnalyzer : public edm::EDAnalyzer { +class AnotherPrimaryVertexAnalyzer : public edm::one::EDAnalyzer { public: explicit AnotherPrimaryVertexAnalyzer(const edm::ParameterSet&); ~AnotherPrimaryVertexAnalyzer() override; diff --git a/Validation/RecoVertex/src/BSvsPVAnalyzer.cc b/Validation/RecoVertex/src/BSvsPVAnalyzer.cc index 3a9955bab5046..eee2359f03426 100644 --- a/Validation/RecoVertex/src/BSvsPVAnalyzer.cc +++ b/Validation/RecoVertex/src/BSvsPVAnalyzer.cc @@ -27,7 +27,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Run.h" @@ -46,7 +46,7 @@ // class decleration // -class BSvsPVAnalyzer : public edm::EDAnalyzer { +class BSvsPVAnalyzer : public edm::one::EDAnalyzer { public: explicit BSvsPVAnalyzer(const edm::ParameterSet&); ~BSvsPVAnalyzer() override; diff --git a/Validation/RecoVertex/src/BeamSpotAnalyzer.cc b/Validation/RecoVertex/src/BeamSpotAnalyzer.cc index a0b54ac5cc40e..15fc97c50e9b3 100644 --- a/Validation/RecoVertex/src/BeamSpotAnalyzer.cc +++ b/Validation/RecoVertex/src/BeamSpotAnalyzer.cc @@ -26,7 +26,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Run.h" @@ -43,7 +43,7 @@ // class decleration // -class AnotherBeamSpotAnalyzer : public edm::EDAnalyzer { +class AnotherBeamSpotAnalyzer : public edm::one::EDAnalyzer { public: explicit AnotherBeamSpotAnalyzer(const edm::ParameterSet&); ~AnotherBeamSpotAnalyzer() override; diff --git a/Validation/RecoVertex/src/BeamSpotHistogramMaker.cc b/Validation/RecoVertex/src/BeamSpotHistogramMaker.cc index c3d55425b1c67..5ea45d79414cd 100644 --- a/Validation/RecoVertex/src/BeamSpotHistogramMaker.cc +++ b/Validation/RecoVertex/src/BeamSpotHistogramMaker.cc @@ -20,11 +20,13 @@ BeamSpotHistogramMaker::~BeamSpotHistogramMaker() { delete _currdir; } void BeamSpotHistogramMaker::book(const std::string dirname) { edm::Service tfserv; - TFileDirectory* currdir = &(tfserv->tFileDirectory()); + TFileDirectory* currdir; if (!dirname.empty()) { currdir = new TFileDirectory(tfserv->mkdir(dirname)); _currdir = currdir; + } else { + currdir = &(tfserv->tFileDirectory()); } edm::LogInfo("HistogramBooking") << "BeamSpot histogram booking in directory " << dirname; diff --git a/Validation/RecoVertex/src/V0Validator.cc b/Validation/RecoVertex/src/V0Validator.cc index 2d8e0eb41dda8..d9d3c8df5b304 100644 --- a/Validation/RecoVertex/src/V0Validator.cc +++ b/Validation/RecoVertex/src/V0Validator.cc @@ -385,12 +385,6 @@ void V0Validator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu using namespace edm; using namespace std; - // Get event setup info, B-field and tracker geometry - ESHandle bFieldHandle; - iSetup.get().get(bFieldHandle); - ESHandle globTkGeomHandle; - iSetup.get().get(globTkGeomHandle); - // Make matching collections Handle recotosimCollectionH; iEvent.getByToken(recoRecoToSimCollectionToken_, recotosimCollectionH);