From 6340241c66e6132b0c5167d25d248e6590b29303 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 29 Mar 2022 15:03:38 +0200 Subject: [PATCH 1/6] Try to resolve compilation warnings in RecoParticleFlow/PFProducer --- .../PFProducer/test/PFBlockComparator.cc | 21 +- .../PFProducer/test/PFEGCandidateTreeMaker.cc | 186 +++++++++--------- .../test/PFEGammaCandidateChecker.cc | 58 ++---- .../test/PFEGammaCandidateChecker.h | 30 ++- 4 files changed, 137 insertions(+), 158 deletions(-) diff --git a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc b/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc index 3965bd145fe1a..f75f3c397a20b 100644 --- a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc +++ b/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc @@ -11,7 +11,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "DataFormats/EgammaCandidates/interface/Photon.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h" @@ -35,9 +35,6 @@ #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "TTree.h" -#include "TVector2.h" - #include #include #include @@ -157,24 +154,22 @@ namespace { typedef edm::ParameterSet PSet; -class PFBlockComparator : public edm::EDAnalyzer { +class PFBlockComparator : public edm::one::EDAnalyzer<> { public: PFBlockComparator(const PSet& c) - : _src(c.getParameter("source")), _srcOld(c.getParameter("sourceOld")){}; - ~PFBlockComparator() {} + : srcToken_(consumes(c.getParameter("source"))), srcOldToken_(consumes(c.getParameter("sourceOld"))) {}; + ~PFBlockComparator() = default; void analyze(const edm::Event&, const edm::EventSetup&); private: - edm::InputTag _src; - edm::InputTag _srcOld; + edm::EDGetTokenT srcToken_; + edm::EDGetTokenT srcOldToken_; }; void PFBlockComparator::analyze(const edm::Event& e, const edm::EventSetup& es) { - edm::Handle blocks; - e.getByLabel(_src, blocks); - edm::Handle oldblocks; - e.getByLabel(_srcOld, oldblocks); + const edm::Handle& blocks = e.getHandle(srcToken_); + const edm::Handle& oldblocks = e.getHandle(srcOldToken_); unsigned matchedblocks = 0; diff --git a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc b/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc index 4f38db4218ce1..b4f24baf4355b 100644 --- a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc +++ b/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc @@ -11,7 +11,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "DataFormats/EgammaCandidates/interface/Photon.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h" @@ -70,22 +70,26 @@ namespace { }; } // namespace -class PFEGCandidateTreeMaker : public edm::EDAnalyzer { +class PFEGCandidateTreeMaker : public edm::one::EDAnalyzer { typedef TTree* treeptr; public: PFEGCandidateTreeMaker(const PSet&); - ~PFEGCandidateTreeMaker() {} + ~PFEGCandidateTreeMaker() override = default; void analyze(const edm::Event&, const edm::EventSetup&) override; private: - edm::Service _fs; - bool _dogen; - edm::InputTag _geninput; - edm::InputTag _vtxsrc; - edm::InputTag _pfEGInput; - edm::InputTag _pfInput; + const bool dogen_; + const edm::InputTag geninput_; + const edm::InputTag vtxsrc_; + const edm::InputTag pfEGInput_; + const edm::InputTag pfInput_; + const edm::EDGetTokenT genToken_; + const edm::EDGetTokenT vtxToken_; + const edm::EDGetTokenT pfEGToken_; + const edm::EDGetTokenT pfToken_; + PFEnergyCalibration _calib; std::map _genmatched; void findBestGenMatches(const edm::Event& e, const edm::Handle&); @@ -95,14 +99,14 @@ class PFEGCandidateTreeMaker : public edm::EDAnalyzer { bool getPFCandMatch(const reco::PFCandidate&, const edm::Handle&, const int); // SC parameters - edm::ESGetToken ecalMustacheSCParametersToken_; + const edm::ESGetToken ecalMustacheSCParametersToken_; const EcalMustacheSCParameters* mustacheSCParams_; - edm::ESGetToken ecalSCDynamicDPhiParametersToken_; + const edm::ESGetToken ecalSCDynamicDPhiParametersToken_; const EcalSCDynamicDPhiParameters* scDynamicDPhiParams_; // the tree void setTreeArraysForSize(const size_t N_ECAL, const size_t N_PS); - treeptr _tree; + treeptr tree_; Int_t nVtx; Float_t scRawEnergy, scCalibratedEnergy, scPreshowerEnergy, scEta, scPhi, scR, scPhiWidth, scEtaWidth, scSeedRawEnergy, scSeedCalibratedEnergy, scSeedEta, scSeedPhi; @@ -122,17 +126,14 @@ void PFEGCandidateTreeMaker::analyze(const edm::Event& e, const edm::EventSetup& mustacheSCParams_ = &es.getData(ecalMustacheSCParametersToken_); scDynamicDPhiParams_ = &es.getData(ecalSCDynamicDPhiParametersToken_); - edm::Handle vtcs; - e.getByLabel(_vtxsrc, vtcs); + const edm::Handle& vtcs = e.getHandle(vtxToken_); if (vtcs.isValid()) nVtx = vtcs->size(); else nVtx = -1; - edm::Handle pfEG; - edm::Handle pfCands; - e.getByLabel(_pfEGInput, pfEG); - e.getByLabel(_pfInput, pfCands); + const edm::Handle& pfEG = e.getHandle(pfEGToken_); + const edm::Handle& pfCands = e.getHandle(pfToken_); if (pfEG.isValid()) { findBestGenMatches(e, pfEG); @@ -150,10 +151,9 @@ void PFEGCandidateTreeMaker::findBestGenMatches(const edm::Event& e, _genmatched.clear(); reco::GenParticleRef genmatch; // gen information (if needed) - if (_dogen) { - edm::Handle genp; + if (dogen_) { + const edm::Handle& genp = e.getHandle(genToken_); std::vector elesandphos; - e.getByLabel(_geninput, genp); if (genp.isValid()) { reco::GenParticleRef bestmatch; for (size_t i = 0; i < genp->size(); ++i) { @@ -211,7 +211,7 @@ void PFEGCandidateTreeMaker::processEGCandidateFillTree(const edm::Event& e, N_PSClusters = N_PS; reco::GenParticleRef genmatch; // gen information (if needed) - if (_dogen) { + if (dogen_) { std::map::iterator itrmatch; if ((itrmatch = _genmatched.find(pf)) != _genmatched.end()) { genmatch = itrmatch->second; @@ -267,7 +267,7 @@ void PFEGCandidateTreeMaker::processEGCandidateFillTree(const edm::Event& e, clusterDPhiToCentroid[iclus] = TVector2::Phi_mpi_pi(pclus->phi() - sc.phi()); clusterDEtaToCentroid[iclus] = pclus->eta() - sc.eta(); clusterHitFractionSharedWithSeed[iclus] = fractionOfSeed(pclus); - if (_dogen && genmatch.isNonnull()) { + if (dogen_ && genmatch.isNonnull()) { clusterDPhiToGen[iclus] = TVector2::Phi_mpi_pi(pclus->phi() - genmatch->phi()); clusterDEtaToGen[iclus] = pclus->eta() - genmatch->eta(); } @@ -292,7 +292,7 @@ void PFEGCandidateTreeMaker::processEGCandidateFillTree(const edm::Event& e, psClusterPhi[ipsclus] = ppsclus->phi(); ++ipsclus; } - _tree->Fill(); + tree_->Fill(); } bool PFEGCandidateTreeMaker::getPFCandMatch(const reco::PFCandidate& cand, @@ -324,118 +324,126 @@ bool PFEGCandidateTreeMaker::getPFCandMatch(const reco::PFCandidate& cand, return false; } -PFEGCandidateTreeMaker::PFEGCandidateTreeMaker(const PSet& p) { - ecalMustacheSCParametersToken_ = esConsumes(); - ecalSCDynamicDPhiParametersToken_ = esConsumes(); +PFEGCandidateTreeMaker::PFEGCandidateTreeMaker(const PSet& p) : + dogen_(p.getUntrackedParameter("doGen", false)), + geninput_(p.getParameter("genSrc")), + vtxsrc_(p.getParameter("primaryVertices")), + pfEGInput_(p.getParameter("pfEGammaCandSrc")), + pfInput_(p.getParameter("pfCandSrc")), + genToken_(consumes(geninput_)), + vtxToken_(consumes(vtxsrc_)), + pfEGToken_(consumes(pfEGInput_)), + pfToken_(consumes (pfInput_)), + ecalMustacheSCParametersToken_(esConsumes()), + ecalSCDynamicDPhiParametersToken_(esConsumes()) { + + usesResource(TFileService::kSharedResource); N_ECALClusters = 1; N_PSClusters = 1; - _tree = _fs->make("SuperClusterTree", "Dump of all available SC info"); - _tree->Branch("N_ECALClusters", &N_ECALClusters, "N_ECALClusters/I"); - _tree->Branch("N_PSClusters", &N_PSClusters, "N_PSClusters/I"); - _tree->Branch("nVtx", &nVtx, "nVtx/I"); - _tree->Branch("hasParentSC", &hasParentSC, "hasParentSC/I"); - _tree->Branch("pfPhotonMatch", &pfPhotonMatch, "pfPhotonMatch/I"); - _tree->Branch("pfElectronMatch", &pfElectronMatch, "pfElectronMatch/I"); - _tree->Branch("scRawEnergy", &scRawEnergy, "scRawEnergy/F"); - _tree->Branch("scCalibratedEnergy", &scCalibratedEnergy, "scCalibratedEnergy/F"); - _tree->Branch("scPreshowerEnergy", &scPreshowerEnergy, "scPreshowerEnergy/F"); - _tree->Branch("scEta", &scEta, "scEta/F"); - _tree->Branch("scPhi", &scPhi, "scPhi/F"); - _tree->Branch("scR", &scR, "scR/F"); - _tree->Branch("scPhiWidth", &scPhiWidth, "scPhiWidth/F"); - _tree->Branch("scEtaWidth", &scEtaWidth, "scEtaWidth/F"); - _tree->Branch("scSeedRawEnergy", &scSeedRawEnergy, "scSeedRawEnergy/F"); - _tree->Branch("scSeedCalibratedEnergy", &scSeedCalibratedEnergy, "scSeedCalibratedEnergy/F"); - _tree->Branch("scSeedEta", &scSeedEta, "scSeedEta/F"); - _tree->Branch("scSeedPhi", &scSeedPhi, "scSeedPhi/F"); + edm::Service fs; + tree_ = fs->make("SuperClusterTree", "Dump of all available SC info"); + tree_->Branch("N_ECALClusters", &N_ECALClusters, "N_ECALClusters/I"); + tree_->Branch("N_PSClusters", &N_PSClusters, "N_PSClusters/I"); + tree_->Branch("nVtx", &nVtx, "nVtx/I"); + tree_->Branch("hasParentSC", &hasParentSC, "hasParentSC/I"); + tree_->Branch("pfPhotonMatch", &pfPhotonMatch, "pfPhotonMatch/I"); + tree_->Branch("pfElectronMatch", &pfElectronMatch, "pfElectronMatch/I"); + tree_->Branch("scRawEnergy", &scRawEnergy, "scRawEnergy/F"); + tree_->Branch("scCalibratedEnergy", &scCalibratedEnergy, "scCalibratedEnergy/F"); + tree_->Branch("scPreshowerEnergy", &scPreshowerEnergy, "scPreshowerEnergy/F"); + tree_->Branch("scEta", &scEta, "scEta/F"); + tree_->Branch("scPhi", &scPhi, "scPhi/F"); + tree_->Branch("scR", &scR, "scR/F"); + tree_->Branch("scPhiWidth", &scPhiWidth, "scPhiWidth/F"); + tree_->Branch("scEtaWidth", &scEtaWidth, "scEtaWidth/F"); + tree_->Branch("scSeedRawEnergy", &scSeedRawEnergy, "scSeedRawEnergy/F"); + tree_->Branch("scSeedCalibratedEnergy", &scSeedCalibratedEnergy, "scSeedCalibratedEnergy/F"); + tree_->Branch("scSeedEta", &scSeedEta, "scSeedEta/F"); + tree_->Branch("scSeedPhi", &scSeedPhi, "scSeedPhi/F"); // ecal cluster information clusterRawEnergy.resize(1); - _tree->Branch("clusterRawEnergy", &clusterRawEnergy[0], "clusterRawEnergy[N_ECALClusters]/F"); + tree_->Branch("clusterRawEnergy", &clusterRawEnergy[0], "clusterRawEnergy[N_ECALClusters]/F"); clusterCalibEnergy.resize(1); - _tree->Branch("clusterCalibEnergy", &clusterCalibEnergy[0], "clusterCalibEnergy[N_ECALClusters]/F"); + tree_->Branch("clusterCalibEnergy", &clusterCalibEnergy[0], "clusterCalibEnergy[N_ECALClusters]/F"); clusterEta.resize(1); - _tree->Branch("clusterEta", &clusterEta[0], "clusterEta[N_ECALClusters]/F"); + tree_->Branch("clusterEta", &clusterEta[0], "clusterEta[N_ECALClusters]/F"); clusterPhi.resize(1); - _tree->Branch("clusterPhi", &clusterPhi[0], "clusterPhi[N_ECALClusters]/F"); + tree_->Branch("clusterPhi", &clusterPhi[0], "clusterPhi[N_ECALClusters]/F"); clusterDPhiToSeed.resize(1); - _tree->Branch("clusterDPhiToSeed", &clusterDPhiToSeed[0], "clusterDPhiToSeed[N_ECALClusters]/F"); + tree_->Branch("clusterDPhiToSeed", &clusterDPhiToSeed[0], "clusterDPhiToSeed[N_ECALClusters]/F"); clusterDEtaToSeed.resize(1); - _tree->Branch("clusterDEtaToSeed", &clusterDEtaToSeed[0], "clusterDEtaToSeed[N_ECALClusters]/F"); + tree_->Branch("clusterDEtaToSeed", &clusterDEtaToSeed[0], "clusterDEtaToSeed[N_ECALClusters]/F"); clusterDPhiToCentroid.resize(1); - _tree->Branch("clusterDPhiToCentroid", &clusterDPhiToCentroid[0], "clusterDPhiToCentroid[N_ECALClusters]/F"); + tree_->Branch("clusterDPhiToCentroid", &clusterDPhiToCentroid[0], "clusterDPhiToCentroid[N_ECALClusters]/F"); clusterDEtaToCentroid.resize(1); - _tree->Branch("clusterDEtaToCentroid", &clusterDEtaToCentroid[0], "clusterDEtaToCentroid[N_ECALClusters]/F"); + tree_->Branch("clusterDEtaToCentroid", &clusterDEtaToCentroid[0], "clusterDEtaToCentroid[N_ECALClusters]/F"); clusterHitFractionSharedWithSeed.resize(1); - _tree->Branch("clusterHitFractionSharedWithSeed", + tree_->Branch("clusterHitFractionSharedWithSeed", &clusterHitFractionSharedWithSeed[0], "clusterHitFractionSharedWithSeed[N_ECALClusters]/F"); clusterInMustache.resize(1); - _tree->Branch("clusterInMustache", &clusterInMustache[0], "clusterInMustache[N_ECALClusters]/I"); + tree_->Branch("clusterInMustache", &clusterInMustache[0], "clusterInMustache[N_ECALClusters]/I"); clusterInDynDPhi.resize(1); - _tree->Branch("clusterInDynDPhi", &clusterInDynDPhi[0], "clusterInDynDPhi[N_ECALClusters]/I"); + tree_->Branch("clusterInDynDPhi", &clusterInDynDPhi[0], "clusterInDynDPhi[N_ECALClusters]/I"); // preshower information psClusterRawEnergy.resize(1); - _tree->Branch("psClusterRawEnergy", &psClusterRawEnergy[0], "psClusterRawEnergy[N_PSClusters]/F"); + tree_->Branch("psClusterRawEnergy", &psClusterRawEnergy[0], "psClusterRawEnergy[N_PSClusters]/F"); psClusterEta.resize(1); - _tree->Branch("psClusterEta", &psClusterEta[0], "psClusterEta[N_PSClusters]/F"); + tree_->Branch("psClusterEta", &psClusterEta[0], "psClusterEta[N_PSClusters]/F"); psClusterPhi.resize(1); - _tree->Branch("psClusterPhi", &psClusterPhi[0], "psClusterPhi[N_PSClusters]/F"); + tree_->Branch("psClusterPhi", &psClusterPhi[0], "psClusterPhi[N_PSClusters]/F"); - if ((_dogen = p.getUntrackedParameter("doGen", false))) { - _geninput = p.getParameter("genSrc"); - _tree->Branch("genEta", &genEta, "genEta/F"); - _tree->Branch("genPhi", &genPhi, "genPhi/F"); - _tree->Branch("genEnergy", &genEnergy, "genEnergy/F"); - _tree->Branch("genDRToCentroid", &genDRToCentroid, "genDRToCentroid/F"); - _tree->Branch("genDRToSeed", &genDRToSeed, "genDRToSeed/F"); + if (dogen_) { + tree_->Branch("genEta", &genEta, "genEta/F"); + tree_->Branch("genPhi", &genPhi, "genPhi/F"); + tree_->Branch("genEnergy", &genEnergy, "genEnergy/F"); + tree_->Branch("genDRToCentroid", &genDRToCentroid, "genDRToCentroid/F"); + tree_->Branch("genDRToSeed", &genDRToSeed, "genDRToSeed/F"); clusterDPhiToGen.resize(1); - _tree->Branch("clusterDPhiToGen", &clusterDPhiToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); + tree_->Branch("clusterDPhiToGen", &clusterDPhiToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); clusterDEtaToGen.resize(1); - _tree->Branch("clusterDEtaToGen", &clusterDEtaToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); + tree_->Branch("clusterDEtaToGen", &clusterDEtaToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); } - _vtxsrc = p.getParameter("primaryVertices"); - _pfEGInput = p.getParameter("pfEGammaCandSrc"); - _pfInput = p.getParameter("pfCandSrc"); } void PFEGCandidateTreeMaker::setTreeArraysForSize(const size_t N_ECAL, const size_t N_PS) { clusterRawEnergy.resize(N_ECAL); - _tree->GetBranch("clusterRawEnergy")->SetAddress(&clusterRawEnergy[0]); + tree_->GetBranch("clusterRawEnergy")->SetAddress(&clusterRawEnergy[0]); clusterCalibEnergy.resize(N_ECAL); - _tree->GetBranch("clusterCalibEnergy")->SetAddress(&clusterCalibEnergy[0]); + tree_->GetBranch("clusterCalibEnergy")->SetAddress(&clusterCalibEnergy[0]); clusterEta.resize(N_ECAL); - _tree->GetBranch("clusterEta")->SetAddress(&clusterEta[0]); + tree_->GetBranch("clusterEta")->SetAddress(&clusterEta[0]); clusterPhi.resize(N_ECAL); - _tree->GetBranch("clusterPhi")->SetAddress(&clusterPhi[0]); + tree_->GetBranch("clusterPhi")->SetAddress(&clusterPhi[0]); clusterDPhiToSeed.resize(N_ECAL); - _tree->GetBranch("clusterDPhiToSeed")->SetAddress(&clusterDPhiToSeed[0]); + tree_->GetBranch("clusterDPhiToSeed")->SetAddress(&clusterDPhiToSeed[0]); clusterDEtaToSeed.resize(N_ECAL); - _tree->GetBranch("clusterDEtaToSeed")->SetAddress(&clusterDEtaToSeed[0]); + tree_->GetBranch("clusterDEtaToSeed")->SetAddress(&clusterDEtaToSeed[0]); clusterDPhiToCentroid.resize(N_ECAL); - _tree->GetBranch("clusterDPhiToCentroid")->SetAddress(&clusterDPhiToCentroid[0]); + tree_->GetBranch("clusterDPhiToCentroid")->SetAddress(&clusterDPhiToCentroid[0]); clusterDEtaToCentroid.resize(N_ECAL); - _tree->GetBranch("clusterDEtaToCentroid")->SetAddress(&clusterDEtaToCentroid[0]); + tree_->GetBranch("clusterDEtaToCentroid")->SetAddress(&clusterDEtaToCentroid[0]); clusterHitFractionSharedWithSeed.resize(N_ECAL); - _tree->GetBranch("clusterHitFractionSharedWithSeed")->SetAddress(&clusterHitFractionSharedWithSeed[0]); + tree_->GetBranch("clusterHitFractionSharedWithSeed")->SetAddress(&clusterHitFractionSharedWithSeed[0]); - if (_dogen) { + if (dogen_) { clusterDPhiToGen.resize(N_ECAL); - _tree->GetBranch("clusterDPhiToGen")->SetAddress(&clusterDPhiToGen[0]); + tree_->GetBranch("clusterDPhiToGen")->SetAddress(&clusterDPhiToGen[0]); clusterDEtaToGen.resize(N_ECAL); - _tree->GetBranch("clusterDEtaToGen")->SetAddress(&clusterDEtaToGen[0]); + tree_->GetBranch("clusterDEtaToGen")->SetAddress(&clusterDEtaToGen[0]); } clusterInMustache.resize(N_ECAL); - _tree->GetBranch("clusterInMustache")->SetAddress(&clusterInMustache[0]); + tree_->GetBranch("clusterInMustache")->SetAddress(&clusterInMustache[0]); clusterInDynDPhi.resize(N_ECAL); - _tree->GetBranch("clusterInDynDPhi")->SetAddress(&clusterInDynDPhi[0]); + tree_->GetBranch("clusterInDynDPhi")->SetAddress(&clusterInDynDPhi[0]); psClusterRawEnergy.resize(N_ECAL); - _tree->GetBranch("psClusterRawEnergy")->SetAddress(&psClusterRawEnergy[0]); + tree_->GetBranch("psClusterRawEnergy")->SetAddress(&psClusterRawEnergy[0]); psClusterEta.resize(N_ECAL); - _tree->GetBranch("psClusterEta")->SetAddress(&psClusterEta[0]); + tree_->GetBranch("psClusterEta")->SetAddress(&psClusterEta[0]); psClusterPhi.resize(N_ECAL); - _tree->GetBranch("psClusterPhi")->SetAddress(&psClusterPhi[0]); + tree_->GetBranch("psClusterPhi")->SetAddress(&psClusterPhi[0]); } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc index ddf9af83ea33f..095694b6f7402 100644 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc +++ b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc @@ -44,54 +44,32 @@ namespace { }; } // namespace -PFEGammaCandidateChecker::PFEGammaCandidateChecker(const edm::ParameterSet& iConfig) { - inputTagPFCandidatesReco_ = iConfig.getParameter("pfCandidatesReco"); - - inputTagPFCandidatesReReco_ = iConfig.getParameter("pfCandidatesReReco"); - - inputTagPFJetsReco_ = iConfig.getParameter("pfJetsReco"); - - inputTagPFJetsReReco_ = iConfig.getParameter("pfJetsReReco"); - - deltaEMax_ = iConfig.getParameter("deltaEMax"); - - deltaEtaMax_ = iConfig.getParameter("deltaEtaMax"); - - deltaPhiMax_ = iConfig.getParameter("deltaPhiMax"); - - verbose_ = iConfig.getUntrackedParameter("verbose", false); - - printBlocks_ = iConfig.getUntrackedParameter("printBlocks", false); - - rankByPt_ = iConfig.getUntrackedParameter("rankByPt", false); - +PFEGammaCandidateChecker::PFEGammaCandidateChecker(const edm::ParameterSet& iConfig) : + tokenPFCandidatesReco_(consumes(iConfig.getParameter("pfCandidatesReco"))), + tokenPFCandidatesReReco_(consumes(iConfig.getParameter("pfCandidatesReReco"))), + tokenPFJetsReco_(consumes(iConfig.getParameter("pfJetsReco"))), + tokenPFJetsReReco_(consumes(iConfig.getParameter("pfJetsReReco"))), + deltaEMax_(iConfig.getParameter("deltaEMax")), + deltaEtaMax_(iConfig.getParameter("deltaEtaMax")), + deltaPhiMax_(iConfig.getParameter("deltaPhiMax")), + verbose_(iConfig.getUntrackedParameter("verbose", false)), + printBlocks_(iConfig.getUntrackedParameter("printBlocks", false)), + rankByPt_(iConfig.getUntrackedParameter("rankByPt", false)) { + entry_ = 0; - LogDebug("PFEGammaCandidateChecker") << " input collections : " << inputTagPFCandidatesReco_ << " " - << inputTagPFCandidatesReReco_; + LogDebug("PFEGammaCandidateChecker") << " input collections : " << (iConfig.getParameter("pfCandidatesReco")) << " " << (iConfig.getParameter("pfCandidatesReReco")); } -PFEGammaCandidateChecker::~PFEGammaCandidateChecker() {} - -void PFEGammaCandidateChecker::beginRun(const edm::Run& run, const edm::EventSetup& es) {} - void PFEGammaCandidateChecker::analyze(const Event& iEvent, const EventSetup& iSetup) { - LogDebug("PFEGammaCandidateChecker") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run() - << endl; + LogDebug("PFEGammaCandidateChecker") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run(); // get PFCandidates - Handle pfCandidatesReco; - iEvent.getByLabel(inputTagPFCandidatesReco_, pfCandidatesReco); - - Handle pfCandidatesReReco; - iEvent.getByLabel(inputTagPFCandidatesReReco_, pfCandidatesReReco); - - Handle pfJetsReco; - iEvent.getByLabel(inputTagPFJetsReco_, pfJetsReco); - - Handle pfJetsReReco; - iEvent.getByLabel(inputTagPFJetsReReco_, pfJetsReReco); + const edm::Handle& pfCandidatesReco = iEvent.getHandle(tokenPFCandidatesReco_); + const edm::Handle& pfCandidatesReReco = iEvent.getHandle(tokenPFCandidatesReReco_); + const edm::Handle& pfJetsReco = iEvent.getHandle(tokenPFJetsReco_); + const edm::Handle& pfJetsReReco = iEvent.getHandle(tokenPFJetsReReco_); reco::PFCandidateCollection pfReco, pfReReco; diff --git a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h index 705843de9fb91..58b339bb37022 100644 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h +++ b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h @@ -8,7 +8,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" #include "FWCore/Framework/interface/Event.h" @@ -25,15 +25,13 @@ \date August 2011 */ -class PFEGammaCandidateChecker : public edm::EDAnalyzer { +class PFEGammaCandidateChecker : public edm::one::EDAnalyzer<> { public: explicit PFEGammaCandidateChecker(const edm::ParameterSet&); - ~PFEGammaCandidateChecker(); + ~PFEGammaCandidateChecker() override = default; - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - virtual void beginRun(const edm::Run& r, const edm::EventSetup& c); + void analyze(const edm::Event&, const edm::EventSetup&) override; private: void printJets(const reco::PFJetCollection& pfJetsReco, const reco::PFJetCollection& pfJetsReReco) const; @@ -43,24 +41,24 @@ class PFEGammaCandidateChecker : public edm::EDAnalyzer { void printElementsInBlocks(const reco::PFCandidate& cand, std::ostream& out = std::cout) const; /// PFCandidates in which we'll look for pile up particles - edm::InputTag inputTagPFCandidatesReco_; - edm::InputTag inputTagPFCandidatesReReco_; - edm::InputTag inputTagPFJetsReco_; - edm::InputTag inputTagPFJetsReReco_; + const edm::EDGetTokenT tokenPFCandidatesReco_; + const edm::EDGetTokenT tokenPFCandidatesReReco_; + const edm::EDGetTokenT tokenPFJetsReco_; + const edm::EDGetTokenT tokenPFJetsReReco_; /// Cuts for comparison - double deltaEMax_; - double deltaEtaMax_; - double deltaPhiMax_; + const double deltaEMax_; + const double deltaEtaMax_; + const double deltaPhiMax_; /// verbose ? - bool verbose_; + const bool verbose_; /// print the blocks associated to a given candidate ? - bool printBlocks_; + const bool printBlocks_; /// rank the candidates by Pt - bool rankByPt_; + const bool rankByPt_; /// Counter unsigned entry_; From c0c64740f552538f480c6788c21068cc558b8545 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 29 Mar 2022 15:21:42 +0200 Subject: [PATCH 2/6] Code check --- .../PFProducer/test/PFBlockComparator.cc | 3 ++- .../PFProducer/test/PFEGCandidateTreeMaker.cc | 25 +++++++++---------- .../test/PFEGammaCandidateChecker.cc | 12 +++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc b/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc index f75f3c397a20b..3dcc78d7f37a1 100644 --- a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc +++ b/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc @@ -157,7 +157,8 @@ typedef edm::ParameterSet PSet; class PFBlockComparator : public edm::one::EDAnalyzer<> { public: PFBlockComparator(const PSet& c) - : srcToken_(consumes(c.getParameter("source"))), srcOldToken_(consumes(c.getParameter("sourceOld"))) {}; + : srcToken_(consumes(c.getParameter("source"))), + srcOldToken_(consumes(c.getParameter("sourceOld"))){}; ~PFBlockComparator() = default; void analyze(const edm::Event&, const edm::EventSetup&); diff --git a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc b/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc index b4f24baf4355b..201a99a57e00c 100644 --- a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc +++ b/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc @@ -324,19 +324,18 @@ bool PFEGCandidateTreeMaker::getPFCandMatch(const reco::PFCandidate& cand, return false; } -PFEGCandidateTreeMaker::PFEGCandidateTreeMaker(const PSet& p) : - dogen_(p.getUntrackedParameter("doGen", false)), - geninput_(p.getParameter("genSrc")), - vtxsrc_(p.getParameter("primaryVertices")), - pfEGInput_(p.getParameter("pfEGammaCandSrc")), - pfInput_(p.getParameter("pfCandSrc")), - genToken_(consumes(geninput_)), - vtxToken_(consumes(vtxsrc_)), - pfEGToken_(consumes(pfEGInput_)), - pfToken_(consumes (pfInput_)), - ecalMustacheSCParametersToken_(esConsumes()), - ecalSCDynamicDPhiParametersToken_(esConsumes()) { - +PFEGCandidateTreeMaker::PFEGCandidateTreeMaker(const PSet& p) + : dogen_(p.getUntrackedParameter("doGen", false)), + geninput_(p.getParameter("genSrc")), + vtxsrc_(p.getParameter("primaryVertices")), + pfEGInput_(p.getParameter("pfEGammaCandSrc")), + pfInput_(p.getParameter("pfCandSrc")), + genToken_(consumes(geninput_)), + vtxToken_(consumes(vtxsrc_)), + pfEGToken_(consumes(pfEGInput_)), + pfToken_(consumes(pfInput_)), + ecalMustacheSCParametersToken_(esConsumes()), + ecalSCDynamicDPhiParametersToken_(esConsumes()) { usesResource(TFileService::kSharedResource); N_ECALClusters = 1; diff --git a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc index 095694b6f7402..cf1bd0fddb8cf 100644 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc +++ b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc @@ -44,9 +44,10 @@ namespace { }; } // namespace -PFEGammaCandidateChecker::PFEGammaCandidateChecker(const edm::ParameterSet& iConfig) : - tokenPFCandidatesReco_(consumes(iConfig.getParameter("pfCandidatesReco"))), - tokenPFCandidatesReReco_(consumes(iConfig.getParameter("pfCandidatesReReco"))), +PFEGammaCandidateChecker::PFEGammaCandidateChecker(const edm::ParameterSet& iConfig) + : tokenPFCandidatesReco_(consumes(iConfig.getParameter("pfCandidatesReco"))), + tokenPFCandidatesReReco_( + consumes(iConfig.getParameter("pfCandidatesReReco"))), tokenPFJetsReco_(consumes(iConfig.getParameter("pfJetsReco"))), tokenPFJetsReReco_(consumes(iConfig.getParameter("pfJetsReReco"))), deltaEMax_(iConfig.getParameter("deltaEMax")), @@ -55,10 +56,11 @@ PFEGammaCandidateChecker::PFEGammaCandidateChecker(const edm::ParameterSet& iCon verbose_(iConfig.getUntrackedParameter("verbose", false)), printBlocks_(iConfig.getUntrackedParameter("printBlocks", false)), rankByPt_(iConfig.getUntrackedParameter("rankByPt", false)) { - entry_ = 0; - LogDebug("PFEGammaCandidateChecker") << " input collections : " << (iConfig.getParameter("pfCandidatesReco")) << " " << (iConfig.getParameter("pfCandidatesReReco")); + LogDebug("PFEGammaCandidateChecker") << " input collections : " + << (iConfig.getParameter("pfCandidatesReco")) << " " + << (iConfig.getParameter("pfCandidatesReReco")); } void PFEGammaCandidateChecker::analyze(const Event& iEvent, const EventSetup& iSetup) { From 5df4766afd1da9dd7d61191cd9bb3b631be25b6b Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 14 Apr 2022 06:19:15 +0200 Subject: [PATCH 3/6] Delete unused files --- .../PFProducer/test/PFBlockComparator.cc | 254 ---------- .../PFProducer/test/PFEGCandidateTreeMaker.cc | 449 ------------------ .../test/PFEGammaCandidateChecker.cc | 338 ------------- .../test/PFEGammaCandidateChecker.h | 73 --- 4 files changed, 1114 deletions(-) delete mode 100644 RecoParticleFlow/PFProducer/test/PFBlockComparator.cc delete mode 100644 RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc delete mode 100644 RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc delete mode 100644 RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h diff --git a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc b/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc deleted file mode 100644 index 3dcc78d7f37a1..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc +++ /dev/null @@ -1,254 +0,0 @@ -// -// Class: PFEGCandidateTreeMaker.cc -// -// Info: Outputs a tree with PF-EGamma information, mostly SC info. -// Checks to see if the input EG candidates are matched to -// some existing PF reco (PF-Photons and PF-Electrons). -// -// Author: L. Gray (FNAL) -// - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "DataFormats/EgammaCandidates/interface/Photon.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrackExtra.h" -#include "DataFormats/EgammaReco/interface/ElectronSeed.h" -#include "DataFormats/EgammaReco/interface/SuperCluster.h" -#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "DataFormats/Math/interface/deltaR.h" -#include "DataFormats/HepMCCandidate/interface/GenParticle.h" -#include "RecoEcal/EgammaCoreTools/interface/Mustache.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlockElementGsfTrack.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlockElementSuperCluster.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlockElementBrem.h" -#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" - -#include -#include -#include - -namespace { - struct ElementEquals { - const reco::PFBlockElement& cmpElem; - ElementEquals(const reco::PFBlockElement& e) : cmpElem(e) {} - bool operator()(const reco::PFBlockElement& chkElem) const { - bool result = false; - if (cmpElem.type() == chkElem.type()) { - switch (cmpElem.type()) { - case reco::PFBlockElement::TRACK: - result = (cmpElem.trackRef().isNonnull() && chkElem.trackRef().isNonnull() && - cmpElem.trackRef()->momentum() == chkElem.trackRef()->momentum()); - break; - case reco::PFBlockElement::PS1: - case reco::PFBlockElement::PS2: - case reco::PFBlockElement::ECAL: - case reco::PFBlockElement::HCAL: - case reco::PFBlockElement::HFEM: - case reco::PFBlockElement::HFHAD: - case reco::PFBlockElement::HO: - result = (cmpElem.clusterRef().isNonnull() && chkElem.clusterRef().isNonnull() && - cmpElem.clusterRef().key() == chkElem.clusterRef().key()); - break; - case reco::PFBlockElement::SC: { - const reco::PFBlockElementSuperCluster& cmpSC = - static_cast(cmpElem); - const reco::PFBlockElementSuperCluster& chkSC = - static_cast(chkElem); - result = (cmpSC.superClusterRef().isNonnull() && chkSC.superClusterRef().isNonnull() && - cmpSC.superClusterRef()->position() == chkSC.superClusterRef()->position()); - } break; - case reco::PFBlockElement::GSF: { - const reco::PFBlockElementGsfTrack& cmpGSF = static_cast(cmpElem); - const reco::PFBlockElementGsfTrack& chkGSF = static_cast(chkElem); - result = (cmpGSF.GsftrackRef().isNonnull() && chkGSF.GsftrackRef().isNonnull() && - cmpGSF.GsftrackRef()->momentum() == chkGSF.GsftrackRef()->momentum()); - } break; - case reco::PFBlockElement::BREM: { - const reco::PFBlockElementBrem& cmpBREM = static_cast(cmpElem); - const reco::PFBlockElementBrem& chkBREM = static_cast(chkElem); - result = (cmpBREM.GsftrackRef().isNonnull() && chkBREM.GsftrackRef().isNonnull() && - cmpBREM.GsftrackRef()->momentum() == chkBREM.GsftrackRef()->momentum() && - cmpBREM.indTrajPoint() == chkBREM.indTrajPoint()); - } break; - default: - throw cms::Exception("UnknownBlockElementType") - << cmpElem.type() << " is not a known PFBlockElement type!" << std::endl; - } - } - return result; - } - }; - - struct HasElementOverlap { - const reco::PFBlock* tocompare; - HasElementOverlap(const reco::PFBlock& a) : tocompare(&a) {} - bool operator()(const reco::PFBlock& b) const { - bool result = false; - for (const auto& cmpElem : tocompare->elements()) { - for (const auto& chkElem : b.elements()) { - // can't be equal elements if type not equal - if (cmpElem.type() != chkElem.type()) - continue; - switch (cmpElem.type()) { - case reco::PFBlockElement::TRACK: - result = (cmpElem.trackRef().isNonnull() && chkElem.trackRef().isNonnull() && - cmpElem.trackRef()->momentum() == chkElem.trackRef()->momentum()); - break; - case reco::PFBlockElement::PS1: - case reco::PFBlockElement::PS2: - case reco::PFBlockElement::ECAL: - case reco::PFBlockElement::HCAL: - case reco::PFBlockElement::HFEM: - case reco::PFBlockElement::HFHAD: - case reco::PFBlockElement::HO: - result = (cmpElem.clusterRef().isNonnull() && chkElem.clusterRef().isNonnull() && - cmpElem.clusterRef().key() == chkElem.clusterRef().key()); - break; - case reco::PFBlockElement::SC: { - const reco::PFBlockElementSuperCluster& cmpSC = - static_cast(cmpElem); - const reco::PFBlockElementSuperCluster& chkSC = - static_cast(chkElem); - result = (cmpSC.superClusterRef().isNonnull() && chkSC.superClusterRef().isNonnull() && - cmpSC.superClusterRef()->position() == chkSC.superClusterRef()->position()); - } break; - case reco::PFBlockElement::GSF: { - const reco::PFBlockElementGsfTrack& cmpGSF = static_cast(cmpElem); - const reco::PFBlockElementGsfTrack& chkGSF = static_cast(chkElem); - result = (cmpGSF.GsftrackRef().isNonnull() && chkGSF.GsftrackRef().isNonnull() && - cmpGSF.GsftrackRef()->momentum() == chkGSF.GsftrackRef()->momentum()); - } break; - case reco::PFBlockElement::BREM: { - const reco::PFBlockElementBrem& cmpBREM = static_cast(cmpElem); - const reco::PFBlockElementBrem& chkBREM = static_cast(chkElem); - result = (cmpBREM.GsftrackRef().isNonnull() && chkBREM.GsftrackRef().isNonnull() && - cmpBREM.GsftrackRef()->momentum() == chkBREM.GsftrackRef()->momentum() && - cmpBREM.indTrajPoint() == chkBREM.indTrajPoint()); - } break; - default: - throw cms::Exception("UnknownBlockElementType") - << cmpElem.type() << " is not a known PFBlockElement type!" << std::endl; - } - if (result) - break; - } - if (result) - break; - } - return result; - } - }; -} // namespace - -typedef edm::ParameterSet PSet; - -class PFBlockComparator : public edm::one::EDAnalyzer<> { -public: - PFBlockComparator(const PSet& c) - : srcToken_(consumes(c.getParameter("source"))), - srcOldToken_(consumes(c.getParameter("sourceOld"))){}; - ~PFBlockComparator() = default; - - void analyze(const edm::Event&, const edm::EventSetup&); - -private: - edm::EDGetTokenT srcToken_; - edm::EDGetTokenT srcOldToken_; -}; - -void PFBlockComparator::analyze(const edm::Event& e, const edm::EventSetup& es) { - const edm::Handle& blocks = e.getHandle(srcToken_); - const edm::Handle& oldblocks = e.getHandle(srcOldToken_); - - unsigned matchedblocks = 0; - - if (blocks->size() != oldblocks->size()) { - std::cout << "+++WARNING+++ Number of new blocks does not match number of old blocks!!!!" << std::endl; - std::cout << " " << blocks->size() << " != " << oldblocks->size() << std::endl; - } - - for (const auto& block : *blocks) { - HasElementOverlap checker(block); - auto matched_block = std::find_if(oldblocks->begin(), oldblocks->end(), checker); - if (matched_block != oldblocks->end()) { - ++matchedblocks; - if (block.elements().size() != matched_block->elements().size()) { - std::cout << "Number of elements in the block is not the same!" << std::endl; - std::cout << block.elements().size() << ' ' << matched_block->elements().size() << std::endl; - } - if (block.linkData().size() != matched_block->linkData().size()) { - std::cout << "Something is really fucked up, captain..." << std::endl; - std::cout << block.elements().size() << ' ' << matched_block->elements().size() << std::endl; - } - unsigned found_elements = 0; - for (const auto& elem : block.elements()) { - ElementEquals ele_check(elem); - auto matched_elem = std::find_if(matched_block->elements().begin(), matched_block->elements().end(), ele_check); - if (matched_elem != matched_block->elements().end()) { - ++found_elements; - std::multimap new_elems, old_elems; - block.associatedElements(elem.index(), block.linkData(), new_elems); - matched_block->associatedElements(matched_elem->index(), matched_block->linkData(), old_elems); - - if (new_elems.size() == old_elems.size()) { - for (auto newitr = new_elems.begin(), olditr = old_elems.begin(); newitr != new_elems.end(); - ++newitr, ++olditr) { - if (newitr->first != olditr->first || - block.elements()[newitr->second].type() != matched_block->elements()[olditr->second].type()) { - std::cout << "( " << newitr->first << " , " << block.elements()[newitr->second].type() << " ) != ( " - << olditr->first << " , " << matched_block->elements()[olditr->second].type() << " )" - << std::endl; - } - } - } - if (new_elems.size() != old_elems.size()) { - std::cout << "block links for element " << elem.index() << " are different from old links!" << std::endl; - std::cout << "new: "; - for (auto newassc : new_elems) { - std::cout << "( " << newassc.first << " , " << newassc.second << " , " - << block.elements()[newassc.second].type() << " ), "; - } - std::cout << std::endl; - std::cout << "old: "; - for (auto oldassc : old_elems) { - std::cout << "( " << oldassc.first << " , " << oldassc.second << " , " - << matched_block->elements()[oldassc.second].type() << " ), "; - } - std::cout << std::endl; - } - } else { - std::cout << "+++WARNING+++ : couldn't find match for element: " << elem << std::endl; - } - } - if (found_elements != block.elements().size() || found_elements != matched_block->elements().size()) { - std::cout << "+++WARNING+++ : couldn't find all elements in block with " << block.elements().size() - << " elements matched to block with " << matched_block->elements().size() << "!" << std::endl; - std::cout << "new block: " << std::endl; - std::cout << block << std::endl; - std::cout << "old block: " << std::endl; - std::cout << *matched_block << std::endl; - } - } else { - std::cout << "+++WARNING+++ : couldn't find another block that matched the new block!" << std::endl; - std::cout << block << std::endl; - } - } // block - if (matchedblocks != oldblocks->size()) { - std::cout << "Wasn't able to match all blocks!" << std::endl; - } -} - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(PFBlockComparator); diff --git a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc b/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc deleted file mode 100644 index 201a99a57e00c..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc +++ /dev/null @@ -1,449 +0,0 @@ -// -// Class: PFEGCandidateTreeMaker.cc -// -// Info: Outputs a tree with PF-EGamma information, mostly SC info. -// Checks to see if the input EG candidates are matched to -// some existing PF reco (PF-Photons and PF-Electrons). -// -// Author: L. Gray (FNAL) -// - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "DataFormats/EgammaCandidates/interface/Photon.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrackExtra.h" -#include "DataFormats/EgammaReco/interface/ElectronSeed.h" -#include "DataFormats/EgammaReco/interface/SuperCluster.h" -#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "DataFormats/Math/interface/deltaR.h" -#include "DataFormats/HepMCCandidate/interface/GenParticle.h" -#include "RecoEcal/EgammaCoreTools/interface/Mustache.h" -#include "CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h" -#include "CondFormats/DataRecord/interface/EcalMustacheSCParametersRcd.h" -#include "CondFormats/EcalObjects/interface/EcalSCDynamicDPhiParameters.h" -#include "CondFormats/DataRecord/interface/EcalSCDynamicDPhiParametersRcd.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h" - -#include "TTree.h" -#include "TVector2.h" - -#include -#include -#include - -typedef edm::ParameterSet PSet; - -namespace { - template - struct array_deleter { - void operator()(T* arr) { delete[] arr; } - }; - - struct GetSharedRecHitFraction { - const edm::Ptr the_seed; - double x_rechits_tot, x_rechits_match; - GetSharedRecHitFraction(const edm::Ptr& s) : the_seed(s) {} - double operator()(const edm::Ptr& x) { - // now see if the clusters overlap in rechits - const auto& seedHitsAndFractions = the_seed->hitsAndFractions(); - const auto& xHitsAndFractions = x->hitsAndFractions(); - x_rechits_tot = xHitsAndFractions.size(); - x_rechits_match = 0.0; - for (const std::pair& seedHit : seedHitsAndFractions) { - for (const std::pair& xHit : xHitsAndFractions) { - if (seedHit.first == xHit.first) { - x_rechits_match += 1.0; - } - } - } - return x_rechits_match / x_rechits_tot; - } - }; -} // namespace - -class PFEGCandidateTreeMaker : public edm::one::EDAnalyzer { - typedef TTree* treeptr; - -public: - PFEGCandidateTreeMaker(const PSet&); - ~PFEGCandidateTreeMaker() override = default; - - void analyze(const edm::Event&, const edm::EventSetup&) override; - -private: - const bool dogen_; - const edm::InputTag geninput_; - const edm::InputTag vtxsrc_; - const edm::InputTag pfEGInput_; - const edm::InputTag pfInput_; - const edm::EDGetTokenT genToken_; - const edm::EDGetTokenT vtxToken_; - const edm::EDGetTokenT pfEGToken_; - const edm::EDGetTokenT pfToken_; - - PFEnergyCalibration _calib; - std::map _genmatched; - void findBestGenMatches(const edm::Event& e, const edm::Handle&); - void processEGCandidateFillTree(const edm::Event&, - const reco::PFCandidateRef&, - const edm::Handle&); - bool getPFCandMatch(const reco::PFCandidate&, const edm::Handle&, const int); - - // SC parameters - const edm::ESGetToken ecalMustacheSCParametersToken_; - const EcalMustacheSCParameters* mustacheSCParams_; - const edm::ESGetToken ecalSCDynamicDPhiParametersToken_; - const EcalSCDynamicDPhiParameters* scDynamicDPhiParams_; - - // the tree - void setTreeArraysForSize(const size_t N_ECAL, const size_t N_PS); - treeptr tree_; - Int_t nVtx; - Float_t scRawEnergy, scCalibratedEnergy, scPreshowerEnergy, scEta, scPhi, scR, scPhiWidth, scEtaWidth, - scSeedRawEnergy, scSeedCalibratedEnergy, scSeedEta, scSeedPhi; - Int_t hasParentSC, pfPhotonMatch, pfElectronMatch; - Float_t genEnergy, genEta, genPhi, genDRToCentroid, genDRToSeed; - Int_t N_ECALClusters; - std::vector clusterRawEnergy; - std::vector clusterCalibEnergy; - std::vector clusterEta, clusterPhi, clusterDPhiToSeed, clusterDEtaToSeed, clusterDPhiToCentroid, - clusterDEtaToCentroid, clusterDPhiToGen, clusterDEtaToGen, clusterHitFractionSharedWithSeed; - std::vector clusterInMustache, clusterInDynDPhi; - Int_t N_PSClusters; - std::vector psClusterRawEnergy, psClusterEta, psClusterPhi; -}; - -void PFEGCandidateTreeMaker::analyze(const edm::Event& e, const edm::EventSetup& es) { - mustacheSCParams_ = &es.getData(ecalMustacheSCParametersToken_); - scDynamicDPhiParams_ = &es.getData(ecalSCDynamicDPhiParametersToken_); - - const edm::Handle& vtcs = e.getHandle(vtxToken_); - if (vtcs.isValid()) - nVtx = vtcs->size(); - else - nVtx = -1; - - const edm::Handle& pfEG = e.getHandle(pfEGToken_); - const edm::Handle& pfCands = e.getHandle(pfToken_); - - if (pfEG.isValid()) { - findBestGenMatches(e, pfEG); - for (size_t i = 0; i < pfEG->size(); ++i) { - processEGCandidateFillTree(e, reco::PFCandidateRef(pfEG, i), pfCands); - } - } else { - throw cms::Exception("PFEGCandidateTreeMaker") - << "Product ID for the EB SuperCluster collection was invalid!" << std::endl; - } -} - -void PFEGCandidateTreeMaker::findBestGenMatches(const edm::Event& e, - const edm::Handle& pfs) { - _genmatched.clear(); - reco::GenParticleRef genmatch; - // gen information (if needed) - if (dogen_) { - const edm::Handle& genp = e.getHandle(genToken_); - std::vector elesandphos; - if (genp.isValid()) { - reco::GenParticleRef bestmatch; - for (size_t i = 0; i < genp->size(); ++i) { - const int pdgid = std::abs(genp->at(i).pdgId()); - if (pdgid == 22 || pdgid == 11) { - elesandphos.push_back(reco::GenParticleRef(genp, i)); - } - } - for (size_t i = 0; i < elesandphos.size(); ++i) { - double dE_min = -1; - reco::PFCandidateRef bestmatch; - for (size_t k = 0; k < pfs->size(); ++k) { - reco::SuperClusterRef scref = pfs->at(k).superClusterRef(); - if (scref.isAvailable() && scref.isNonnull() && reco::deltaR(*scref, *elesandphos[i]) < 0.3) { - double dE = std::abs(scref->energy() - elesandphos[i]->energy()); - if (dE_min == -1 || dE < dE_min) { - dE_min = dE; - bestmatch = reco::PFCandidateRef(pfs, k); - } - } - } - _genmatched[bestmatch] = elesandphos[i]; - } - } else { - throw cms::Exception("PFSuperClusterTreeMaker") - << "Requested generator level information was not available!" << std::endl; - } - } -} - -void PFEGCandidateTreeMaker::processEGCandidateFillTree(const edm::Event& e, - const reco::PFCandidateRef& pf, - const edm::Handle& pfCands) { - if (pf->superClusterRef().isNull() || !pf->superClusterRef().isAvailable()) { - return; - } - if (pf->egammaExtraRef().isNull() || !pf->egammaExtraRef().isAvailable()) { - return; - } - const reco::SuperCluster& sc = *(pf->superClusterRef()); - reco::SuperClusterRef egsc = pf->egammaExtraRef()->superClusterPFECALRef(); - bool eleMatch(getPFCandMatch(*pf, pfCands, 11)); - bool phoMatch(getPFCandMatch(*pf, pfCands, 22)); - - const int N_ECAL = sc.clustersSize(); - const int N_PS = sc.preshowerClustersSize(); - const double sc_eta = std::abs(sc.position().Eta()); - const double sc_cosheta = std::cosh(sc_eta); - const double sc_pt = sc.rawEnergy() / sc_cosheta; - if (!N_ECAL) - return; - if ((sc_pt < 3.0 && sc_eta < 2.0) || (sc_pt < 4.0 && sc_eta < 2.5 && sc_eta > 2.0) || (sc_pt < 6.0 && sc_eta > 2.5)) - return; - N_ECALClusters = std::max(0, N_ECAL - 1); // minus 1 because of seed - N_PSClusters = N_PS; - reco::GenParticleRef genmatch; - // gen information (if needed) - if (dogen_) { - std::map::iterator itrmatch; - if ((itrmatch = _genmatched.find(pf)) != _genmatched.end()) { - genmatch = itrmatch->second; - genEnergy = genmatch->energy(); - genEta = genmatch->eta(); - genPhi = genmatch->phi(); - genDRToCentroid = reco::deltaR(sc, *genmatch); - genDRToSeed = reco::deltaR(*genmatch, **(sc.clustersBegin())); - } else { - genEnergy = -1.0; - genEta = 999.0; - genPhi = 999.0; - genDRToCentroid = 999.0; - genDRToSeed = 999.0; - } - } - // supercluster information - setTreeArraysForSize(N_ECALClusters, N_PSClusters); - hasParentSC = (Int_t)(egsc.isAvailable() && egsc.isNonnull()); - pfElectronMatch = (Int_t)eleMatch; - pfPhotonMatch = (Int_t)phoMatch; - scRawEnergy = sc.rawEnergy(); - scCalibratedEnergy = sc.energy(); - scPreshowerEnergy = sc.preshowerEnergy(); - scEta = sc.position().Eta(); - scPhi = sc.position().Phi(); - scR = sc.position().R(); - scPhiWidth = sc.phiWidth(); - scEtaWidth = sc.etaWidth(); - // sc seed information - edm::Ptr theseed = edm::Ptr(sc.seed()); - GetSharedRecHitFraction fractionOfSeed(theseed); - scSeedRawEnergy = theseed->energy(); - scSeedCalibratedEnergy = _calib.energyEm(*theseed, 0.0, 0.0, false); - scSeedEta = theseed->eta(); - scSeedPhi = theseed->phi(); - // loop over all clusters that aren't the seed - auto clusend = sc.clustersEnd(); - size_t iclus = 0; - edm::Ptr pclus; - for (auto clus = sc.clustersBegin(); clus != clusend; ++clus) { - pclus = edm::Ptr(*clus); - if (theseed == pclus) - continue; - clusterRawEnergy[iclus] = pclus->energy(); - clusterCalibEnergy[iclus] = _calib.energyEm(*pclus, 0.0, 0.0, false); - clusterEta[iclus] = pclus->eta(); - clusterPhi[iclus] = pclus->phi(); - clusterDPhiToSeed[iclus] = TVector2::Phi_mpi_pi(pclus->phi() - theseed->phi()); - clusterDEtaToSeed[iclus] = pclus->eta() - theseed->eta(); - clusterDPhiToCentroid[iclus] = TVector2::Phi_mpi_pi(pclus->phi() - sc.phi()); - clusterDEtaToCentroid[iclus] = pclus->eta() - sc.eta(); - clusterDPhiToCentroid[iclus] = TVector2::Phi_mpi_pi(pclus->phi() - sc.phi()); - clusterDEtaToCentroid[iclus] = pclus->eta() - sc.eta(); - clusterHitFractionSharedWithSeed[iclus] = fractionOfSeed(pclus); - if (dogen_ && genmatch.isNonnull()) { - clusterDPhiToGen[iclus] = TVector2::Phi_mpi_pi(pclus->phi() - genmatch->phi()); - clusterDEtaToGen[iclus] = pclus->eta() - genmatch->eta(); - } - clusterInMustache[iclus] = (Int_t)reco::MustacheKernel::inMustache( - mustacheSCParams_, theseed->eta(), theseed->phi(), pclus->energy(), pclus->eta(), pclus->phi()); - clusterInDynDPhi[iclus] = (Int_t)reco::MustacheKernel::inDynamicDPhiWindow(scDynamicDPhiParams_, - PFLayer::ECAL_BARREL == pclus->layer(), - theseed->phi(), - pclus->energy(), - pclus->eta(), - pclus->phi()); - ++iclus; - } - // loop over all preshower clusters - auto psclusend = sc.preshowerClustersEnd(); - size_t ipsclus = 0; - edm::Ptr ppsclus; - for (auto psclus = sc.preshowerClustersBegin(); psclus != psclusend; ++psclus) { - ppsclus = edm::Ptr(*psclus); - psClusterRawEnergy[ipsclus] = ppsclus->energy(); - psClusterEta[ipsclus] = ppsclus->eta(); - psClusterPhi[ipsclus] = ppsclus->phi(); - ++ipsclus; - } - tree_->Fill(); -} - -bool PFEGCandidateTreeMaker::getPFCandMatch(const reco::PFCandidate& cand, - const edm::Handle& pf, - const int pdgid_search) { - reco::PFCandidateEGammaExtraRef egxtra = cand.egammaExtraRef(); - if (egxtra.isAvailable() && egxtra.isNonnull()) { - reco::SuperClusterRef scref = egxtra->superClusterPFECALRef(); - if (scref.isAvailable() && scref.isNonnull()) { - for (auto ipf = pf->begin(); ipf != pf->end(); ++ipf) { - if (std::abs(ipf->pdgId()) == pdgid_search && pdgid_search == 11) { - reco::GsfTrackRef gsfref = ipf->gsfTrackRef(); - reco::ElectronSeedRef sRef = gsfref->seedRef().castTo(); - if (sRef.isNonnull() && sRef.isAvailable() && sRef->isEcalDriven()) { - reco::SuperClusterRef temp(sRef->caloCluster().castTo()); - if (scref == temp) { - return true; - } - } - } else if (std::abs(ipf->pdgId()) == 22 && pdgid_search == 22) { - reco::SuperClusterRef temp(ipf->superClusterRef()); - if (scref == temp) { - return true; - } - } - } - } - } - return false; -} - -PFEGCandidateTreeMaker::PFEGCandidateTreeMaker(const PSet& p) - : dogen_(p.getUntrackedParameter("doGen", false)), - geninput_(p.getParameter("genSrc")), - vtxsrc_(p.getParameter("primaryVertices")), - pfEGInput_(p.getParameter("pfEGammaCandSrc")), - pfInput_(p.getParameter("pfCandSrc")), - genToken_(consumes(geninput_)), - vtxToken_(consumes(vtxsrc_)), - pfEGToken_(consumes(pfEGInput_)), - pfToken_(consumes(pfInput_)), - ecalMustacheSCParametersToken_(esConsumes()), - ecalSCDynamicDPhiParametersToken_(esConsumes()) { - usesResource(TFileService::kSharedResource); - - N_ECALClusters = 1; - N_PSClusters = 1; - edm::Service fs; - tree_ = fs->make("SuperClusterTree", "Dump of all available SC info"); - tree_->Branch("N_ECALClusters", &N_ECALClusters, "N_ECALClusters/I"); - tree_->Branch("N_PSClusters", &N_PSClusters, "N_PSClusters/I"); - tree_->Branch("nVtx", &nVtx, "nVtx/I"); - tree_->Branch("hasParentSC", &hasParentSC, "hasParentSC/I"); - tree_->Branch("pfPhotonMatch", &pfPhotonMatch, "pfPhotonMatch/I"); - tree_->Branch("pfElectronMatch", &pfElectronMatch, "pfElectronMatch/I"); - tree_->Branch("scRawEnergy", &scRawEnergy, "scRawEnergy/F"); - tree_->Branch("scCalibratedEnergy", &scCalibratedEnergy, "scCalibratedEnergy/F"); - tree_->Branch("scPreshowerEnergy", &scPreshowerEnergy, "scPreshowerEnergy/F"); - tree_->Branch("scEta", &scEta, "scEta/F"); - tree_->Branch("scPhi", &scPhi, "scPhi/F"); - tree_->Branch("scR", &scR, "scR/F"); - tree_->Branch("scPhiWidth", &scPhiWidth, "scPhiWidth/F"); - tree_->Branch("scEtaWidth", &scEtaWidth, "scEtaWidth/F"); - tree_->Branch("scSeedRawEnergy", &scSeedRawEnergy, "scSeedRawEnergy/F"); - tree_->Branch("scSeedCalibratedEnergy", &scSeedCalibratedEnergy, "scSeedCalibratedEnergy/F"); - tree_->Branch("scSeedEta", &scSeedEta, "scSeedEta/F"); - tree_->Branch("scSeedPhi", &scSeedPhi, "scSeedPhi/F"); - // ecal cluster information - clusterRawEnergy.resize(1); - tree_->Branch("clusterRawEnergy", &clusterRawEnergy[0], "clusterRawEnergy[N_ECALClusters]/F"); - clusterCalibEnergy.resize(1); - tree_->Branch("clusterCalibEnergy", &clusterCalibEnergy[0], "clusterCalibEnergy[N_ECALClusters]/F"); - clusterEta.resize(1); - tree_->Branch("clusterEta", &clusterEta[0], "clusterEta[N_ECALClusters]/F"); - clusterPhi.resize(1); - tree_->Branch("clusterPhi", &clusterPhi[0], "clusterPhi[N_ECALClusters]/F"); - clusterDPhiToSeed.resize(1); - tree_->Branch("clusterDPhiToSeed", &clusterDPhiToSeed[0], "clusterDPhiToSeed[N_ECALClusters]/F"); - clusterDEtaToSeed.resize(1); - tree_->Branch("clusterDEtaToSeed", &clusterDEtaToSeed[0], "clusterDEtaToSeed[N_ECALClusters]/F"); - clusterDPhiToCentroid.resize(1); - tree_->Branch("clusterDPhiToCentroid", &clusterDPhiToCentroid[0], "clusterDPhiToCentroid[N_ECALClusters]/F"); - clusterDEtaToCentroid.resize(1); - tree_->Branch("clusterDEtaToCentroid", &clusterDEtaToCentroid[0], "clusterDEtaToCentroid[N_ECALClusters]/F"); - clusterHitFractionSharedWithSeed.resize(1); - tree_->Branch("clusterHitFractionSharedWithSeed", - &clusterHitFractionSharedWithSeed[0], - "clusterHitFractionSharedWithSeed[N_ECALClusters]/F"); - clusterInMustache.resize(1); - tree_->Branch("clusterInMustache", &clusterInMustache[0], "clusterInMustache[N_ECALClusters]/I"); - clusterInDynDPhi.resize(1); - tree_->Branch("clusterInDynDPhi", &clusterInDynDPhi[0], "clusterInDynDPhi[N_ECALClusters]/I"); - // preshower information - psClusterRawEnergy.resize(1); - tree_->Branch("psClusterRawEnergy", &psClusterRawEnergy[0], "psClusterRawEnergy[N_PSClusters]/F"); - psClusterEta.resize(1); - tree_->Branch("psClusterEta", &psClusterEta[0], "psClusterEta[N_PSClusters]/F"); - psClusterPhi.resize(1); - tree_->Branch("psClusterPhi", &psClusterPhi[0], "psClusterPhi[N_PSClusters]/F"); - - if (dogen_) { - tree_->Branch("genEta", &genEta, "genEta/F"); - tree_->Branch("genPhi", &genPhi, "genPhi/F"); - tree_->Branch("genEnergy", &genEnergy, "genEnergy/F"); - tree_->Branch("genDRToCentroid", &genDRToCentroid, "genDRToCentroid/F"); - tree_->Branch("genDRToSeed", &genDRToSeed, "genDRToSeed/F"); - - clusterDPhiToGen.resize(1); - tree_->Branch("clusterDPhiToGen", &clusterDPhiToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); - clusterDEtaToGen.resize(1); - tree_->Branch("clusterDEtaToGen", &clusterDEtaToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); - } -} - -void PFEGCandidateTreeMaker::setTreeArraysForSize(const size_t N_ECAL, const size_t N_PS) { - clusterRawEnergy.resize(N_ECAL); - tree_->GetBranch("clusterRawEnergy")->SetAddress(&clusterRawEnergy[0]); - clusterCalibEnergy.resize(N_ECAL); - tree_->GetBranch("clusterCalibEnergy")->SetAddress(&clusterCalibEnergy[0]); - clusterEta.resize(N_ECAL); - tree_->GetBranch("clusterEta")->SetAddress(&clusterEta[0]); - clusterPhi.resize(N_ECAL); - tree_->GetBranch("clusterPhi")->SetAddress(&clusterPhi[0]); - clusterDPhiToSeed.resize(N_ECAL); - tree_->GetBranch("clusterDPhiToSeed")->SetAddress(&clusterDPhiToSeed[0]); - clusterDEtaToSeed.resize(N_ECAL); - tree_->GetBranch("clusterDEtaToSeed")->SetAddress(&clusterDEtaToSeed[0]); - clusterDPhiToCentroid.resize(N_ECAL); - tree_->GetBranch("clusterDPhiToCentroid")->SetAddress(&clusterDPhiToCentroid[0]); - clusterDEtaToCentroid.resize(N_ECAL); - tree_->GetBranch("clusterDEtaToCentroid")->SetAddress(&clusterDEtaToCentroid[0]); - clusterHitFractionSharedWithSeed.resize(N_ECAL); - tree_->GetBranch("clusterHitFractionSharedWithSeed")->SetAddress(&clusterHitFractionSharedWithSeed[0]); - - if (dogen_) { - clusterDPhiToGen.resize(N_ECAL); - tree_->GetBranch("clusterDPhiToGen")->SetAddress(&clusterDPhiToGen[0]); - clusterDEtaToGen.resize(N_ECAL); - tree_->GetBranch("clusterDEtaToGen")->SetAddress(&clusterDEtaToGen[0]); - } - clusterInMustache.resize(N_ECAL); - tree_->GetBranch("clusterInMustache")->SetAddress(&clusterInMustache[0]); - clusterInDynDPhi.resize(N_ECAL); - tree_->GetBranch("clusterInDynDPhi")->SetAddress(&clusterInDynDPhi[0]); - psClusterRawEnergy.resize(N_ECAL); - tree_->GetBranch("psClusterRawEnergy")->SetAddress(&psClusterRawEnergy[0]); - psClusterEta.resize(N_ECAL); - tree_->GetBranch("psClusterEta")->SetAddress(&psClusterEta[0]); - psClusterPhi.resize(N_ECAL); - tree_->GetBranch("psClusterPhi")->SetAddress(&psClusterPhi[0]); -} - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(PFEGCandidateTreeMaker); diff --git a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc deleted file mode 100644 index cf1bd0fddb8cf..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc +++ /dev/null @@ -1,338 +0,0 @@ -#include "PFEGammaCandidateChecker.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlock.h" -#include "DataFormats/JetReco/interface/PFJet.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/EgammaCandidates/interface/Photon.h" -#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" - -#include "FWCore/Framework/interface/ESHandle.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" -#include "FWCore/Framework/interface/EventSetup.h" - -using namespace std; -using namespace edm; -using namespace reco; - -// we always assume we a looping over a -namespace { - struct gsfequals { - reco::GsfTrackRef mytrack; - gsfequals(const reco::PFCandidate& tofind) : mytrack(tofind.gsfTrackRef()) {} - bool operator()(const reco::PFCandidate& c) const { - if (c.gsfTrackRef().isNonnull()) { - return (c.gsfTrackRef()->ptMode() == mytrack->ptMode() && c.gsfTrackRef()->etaMode() == mytrack->etaMode()); - } - return false; - } - }; - struct scequals { - reco::SuperClusterRef mysc; - scequals(const reco::PFCandidate& tofind) { - if (tofind.photonRef().isNonnull()) { - mysc = tofind.photonRef()->superCluster(); - } - } - bool operator()(const reco::PFCandidate& c) const { - return (mysc.isNonnull() && c.egammaExtraRef().isNonnull() && - (c.egammaExtraRef()->superClusterPFECALRef()->seed() == mysc->seed())); - } - }; -} // namespace - -PFEGammaCandidateChecker::PFEGammaCandidateChecker(const edm::ParameterSet& iConfig) - : tokenPFCandidatesReco_(consumes(iConfig.getParameter("pfCandidatesReco"))), - tokenPFCandidatesReReco_( - consumes(iConfig.getParameter("pfCandidatesReReco"))), - tokenPFJetsReco_(consumes(iConfig.getParameter("pfJetsReco"))), - tokenPFJetsReReco_(consumes(iConfig.getParameter("pfJetsReReco"))), - deltaEMax_(iConfig.getParameter("deltaEMax")), - deltaEtaMax_(iConfig.getParameter("deltaEtaMax")), - deltaPhiMax_(iConfig.getParameter("deltaPhiMax")), - verbose_(iConfig.getUntrackedParameter("verbose", false)), - printBlocks_(iConfig.getUntrackedParameter("printBlocks", false)), - rankByPt_(iConfig.getUntrackedParameter("rankByPt", false)) { - entry_ = 0; - - LogDebug("PFEGammaCandidateChecker") << " input collections : " - << (iConfig.getParameter("pfCandidatesReco")) << " " - << (iConfig.getParameter("pfCandidatesReReco")); -} - -void PFEGammaCandidateChecker::analyze(const Event& iEvent, const EventSetup& iSetup) { - LogDebug("PFEGammaCandidateChecker") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run(); - - // get PFCandidates - - const edm::Handle& pfCandidatesReco = iEvent.getHandle(tokenPFCandidatesReco_); - const edm::Handle& pfCandidatesReReco = iEvent.getHandle(tokenPFCandidatesReReco_); - const edm::Handle& pfJetsReco = iEvent.getHandle(tokenPFJetsReco_); - const edm::Handle& pfJetsReReco = iEvent.getHandle(tokenPFJetsReReco_); - - reco::PFCandidateCollection pfReco, pfReReco; - - // to sort, one needs to copy - if (rankByPt_) { - pfReco = *pfCandidatesReco; - pfReReco = *pfCandidatesReReco; - sort(pfReco.begin(), pfReco.end(), greaterPt); - sort(pfReReco.begin(), pfReReco.end(), greaterPt); - } - - unsigned recoSize = pfReco.size(); - unsigned reRecoSize = pfReReco.size(); - //unsigned minSize = std::min(recoSize,pfReReco.size()); - bool differentCand = false; - bool differentSize = pfReco.size() != pfReReco.size(); - if (differentSize) - std::cout << "+++WARNING+++ PFCandidate size changed for entry " << entry_ << " !" << endl - << " - RECO size : " << pfReco.size() << endl - << " - Re-RECO size : " << pfReReco.size() << endl; - - unsigned npr = 0; - - std::cout << "========= check pf -> ged =========" << std::endl; - for (unsigned i = 0; i < recoSize; i++) { - const reco::PFCandidate& candReco = (rankByPt_) ? pfReco[i] : (*pfCandidatesReco)[i]; - const reco::PFCandidate* candReReco = NULL; - - switch (std::abs(candReco.pdgId())) { - case 11: { - std::cout << "got a pfElectron!" << std::endl; - std::cout << '\t' << candReco << std::endl; - std::cout << '\t' << candReco.gsfTrackRef()->ptMode() << std::endl; - gsfequals findbygsf(candReco); - reco::PFCandidateCollection::const_iterator found = std::find_if(pfReReco.begin(), pfReReco.end(), findbygsf); - if (found != pfReReco.end()) { - std::cout << "Found matching electron candidate by gsf track!" << std::endl; - candReReco = &*found; - } else { - std::cout << "NO MATCHING GED ELECTRON" << std::endl; - } - reco::GsfElectronRef oldpf = candReco.gsfElectronRef(); - reco::GsfElectronRef pfeg; - if (candReReco) - pfeg = candReReco->gsfElectronRef(); - if (oldpf.isNonnull() && pfeg.isNonnull()) { - const double oldpf_sihih = oldpf->sigmaIetaIeta(); - const double pfeg_sihih = pfeg->sigmaIetaIeta(); - std::cout << "matched set of gsf electrons" << std::endl; - if (oldpf_sihih < pfeg_sihih) { - std::cout << "pfeg sigma-ieta-ieta > oldpf sigma-ieta-ieta" << std::endl; - } - if (oldpf_sihih > pfeg_sihih) { - std::cout << "pfeg sigma-ieta-ieta < oldpf sigma-ieta-ieta" << std::endl; - } - } - } break; - case 22: { - scequals findbysc(candReco); - reco::PFCandidateCollection::const_iterator found = std::find_if(pfReReco.begin(), pfReReco.end(), findbysc); - if (candReco.photonRef().isNonnull() && found != pfReReco.end()) { - std::cout << "Found matching photon candidate by parent!" << std::endl; - candReReco = &*found; - } - } break; - default: - break; - } - - if (candReReco != NULL) { - double deltaE = (candReReco->energy() - candReco.energy()) / (candReReco->energy() + candReco.energy()); - double deltaEta = candReReco->eta() - candReco.eta(); - double deltaPhi = candReReco->phi() - candReco.phi(); - if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) { - differentCand = true; - std::cout << "+++WARNING+++ PFCandidate (e or gamma) " << i << " changed for entry " << entry_ << " ! " - << std::endl - << " - RECO : " << candReco << std::endl - << " - Re-RECO : " << *candReReco << std::endl - << " DeltaE = : " << deltaE << std::endl - << " DeltaEta = : " << deltaEta << std::endl - << " DeltaPhi = : " << deltaPhi << std::endl - << std::endl; - if (printBlocks_) { - std::cout << "Elements in Block for RECO: " << std::endl; - printElementsInBlocks(candReco); - std::cout << "Elements in Block for Re-RECO: " << std::endl; - printElementsInBlocks(*candReReco); - } - if (++npr == 5) - break; - } - } - } - std::cout << "========= check ged -> pf =========" << std::endl; - for (unsigned i = 0; i < reRecoSize; i++) { - const reco::PFCandidate* candReco = NULL; - const reco::PFCandidate& candReReco = (rankByPt_) ? pfReReco[i] : (*pfCandidatesReReco)[i]; - - switch (std::abs(candReReco.pdgId())) { - case 11: { - std::cout << "got a ged electron!" << std::endl; - std::cout << '\t' << candReReco << std::endl; - std::cout << '\t' << candReReco.gsfTrackRef()->ptMode() << std::endl; - gsfequals findbygsf(candReReco); - reco::PFCandidateCollection::const_iterator found = std::find_if(pfReco.begin(), pfReco.end(), findbygsf); - if (found != pfReco.end()) { - std::cout << "Found matching electron candidate by gsf track!" << std::endl; - candReco = &*found; - } - reco::GsfElectronRef oldpf; - reco::GsfElectronRef pfeg = candReReco.gsfElectronRef(); - if (candReco) - oldpf = candReco->gsfElectronRef(); - if (pfeg.isNonnull()) { - const double pfeg_sihih = pfeg->sigmaIetaIeta(); - if ((std::abs(pfeg->superCluster()->eta()) < 1.479 && pfeg_sihih > 0.012) || - (std::abs(pfeg->superCluster()->eta()) > 1.479 && pfeg_sihih > 0.032)) { - std::cout << "anomalously large sigma ieta ieta in pfeg!" << std::endl; - std::cout << "\tsihih : " << pfeg_sihih << std::endl; - std::cout << "\te1x5 : " << pfeg->e1x5() << std::endl; - std::cout << "\te2x5 max : " << pfeg->e2x5Max() << std::endl; - std::cout << "\te5x5 : " << pfeg->e5x5() << std::endl; - std::cout << "\tfBrem : " << pfeg->trackFbrem() << std::endl; - } - if (oldpf.isNonnull() && pfeg.isNonnull()) { - const double oldpf_sihih = oldpf->sigmaIetaIeta(); - std::cout << "matched set of gsf electrons" << std::endl; - if (oldpf_sihih < pfeg_sihih) { - std::cout << "pfeg sigma-ieta-ieta > oldpf sigma-ieta-ieta" << std::endl; - } - if (oldpf_sihih > pfeg_sihih) { - std::cout << "pfeg sigma-ieta-ieta < oldpf sigma-ieta-ieta" << std::endl; - } - } - } - } break; - case 22: { - scequals findbysc(candReReco); - reco::PFCandidateCollection::const_iterator found = std::find_if(pfReco.begin(), pfReco.end(), findbysc); - if (candReReco.photonRef().isNonnull() && found != pfReco.end()) { - std::cout << "Found matching photon candidate by parent!" << std::endl; - candReco = &*found; - } - } break; - default: - break; - } - - if (candReco != NULL) { - double deltaE = (candReReco.energy() - candReco->energy()) / (candReReco.energy() + candReco->energy()); - double deltaEta = candReReco.eta() - candReco->eta(); - double deltaPhi = candReReco.phi() - candReco->phi(); - if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) { - differentCand = true; - std::cout << "+++WARNING+++ PFCandidate (e or gamma) " << i << " changed for entry " << entry_ << " ! " - << std::endl - << " - RECO : " << *candReco << std::endl - << " - Re-RECO : " << candReReco << std::endl - << " DeltaE = : " << deltaE << std::endl - << " DeltaEta = : " << deltaEta << std::endl - << " DeltaPhi = : " << deltaPhi << std::endl - << std::endl; - if (printBlocks_) { - std::cout << "Elements in Block for RECO: " << std::endl; - printElementsInBlocks(*candReco); - std::cout << "Elements in Block for Re-RECO: " << std::endl; - printElementsInBlocks(candReReco); - } - if (++npr == 5) - break; - } - } - } - - if (differentSize || differentCand) { - printJets(*pfJetsReco, *pfJetsReReco); - printMet(pfReco, pfReReco); - } - - ++entry_; - LogDebug("PFEGammaCandidateChecker") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run() - << std::endl; -} - -void PFEGammaCandidateChecker::printMet(const PFCandidateCollection& pfReco, - const PFCandidateCollection& pfReReco) const { - double metX = 0.; - double metY = 0.; - for (unsigned i = 0; i < pfReco.size(); i++) { - metX += pfReco[i].px(); - metY += pfReco[i].py(); - } - double met = std::sqrt(metX * metX + metY * metY); - std::cout << "MET RECO = " << metX << " " << metY << " " << met << std::endl; - - metX = 0.; - metY = 0.; - for (unsigned i = 0; i < pfReReco.size(); i++) { - metX += pfReReco[i].px(); - metY += pfReReco[i].py(); - } - met = std::sqrt(metX * metX + metY * metY); - std::cout << "MET Re-RECO = " << metX << " " << metY << " " << met << std::endl; -} - -void PFEGammaCandidateChecker::printJets(const PFJetCollection& pfJetsReco, const PFJetCollection& pfJetsReReco) const { - bool differentSize = pfJetsReco.size() != pfJetsReReco.size(); - if (differentSize) - std::cout << "+++WARNING+++ PFJet size changed for entry " << entry_ << " !" << endl - << " - RECO size : " << pfJetsReco.size() << endl - << " - Re-RECO size : " << pfJetsReReco.size() << endl; - unsigned minSize = pfJetsReco.size() < pfJetsReReco.size() ? pfJetsReco.size() : pfJetsReReco.size(); - unsigned npr = 0; - for (unsigned i = 0; i < minSize; ++i) { - const reco::PFJet& candReco = pfJetsReco[i]; - const reco::PFJet& candReReco = pfJetsReReco[i]; - if (candReco.et() < 20. && candReReco.et() < 20.) - break; - double deltaE = (candReReco.et() - candReco.et()) / (candReReco.et() + candReco.et()); - double deltaEta = candReReco.eta() - candReco.eta(); - double deltaPhi = candReReco.phi() - candReco.phi(); - if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) { - std::cout << "+++WARNING+++ PFJet " << i << " changed for entry " << entry_ << " ! " << std::endl - << " - RECO : " << candReco.et() << " " << candReco.eta() << " " << candReco.phi() << std::endl - << " - Re-RECO : " << candReReco.et() << " " << candReReco.eta() << " " << candReReco.phi() - << std::endl - << " DeltaE = : " << deltaE << std::endl - << " DeltaEta = : " << deltaEta << std::endl - << " DeltaPhi = : " << deltaPhi << std::endl - << std::endl; - if (++npr == 5) - break; - } else { - std::cout << "Jet " << i << " " << candReco.et() << std::endl; - } - } -} - -void PFEGammaCandidateChecker::printElementsInBlocks(const PFCandidate& cand, ostream& out) const { - if (!out) - return; - - PFBlockRef firstRef; - - assert(!cand.elementsInBlocks().empty()); - for (unsigned i = 0; i < cand.elementsInBlocks().size(); i++) { - PFBlockRef blockRef = cand.elementsInBlocks()[i].first; - - if (blockRef.isNull()) { - cerr << "ERROR! no block ref!"; - continue; - } - - if (!i) { - out << (*blockRef); - firstRef = blockRef; - } else if (blockRef != firstRef) { - cerr << "WARNING! This PFCandidate is not made from a single block" << endl; - } - - out << "\t" << cand.elementsInBlocks()[i].second << endl; - } -} diff --git a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h b/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h deleted file mode 100644 index 58b339bb37022..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef RecoParticleFlow_PFEGammaCandidateChecker_ -#define RecoParticleFlow_PFEGammaCandidateChecker_ - -// system include files -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" - -/**\class PFEGammaCandidateChecker -\brief Checks what a re-reco changes in PFCandidates. - -\author Patrick Janot -\date August 2011 -*/ - -class PFEGammaCandidateChecker : public edm::one::EDAnalyzer<> { -public: - explicit PFEGammaCandidateChecker(const edm::ParameterSet&); - - ~PFEGammaCandidateChecker() override = default; - - void analyze(const edm::Event&, const edm::EventSetup&) override; - -private: - void printJets(const reco::PFJetCollection& pfJetsReco, const reco::PFJetCollection& pfJetsReReco) const; - - void printMet(const reco::PFCandidateCollection& pfReco, const reco::PFCandidateCollection& pfReReco) const; - - void printElementsInBlocks(const reco::PFCandidate& cand, std::ostream& out = std::cout) const; - - /// PFCandidates in which we'll look for pile up particles - const edm::EDGetTokenT tokenPFCandidatesReco_; - const edm::EDGetTokenT tokenPFCandidatesReReco_; - const edm::EDGetTokenT tokenPFJetsReco_; - const edm::EDGetTokenT tokenPFJetsReReco_; - - /// Cuts for comparison - const double deltaEMax_; - const double deltaEtaMax_; - const double deltaPhiMax_; - - /// verbose ? - const bool verbose_; - - /// print the blocks associated to a given candidate ? - const bool printBlocks_; - - /// rank the candidates by Pt - const bool rankByPt_; - - /// Counter - unsigned entry_; - - static bool greaterPt(const reco::PFCandidate& a, const reco::PFCandidate& b) { return (a.pt() > b.pt()); } -}; - -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ModuleFactory.h" -DEFINE_FWK_MODULE(PFEGammaCandidateChecker); - -#endif From e0c0ddd8d432efdd58e4791883922470103e9cba Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 14 Apr 2022 06:53:58 +0200 Subject: [PATCH 4/6] Remove reference of deleted files from Builfile --- .../PFProducer/test/BuildFile.xml | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/RecoParticleFlow/PFProducer/test/BuildFile.xml b/RecoParticleFlow/PFProducer/test/BuildFile.xml index 50e22630a89c7..2851dc96cdf3f 100644 --- a/RecoParticleFlow/PFProducer/test/BuildFile.xml +++ b/RecoParticleFlow/PFProducer/test/BuildFile.xml @@ -1,18 +1,3 @@ - - - - - - - - - - - - - - - @@ -55,18 +40,6 @@ - - - - - - - - - - - - @@ -78,19 +51,3 @@ - - - - - - - - - - - - - - - - From 1cc6b5f88d6b7079a2060c22e64b53d2e0bc7656 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 15 Apr 2022 03:18:52 +0200 Subject: [PATCH 5/6] Remove reference to deleted code --- .../test/RecoToDisplay_batch_cfg.py | 183 ------------------ .../test/particleFlowCandidateChecker_cfi.py | 27 --- 2 files changed, 210 deletions(-) delete mode 100644 RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py delete mode 100644 RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py diff --git a/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py b/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py deleted file mode 100644 index 51bb0c7595849..0000000000000 --- a/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py +++ /dev/null @@ -1,183 +0,0 @@ -import FWCore.ParameterSet.Config as cms -import sys - -infile_name = sys.argv[2] -outfile_name = '/afs/cern.ch/user/l/lgray/work/public/CMSSW_7_0_0_pre3_singlegconv/src/RecoParticleFlow/Configuration/test/%s/superClusterDump_%i.root'%(sys.argv[5],int(sys.argv[3])) -nevents = int(sys.argv[4]) - - -process = cms.Process("REPROD") -process.load("Configuration.StandardSequences.Reconstruction_cff") -process.load("Configuration.StandardSequences.MagneticField_38T_cff") -#process.load("Configuration.StandardSequences.MagneticField_4T_cff") -process.load("Configuration.StandardSequences.Geometry_cff") -process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff') -from Configuration.AlCa.autoCond import autoCond -process.GlobalTag.globaltag = autoCond['startup'] -#process.GlobalTag.globaltag = 'START50_V10::All' - -#process.Timing =cms.Service("Timing") -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(nevents) -) - -process.source = cms.Source( - "PoolSource", - fileNames = cms.untracked.vstring( - 'root://cms-xrd-global.cern.ch/%s'%infile_name - ), - eventsToProcess = cms.untracked.VEventRange(), - #eventsToProcess = cms.untracked.VEventRange('1:1217421-1:1217421'), - # '1:1220344-1:1220344', - # '1:1655912-1:1655912', - # '1:415027-1:415027', - # '1:460640-1:460640', - # '1:2054772-1:2054772'), - secondaryFileNames = cms.untracked.vstring(), - noEventSort = cms.untracked.bool(True), - duplicateCheckMode = cms.untracked.string('noDuplicateCheck') -) - -#from RecoParticleFlow.Configuration.reco_QCDForPF_cff import fileNames -#process.source.fileNames = fileNames - - -# modify reconstruction sequence -#process.hbhereflag = process.hbhereco.clone() -#process.hbhereflag.hbheInput = 'hbhereco' -#process.towerMakerPF.hbheInput = 'hbhereflag' -#process.particleFlowRecHitHCAL.hcalRecHitsHBHE = cms.InputTag("hbhereflag") -process.particleFlowTmp.useHO = False - -process.TFileService = cms.Service( - "TFileService", - fileName=cms.string(outfile_name) - ) - -process.pfEGAlgoNewSCTree = cms.EDAnalyzer( - "PFEGCandidateTreeMaker", - doGen = cms.untracked.bool(True), - genSrc = cms.InputTag("genParticles"), - primaryVertices = cms.InputTag("offlinePrimaryVertices"), - pfEGammaCandSrc = cms.InputTag('particleFlowEGamma'), - pfCandSrc = cms.InputTag('particleFlow') - ) - -process.pfElectronSCTree = cms.EDAnalyzer( - "PFSuperClusterTreeMaker", - doGen = cms.untracked.bool(True), - genSrc = cms.InputTag("genParticles"), - primaryVertices = cms.InputTag("offlinePrimaryVertices"), - superClusterSrcEB = cms.InputTag('pfElectronTranslator','pf') - ) - -process.pfPhotonSCTree = cms.EDAnalyzer( - "PFSuperClusterTreeMaker", - doGen = cms.untracked.bool(True), - genSrc = cms.InputTag("genParticles"), - primaryVertices = cms.InputTag("offlinePrimaryVertices"), - superClusterSrcEB = cms.InputTag('pfPhotonTranslator','pfphot') - ) - -process.pfMustacheSCTree = cms.EDAnalyzer( - "PFSuperClusterTreeMaker", - doGen = cms.untracked.bool(True), - genSrc = cms.InputTag("genParticles"), - primaryVertices = cms.InputTag("offlinePrimaryVertices"), - superClusterSrcEB = cms.InputTag("particleFlowSuperClusterECAL", - "particleFlowSuperClusterECALBarrel"), - superClusterSrcEE = cms.InputTag("particleFlowSuperClusterECAL", - "particleFlowSuperClusterECALEndcapWithPreshower") - ) - -# Local re-reco: Produce tracker rechits, pf rechits and pf clusters -process.localReReco = cms.Sequence(process.siPixelRecHits+ - process.siStripMatchedRecHits+ - #process.hbhereflag+ - process.particleFlowCluster+ - process.ecalClusters) - -# Track re-reco -process.globalReReco = cms.Sequence(process.offlineBeamSpot+ - process.recopixelvertexing+ - process.ckftracks+ - process.caloTowersRec+ - process.vertexreco+ - process.recoJets+ - process.muonrecoComplete+ - process.muoncosmicreco+ - process.egammaGlobalReco+ - process.pfTrackingGlobalReco+ - process.egammaHighLevelRecoPrePF+ - process.muoncosmichighlevelreco+ - process.metreco) - -# Particle Flow re-processing -process.pfReReco = cms.Sequence(process.particleFlowReco+ - process.egammaHighLevelRecoPostPF+ - process.muonshighlevelreco+ - process.particleFlowLinks+ - process.recoPFJets+ - process.recoPFMET+ - process.PFTau+ - process.pfEGAlgoNewSCTree+ - process.pfElectronSCTree+ - process.pfPhotonSCTree+ - process.pfMustacheSCTree) - - -# Gen Info re-processing -process.load("PhysicsTools.HepMCCandAlgos.genParticles_cfi") -process.load("RecoJets.Configuration.GenJetParticles_cff") -process.load("RecoJets.Configuration.RecoGenJets_cff") -process.load("RecoMET.Configuration.GenMETParticles_cff") -process.load("RecoMET.Configuration.RecoGenMET_cff") -process.load("RecoParticleFlow.PFProducer.particleFlowSimParticle_cff") -process.load("RecoParticleFlow.Configuration.HepMCCopy_cfi") -process.genReReco = cms.Sequence(process.generator+ - process.genParticles+ - process.genJetParticles+ - process.recoGenJets+ - process.genMETParticles+ - process.recoGenMET+ - process.particleFlowSimParticle) - -# pf reprocessing -process.p = cms.Path(process.localReReco+ - process.globalReReco+ - process.pfReReco+ - process.genReReco - #+process.particleFlowCandidateChecker - ) - -# And the logger -process.load("FWCore.MessageLogger.MessageLogger_cfi") -#process.MessageLogger.cout = cms.untracked.PSet( -# threshold = cms.untracked.string('INFO') -# ) -process.options = cms.untracked.PSet( - makeTriggerResults = cms.untracked.bool(True), - #wantSummary = cms.untracked.bool(True), - Rethrow = cms.untracked.vstring('Unknown', - 'ProductNotFound', - 'DictionaryNotFound', - 'InsertFailure', - 'Configuration', - 'LogicError', - 'UnimplementedFeature', - 'InvalidReference', - 'NullPointerError', - 'NoProductSpecified', - 'EventTimeout', - 'EventCorruption', - 'ModuleFailure', - 'ScheduleExecutionFailure', - 'EventProcessorFailure', - 'FileInPathError', - 'FatalRootError', - 'NotFound') -) - -process.MessageLogger.cerr.FwkReport.reportEvery = 1 - - diff --git a/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py b/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py deleted file mode 100644 index c9df34d69d6f4..0000000000000 --- a/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py +++ /dev/null @@ -1,27 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -particleFlowCandidateChecker = cms.EDAnalyzer( - "PFCandidateChecker", - pfCandidatesReco = cms.InputTag("particleFlow","","RECO"), - pfCandidatesReReco = cms.InputTag("particleFlow","","REPROD"), - pfJetsReco = cms.InputTag("ak5PFJets","","RECO"), - pfJetsReReco = cms.InputTag("ak5PFJets","","REPROD"), - deltaEMax = cms.double(1E-5), - deltaEtaMax = cms.double(1E-5), - deltaPhiMax = cms.double(1E-5), - printBlocks = cms.untracked.bool(False), - rankByPt = cms.untracked.bool(True) - ) - -particleFlowEGammaCandidateChecker = cms.EDAnalyzer( - "PFEGammaCandidateChecker", - pfCandidatesReco = cms.InputTag("particleFlow","","RECO"), - pfCandidatesReReco = cms.InputTag("particleFlow","","REPROD"), - pfJetsReco = cms.InputTag("ak5PFJets","","RECO"), - pfJetsReReco = cms.InputTag("ak5PFJets","","REPROD"), - deltaEMax = cms.double(1E-5), - deltaEtaMax = cms.double(1E-5), - deltaPhiMax = cms.double(1E-5), - printBlocks = cms.untracked.bool(False), - rankByPt = cms.untracked.bool(True) - ) From af84bf60a5a2d0a515e8eaec90d2823bafad8e7e Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 18 Apr 2022 13:09:27 +0200 Subject: [PATCH 6/6] Take Andreas comments --- .../test/RecoToDisplay_NoTracking_cfg.py | 4 +- .../test/RecoToDisplay_batch_cfg.py | 173 ++++++++++++++++++ .../test/particleFlowCandidateChecker_cfi.py | 14 ++ 3 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py create mode 100644 RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py diff --git a/RecoParticleFlow/Configuration/test/RecoToDisplay_NoTracking_cfg.py b/RecoParticleFlow/Configuration/test/RecoToDisplay_NoTracking_cfg.py index f067545d09d7e..e71c407c1b180 100644 --- a/RecoParticleFlow/Configuration/test/RecoToDisplay_NoTracking_cfg.py +++ b/RecoParticleFlow/Configuration/test/RecoToDisplay_NoTracking_cfg.py @@ -4,7 +4,7 @@ process.load("Configuration.StandardSequences.Reconstruction_cff") process.load("Configuration.StandardSequences.MagneticField_38T_cff") #process.load("Configuration.StandardSequences.MagneticField_4T_cff") -process.load("Configuration.StandardSequences.Geometry_cff") +process.load("Configuration.StandardSequences.GeometryRecoDB_cff") process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff') #from Configuration.AlCa.autoCond import autoCond #process.GlobalTag.globaltag = autoCond['mc'] @@ -81,7 +81,7 @@ process.recoGenMET+ process.particleFlowSimParticle) -process.load("RecoParticleFlow.PFProducer.particleFlowCandidateChecker_cfi") +#process.load("RecoParticleFlow.PFProducer.particleFlowCandidateChecker_cfi") #process.particleFlowCandidateChecker.pfCandidatesReco = cms.InputTag("particleFlow","","REPROD") #process.particleFlowCandidateChecker.pfCandidatesReReco = cms.InputTag("particleFlow","","REPROD2") #process.particleFlowCandidateChecker.pfJetsReco = cms.InputTag("ak5PFJets","","REPROD") diff --git a/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py b/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py new file mode 100644 index 0000000000000..a38d34307e72a --- /dev/null +++ b/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py @@ -0,0 +1,173 @@ +import FWCore.ParameterSet.Config as cms +import sys + +infile_name = sys.argv[2] +outfile_name = '/afs/cern.ch/user/l/lgray/work/public/CMSSW_7_0_0_pre3_singlegconv/src/RecoParticleFlow/Configuration/test/%s/superClusterDump_%i.root'%(sys.argv[5],int(sys.argv[3])) +nevents = int(sys.argv[4]) + + +process = cms.Process("REPROD") +process.load("Configuration.StandardSequences.Reconstruction_cff") +process.load("Configuration.StandardSequences.MagneticField_38T_cff") +#process.load("Configuration.StandardSequences.MagneticField_4T_cff") +process.load("Configuration.StandardSequences.GeometryRecoDB_cff") +process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.autoCond import autoCond +process.GlobalTag.globaltag = autoCond['startup'] +#process.GlobalTag.globaltag = 'START50_V10::All' + +#process.Timing =cms.Service("Timing") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(nevents) +) + +process.source = cms.Source( + "PoolSource", + fileNames = cms.untracked.vstring( + 'root://cms-xrd-global.cern.ch/%s'%infile_name + ), + eventsToProcess = cms.untracked.VEventRange(), + #eventsToProcess = cms.untracked.VEventRange('1:1217421-1:1217421'), + # '1:1220344-1:1220344', + # '1:1655912-1:1655912', + # '1:415027-1:415027', + # '1:460640-1:460640', + # '1:2054772-1:2054772'), + secondaryFileNames = cms.untracked.vstring(), + noEventSort = cms.untracked.bool(True), + duplicateCheckMode = cms.untracked.string('noDuplicateCheck') +) + +#from RecoParticleFlow.Configuration.reco_QCDForPF_cff import fileNames +#process.source.fileNames = fileNames + + +# modify reconstruction sequence +#process.hbhereflag = process.hbhereco.clone() +#process.hbhereflag.hbheInput = 'hbhereco' +#process.towerMakerPF.hbheInput = 'hbhereflag' +#process.particleFlowRecHitHCAL.hcalRecHitsHBHE = cms.InputTag("hbhereflag") +process.particleFlowTmp.useHO = False + +process.TFileService = cms.Service( + "TFileService", + fileName=cms.string(outfile_name) + ) + +process.pfElectronSCTree = cms.EDAnalyzer( + "PFSuperClusterTreeMaker", + doGen = cms.untracked.bool(True), + genSrc = cms.InputTag("genParticles"), + primaryVertices = cms.InputTag("offlinePrimaryVertices"), + superClusterSrcEB = cms.InputTag('pfElectronTranslator','pf') + ) + +process.pfPhotonSCTree = cms.EDAnalyzer( + "PFSuperClusterTreeMaker", + doGen = cms.untracked.bool(True), + genSrc = cms.InputTag("genParticles"), + primaryVertices = cms.InputTag("offlinePrimaryVertices"), + superClusterSrcEB = cms.InputTag('pfPhotonTranslator','pfphot') + ) + +process.pfMustacheSCTree = cms.EDAnalyzer( + "PFSuperClusterTreeMaker", + doGen = cms.untracked.bool(True), + genSrc = cms.InputTag("genParticles"), + primaryVertices = cms.InputTag("offlinePrimaryVertices"), + superClusterSrcEB = cms.InputTag("particleFlowSuperClusterECAL", + "particleFlowSuperClusterECALBarrel"), + superClusterSrcEE = cms.InputTag("particleFlowSuperClusterECAL", + "particleFlowSuperClusterECALEndcapWithPreshower") + ) + +# Local re-reco: Produce tracker rechits, pf rechits and pf clusters +process.localReReco = cms.Sequence(process.siPixelRecHits+ + process.siStripMatchedRecHits+ + #process.hbhereflag+ + process.particleFlowCluster+ + process.ecalClusters) + +# Track re-reco +process.globalReReco = cms.Sequence(process.offlineBeamSpot+ + process.recopixelvertexing+ + process.ckftracks+ + process.caloTowersRec+ + process.vertexreco+ + process.recoJets+ + process.muonrecoComplete+ + process.muoncosmicreco+ + process.egammaGlobalReco+ + process.pfTrackingGlobalReco+ + process.egammaHighLevelRecoPrePF+ + process.muoncosmichighlevelreco+ + process.metreco) + +# Particle Flow re-processing +process.pfReReco = cms.Sequence(process.particleFlowReco+ + process.egammaHighLevelRecoPostPF+ + process.muonshighlevelreco+ + process.particleFlowLinks+ + process.recoPFJets+ + process.recoPFMET+ + process.PFTau+ + process.pfElectronSCTree+ + process.pfPhotonSCTree+ + process.pfMustacheSCTree) + + +# Gen Info re-processing +process.load("PhysicsTools.HepMCCandAlgos.genParticles_cfi") +process.load("RecoJets.Configuration.GenJetParticles_cff") +process.load("RecoJets.Configuration.RecoGenJets_cff") +process.load("RecoMET.Configuration.GenMETParticles_cff") +process.load("RecoMET.Configuration.RecoGenMET_cff") +process.load("RecoParticleFlow.PFProducer.particleFlowSimParticle_cff") +process.load("RecoParticleFlow.Configuration.HepMCCopy_cfi") +process.genReReco = cms.Sequence(process.generator+ + process.genParticles+ + process.genJetParticles+ + process.recoGenJets+ + process.genMETParticles+ + process.recoGenMET+ + process.particleFlowSimParticle) + +# pf reprocessing +process.p = cms.Path(process.localReReco+ + process.globalReReco+ + process.pfReReco+ + process.genReReco + #+process.particleFlowCandidateChecker + ) + +# And the logger +process.load("FWCore.MessageLogger.MessageLogger_cfi") +#process.MessageLogger.cout = cms.untracked.PSet( +# threshold = cms.untracked.string('INFO') +# ) +process.options = cms.untracked.PSet( + makeTriggerResults = cms.untracked.bool(True), + #wantSummary = cms.untracked.bool(True), + Rethrow = cms.untracked.vstring('Unknown', + 'ProductNotFound', + 'DictionaryNotFound', + 'InsertFailure', + 'Configuration', + 'LogicError', + 'UnimplementedFeature', + 'InvalidReference', + 'NullPointerError', + 'NoProductSpecified', + 'EventTimeout', + 'EventCorruption', + 'ModuleFailure', + 'ScheduleExecutionFailure', + 'EventProcessorFailure', + 'FileInPathError', + 'FatalRootError', + 'NotFound') +) + +process.MessageLogger.cerr.FwkReport.reportEvery = 1 + + diff --git a/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py b/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py new file mode 100644 index 0000000000000..8274a7de34732 --- /dev/null +++ b/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py @@ -0,0 +1,14 @@ +import FWCore.ParameterSet.Config as cms + +particleFlowCandidateChecker = cms.EDAnalyzer( + "PFCandidateChecker", + pfCandidatesReco = cms.InputTag("particleFlow","","RECO"), + pfCandidatesReReco = cms.InputTag("particleFlow","","REPROD"), + pfJetsReco = cms.InputTag("ak5PFJets","","RECO"), + pfJetsReReco = cms.InputTag("ak5PFJets","","REPROD"), + deltaEMax = cms.double(1E-5), + deltaEtaMax = cms.double(1E-5), + deltaPhiMax = cms.double(1E-5), + printBlocks = cms.untracked.bool(False), + rankByPt = cms.untracked.bool(True) + )