From 31cc8fea292ca11f085b91b8b0e3d7e9df535753 Mon Sep 17 00:00:00 2001 From: Huilin Qu Date: Thu, 19 Sep 2024 22:40:54 +0200 Subject: [PATCH 01/14] Remove run3_nanoAOD_122 & 124 modifiers. --- .../python/Modifier_run3_nanoAOD_122_cff.py | 3 -- .../python/Modifier_run3_nanoAOD_124_cff.py | 3 -- .../StandardSequences/python/Eras.py | 2 +- .../NanoAOD/python/boostedTaus_cff.py | 9 ----- PhysicsTools/NanoAOD/python/custom_btv_cff.py | 11 ------ PhysicsTools/NanoAOD/python/globals_cff.py | 2 +- .../NanoAOD/python/jetsAK4_CHS_cff.py | 18 --------- .../NanoAOD/python/jetsAK4_Puppi_cff.py | 18 --------- PhysicsTools/NanoAOD/python/jetsAK8_cff.py | 29 +------------- PhysicsTools/NanoAOD/python/nanoDQM_cff.py | 39 +------------------ PhysicsTools/NanoAOD/python/nano_cff.py | 16 +------- PhysicsTools/NanoAOD/python/nano_eras_cff.py | 2 - PhysicsTools/NanoAOD/python/taus_cff.py | 22 ----------- 13 files changed, 7 insertions(+), 167 deletions(-) delete mode 100644 Configuration/Eras/python/Modifier_run3_nanoAOD_122_cff.py delete mode 100644 Configuration/Eras/python/Modifier_run3_nanoAOD_124_cff.py diff --git a/Configuration/Eras/python/Modifier_run3_nanoAOD_122_cff.py b/Configuration/Eras/python/Modifier_run3_nanoAOD_122_cff.py deleted file mode 100644 index 0ed0952dbe29f..0000000000000 --- a/Configuration/Eras/python/Modifier_run3_nanoAOD_122_cff.py +++ /dev/null @@ -1,3 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -run3_nanoAOD_122 = cms.Modifier() diff --git a/Configuration/Eras/python/Modifier_run3_nanoAOD_124_cff.py b/Configuration/Eras/python/Modifier_run3_nanoAOD_124_cff.py deleted file mode 100644 index 62c902fc79512..0000000000000 --- a/Configuration/Eras/python/Modifier_run3_nanoAOD_124_cff.py +++ /dev/null @@ -1,3 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -run3_nanoAOD_124 = cms.Modifier() diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index b86d2867397ca..dc4d2c005bbb8 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -91,7 +91,7 @@ def __init__(self): 'trackingPhase2PU140','highBetaStar_2018', 'tracker_apv_vfp30_2016', 'pf_badHcalMitigationOff', 'run2_nanoAOD_106Xv2', - 'run3_nanoAOD_122', 'run3_nanoAOD_124', 'run3_nanoAOD_pre142X', + 'run3_nanoAOD_pre142X', 'run3_ecal_devel', 'run3_upc', 'hcalHardcodeConditions', 'hcalSkipPacker', diff --git a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py index 10c382ac13855..61d8b4e56d594 100644 --- a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py +++ b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py @@ -95,12 +95,3 @@ boostedTauTask = cms.Task(finalBoostedTaus) boostedTauTablesTask = cms.Task(boostedTauTable) boostedTauMCTask = cms.Task(boostedTausMCMatchLepTauForTable,boostedTausMCMatchHadTauForTable,boostedTauMCTable) - -#remove boosted tau from previous eras -(run3_nanoAOD_122).toReplaceWith( - boostedTauTask,cms.Task() -).toReplaceWith( - boostedTauTablesTask,cms.Task() -).toReplaceWith( - boostedTauMCTask,cms.Task() -) diff --git a/PhysicsTools/NanoAOD/python/custom_btv_cff.py b/PhysicsTools/NanoAOD/python/custom_btv_cff.py index f068ea5990336..190141d44bced 100644 --- a/PhysicsTools/NanoAOD/python/custom_btv_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_btv_cff.py @@ -496,17 +496,6 @@ def add_BTV(process, addAK4=False, addAK8=False, scheme="btvSF"): get_ParticleNetAK4_outputs(), #get_ParticleTransformerAK4_outputs(),# removed in 2024 )) - - # disable the ParT branches in default jetPuppi table - from PhysicsTools.NanoAOD.nano_eras_cff import run3_nanoAOD_122, run3_nanoAOD_124 - (run3_nanoAOD_122 | run3_nanoAOD_124).toModify( - process.jetPuppiTable.variables, - btagRobustParTAK4B = None, - btagRobustParTAK4CvL = None, - btagRobustParTAK4CvB = None, - btagRobustParTAK4QG = None, - ) - # from Run3 onwards, always set storeAK4Truth to True for MC process.customAK4ConstituentsForDeepJetTable = cms.EDProducer("PatJetDeepJetTableProducer", diff --git a/PhysicsTools/NanoAOD/python/globals_cff.py b/PhysicsTools/NanoAOD/python/globals_cff.py index 20e63336efa9b..50c1b98c66f9a 100644 --- a/PhysicsTools/NanoAOD/python/globals_cff.py +++ b/PhysicsTools/NanoAOD/python/globals_cff.py @@ -37,7 +37,7 @@ zbins = cms.vdouble( [0.0,1.7,2.6,3.0,3.5,4.2,5.2,6.0,7.5,9.0,12.0] ), savePtHatMax = cms.bool(True), ) -(run2_nanoAOD_ANY | run3_nanoAOD_122 | run3_nanoAOD_124).toModify( +(run2_nanoAOD_ANY).toModify( puTable, savePtHatMax=False ) diff --git a/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py b/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py index 48554879c92bf..0a4d9ab68f6ef 100644 --- a/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py +++ b/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py @@ -170,24 +170,6 @@ hfEmEF = None ) -(run3_nanoAOD_122 | run3_nanoAOD_124).toModify( - jetTable.variables, - # New ParticleNet trainings are not available in MiniAOD until Run3 13X - btagPNetB = None, - btagPNetCvL = None, - btagPNetCvB = None, - btagPNetQvG = None, - btagPNetTauVJet = None, - PNetRegPtRawCorr = None, - PNetRegPtRawCorrNeutrino = None, - PNetRegPtRawRes = None, - # Remove for V11 and earlier Run3 versions - chMultiplicity = None, - neMultiplicity = None, - hfHEF = None, - hfEmEF = None -) - bjetNN = cms.EDProducer("BJetEnergyRegressionMVA", backend = cms.string("ONNX"), batch_eval = cms.bool(True), diff --git a/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py b/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py index 491695a47eb34..ec17a8ee941b7 100644 --- a/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py +++ b/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py @@ -117,24 +117,6 @@ btagDeepCvB = Var("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1",float,doc="DeepCSV c vs b+bb discriminator",precision=10) ) -(run3_nanoAOD_122 | run3_nanoAOD_124).toModify( - jetPuppiTable.variables, - # New ParticleNet trainings are not available in MiniAOD until Run3 13X - btagPNetB = None, - btagPNetCvL = None, - btagPNetCvB = None, - btagPNetQvG = None, - btagPNetTauVJet = None, - PNetRegPtRawCorr = None, - PNetRegPtRawCorrNeutrino = None, - PNetRegPtRawRes = None, - # Remove for V11 and earlier Run3 versions - chMultiplicity = None, - neMultiplicity = None, - hfHEF = None, - hfEmEF = None -) - run3_nanoAOD_pre142X.toModify( jetPuppiTable.variables, puIdDisc = None, diff --git a/PhysicsTools/NanoAOD/python/jetsAK8_cff.py b/PhysicsTools/NanoAOD/python/jetsAK8_cff.py index 6249dba8fa838..3915ba356dd0b 100644 --- a/PhysicsTools/NanoAOD/python/jetsAK8_cff.py +++ b/PhysicsTools/NanoAOD/python/jetsAK8_cff.py @@ -115,33 +115,8 @@ neEmEF = None, muEF = None ) -(run3_nanoAOD_122 | run3_nanoAOD_124).toModify( - fatJetTable.variables, - # New ParticleNet trainings are not available in MiniAOD until Run3 13X - particleNet_QCD = None, - particleNet_QCD2HF = None, - particleNet_QCD1HF = None, - particleNet_QCD0HF = None, - particleNet_massCorr = None, - particleNet_XbbVsQCD = None, - particleNet_XccVsQCD = None, - particleNet_XqqVsQCD = None, - particleNet_XggVsQCD = None, - particleNet_XttVsQCD = None, - particleNet_XtmVsQCD = None, - particleNet_XteVsQCD = None, - particleNet_WVsQCD = None, - # Remove for V11 and earlier versions - chMultiplicity = None, - neMultiplicity = None, - chHEF = None, - neHEF = None, - chEmEF = None, - neEmEF = None, - muEF = None -) -(run2_nanoAOD_106Xv2 | run3_nanoAOD_122 | run3_nanoAOD_124).toModify( +(run2_nanoAOD_106Xv2).toModify( fatJetTable.variables, # Restore taggers that were decommisionned for Run-3 btagDeepB = Var("?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc="DeepCSV b+bb tag discriminator",precision=10), @@ -264,7 +239,7 @@ def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubl btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10) ) -(run2_nanoAOD_106Xv2 | run3_nanoAOD_122 | run3_nanoAOD_124).toModify( +(run2_nanoAOD_106Xv2).toModify( subJetTable.variables, area = None, ) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cff.py b/PhysicsTools/NanoAOD/python/nanoDQM_cff.py index 83133f9c88104..73ed541241bcc 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cff.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cff.py @@ -188,20 +188,6 @@ def _match(name): Plot1D('particleNetLegacy_QCD', 'particleNetLegacy_QCD', 20, 0, 1, 'ParticleNet Legacy Run-2 QCD score'), ]) -_FatJet_EarlyRun3_plots = cms.VPSet() -for plot in _FatJet_Run2_plots: - if 'particleNet_' not in plot.name.value() and 'btagCSVV2' not in plot.name.value() \ - and 'Multiplicity' not in plot.name.value() and 'EF' not in plot.name.value(): - _FatJet_EarlyRun3_plots.append(plot) -_FatJet_EarlyRun3_plots.extend([ - Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), - Plot1D('btagHbb', 'btagHbb', 20, -1, 1, 'Higgs to BB tagger discriminator'), - Plot1D('btagCMVA', 'btagCMVA', 20, -1, 1, 'CMVA V2 btag discriminator'), - Plot1D('btagDDBvLV2', 'btagDDBvLV2', 20, 0, 1, 'DeepDoubleX V2(mass-decorrelated) discriminator for H(Z)->bb vs QCD'), - Plot1D('btagDDCvBV2', 'btagDDCvBV2', 20, 0, 1, 'DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb'), - Plot1D('btagDDCvLV2', 'btagDDCvLV2', 20, 0, 1, 'DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs QCD'), -]) - _Jet_Run2_plots = cms.VPSet() for plot in nanoDQM.vplots.Jet.plots: _Jet_Run2_plots.append(plot) @@ -215,13 +201,6 @@ def _match(name): Plot1D('btagDeepCvB', 'btagDeepCvB', 20, -1, 1, 'DeepCSV c vs b+bb discriminator'), Plot1D('btagDeepCvL', 'btagDeepCvL', 20, -1, 1, 'DeepCSV c vs udsg discriminator') ]) - -_Jet_EarlyRun3_plots = cms.VPSet() -for plot in nanoDQM.vplots.Jet.plots: - if 'PNet' not in plot.name.value() and 'Multiplicity' not in plot.name.value() \ - and 'hfHEF' not in plot.name.value() and 'hfEmEF' not in plot.name.value(): - _Jet_EarlyRun3_plots.append(plot) - _Jet_pre142X_plots = cms.VPSet() for plot in nanoDQM.vplots.Jet.plots: if 'puIdDisc' not in plot.name.value(): @@ -233,10 +212,6 @@ def _match(name): _SubJet_Run2_plots.extend([ Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), ]) -_SubJet_EarlyRun3_plots = cms.VPSet() -for plot in nanoDQM.vplots.SubJet.plots: - if 'area' not in plot.name.value(): - _SubJet_EarlyRun3_plots.append(plot) _SubJet_pre142X_plots = cms.VPSet() for plot in nanoDQM.vplots.SubJet.plots: @@ -256,18 +231,6 @@ def _match(name): nanoDQM.vplots.SubJet, plots = _SubJet_Run2_plots ) - -(run3_nanoAOD_122 | run3_nanoAOD_124).toModify( - nanoDQM.vplots.FatJet, - plots = _FatJet_EarlyRun3_plots -).toModify( - nanoDQM.vplots.Jet, - plots = _Jet_EarlyRun3_plots -).toModify( - nanoDQM.vplots.SubJet, - plots = _SubJet_EarlyRun3_plots -) - run3_nanoAOD_pre142X.toModify( nanoDQM.vplots.Jet, plots = _Jet_pre142X_plots @@ -281,7 +244,7 @@ def _match(name): if 'pthatmax' not in plot.name.value(): _Pileup_pre13X_plots.append(plot) -(run2_nanoAOD_ANY | run3_nanoAOD_122 | run3_nanoAOD_124).toModify( +(run2_nanoAOD_ANY).toModify( nanoDQM.vplots.Pileup, plots = _Pileup_pre13X_plots ) diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 1c739d9f5bbcf..a4c8469df8602 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -51,11 +51,6 @@ linkedObjects, jets="finalJets" ) -# boosted taus don't exist in 122X MINI -run3_nanoAOD_122.toModify( - linkedObjects, boostedTaus=None, -) - from PhysicsTools.NanoAOD.lhcInfoProducer_cfi import lhcInfoProducer lhcInfoTable = lhcInfoProducer.clone() (~run3_common).toModify( @@ -214,13 +209,6 @@ def nanoAOD_customizeCommon(process): nanoAOD_addUnifiedParTAK4Tag_switch=True, ) - # enable rerun of PNet for CHS jets for early run3 eras - # (it is rerun for run2 within jet tasks while is not needed for newer - # run3 eras as it is present in miniAOD) - (run3_nanoAOD_122 | run3_nanoAOD_124).toModify( - nanoAOD_addDeepInfoAK4CHS_switch, nanoAOD_addParticleNet_switch = True - ) - # This function is defined in jetsAK4_Puppi_cff.py process = nanoAOD_addDeepInfoAK4(process, addParticleNet=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addParticleNet_switch, @@ -253,7 +241,7 @@ def nanoAOD_customizeCommon(process): addUParTInfo = cms.bool(True), addPNet = cms.bool(True) ) - (run2_nanoAOD_106Xv2 | run3_nanoAOD_122).toModify( + (run2_nanoAOD_106Xv2).toModify( nanoAOD_tau_switch, idsToAdd = ["deepTau2018v2p5"] ).toModify( process, lambda p : nanoAOD_addTauIds(p, nanoAOD_tau_switch.idsToAdd.value()) @@ -261,7 +249,7 @@ def nanoAOD_customizeCommon(process): # Don't add Unified Tagger for PUPPI jets for Run 2 (as different PUPPI tune # and base jet algorithm) or early Run 3 eras - (run3_nanoAOD_122 | run3_nanoAOD_124 | run2_nanoAOD_106Xv2).toModify( + (run2_nanoAOD_106Xv2).toModify( nanoAOD_tau_switch, addUParTInfo = False ) diff --git a/PhysicsTools/NanoAOD/python/nano_eras_cff.py b/PhysicsTools/NanoAOD/python/nano_eras_cff.py index cce9c50e42e35..2afb8bcaa02e0 100644 --- a/PhysicsTools/NanoAOD/python/nano_eras_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_eras_cff.py @@ -17,8 +17,6 @@ from Configuration.Eras.Modifier_tracker_apv_vfp30_2016_cff import tracker_apv_vfp30_2016 from Configuration.Eras.Modifier_run3_common_cff import run3_common -from Configuration.Eras.Modifier_run3_nanoAOD_122_cff import run3_nanoAOD_122 -from Configuration.Eras.Modifier_run3_nanoAOD_124_cff import run3_nanoAOD_124 from Configuration.Eras.Modifier_run3_nanoAOD_pre142X_cff import run3_nanoAOD_pre142X from Configuration.Eras.Modifier_run3_jme_Winter22runsBCDEprompt_cff import run3_jme_Winter22runsBCDEprompt diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index dff543fe3b2b4..05f0437eb9399 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -1,6 +1,5 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.nano_eras_cff import run3_nanoAOD_124 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer from PhysicsTools.NanoAOD.simpleGenParticleFlatTableProducer_cfi import simpleGenParticleFlatTableProducer from PhysicsTools.NanoAOD.simplePATTauFlatTableProducer_cfi import simplePATTauFlatTableProducer @@ -21,11 +20,6 @@ cut = cms.string("pt > 18 && ((tauID('decayModeFindingNewDMs') > 0.5 && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || (tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum'))<2.5) || tauID('byVVVLooseDeepTau2018v2p5VSjet'))) || (?isTauIDAvailable('byUTagCHSVSjetraw')?tauID('byUTagCHSVSjetraw'):-1) > {} || (?isTauIDAvailable('byUTagPUPPIVSjetraw')?tauID('byUTagPUPPIVSjetraw'):-1) > {})".format(0.05, 0.05)) ) -run3_nanoAOD_124.toModify( - finalTaus, - cut = cms.string("pt > 18 && ((tauID('decayModeFindingNewDMs') > 0.5 && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || (tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum'))<2.5) || (tauID('byDeepTau2018v2p5VSjetraw') > {}))) || (?isTauIDAvailable('byUTagCHSVSjetraw')?tauID('byUTagCHSVSjetraw'):-1) > {} || (?isTauIDAvailable('byUTagPUPPIVSjetraw')?tauID('byUTagPUPPIVSjetraw'):-1) > {})".format(WORKING_POINTS_v2p5["jet"]["VVVLoose"], 0.05, 0.05)) -) - ##################### Tables for final output and docs ########################## def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None): if from_raw: @@ -137,22 +131,6 @@ def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None): tauTable.variables = _variablesMiniV2 -run3_nanoAOD_124.toModify( - tauTable.variables, - idDeepTau2018v2p5VSe = _tauIdWPMask("byDeepTau2018v2p5VSeraw", - choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"), - doc="byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)", - from_raw=True, wp_thrs=WORKING_POINTS_v2p5["e"]), - idDeepTau2018v2p5VSmu = _tauIdWPMask("byDeepTau2018v2p5VSmuraw", - choices=("VLoose", "Loose", "Medium", "Tight"), - doc="byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)", - from_raw=True, wp_thrs=WORKING_POINTS_v2p5["mu"]), - idDeepTau2018v2p5VSjet = _tauIdWPMask("byDeepTau2018v2p5VSjetraw", - choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"), - doc="byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)", - from_raw=True, wp_thrs=WORKING_POINTS_v2p5["jet"]) -) - tauSignalCands = patTauSignalCandidatesProducer.clone( src = tauTable.src, storeLostTracks = True From 3da51ef45c3cf36ad19ddad31e0c64ace3b70fa7 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Fri, 4 Oct 2024 14:46:11 +0200 Subject: [PATCH 02/14] [RECONSTRUCTION] [Clang]Cleanup clang-analyzer warnings --- .../JetPlusTracks/plugins/JetPlusTrackProducer.cc | 11 +++-------- .../JetPlusTracks/plugins/JetPlusTrackProducerAA.cc | 8 ++------ RecoJets/JetProducers/plugins/VirtualJetProducer.cc | 4 +++- RecoJets/JetProducers/src/PileupJetIdAlgo.cc | 1 + RecoMET/METAlgorithms/src/SignAlgoResolutions.cc | 2 ++ .../src/EcalTBHodoscopeRecInfoAlgo.cc | 2 +- .../HcalTBObjectUnpacker/src/HcalTBQADCUnpacker.cc | 2 +- RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc | 1 + .../plugins/CosmicTrackSplitter.cc | 5 +++-- .../FinalTrackSelectors/plugins/MultiTrackSelector.cc | 4 +++- .../FinalTrackSelectors/plugins/TrackMerger.cc | 1 + RecoTracker/MkFitCore/src/PropagationMPlex.cc | 2 +- .../PixelSeeding/plugins/PixelTripletHLTGenerator.cc | 2 +- .../plugins/PixelTripletLargeTipGenerator.cc | 2 +- .../plugins/MultiHitGeneratorFromChi2.cc | 2 +- 15 files changed, 25 insertions(+), 24 deletions(-) diff --git a/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducer.cc b/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducer.cc index 6502bf44b5a4b..9e4e6779e9d0c 100644 --- a/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducer.cc +++ b/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducer.cc @@ -107,7 +107,6 @@ void JetPlusTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS auto pOut = std::make_unique(); auto pOut1 = std::make_unique(); - double scaleJPT = 1.; for (auto const& jet : iEvent.get(input_trackjets_token_)) { int icalo = -1; int i = 0; @@ -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_; @@ -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; @@ -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; diff --git a/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducerAA.cc b/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducerAA.cc index 9e8fd0acc207c..79ce756cab0b2 100644 --- a/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducerAA.cc +++ b/RecoJets/JetPlusTracks/plugins/JetPlusTrackProducerAA.cc @@ -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 @@ -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; diff --git a/RecoJets/JetProducers/plugins/VirtualJetProducer.cc b/RecoJets/JetProducers/plugins/VirtualJetProducer.cc index 175e2fbb4b9a1..5dd9b88ab6d74 100644 --- a/RecoJets/JetProducers/plugins/VirtualJetProducer.cc +++ b/RecoJets/JetProducers/plugins/VirtualJetProducer.cc @@ -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_; @@ -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]; diff --git a/RecoJets/JetProducers/src/PileupJetIdAlgo.cc b/RecoJets/JetProducers/src/PileupJetIdAlgo.cc index 51b2ccea43760..987a55d3d148f 100644 --- a/RecoJets/JetProducers/src/PileupJetIdAlgo.cc +++ b/RecoJets/JetProducers/src/PileupJetIdAlgo.cc @@ -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(icand); const reco::PFCandidate* lPF = dynamic_cast(icand); bool isPacked = true; diff --git a/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc b/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc index fa6103e521ba4..6bc3d041e0c26 100644 --- a/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc +++ b/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc @@ -385,7 +385,9 @@ void metsig::SignAlgoResolutions::initializeJetResolutions(const edm::ParameterS string resolutionsAlgo = iConfig.getParameter("resolutionsAlgo"); string resolutionsEra = iConfig.getParameter("resolutionsEra"); + [[clang::suppress]] string cmssw_base(std::getenv("CMSSW_BASE")); + [[clang::suppress]] string cmssw_release_base(std::getenv("CMSSW_RELEASE_BASE")); string path = cmssw_base + "/src/CondFormats/JetMETObjects/data"; struct stat st; diff --git a/RecoTBCalo/EcalTBHodoscopeReconstructor/src/EcalTBHodoscopeRecInfoAlgo.cc b/RecoTBCalo/EcalTBHodoscopeReconstructor/src/EcalTBHodoscopeRecInfoAlgo.cc index 8378f9363b524..087127e9d28d4 100644 --- a/RecoTBCalo/EcalTBHodoscopeReconstructor/src/EcalTBHodoscopeRecInfoAlgo.cc +++ b/RecoTBCalo/EcalTBHodoscopeReconstructor/src/EcalTBHodoscopeRecInfoAlgo.cc @@ -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 xclus[4]; std::vector wclus[4]; diff --git a/RecoTBCalo/HcalTBObjectUnpacker/src/HcalTBQADCUnpacker.cc b/RecoTBCalo/HcalTBObjectUnpacker/src/HcalTBQADCUnpacker.cc index 7c43a6af6c004..b1565448c12e9 100644 --- a/RecoTBCalo/HcalTBObjectUnpacker/src/HcalTBQADCUnpacker.cc +++ b/RecoTBCalo/HcalTBObjectUnpacker/src/HcalTBQADCUnpacker.cc @@ -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]; diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 582649b850462..7a2c3f2b39910 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -111,6 +111,7 @@ namespace reco { if (pfCand) return pfCand->positionAtECALEntrance(); + assert(part); math::XYZPointF pos; BaseParticlePropagator theParticle = BaseParticlePropagator( RawParticle(math::XYZTLorentzVector(part->px(), part->py(), part->pz(), part->energy()), diff --git a/RecoTracker/FinalTrackSelectors/plugins/CosmicTrackSplitter.cc b/RecoTracker/FinalTrackSelectors/plugins/CosmicTrackSplitter.cc index 4e9cafdc9c7bc..445a8d0a220eb 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/CosmicTrackSplitter.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/CosmicTrackSplitter.cc @@ -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)) { diff --git a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc index 837942b607c5a..702fbaa542ff1 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc @@ -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; @@ -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; diff --git a/RecoTracker/FinalTrackSelectors/plugins/TrackMerger.cc b/RecoTracker/FinalTrackSelectors/plugins/TrackMerger.cc index e26eb719b3a9b..7be6299c98160 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/TrackMerger.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/TrackMerger.cc @@ -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; diff --git a/RecoTracker/MkFitCore/src/PropagationMPlex.cc b/RecoTracker/MkFitCore/src/PropagationMPlex.cc index 00f0ae09c742c..3dc3b4d58f8a5 100644 --- a/RecoTracker/MkFitCore/src/PropagationMPlex.cc +++ b/RecoTracker/MkFitCore/src/PropagationMPlex.cc @@ -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; @@ -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; diff --git a/RecoTracker/PixelSeeding/plugins/PixelTripletHLTGenerator.cc b/RecoTracker/PixelSeeding/plugins/PixelTripletHLTGenerator.cc index 162dac51a1cba..d11e10340981e 100644 --- a/RecoTracker/PixelSeeding/plugins/PixelTripletHLTGenerator.cc +++ b/RecoTracker/PixelSeeding/plugins/PixelTripletHLTGenerator.cc @@ -133,7 +133,7 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region, foundNodes.reserve(100); declareDynArray(KDTreeLinkerAlgo, nThirdLayers, hitTree); - float rzError[nThirdLayers]; //save maximum errors + std::vector 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 diff --git a/RecoTracker/PixelSeeding/plugins/PixelTripletLargeTipGenerator.cc b/RecoTracker/PixelSeeding/plugins/PixelTripletLargeTipGenerator.cc index 8b455e7261865..163236d058f3a 100644 --- a/RecoTracker/PixelSeeding/plugins/PixelTripletLargeTipGenerator.cc +++ b/RecoTracker/PixelSeeding/plugins/PixelTripletLargeTipGenerator.cc @@ -169,7 +169,7 @@ void PixelTripletLargeTipGenerator::hitTriplets(const TrackingRegion& region, declareDynArray(KDTreeLinkerAlgo, nThirdLayers, hitTree); declareDynArray(LayerRZPredictions, nThirdLayers, mapPred); - float rzError[nThirdLayers]; //save maximum errors + std::vector 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 diff --git a/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc b/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc index bcd454c351a1b..e95c032af525d 100644 --- a/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc +++ b/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc @@ -233,7 +233,7 @@ void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region, foundNodes.reserve(100); declareDynArray(KDTreeLinkerAlgo, nThirdLayers, hitTree); declareDynArray(LayerRZPredictions, nThirdLayers, mapPred); - float rzError[nThirdLayers]; //save maximum errors + std::vector 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 From 401976a59f798bb3f33f903fa37ce7bc392c7a92 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Fri, 4 Oct 2024 14:46:20 +0200 Subject: [PATCH 03/14] [CORE] [Clang]Cleanup clang-analyzer warnings --- Utilities/StaticAnalyzers/src/ClassChecker.cpp | 5 +++++ Utilities/StaticAnalyzers/src/CmsSupport.h | 1 + Utilities/StaticAnalyzers/src/ESRecordGetChecker.cpp | 2 ++ Utilities/StaticAnalyzers/src/FiniteMathChecker.cc | 2 +- Utilities/StaticAnalyzers/src/FunctionChecker.cpp | 4 +++- Utilities/StaticAnalyzers/src/getByChecker.cpp | 3 +++ Utilities/StorageFactory/src/LocalFileSystem.cc | 3 ++- 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Utilities/StaticAnalyzers/src/ClassChecker.cpp b/Utilities/StaticAnalyzers/src/ClassChecker.cpp index 934867cd1fa3a..7d5cc15be173a 100644 --- a/Utilities/StaticAnalyzers/src/ClassChecker.cpp +++ b/Utilities/StaticAnalyzers/src/ClassChecker.cpp @@ -261,6 +261,7 @@ namespace clangcms { MD = llvm::dyn_cast(AD); if (llvm::isa(RE)) return; + assert(MD); clang::QualType RQT = MD->getCallResultType(); clang::QualType RTy = Ctx.getCanonicalType(RQT); if ((RTy->isPointerType() || RTy->isReferenceType())) { @@ -467,6 +468,7 @@ namespace clangcms { const clang::MemberExpr *AME = llvm::dyn_cast_or_null(E); if (AME && AME->isImplicitAccess()) { clang::ParmVarDecl *PVD = llvm::dyn_cast_or_null(MD->getParamDecl(i)); + assert(PVD); clang::QualType QT = PVD->getOriginalType(); const clang::Type *T = QT.getTypePtr(); if (!support::isConst(QT) && T->isReferenceType() && ME && ME->isImplicitAccess()) @@ -575,9 +577,12 @@ namespace clangcms { LangOpts.CPlusPlus = true; clang::PrintingPolicy Policy(LangOpts); + assert(llvm::dyn_cast(CE)); clang::CXXMethodDecl *CMD = llvm::dyn_cast(CE)->getMethodDecl(); const clang::MemberExpr *E = llvm::dyn_cast(CE->getArg(i)); + assert(E); clang::ValueDecl *VD = llvm::dyn_cast(E->getMemberDecl()); + assert(VD); os << "Member data '" << VD->getQualifiedNameAsString(); os << "' is passed to a non-const reference parameter"; os << " of CXX method '" << CMD->getQualifiedNameAsString() << "' in const function"; diff --git a/Utilities/StaticAnalyzers/src/CmsSupport.h b/Utilities/StaticAnalyzers/src/CmsSupport.h index a7e2e21a095ca..5edf69fa02b7c 100644 --- a/Utilities/StaticAnalyzers/src/CmsSupport.h +++ b/Utilities/StaticAnalyzers/src/CmsSupport.h @@ -32,6 +32,7 @@ namespace clangcms { } if (qt->isPointerType()) { clang::PointerType const *pt = qt->getAs(); + assert(pt); return pt->getPointeeType().isConstQualified(); } diff --git a/Utilities/StaticAnalyzers/src/ESRecordGetChecker.cpp b/Utilities/StaticAnalyzers/src/ESRecordGetChecker.cpp index 1e8f3a85f8139..1bc32426a21a6 100644 --- a/Utilities/StaticAnalyzers/src/ESRecordGetChecker.cpp +++ b/Utilities/StaticAnalyzers/src/ESRecordGetChecker.cpp @@ -31,6 +31,7 @@ namespace clangcms { LangOpts.CPlusPlus = true; PrintingPolicy Policy(LangOpts); const Decl *D = AC->getDecl(); + assert(D); std::string dname = ""; if (const NamedDecl *ND = llvm::dyn_cast_or_null(D)) dname = ND->getQualifiedNameAsString(); @@ -45,6 +46,7 @@ namespace clangcms { llvm::SmallString<100> buf; llvm::raw_svector_ostream os(buf); os << "function '"; + assert(llvm::dyn_cast(D)); llvm::dyn_cast(D)->getNameForDiagnostic(os, Policy, true); os << "' "; os << "calls function '"; diff --git a/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc b/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc index 1ab873d108188..b556357d6cbe4 100644 --- a/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc +++ b/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc @@ -44,7 +44,7 @@ namespace clangcms { } void FMWalkAST::VisitCallExpr(clang::CallExpr *CE) { - const clang::Expr *Callee = CE->getCallee(); + assert(CE); const FunctionDecl *FD = CE->getDirectCallee(); if (!FD) return; diff --git a/Utilities/StaticAnalyzers/src/FunctionChecker.cpp b/Utilities/StaticAnalyzers/src/FunctionChecker.cpp index 3566e03073892..c2f445d136385 100644 --- a/Utilities/StaticAnalyzers/src/FunctionChecker.cpp +++ b/Utilities/StaticAnalyzers/src/FunctionChecker.cpp @@ -66,7 +66,9 @@ namespace clangcms { void FWalker::ReportDeclRef(const clang::DeclRefExpr *DRE) { const clang::VarDecl *D = llvm::dyn_cast_or_null(DRE->getDecl()); - if (D && (D->hasAttr() || D->hasAttr()) || D->hasAttr()) + if (!D) + return; + if ((D->hasAttr() || D->hasAttr()) || D->hasAttr()) return; if (support::isSafeClassName(D->getCanonicalDecl()->getQualifiedNameAsString())) return; diff --git a/Utilities/StaticAnalyzers/src/getByChecker.cpp b/Utilities/StaticAnalyzers/src/getByChecker.cpp index 2679ec7792859..a31c2a9b7ede4 100644 --- a/Utilities/StaticAnalyzers/src/getByChecker.cpp +++ b/Utilities/StaticAnalyzers/src/getByChecker.cpp @@ -42,6 +42,7 @@ namespace clangcms { llvm::raw_svector_ostream os(buf); if (mname == "edm::Event::getByLabel" || mname == "edm::Event::getManyByType") { os << "function '"; + assert(llvm::dyn_cast(D)); llvm::dyn_cast(D)->getNameForDiagnostic(os, Policy, true); os << "' "; if (mname == "edm::Event::getByLabel") { @@ -58,6 +59,7 @@ namespace clangcms { std::string rname = RD->getQualifiedNameAsString(); os << rname << " "; const ClassTemplateSpecializationDecl *SD = dyn_cast(RD); + assert(SD); for (unsigned J = 0, F = SD->getTemplateArgs().size(); J != F; ++J) { #if LLVM_VERSION_MAJOR >= 13 SD->getTemplateArgs().data()[J].print(Policy, os, false); @@ -79,6 +81,7 @@ namespace clangcms { const CXXRecordDecl *RD = QT->getAsCXXRecordDecl(); os << "getManyByType , "; const ClassTemplateSpecializationDecl *SD = dyn_cast(RD); + assert(SD); const TemplateArgument TA = SD->getTemplateArgs().data()[0]; const QualType AQT = TA.getAsType(); const CXXRecordDecl *SRD = AQT->getAsCXXRecordDecl(); diff --git a/Utilities/StorageFactory/src/LocalFileSystem.cc b/Utilities/StorageFactory/src/LocalFileSystem.cc index 44bd538f0f9bc..e72ad5acfc2a1 100644 --- a/Utilities/StorageFactory/src/LocalFileSystem.cc +++ b/Utilities/StorageFactory/src/LocalFileSystem.cc @@ -168,7 +168,7 @@ LocalFileSystem::FSInfo *LocalFileSystem::initFSInfo(void *arg) { i->fsname = static_cast(memcpy(p += infolen, m->mnt_fsname, fslen)); i->type = static_cast(memcpy(p += fslen, m->mnt_type, typelen)); i->dir = static_cast(memcpy(p += typelen, m->mnt_dir, dirlen)); - i->origin = static_cast(memcpy(p += dirlen, m->mnt_fsname, originlen)); + [[clang::suppress]] i->origin = static_cast(memcpy(p += dirlen, m->mnt_fsname, originlen)); i->dev = -1; i->fstype = -1; i->freespc = 0; @@ -361,6 +361,7 @@ LocalFileSystem::FSInfo *LocalFileSystem::findMount(const char *path, prev_paths.push_back(path); LocalFileSystem::FSInfo *new_best = findMount(fullpath, &sfs2, &s2, prev_paths); + free(fullpath); return new_best ? new_best : best; } From 595c99b8ce15aeb8a5d697ce544daf68aa81f628 Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Fri, 4 Oct 2024 15:15:24 +0200 Subject: [PATCH 04/14] [LLVM Analyzer][ALCA,ANALYSIS] Remove dead assignments --- IORawData/DTCommissioning/plugins/DTNewROS8FileReader.cc | 2 +- IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc | 2 +- JetMETCorrections/MCJet/bin/ReadTree.cc | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/IORawData/DTCommissioning/plugins/DTNewROS8FileReader.cc b/IORawData/DTCommissioning/plugins/DTNewROS8FileReader.cc index 9b230fbc92e8d..fc7d7e1195550 100644 --- a/IORawData/DTCommissioning/plugins/DTNewROS8FileReader.cc +++ b/IORawData/DTCommissioning/plugins/DTNewROS8FileReader.cc @@ -100,7 +100,7 @@ int DTNewROS8FileReader::fillRawData(Event& e, //2.- Get the HEADER ============================================================================ int datahead[numberEventHeadWords]; for (int iih = 0; iih < numberEventHeadWords; iih++) { - nread = inputFile.read(dataPointer(&datahead[iih]), ros8WordLenght); + inputFile.read(dataPointer(&datahead[iih]), ros8WordLenght); } //3.- ROS DATA & 4.- PU DATA (Trigger) ======================================================= diff --git a/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc b/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc index b7a1fe2b7d771..d8fe1f563997c 100644 --- a/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc +++ b/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc @@ -260,7 +260,7 @@ bool PixelSLinkDataInputSource::setRunAndEventInfo(edm::EventID &id, buffers = std::make_unique(); // uint32_t currenteventnumber = (m_data >> 32)&0x00ffffff; - uint32_t eventnumber = (m_data >> 32) & 0x00ffffff; + uint32_t eventnumber = 0; do { std::vector buffer; diff --git a/JetMETCorrections/MCJet/bin/ReadTree.cc b/JetMETCorrections/MCJet/bin/ReadTree.cc index a41cb75f28a35..df4fbc2630785 100644 --- a/JetMETCorrections/MCJet/bin/ReadTree.cc +++ b/JetMETCorrections/MCJet/bin/ReadTree.cc @@ -119,7 +119,6 @@ int main(int argc, char **argv) { if (cut_ptmin && cut_dR && cut_njets) { ind_pt = getBin(ptGen, pt_vec); ind_eta = getBin(etaJet, eta_vec); - resp = 0.; if (UseRatioForResponse && ptGen > 0) resp = ptJet / ptGen; else From 5af2b72d361e81f2758874db5b45bb66163c4f4b Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Fri, 4 Oct 2024 17:43:21 +0200 Subject: [PATCH 05/14] code review: use FileInPath --- .../METAlgorithms/src/SignAlgoResolutions.cc | 25 ++++++------------- .../RecoTau/src/RecoTauCommonUtilities.cc | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc b/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc index 6bc3d041e0c26..5d4c0a73f494f 100644 --- a/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc +++ b/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc @@ -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" @@ -384,24 +385,12 @@ void metsig::SignAlgoResolutions::initializeJetResolutions(const edm::ParameterS if (ptResol_ == nullptr) { string resolutionsAlgo = iConfig.getParameter("resolutionsAlgo"); string resolutionsEra = iConfig.getParameter("resolutionsEra"); - - [[clang::suppress]] - string cmssw_base(std::getenv("CMSSW_BASE")); - [[clang::suppress]] - 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); } diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 7a2c3f2b39910..3096fc9661946 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -107,11 +107,11 @@ namespace reco { } math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField) { + assert(part); const reco::PFCandidate* pfCand = dynamic_cast(part); if (pfCand) return pfCand->positionAtECALEntrance(); - assert(part); math::XYZPointF pos; BaseParticlePropagator theParticle = BaseParticlePropagator( RawParticle(math::XYZTLorentzVector(part->px(), part->py(), part->pz(), part->energy()), From 3f2c77c8dc1f92530600e6d827a6c2054dd3bde2 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Mon, 7 Oct 2024 09:29:14 +0200 Subject: [PATCH 06/14] LocalFileSystem: use unique_ptr --- .../StorageFactory/src/LocalFileSystem.cc | 83 ++++++++----------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/Utilities/StorageFactory/src/LocalFileSystem.cc b/Utilities/StorageFactory/src/LocalFileSystem.cc index e72ad5acfc2a1..866331e73f14e 100644 --- a/Utilities/StorageFactory/src/LocalFileSystem.cc +++ b/Utilities/StorageFactory/src/LocalFileSystem.cc @@ -338,30 +338,27 @@ LocalFileSystem::FSInfo *LocalFileSystem::findMount(const char *path, if (best && best->bind && best->origin) { struct stat s2; struct statfs sfs2; - char *fullpath = realpath(best->origin, nullptr); + std::unique_ptr fullpath{realpath(best->origin, nullptr), std::free}; if (!fullpath) - fullpath = strdup(best->origin); + fullpath.reset(strdup(best->origin)); - if (lstat(fullpath, &s2) < 0) { + if (lstat(fullpath.get(), &s2) < 0) { int nerr = errno; - edm::LogWarning("LocalFileSystem::findMount()") << "Cannot lstat('" << fullpath << "' alias '" << path + edm::LogWarning("LocalFileSystem::findMount()") << "Cannot lstat('" << fullpath.get() << "' alias '" << path << "'): " << strerror(nerr) << " (error " << nerr << ")"; - free(fullpath); return best; } - if (statfs(fullpath, &sfs2) < 0) { + if (statfs(fullpath.get(), &sfs2) < 0) { int nerr = errno; - edm::LogWarning("LocalFileSystem::findMount()") << "Cannot statfs('" << fullpath << "' alias '" << path + edm::LogWarning("LocalFileSystem::findMount()") << "Cannot statfs('" << fullpath.get() << "' alias '" << path << "'): " << strerror(nerr) << " (error " << nerr << ")"; - free(fullpath); return best; } prev_paths.push_back(path); - LocalFileSystem::FSInfo *new_best = findMount(fullpath, &sfs2, &s2, prev_paths); - free(fullpath); + LocalFileSystem::FSInfo *new_best = findMount(fullpath.get(), &sfs2, &s2, prev_paths); return new_best ? new_best : best; } @@ -380,31 +377,27 @@ LocalFileSystem::FSInfo *LocalFileSystem::findMount(const char *path, bool LocalFileSystem::isLocalPath(const std::string &path) const { struct stat s; struct statfs sfs; - char *fullpath = realpath(path.c_str(), nullptr); + std::unique_ptr fullpath{realpath(path.c_str(), nullptr), std::free}; if (!fullpath) - fullpath = strdup(path.c_str()); + fullpath.reset(strdup(path.c_str())); - if (lstat(fullpath, &s) < 0) { + if (lstat(fullpath.get(), &s) < 0) { int nerr = errno; - edm::LogWarning("LocalFileSystem::isLocalPath()") - << "Cannot lstat('" << fullpath << "' alias '" << path << "'): " << strerror(nerr) << " (error " << nerr << ")"; - free(fullpath); + edm::LogWarning("LocalFileSystem::isLocalPath()") << "Cannot lstat('" << fullpath.get() << "' alias '" << path + << "'): " << strerror(nerr) << " (error " << nerr << ")"; return false; } - if (statfs(fullpath, &sfs) < 0) { + if (statfs(fullpath.get(), &sfs) < 0) { int nerr = errno; - edm::LogWarning("LocalFileSystem::isLocalPath()") << "Cannot statfs('" << fullpath << "' alias '" << path + edm::LogWarning("LocalFileSystem::isLocalPath()") << "Cannot statfs('" << fullpath.get() << "' alias '" << path << "'): " << strerror(nerr) << " (error " << nerr << ")"; - free(fullpath); return false; } std::vector prev_paths; - FSInfo *m = findMount(fullpath, &sfs, &s, prev_paths); - free(fullpath); - + FSInfo *m = findMount(fullpath.get(), &sfs, &s, prev_paths); return m ? m->local : false; } @@ -434,7 +427,6 @@ std::pair LocalFileSystem::findCachePath(const std::ve warningst << "Cannot use lazy-download because:\n"; for (size_t i = 0, e = paths.size(); i < e; ++i) { - char *fullpath; const char *inpath = paths[i].c_str(); const char *path = inpath; @@ -446,61 +438,58 @@ std::pair LocalFileSystem::findCachePath(const std::ve path = "/tmp"; } - if (!(fullpath = realpath(path, nullptr))) - fullpath = strdup(path); + std::unique_ptr fullpath{realpath(path, nullptr), std::free}; + if (!fullpath) + fullpath.reset(strdup(path)); #if 0 std::cerr /* edm::LogInfo("LocalFileSystem") */ - << "Checking if '" << fullpath << "', from '" + << "Checking if '" << fullpath.get() << "', from '" << inpath << "' is valid cache path with " << minFreeSpace << " free space" << std::endl; #endif - if (lstat(fullpath, &s) < 0) { + if (lstat(fullpath.get(), &s) < 0) { int nerr = errno; if (nerr != ENOENT && nerr != EACCES) - edm::LogWarning("LocalFileSystem::findCachePath()") << "Cannot lstat('" << fullpath << "', from '" << inpath - << "'): " << strerror(nerr) << " (error " << nerr << ")"; - free(fullpath); + edm::LogWarning("LocalFileSystem::findCachePath()") + << "Cannot lstat('" << fullpath.get() << "', from '" << inpath << "'): " << strerror(nerr) << " (error " + << nerr << ")"; continue; } - if (statfs(fullpath, &sfs) < 0) { + if (statfs(fullpath.get(), &sfs) < 0) { int nerr = errno; - edm::LogWarning("LocalFileSystem::findCachePath()") << "Cannot statfs('" << fullpath << "', from '" << inpath - << "'): " << strerror(nerr) << " (error " << nerr << ")"; - free(fullpath); + edm::LogWarning("LocalFileSystem::findCachePath()") + << "Cannot statfs('" << fullpath.get() << "', from '" << inpath << "'): " << strerror(nerr) << " (error " + << nerr << ")"; continue; } std::vector prev_paths; - FSInfo *m = findMount(fullpath, &sfs, &s, prev_paths); + FSInfo *m = findMount(fullpath.get(), &sfs, &s, prev_paths); #if 0 std::cerr /* edm::LogInfo("LocalFileSystem") */ - << "Candidate '" << fullpath << "': " + << "Candidate '" << fullpath.get() << "': " << "found=" << (m ? 1 : 0) << " local=" << (m && m->local) << " free=" << (m ? m->freespc : 0) - << " access=" << access(fullpath, W_OK) + << " access=" << access(fullpath.get(), W_OK) << std::endl; #endif - if (m && m->local && m->freespc >= minFreeSpace && access(fullpath, W_OK) == 0) { - std::string result(fullpath); - free(fullpath); - return std::make_pair(result, std::string()); + if (m && m->local && m->freespc >= minFreeSpace && access(fullpath.get(), W_OK) == 0) { + return std::make_pair(std::string(fullpath.get()), std::string()); } else if (m) { if (!m->local) { - warningst << "- The mount " << fullpath << " is not local.\n"; + warningst << "- The mount " << fullpath.get() << " is not local.\n"; } else if (m->freespc < minFreeSpace) { - warningst << " - The mount at " << fullpath << " has only " << m->freespc << " GB free; a minumum of " + warningst << " - The mount at " << fullpath.get() << " has only " << m->freespc << " GB free; a minumum of " << minFreeSpace << " GB is required.\n"; - } else if (access(fullpath, W_OK)) { - warningst << " - The process has no permission to write into " << fullpath << "\n"; + } else if (access(fullpath.get(), W_OK)) { + warningst << " - The process has no permission to write into " << fullpath.get() << "\n"; } } - - free(fullpath); } std::string warning_str = warningst.str(); From 4deb2ab36507a39c326bc664c90289f1a2aa2dec Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Mon, 7 Oct 2024 10:03:50 +0200 Subject: [PATCH 07/14] [LLVM Analyzer][DB] Fix dead assignment in FEConfigLUTGroupDat --- OnlineDB/EcalCondDB/src/FEConfigLUTGroupDat.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OnlineDB/EcalCondDB/src/FEConfigLUTGroupDat.cc b/OnlineDB/EcalCondDB/src/FEConfigLUTGroupDat.cc index 55ac2eb82a44b..25159d2d10eca 100644 --- a/OnlineDB/EcalCondDB/src/FEConfigLUTGroupDat.cc +++ b/OnlineDB/EcalCondDB/src/FEConfigLUTGroupDat.cc @@ -127,8 +127,7 @@ void FEConfigLUTGroupDat::fetchData(map* fillM int nrows = 1024; - int igold = -1; - int ig = igold; + int ig = -1; while (rset->next()) { ig = rset->getInt(1); From d2801146f9d025b19a4a9da102d028a0392d07f5 Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Mon, 7 Oct 2024 12:01:05 +0200 Subject: [PATCH 08/14] Changes from review --- IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc b/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc index d8fe1f563997c..61a75bad3f7da 100644 --- a/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc +++ b/IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc @@ -259,8 +259,7 @@ bool PixelSLinkDataInputSource::setRunAndEventInfo(edm::EventID &id, // create product (raw data) buffers = std::make_unique(); - // uint32_t currenteventnumber = (m_data >> 32)&0x00ffffff; - uint32_t eventnumber = 0; + uint32_t eventnumber; do { std::vector buffer; From 92112aa65e6e12cea0bf42869c30b1367be225fb Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 7 Oct 2024 14:42:25 +0200 Subject: [PATCH 09/14] Allow only valid ZDChits to enter the digitization phase --- Geometry/ForwardGeometry/src/ZdcTopology.cc | 5 ++-- SimCalorimetry/HcalSimProducers/BuildFile.xml | 1 + .../interface/HcalDigitizer.h | 5 +++- .../HcalSimProducers/src/HcalDigitizer.cc | 29 ++++++++++++++++--- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Geometry/ForwardGeometry/src/ZdcTopology.cc b/Geometry/ForwardGeometry/src/ZdcTopology.cc index 56bd818f52dee..e0b92ccff8ae3 100644 --- a/Geometry/ForwardGeometry/src/ZdcTopology.cc +++ b/Geometry/ForwardGeometry/src/ZdcTopology.cc @@ -52,7 +52,7 @@ bool ZdcTopology::isExcluded(const HcalZDCDetId& id) const { exed = excludeRPD_; break; default: - exed = false; + exed = true; } // check the entire list @@ -167,7 +167,6 @@ bool ZdcTopology::validRaw(const HcalZDCDetId& id) const { ok = false; else if (id.channel() <= 0) ok = false; - //else if (!(id.section() == HcalZDCDetId::EM || id.section() == HcalZDCDetId::HAD || id.section() == HcalZDCDetId::LUM)) else if (!(id.section() == HcalZDCDetId::EM || id.section() == HcalZDCDetId::HAD || id.section() == HcalZDCDetId::LUM || id.section() == HcalZDCDetId::RPD)) ok = false; @@ -179,6 +178,8 @@ bool ZdcTopology::validRaw(const HcalZDCDetId& id) const { ok = false; else if (id.section() == HcalZDCDetId::RPD && id.channel() > HcalZDCDetId::kDepRPD) ok = false; + else if (id.section() == HcalZDCDetId::Unknown) + ok = false; return ok; } diff --git a/SimCalorimetry/HcalSimProducers/BuildFile.xml b/SimCalorimetry/HcalSimProducers/BuildFile.xml index 91092d4898831..e9afdf5da9965 100644 --- a/SimCalorimetry/HcalSimProducers/BuildFile.xml +++ b/SimCalorimetry/HcalSimProducers/BuildFile.xml @@ -1,6 +1,7 @@ + diff --git a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h index 5762b3ca1e29a..2def423fb366f 100644 --- a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h +++ b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h @@ -38,6 +38,7 @@ class HcalBaseSignalGenerator; class HcalShapes; class PileUpEventPrincipal; class HcalTopology; +class ZdcTopology; namespace CLHEP { class HepRandomEngine; @@ -67,7 +68,8 @@ class HcalDigitizer { edm::Handle> const &zdcHits, int bunchCrossing, CLHEP::HepRandomEngine *, - const HcalTopology *h); + const HcalTopology *h, + const ZdcTopology *z); /// some hits in each subdetector, just for testing purposes void fillFakeHits(); @@ -86,6 +88,7 @@ class HcalDigitizer { const edm::ESGetToken conditionsToken_; const edm::ESGetToken topoToken_; + const edm::ESGetToken topoZToken_; edm::ESGetToken m_HBDarkeningToken; edm::ESGetToken m_HEDarkeningToken; const edm::ESGetToken hcalTimeSlew_delay_token_; diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 612a894d32be9..35674acbef95c 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -13,6 +13,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" +#include "Geometry/ForwardGeometry/interface/ZdcTopology.h" #include "SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h" #include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h" #include "SimCalorimetry/HcalSimAlgos/interface/HPDIonFeedbackSim.h" @@ -34,6 +35,7 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC) : conditionsToken_(iC.esConsumes()), topoToken_(iC.esConsumes()), + topoZToken_(iC.esConsumes()), hcalTimeSlew_delay_token_(iC.esConsumes(edm::ESInputTag("", "HBHE"))), theGeometryToken(iC.esConsumes()), theRecNumberToken(iC.esConsumes()), @@ -348,7 +350,8 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const edm::Handle> const &zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine *engine, - const HcalTopology *htopoP) { + const HcalTopology *htopoP, + const ZdcTopology *ztopoP) { // Step A: pass in inputs, and accumulate digis if (isHCAL) { std::vector hcalHitsOrig = *hcalHandle.product(); @@ -420,7 +423,23 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const if (isZDC) { if (zdcgeo && theZDCDigitizer) { - theZDCDigitizer->add(*zdcHandle.product(), bunchCrossing, engine); + std::vector zdcHitsOrig = *zdcHandle.product(); + std::vector zdcHits; + zdcHits.reserve(zdcHitsOrig.size()); + // eliminate bad hits + for (unsigned int i = 0; i < zdcHitsOrig.size(); i++) { + DetId id(zdcHitsOrig[i].id()); + HcalZDCDetId hid(id); + if (!ztopoP->valid(hid)) { + edm::LogError("HcalDigitizer") << "bad zdc id found in digitizer. Skipping " << std::hex << id.rawId() << std::dec << " " << hid; + continue; + } + zdcHits.push_back(zdcHitsOrig[i]); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << zdcHitsOrig.size() << " " << std::hex << id.rawId() << " " << hid; +#endif + } + theZDCDigitizer->add(zdcHits, bunchCrossing, engine); } } else { edm::LogInfo("HcalDigitizer") << "We don't have ZDC hit collection available "; @@ -436,8 +455,9 @@ void HcalDigitizer::accumulate(edm::Event const &e, edm::EventSetup const &event isHCAL = hcalHandle.isValid() or injectTestHits_; const HcalTopology *htopoP = &eventSetup.getData(topoToken_); + const ZdcTopology *ztopoP = &eventSetup.getData(topoZToken_); - accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP); + accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP, ztopoP); } void HcalDigitizer::accumulate(PileUpEventPrincipal const &e, @@ -455,8 +475,9 @@ void HcalDigitizer::accumulate(PileUpEventPrincipal const &e, isHCAL = hcalHandle.isValid(); const HcalTopology *htopoP = &eventSetup.getData(topoToken_); + const ZdcTopology *ztopoP = &eventSetup.getData(topoZToken_); - accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP); + accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP, ztopoP); } void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSetup, CLHEP::HepRandomEngine *engine) { From fa726f26adc8183c3372a8e8b94793cecb099464 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 7 Oct 2024 14:50:21 +0200 Subject: [PATCH 10/14] Code check --- SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h | 2 +- SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h index 2def423fb366f..e462f466206a1 100644 --- a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h +++ b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h @@ -69,7 +69,7 @@ class HcalDigitizer { int bunchCrossing, CLHEP::HepRandomEngine *, const HcalTopology *h, - const ZdcTopology *z); + const ZdcTopology *z); /// some hits in each subdetector, just for testing purposes void fillFakeHits(); diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 35674acbef95c..38a51d5cea3ab 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -431,12 +431,14 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const DetId id(zdcHitsOrig[i].id()); HcalZDCDetId hid(id); if (!ztopoP->valid(hid)) { - edm::LogError("HcalDigitizer") << "bad zdc id found in digitizer. Skipping " << std::hex << id.rawId() << std::dec << " " << hid; + edm::LogError("HcalDigitizer") << "bad zdc id found in digitizer. Skipping " << std::hex << id.rawId() + << std::dec << " " << hid; continue; } zdcHits.push_back(zdcHitsOrig[i]); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << zdcHitsOrig.size() << " " << std::hex << id.rawId() << " " << hid; + edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << zdcHitsOrig.size() << " " << std::hex << id.rawId() + << " " << hid; #endif } theZDCDigitizer->add(zdcHits, bunchCrossing, engine); From 49c17d9516bfdb72bf154f8a495ba20c62d82d06 Mon Sep 17 00:00:00 2001 From: Malik Shahzad Muzaffar Date: Mon, 7 Oct 2024 16:48:05 +0200 Subject: [PATCH 11/14] Update Utilities/StorageFactory/src/LocalFileSystem.cc Co-authored-by: Matti Kortelainen --- Utilities/StorageFactory/src/LocalFileSystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/StorageFactory/src/LocalFileSystem.cc b/Utilities/StorageFactory/src/LocalFileSystem.cc index 866331e73f14e..31f0824e3eac0 100644 --- a/Utilities/StorageFactory/src/LocalFileSystem.cc +++ b/Utilities/StorageFactory/src/LocalFileSystem.cc @@ -168,7 +168,7 @@ LocalFileSystem::FSInfo *LocalFileSystem::initFSInfo(void *arg) { i->fsname = static_cast(memcpy(p += infolen, m->mnt_fsname, fslen)); i->type = static_cast(memcpy(p += fslen, m->mnt_type, typelen)); i->dir = static_cast(memcpy(p += typelen, m->mnt_dir, dirlen)); - [[clang::suppress]] i->origin = static_cast(memcpy(p += dirlen, m->mnt_fsname, originlen)); + i->origin = static_cast(memcpy(p + dirlen, m->mnt_fsname, originlen)); i->dev = -1; i->fstype = -1; i->freespc = 0; From 1d556025da7b07ae075411ee9c4bd6a71a9ec806 Mon Sep 17 00:00:00 2001 From: rseidita <43850110+rseidita@users.noreply.github.com> Date: Mon, 7 Oct 2024 18:18:17 +0200 Subject: [PATCH 12/14] Removing Muon POG sequence from Express DQM sequence --- DQMOffline/Configuration/python/DQMOffline_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMOffline/Configuration/python/DQMOffline_cff.py b/DQMOffline/Configuration/python/DQMOffline_cff.py index 1adbfe40a9677..206eef364931a 100644 --- a/DQMOffline/Configuration/python/DQMOffline_cff.py +++ b/DQMOffline/Configuration/python/DQMOffline_cff.py @@ -158,7 +158,7 @@ DQMOfflinePrePOGExpress = cms.Sequence( DQMOfflineTracking * - DQMOfflineMUO * + #DQMOfflineMUO * #DQMOfflineJetMET * #DQMOfflineEGamma * DQMOfflineTrigger * From 306cab40c1fa06297f61933f5ccd6d01e8cd26f0 Mon Sep 17 00:00:00 2001 From: rseidita <43850110+rseidita@users.noreply.github.com> Date: Mon, 7 Oct 2024 18:22:05 +0200 Subject: [PATCH 13/14] Update DQMOffline_SecondStep_cff.py --- DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py b/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py index e35df7d8f08a7..efc8c19ae01c3 100644 --- a/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py +++ b/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py @@ -115,7 +115,7 @@ DQMOffline_SecondStep_PrePOG_Express = cms.Sequence( DQMOffline_SecondStepTracking * - DQMOffline_SecondStepMUO * + #DQMOffline_SecondStepMUO * #DQMOffline_SecondStepEGamma * DQMOffline_SecondStepTrigger * DQMOffline_SecondStepBTag * From 228bf6e028fb1994c739e3ac0af88fd90f3c2b87 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 7 Oct 2024 09:03:13 -0500 Subject: [PATCH 14/14] Improve constructor for PhotonIsolationCalculator It is in general better to use a constructor rather than a setup method. --- .../src/GEDPhotonProducer.cc | 13 +++--- .../src/PhotonProducer.cc | 40 +++++++------------ .../interface/PhotonIsolationCalculator.h | 18 ++++----- .../src/PhotonIsolationCalculator.cc | 12 +++--- 4 files changed, 34 insertions(+), 49 deletions(-) diff --git a/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc index 6344c589a519b..009467ec07b4d 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc @@ -426,14 +426,13 @@ GEDPhotonProducer::GEDPhotonProducer(const edm::ParameterSet& config, const Cach //moved from beginRun to here, I dont see how this could cause harm as its just reading in the exactly same parameters each run if (!recoStep_.isFinal()) { - photonIsoCalculator_ = std::make_unique(); edm::ParameterSet isolationSumsCalculatorSet = config.getParameter("isolationSumsCalculatorSet"); - photonIsoCalculator_->setup(isolationSumsCalculatorSet, - flagsexclEB_, - flagsexclEE_, - severitiesexclEB_, - severitiesexclEE_, - consumesCollector()); + photonIsoCalculator_ = std::make_unique(isolationSumsCalculatorSet, + flagsexclEB_, + flagsexclEE_, + severitiesexclEB_, + severitiesexclEE_, + consumesCollector()); edm::ParameterSet mipVariableSet = config.getParameter("mipVariableSet"); photonMIPHaloTagger_ = std::make_unique(mipVariableSet, consumesCollector()); } diff --git a/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc index 3f2b6d6189962..a90c6cece1802 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc @@ -125,6 +125,20 @@ DEFINE_FWK_MODULE(PhotonProducer); PhotonProducer::PhotonProducer(const edm::ParameterSet& config) : caloGeomToken_(esConsumes()), topologyToken_(esConsumes()), + flagsexclEB_{StringToEnumValue( + config.getParameter>("RecHitFlagToBeExcludedEB"))}, + flagsexclEE_{StringToEnumValue( + config.getParameter>("RecHitFlagToBeExcludedEE"))}, + severitiesexclEB_{StringToEnumValue( + config.getParameter>("RecHitSeverityToBeExcludedEB"))}, + severitiesexclEE_{StringToEnumValue( + config.getParameter>("RecHitSeverityToBeExcludedEE"))}, + photonIsolationCalculator_(config.getParameter("isolationSumsCalculatorSet"), + flagsexclEB_, + flagsexclEE_, + severitiesexclEB_, + severitiesexclEE_, + consumesCollector()), photonMIPHaloTagger_(config.getParameter("mipVariableSet"), consumesCollector()), photonEnergyCorrector_(config, consumesCollector()) { // use configuration file to setup input/output collection names @@ -154,28 +168,6 @@ PhotonProducer::PhotonProducer(const edm::ParameterSet& config) hcalCutsToken_ = esConsumes(edm::ESInputTag("", "withTopo")); } - //AA - //Flags and Severities to be excluded from photon calculations - const std::vector flagnamesEB = - config.getParameter>("RecHitFlagToBeExcludedEB"); - - const std::vector flagnamesEE = - config.getParameter>("RecHitFlagToBeExcludedEE"); - - flagsexclEB_ = StringToEnumValue(flagnamesEB); - - flagsexclEE_ = StringToEnumValue(flagnamesEE); - - const std::vector severitynamesEB = - config.getParameter>("RecHitSeverityToBeExcludedEB"); - - severitiesexclEB_ = StringToEnumValue(severitynamesEB); - - const std::vector severitynamesEE = - config.getParameter>("RecHitSeverityToBeExcludedEE"); - - severitiesexclEE_ = StringToEnumValue(severitynamesEE); - ElectronHcalHelper::Configuration cfgCone, cfgBc; cfgCone.hOverEConeSize = hOverEConeSize_; if (cfgCone.hOverEConeSize > 0) { @@ -245,10 +237,6 @@ PhotonProducer::PhotonProducer(const edm::ParameterSet& config) preselCutValuesEndcap_.push_back(config.getParameter("sigmaIetaIetaCutEndcap")); // - edm::ParameterSet isolationSumsCalculatorSet = config.getParameter("isolationSumsCalculatorSet"); - photonIsolationCalculator_.setup( - isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_, consumesCollector()); - // Register the product produces(PhotonCollection_); } diff --git a/RecoEgamma/PhotonIdentification/interface/PhotonIsolationCalculator.h b/RecoEgamma/PhotonIdentification/interface/PhotonIsolationCalculator.h index 85204bd35ebb1..8983bce0d8e9a 100644 --- a/RecoEgamma/PhotonIdentification/interface/PhotonIsolationCalculator.h +++ b/RecoEgamma/PhotonIdentification/interface/PhotonIsolationCalculator.h @@ -32,16 +32,14 @@ class EcalSeverityLevelAlgoRcd; class PhotonIsolationCalculator { public: - PhotonIsolationCalculator() {} - - ~PhotonIsolationCalculator() {} - - void setup(const edm::ParameterSet& conf, - std::vector const& flagsEB_, - std::vector const& flagsEE_, - std::vector const& severitiesEB_, - std::vector const& severitiesEE_, - edm::ConsumesCollector&& iC); + PhotonIsolationCalculator(const edm::ParameterSet& conf, + std::vector const& flagsEB_, + std::vector const& flagsEE_, + std::vector const& severitiesEB_, + std::vector const& severitiesEE_, + edm::ConsumesCollector&& iC); + + ~PhotonIsolationCalculator() = default; void calculate(const reco::Photon*, const edm::Event&, diff --git a/RecoEgamma/PhotonIdentification/src/PhotonIsolationCalculator.cc b/RecoEgamma/PhotonIdentification/src/PhotonIsolationCalculator.cc index 1774cb2f047ee..be5f5e940a591 100644 --- a/RecoEgamma/PhotonIdentification/src/PhotonIsolationCalculator.cc +++ b/RecoEgamma/PhotonIdentification/src/PhotonIsolationCalculator.cc @@ -26,12 +26,12 @@ #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" -void PhotonIsolationCalculator::setup(const edm::ParameterSet& conf, - std::vector const& flagsEB, - std::vector const& flagsEE, - std::vector const& severitiesEB, - std::vector const& severitiesEE, - edm::ConsumesCollector&& iC) { +PhotonIsolationCalculator::PhotonIsolationCalculator(const edm::ParameterSet& conf, + std::vector const& flagsEB, + std::vector const& flagsEE, + std::vector const& severitiesEB, + std::vector const& severitiesEE, + edm::ConsumesCollector&& iC) { trackInputTag_ = iC.consumes(conf.getParameter("trackProducer")); beamSpotProducerTag_ = iC.consumes(conf.getParameter("beamSpotProducer")); barrelecalCollection_ =