Skip to content

Commit

Permalink
reduced interface of PFEGammaAlgo
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Apr 1, 2020
1 parent c2183b2 commit 7216d10
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 130 deletions.
23 changes: 9 additions & 14 deletions RecoParticleFlow/PFProducer/interface/PFEGammaAlgo.h
Expand Up @@ -121,17 +121,12 @@ class PFEGammaAlgo {
};

//constructor
PFEGammaAlgo(const PFEGConfigInfo&, GBRForests const& gbrForests);

void setEEtoPSAssociation(EEtoPSAssociation const& eetops) { eetops_ = &eetops; }

void setAlphaGamma_ESplanes_fromDB(const ESEEIntercalibConstants* esEEInterCalib) {
thePFEnergyCalibration_.initAlphaGamma_ESplanes_fromDB(esEEInterCalib);
}

void setESChannelStatus(const ESChannelStatus* channelStatus) { channelStatus_ = channelStatus; }

void setPrimaryVertex(reco::Vertex const& primaryVertex) { primaryVertex_ = &primaryVertex; }
PFEGammaAlgo(const PFEGConfigInfo&,
GBRForests const& gbrForests,
EEtoPSAssociation const& eetops,
ESEEIntercalibConstants const& esEEInterCalib,
ESChannelStatus const& channelStatus,
reco::Vertex const& primaryVertex);

// this runs the functions below
EgammaObjects operator()(const reco::PFBlockRef& block);
Expand All @@ -145,7 +140,7 @@ class PFEGammaAlgo {

// useful pre-cached mappings:
// hopefully we get an enum that lets us just make an array in the future
reco::PFCluster::EEtoPSAssociation const* eetops_;
reco::PFCluster::EEtoPSAssociation const& eetops_;
reco::PFBlockRef _currentblock;
reco::PFBlock::LinkData _currentlinks;
// keep a map of pf indices to the splayed block for convenience
Expand Down Expand Up @@ -224,9 +219,9 @@ class PFEGammaAlgo {
bool isPrimaryTrack(const reco::PFBlockElementTrack& KfEl, const reco::PFBlockElementGsfTrack& GsfEl);

PFEGConfigInfo const& cfg_;
reco::Vertex const* primaryVertex_;
reco::Vertex const& primaryVertex_;

const ESChannelStatus* channelStatus_;
ESChannelStatus const& channelStatus_;

float evaluateSingleLegMVA(const reco::PFBlockRef& blockref, const reco::Vertex& primaryVtx, unsigned int trackIndex);
};
Expand Down
26 changes: 12 additions & 14 deletions RecoParticleFlow/PFProducer/plugins/PFEGammaProducer.cc
Expand Up @@ -99,19 +99,12 @@ void PFEGammaProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::Eve
reco::PFCandidateEGammaExtraCollection egExtra{};
reco::SuperClusterCollection sClusters{};

PFEGammaAlgo pfEGammaAlgo{pfEGConfigInfo_, gbrForests_};

// Get the EE-PS associations
pfEGammaAlgo.setEEtoPSAssociation(iEvent.get(eetopsSrc_));

// preshower conditions
edm::ESHandle<ESEEIntercalibConstants> esEEInterCalibHandle_;
iSetup.get<ESEEIntercalibConstantsRcd>().get(esEEInterCalibHandle_);
pfEGammaAlgo.setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.product());

edm::ESHandle<ESChannelStatus> esChannelStatusHandle_;
iSetup.get<ESChannelStatusRcd>().get(esChannelStatusHandle_);
pfEGammaAlgo.setESChannelStatus(esChannelStatusHandle_.product());

//Assign the PFAlgo Parameters
auto const& primaryVertices = iEvent.get(vertices_);
Expand All @@ -123,7 +116,12 @@ void PFEGammaProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::Eve
}
}

pfEGammaAlgo.setPrimaryVertex(*primaryVertex);
PFEGammaAlgo pfEGammaAlgo{pfEGConfigInfo_,
gbrForests_,
iEvent.get(eetopsSrc_),
*esEEInterCalibHandle_,
*esChannelStatusHandle_,
*primaryVertex};

// get the collection of blocks

Expand Down Expand Up @@ -273,8 +271,8 @@ void PFEGammaProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::Eve
}

//put calocluster output collections in event and get orphan handles to create ptrs
auto const& caloClusHandleEBEE = iEvent.emplace(caloClusterCollectionEBEEPutToken_, caloClustersEBEE);
auto const& caloClusHandleES = iEvent.emplace(caloClusterCollectionESPutToken_, caloClustersES);
auto const& caloClusHandleEBEE = iEvent.emplace(caloClusterCollectionEBEEPutToken_, std::move(caloClustersEBEE));
auto const& caloClusHandleES = iEvent.emplace(caloClusterCollectionESPutToken_, std::move(caloClustersES));

//relink superclusters to output caloclusters
for (auto& sc : sClusters) {
Expand All @@ -301,10 +299,10 @@ void PFEGammaProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::Eve
auto singleLegConv = createSingleLegConversions(egExtra, iEvent.getRefBeforePut<reco::ConversionCollection>());

// release our demonspawn into the wild to cause havoc
iEvent.emplace(superClusterCollectionPutToken_, sClusters);
iEvent.emplace(pfCandidateEGammaExtraCollectionPutToken_, egExtra);
iEvent.emplace(conversionCollectionPutToken_, singleLegConv);
iEvent.emplace(pfCandidateCollectionPutToken_, egCandidates);
iEvent.emplace(superClusterCollectionPutToken_, std::move(sClusters));
iEvent.emplace(pfCandidateEGammaExtraCollectionPutToken_, std::move(egExtra));
iEvent.emplace(conversionCollectionPutToken_, std::move(singleLegConv));
iEvent.emplace(pfCandidateCollectionPutToken_, std::move(egCandidates));
}

reco::ConversionCollection PFEGammaProducer::createSingleLegConversions(
Expand Down
1 change: 0 additions & 1 deletion RecoParticleFlow/PFProducer/src/PFCandConnector.cc
@@ -1,5 +1,4 @@
#include "RecoParticleFlow/PFProducer/interface/PFCandConnector.h"
#include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertex.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
Expand Down
29 changes: 19 additions & 10 deletions RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc
@@ -1,9 +1,7 @@
#include "RecoParticleFlow/PFProducer/interface/PFEGammaAlgo.h"
#include "RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
#include "RecoParticleFlow/PFClusterTools/interface/ClusterClusterMapping.h"
#include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
Expand Down Expand Up @@ -444,8 +442,19 @@ namespace {
}
} // namespace

PFEGammaAlgo::PFEGammaAlgo(const PFEGammaAlgo::PFEGConfigInfo& cfg, GBRForests const& gbrForests)
: gbrForests_(gbrForests), cfg_(cfg) {}
PFEGammaAlgo::PFEGammaAlgo(const PFEGammaAlgo::PFEGConfigInfo& cfg,
GBRForests const& gbrForests,
EEtoPSAssociation const& eetops,
ESEEIntercalibConstants const& esEEInterCalib,
ESChannelStatus const& channelStatus,
reco::Vertex const& primaryVertex)
: gbrForests_(gbrForests),
eetops_(eetops),
cfg_(cfg),
primaryVertex_(primaryVertex),
channelStatus_(channelStatus) {
thePFEnergyCalibration_.initAlphaGamma_ESplanes_fromDB(&esEEInterCalib);
}

float PFEGammaAlgo::evaluateSingleLegMVA(const reco::PFBlockRef& blockRef,
const reco::Vertex& primaryVtx,
Expand Down Expand Up @@ -895,7 +904,7 @@ int PFEGammaAlgo::attachPSClusters(const ClusterElement* ecalclus, ClusterMap::m
edm::Ptr<reco::PFCluster> clusptr = refToPtr(ecalclus->clusterRef());
EEtoPSElement ecalkey(clusptr.key(), clusptr);
auto assc_ps =
std::equal_range(eetops_->cbegin(), eetops_->cend(), ecalkey, [](const EEtoPSElement& a, const EEtoPSElement& b) {
std::equal_range(eetops_.cbegin(), eetops_.cend(), ecalkey, [](const EEtoPSElement& a, const EEtoPSElement& b) {
return a.first < b.first;
});
for (const auto& ps1 : _splayedblock[reco::PFBlockElement::PS1]) {
Expand Down Expand Up @@ -1051,7 +1060,7 @@ void PFEGammaAlgo::removeOrLinkECALClustersToKFTracks() {

const int nexhits = trackref->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
bool fromprimaryvertex = false;
for (auto vtxtks = primaryVertex_->tracks_begin(); vtxtks != primaryVertex_->tracks_end(); ++vtxtks) {
for (auto vtxtks = primaryVertex_.tracks_begin(); vtxtks != primaryVertex_.tracks_end(); ++vtxtks) {
if (trackref == vtxtks->castTo<reco::TrackRef>()) {
fromprimaryvertex = true;
break;
Expand Down Expand Up @@ -1425,7 +1434,7 @@ void PFEGammaAlgo::linkRefinableObjectECALToSingleLegConv(ProtoEGObject& RO) {
}
// go through non-conv-identified kfs and check MVA to add conversions
for (auto kf = notconvkf; kf != notmatchedkf; ++kf) {
float mvaval = evaluateSingleLegMVA(_currentblock, *primaryVertex_, (*kf)->index());
float mvaval = evaluateSingleLegMVA(_currentblock, primaryVertex_, (*kf)->index());
if (mvaval > cfg_.mvaConvCut) {
const reco::PFBlockElementTrack* elemaskf = docast(const reco::PFBlockElementTrack*, kf->get());
RO.secondaryKFs.push_back(elemaskf);
Expand Down Expand Up @@ -1528,7 +1537,7 @@ PFEGammaAlgo::EgammaObjects PFEGammaAlgo::fillPFCandidates(const std::list<PFEGa
//by storing 3.0 + mvaval
float mvaval = (mvavalmapped != RO.singleLegConversionMvaMap.end()
? mvavalmapped->second
: 3.0 + evaluateSingleLegMVA(_currentblock, *primaryVertex_, kf->index()));
: 3.0 + evaluateSingleLegMVA(_currentblock, primaryVertex_, kf->index()));

xtra.addSingleLegConvTrackRefMva(std::make_pair(kf->trackRef(), mvaval));
}
Expand Down Expand Up @@ -1558,7 +1567,7 @@ PFEGammaAlgo::EgammaObjects PFEGammaAlgo::fillPFCandidates(const std::list<PFEGa
const double scE = the_sc.energy();
if (scE != 0.0) {
const math::XYZPoint& seedPos = the_sc.seed()->position();
math::XYZVector egDir = the_sc.position() - primaryVertex_->position();
math::XYZVector egDir = the_sc.position() - primaryVertex_.position();
egDir = egDir.Unit();
cand.setP4(math::XYZTLorentzVector(scE * egDir.x(), scE * egDir.y(), scE * egDir.z(), scE));
math::XYZPointF ecalPOS_f(seedPos.x(), seedPos.y(), seedPos.z());
Expand Down Expand Up @@ -1806,7 +1815,7 @@ reco::SuperCluster PFEGammaAlgo::buildRefinedSuperCluster(const PFEGammaAlgo::Pr
psClusterPointers.push_back(psc->clusterRef().get());
}
auto calibratedEnergies = thePFEnergyCalibration_.calibrateEndcapClusterEnergies(
*clusptr, psClusterPointers, *channelStatus_, cfg_.applyCrackCorrections);
*clusptr, psClusterPointers, channelStatus_, cfg_.applyCrackCorrections);
cluscalibe = calibratedEnergies.clusterEnergy;
ePS1 = calibratedEnergies.ps1Energy;
ePS2 = calibratedEnergies.ps2Energy;
Expand Down
11 changes: 0 additions & 11 deletions RecoParticleFlow/PFProducer/test/EgGEDPhotonAnalyzer.cc
Expand Up @@ -17,29 +17,18 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrack.h"
#include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrackFwd.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
#include "DataFormats/EgammaReco/interface/ElectronSeed.h"
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "DataFormats/Math/interface/normalizedPhi.h"

Expand Down
11 changes: 0 additions & 11 deletions RecoParticleFlow/PFProducer/test/GsfGEDElectronAnalyzer.cc
Expand Up @@ -17,30 +17,19 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrack.h"
#include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrackFwd.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
#include "DataFormats/EgammaReco/interface/ElectronSeed.h"
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
#include "DataFormats/METReco/interface/PFMET.h"
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/Math/interface/normalizedPhi.h"
Expand Down
38 changes: 4 additions & 34 deletions RecoParticleFlow/PFProducer/test/PFBlockComparator.cc
Expand Up @@ -8,68 +8,38 @@
// Author: L. Gray (FNAL)
//

#include <memory>
#include <map>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#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/EgammaCandidates/interface/PhotonFwd.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtraFwd.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtraFwd.h"

#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"

#include "DataFormats/GsfTrackReco/interface/GsfTrackExtra.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrackExtraFwd.h"

#include "DataFormats/EgammaReco/interface/ElectronSeed.h"
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"

#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"

#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/VertexReco/interface/Vertex.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "TTree.h"
#include "TVector2.h"

#include "DataFormats/Math/interface/deltaR.h"

#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

#include "RecoEcal/EgammaCoreTools/interface/Mustache.h"
namespace MK = reco::MustacheKernel;

#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 <algorithm>
#include <map>
#include <memory>

namespace {
Expand Down

0 comments on commit 7216d10

Please sign in to comment.