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 index 51bb0c7595849..a38d34307e72a 100644 --- a/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py +++ b/RecoParticleFlow/Configuration/test/RecoToDisplay_batch_cfg.py @@ -10,7 +10,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['startup'] @@ -54,15 +54,6 @@ 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), @@ -120,7 +111,6 @@ process.recoPFJets+ process.recoPFMET+ process.PFTau+ - process.pfEGAlgoNewSCTree+ process.pfElectronSCTree+ process.pfPhotonSCTree+ process.pfMustacheSCTree) 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 @@ - - - - - - - - - - - - - - - - diff --git a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc b/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc deleted file mode 100644 index 3965bd145fe1a..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFBlockComparator.cc +++ /dev/null @@ -1,258 +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/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 "TTree.h" -#include "TVector2.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::EDAnalyzer { -public: - PFBlockComparator(const PSet& c) - : _src(c.getParameter("source")), _srcOld(c.getParameter("sourceOld")){}; - ~PFBlockComparator() {} - - void analyze(const edm::Event&, const edm::EventSetup&); - -private: - edm::InputTag _src; - edm::InputTag _srcOld; -}; - -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); - - 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 4f38db4218ce1..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFEGCandidateTreeMaker.cc +++ /dev/null @@ -1,442 +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/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::EDAnalyzer { - typedef TTree* treeptr; - -public: - PFEGCandidateTreeMaker(const PSet&); - ~PFEGCandidateTreeMaker() {} - - 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; - 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 - edm::ESGetToken ecalMustacheSCParametersToken_; - const EcalMustacheSCParameters* mustacheSCParams_; - 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_); - - edm::Handle vtcs; - e.getByLabel(_vtxsrc, vtcs); - if (vtcs.isValid()) - nVtx = vtcs->size(); - else - nVtx = -1; - - edm::Handle pfEG; - edm::Handle pfCands; - e.getByLabel(_pfEGInput, pfEG); - e.getByLabel(_pfInput, pfCands); - - 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) { - edm::Handle genp; - std::vector elesandphos; - e.getByLabel(_geninput, genp); - 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) { - ecalMustacheSCParametersToken_ = esConsumes(); - ecalSCDynamicDPhiParametersToken_ = esConsumes(); - - 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"); - // 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 = 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"); - - clusterDPhiToGen.resize(1); - _tree->Branch("clusterDPhiToGen", &clusterDPhiToGen[0], "clusterDPhiToGen[N_ECALClusters]/F"); - clusterDEtaToGen.resize(1); - _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]); - 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 ddf9af83ea33f..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.cc +++ /dev/null @@ -1,358 +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) { - 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); - - entry_ = 0; - - LogDebug("PFEGammaCandidateChecker") << " input collections : " << inputTagPFCandidatesReco_ << " " - << inputTagPFCandidatesReReco_; -} - -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; - - // 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); - - 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 705843de9fb91..0000000000000 --- a/RecoParticleFlow/PFProducer/test/PFEGammaCandidateChecker.h +++ /dev/null @@ -1,75 +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/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::EDAnalyzer { -public: - explicit PFEGammaCandidateChecker(const edm::ParameterSet&); - - ~PFEGammaCandidateChecker(); - - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - virtual void beginRun(const edm::Run& r, const edm::EventSetup& c); - -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 - edm::InputTag inputTagPFCandidatesReco_; - edm::InputTag inputTagPFCandidatesReReco_; - edm::InputTag inputTagPFJetsReco_; - edm::InputTag inputTagPFJetsReReco_; - - /// Cuts for comparison - double deltaEMax_; - double deltaEtaMax_; - double deltaPhiMax_; - - /// verbose ? - bool verbose_; - - /// print the blocks associated to a given candidate ? - bool printBlocks_; - - /// rank the candidates by Pt - 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 diff --git a/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py b/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py index c9df34d69d6f4..8274a7de34732 100644 --- a/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py +++ b/RecoParticleFlow/PFProducer/test/particleFlowCandidateChecker_cfi.py @@ -12,16 +12,3 @@ 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) - )