Skip to content

Commit

Permalink
Merge pull request #46258 from smuzaffar/reconstruction-clang-ana-warn1
Browse files Browse the repository at this point in the history
[RECONSTRUCTION] [Clang]Cleanup clang-analyzer warnings
  • Loading branch information
cmsbuild authored Oct 8, 2024
2 parents c41f7e1 + 5af2b72 commit d4aca16
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 40 deletions.
11 changes: 3 additions & 8 deletions RecoJets/JetPlusTracks/plugins/JetPlusTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ void JetPlusTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS
auto pOut = std::make_unique<reco::JPTJetCollection>();
auto pOut1 = std::make_unique<reco::CaloJetCollection>();

double scaleJPT = 1.;
for (auto const& jet : iEvent.get(input_trackjets_token_)) {
int icalo = -1;
int i = 0;
Expand Down Expand Up @@ -152,8 +151,7 @@ void JetPlusTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS
jpt::MatchedTracks muons;
jpt::MatchedTracks elecs;

scaleJPT =
mJPTalgo->correction(corrected, mycalo, iEvent, iSetup, tracksinvert, tracksincalo, p4, pions, muons, elecs);
mJPTalgo->correction(corrected, mycalo, iEvent, iSetup, tracksinvert, tracksincalo, p4, pions, muons, elecs);
if (p4.pt() > ptCUT_) {
reco::JPTJet::Specific jptspe;
jptspe.pionsInVertexInCalo = pions.inVertexInCalo_;
Expand Down Expand Up @@ -184,9 +182,6 @@ void JetPlusTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS
factorZSP = mZSPalgo->correction(corrected, iEvent, iSetup);
corrected.scaleEnergy(factorZSP);

// JPT corrections
scaleJPT = 1.;

math::XYZTLorentzVector p4;

jpt::MatchedTracks pions;
Expand All @@ -195,13 +190,13 @@ void JetPlusTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS
bool validMatches = false;

if (!vectorial_) {
scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches);
double scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches);
p4 = math::XYZTLorentzVector(corrected.px() * scaleJPT,
corrected.py() * scaleJPT,
corrected.pz() * scaleJPT,
corrected.energy() * scaleJPT);
} else {
scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, p4, pions, muons, elecs, validMatches);
mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, p4, pions, muons, elecs, validMatches);
}

reco::JPTJet::Specific specific;
Expand Down
8 changes: 2 additions & 6 deletions RecoJets/JetPlusTracks/plugins/JetPlusTrackProducerAA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ void JetPlusTrackProducerAA::produce(edm::Event& iEvent, const edm::EventSetup&

corrected.scaleEnergy(factorZSP);

// JPT corrections

double scaleJPT = 1.;

math::XYZTLorentzVector p4;

// Construct JPTJet constituent
Expand All @@ -157,13 +153,13 @@ void JetPlusTrackProducerAA::produce(edm::Event& iEvent, const edm::EventSetup&
bool validMatches = false;

if (!vectorial_) {
scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches);
double scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches);
p4 = math::XYZTLorentzVector(corrected.px() * scaleJPT,
corrected.py() * scaleJPT,
corrected.pz() * scaleJPT,
corrected.energy() * scaleJPT);
} else {
scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, p4, pions, muons, elecs, validMatches);
mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, p4, pions, muons, elecs, validMatches);
}

reco::JPTJet::Specific specific;
Expand Down
4 changes: 3 additions & 1 deletion RecoJets/JetProducers/plugins/VirtualJetProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ void VirtualJetProducer::writeJets(edm::Event& iEvent, edm::EventSetup const& iS
// Here it is assumed that fjJets_ is in decreasing order of pT,
// which should happen in FastjetJetProducer::runAlgorithm()
jetArea = M_PI;
//rij is properly initialized above
[[clang::suppress]]
RIJ* distance = rij[ijet];
for (unsigned jJet = 0; jJet < ijet; ++jJet) {
distance[jJet].first = std::sqrt(reco::deltaR2(etaJ[ijet], phiJ[ijet], etaJ[jJet], phiJ[jJet])) * orParam_;
Expand All @@ -765,7 +767,7 @@ void VirtualJetProducer::writeJets(edm::Event& iEvent, edm::EventSetup const& iS
distance[kJet].second,
rij[jJet][kJet].second);
} // end loop over harder jets
} // end loop over harder jets
} // end loop over harder jets
jetArea *= (rParam_ * rParam_);
}
auto& jet = (*jets)[ijet];
Expand Down
1 change: 1 addition & 0 deletions RecoJets/JetProducers/src/PileupJetIdAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ PileupJetIdentifier PileupJetIdAlgo::computeIdVariables(const reco::Jet* jet,
for (unsigned i = 0; i < jet->numberOfSourceCandidatePtrs(); ++i) {
reco::CandidatePtr pfJetConstituent = jet->sourceCandidatePtr(i);
const reco::Candidate* icand = pfJetConstituent.get();
assert(icand);
const pat::PackedCandidate* lPack = dynamic_cast<const pat::PackedCandidate*>(icand);
const reco::PFCandidate* lPF = dynamic_cast<const reco::PFCandidate*>(icand);
bool isPacked = true;
Expand Down
23 changes: 7 additions & 16 deletions RecoMET/METAlgorithms/src/SignAlgoResolutions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//
//
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
Expand Down Expand Up @@ -384,22 +385,12 @@ void metsig::SignAlgoResolutions::initializeJetResolutions(const edm::ParameterS
if (ptResol_ == nullptr) {
string resolutionsAlgo = iConfig.getParameter<std::string>("resolutionsAlgo");
string resolutionsEra = iConfig.getParameter<std::string>("resolutionsEra");

string cmssw_base(std::getenv("CMSSW_BASE"));
string cmssw_release_base(std::getenv("CMSSW_RELEASE_BASE"));
string path = cmssw_base + "/src/CondFormats/JetMETObjects/data";
struct stat st;
if (stat(path.c_str(), &st) != 0) {
path = cmssw_release_base + "/src/CondFormats/JetMETObjects/data";
}
if (stat(path.c_str(), &st) != 0) {
cerr << "ERROR: tried to set path but failed, abort." << endl;
}
const string &era(resolutionsEra);
const string &alg(resolutionsAlgo);
string ptFileName = path + "/" + era + "_PtResolution_" + alg + ".txt";
string phiFileName = path + "/" + era + "_PhiResolution_" + alg + ".txt";

string ptFileName = edm::FileInPath("CondFormats/JetMETObjects/data/" + resolutionsEra + "_PtResolution_" +
resolutionsAlgo + ".txt")
.fullPath();
string phiFileName = edm::FileInPath("CondFormats/JetMETObjects/data/" + resolutionsEra + "_PhiResolution_" +
resolutionsAlgo + ".txt")
.fullPath();
ptResol_ = new JetResolution(ptFileName, false);
phiResol_ = new JetResolution(phiFileName, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ EcalTBHodoscopeRecInfo EcalTBHodoscopeRecInfoAlgo::reconstruct(const EcalTBHodos
float xSlope = 0.0, ySlope = 0.0;
float xQuality = -100.0, yQuality = -100.0;

int nclus[4];
int nclus[4] = {0};
std::vector<int> xclus[4];
std::vector<int> wclus[4];

Expand Down
2 changes: 1 addition & 1 deletion RecoTBCalo/HcalTBObjectUnpacker/src/HcalTBQADCUnpacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace hcaltb {
Ecal7x7);
} else { /// this is TB06
const CombinedTDCQDCDataFormat* qdctdc = (const CombinedTDCQDCDataFormat*)raw.data();
double qdc_calib_hits[32];
double qdc_calib_hits[32] = {0.};
for (unsigned int i = 0; i < qdctdc->n_qdc_hits; i++)
qdc_calib_hits[i] = ((qdctdc->qdc_values[i] & 0xFFF) - qdc_ped[i]) / qdc_gain[i];

Expand Down
1 change: 1 addition & 0 deletions RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ namespace reco {
}

math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField) {
assert(part);
const reco::PFCandidate* pfCand = dynamic_cast<const reco::PFCandidate*>(part);
if (pfCand)
return pfCand->positionAtECALEntrance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ namespace reco {
//trying to get the global position of the hit
//const GeomDetUnit* geomDetUnit = theGeometry->idToDetUnit( detid ).;

const GlobalPoint pos = theGeometry->idToDetUnit(detid)->surface().toGlobal(hit->localPosition());
LogDebug("CosmicTrackSplitter") << "hit pos: " << pos << ", dca pos: " << v;
LogDebug("CosmicTrackSplitter")
<< "hit pos: " << theGeometry->idToDetUnit(detid)->surface().toGlobal(hit->localPosition())
<< ", dca pos: " << v;

// top half
if ((i == 0) && (hitCtr < HITTOSPLITFROM)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ bool MultiTrackSelector::select(unsigned int tsNum,

//cuts on number of valid hits
auto nhits = tk.numberOfValidHits();
if (nhits >= min_hits_bypass_[tsNum])
if ((nhits >= min_hits_bypass_[tsNum]) || (nhits == 0))
return true;
if (nhits < min_nhits_[tsNum])
return false;
Expand Down Expand Up @@ -422,6 +422,8 @@ bool MultiTrackSelector::select(unsigned int tsNum,
int minLost = std::min(lostIn, lostOut);
if (minLost > max_minMissHitOutOrIn_[tsNum])
return false;
//numberOfValidHits is not 0 here
[[clang::suppress]]
float lostMidFrac = tk.numberOfLostHits() / (tk.numberOfValidHits() + tk.numberOfLostHits());
if (lostMidFrac > max_lostHitFraction_[tsNum])
return false;
Expand Down
1 change: 1 addition & 0 deletions RecoTracker/FinalTrackSelectors/plugins/TrackMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ TrackCandidate TrackMerger::merge(const reco::Track &inner,
for (auto it = inner.recHitsBegin(), ed = inner.recHitsEnd(); it != ed; ++it) {
hits.push_back(&**it);
if (debug_) {
[[clang::suppress]]
DetId id(hits.back()->geographicalId());
PRINT << " subdet " << id.subdetId() << " layer " << theTrkTopo->layer(id) << " valid "
<< hits.back()->isValid() << " detid: " << id() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/MkFitCore/src/PropagationMPlex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,6 @@ namespace mkfit {
// const float pt = 1.f / outPar.constAt(n, 3, 0); //fixme, make sure it is positive?
const float ipt = outPar.constAt(n, 3, 0);
const float pt = 1.f / ipt; //fixme, make sure it is positive?
const float ipt2 = ipt * ipt;
const float p = pt / std::sin(theta);
const float pz = p * std::cos(theta);
const float p2 = p * p;
Expand All @@ -1285,6 +1284,7 @@ namespace mkfit {
const float thetaMSC = 0.0136f * (1.f + 0.038f * std::log(radL)) / (beta * p); // eq 32.15
const float thetaMSC2 = thetaMSC * thetaMSC * radL;
if constexpr (Config::usePtMultScat) {
const float ipt2 = ipt * ipt;
outErr.At(n, 3, 3) += thetaMSC2 * pz * pz * ipt2 * ipt2;
outErr.At(n, 3, 5) -= thetaMSC2 * pz * ipt2;
outErr.At(n, 4, 4) += thetaMSC2 * p2 * ipt2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
foundNodes.reserve(100);

declareDynArray(KDTreeLinkerAlgo<unsigned int>, nThirdLayers, hitTree);
float rzError[nThirdLayers]; //save maximum errors
std::vector<float> rzError(nThirdLayers); //save maximum errors

const float maxDelphi = region.ptMin() < 0.3f ? float(M_PI) / 4.f : float(M_PI) / 8.f; // FIXME move to config??
const float maxphi = M_PI + maxDelphi, minphi = -maxphi; // increase to cater for any range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void PixelTripletLargeTipGenerator::hitTriplets(const TrackingRegion& region,
declareDynArray(KDTreeLinkerAlgo<unsigned int>, nThirdLayers, hitTree);
declareDynArray(LayerRZPredictions, nThirdLayers, mapPred);

float rzError[nThirdLayers]; //save maximum errors
std::vector<float> rzError(nThirdLayers); //save maximum errors

const float maxDelphi = region.ptMin() < 0.3f ? float(M_PI) / 4.f : float(M_PI) / 8.f; // FIXME move to config??
const float maxphi = M_PI + maxDelphi, minphi = -maxphi; // increase to cater for any range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region,
foundNodes.reserve(100);
declareDynArray(KDTreeLinkerAlgo<RecHitsSortedInPhi::HitIter>, nThirdLayers, hitTree);
declareDynArray(LayerRZPredictions, nThirdLayers, mapPred);
float rzError[nThirdLayers]; //save maximum errors
std::vector<float> rzError(nThirdLayers); //save maximum errors

const float maxDelphi = region.ptMin() < 0.3f ? float(M_PI) / 4.f : float(M_PI) / 8.f; // FIXME move to config??
const float maxphi = M_PI + maxDelphi, minphi = -maxphi; // increase to cater for any range
Expand Down

0 comments on commit d4aca16

Please sign in to comment.